Browse Source

2026-07-01

RoHS优化
master
fengyuan_yang 4 weeks ago
parent
commit
60c3e6daed
  1. 220
      src/views/modules/oss/ossComponents.vue
  2. 186
      src/views/modules/rohs/rohsRecord.vue

220
src/views/modules/oss/ossComponents.vue

@ -83,6 +83,26 @@ export default {
singleUpload: {
type: Boolean,
default: false
},
queryOrderRef3List: {
type: Array,
default: () => []
},
showOrderRef3Filter: {
type: Boolean,
default: false
},
orderRef3FilterOptions: {
type: Array,
default: () => []
},
orderRef3FilterQueryMap: {
type: Object,
default: () => ({})
},
orderRef3LabelMap: {
type: Object,
default: () => ({})
}
},
data(){
@ -111,7 +131,8 @@ export default {
currentRev:null,
newRev:null,
fileRemark:''
}
},
orderRef3FilterValue:''
}
},
methods:{
@ -154,17 +175,109 @@ export default {
this.$refs.table.setCurrentRow()
}
},
handleQuery(){
resolveOrderRef3Label(orderRef3){
const key = String(orderRef3 || '').trim()
if (!key) {
return ''
}
if (this.orderRef3LabelMap && this.orderRef3LabelMap[key]) {
return this.orderRef3LabelMap[key]
}
const option = (this.orderRef3FilterOptions || []).find(item => String(item.value || '').trim() === key)
if (option) {
return option.label || key
}
return key
},
resolveFilterQueryOrderRef3(value){
const key = String(value || '').trim()
if (!key) {
return []
}
const mapping = this.orderRef3FilterQueryMap || {}
const mapped = mapping[key]
if (Array.isArray(mapped) && mapped.length > 0) {
return mapped
}
return [key]
},
buildQueryOrderRef3List(){
let list = []
if (this.showOrderRef3Filter && this.orderRef3FilterValue) {
list = this.resolveFilterQueryOrderRef3(this.orderRef3FilterValue)
} else if (Array.isArray(this.queryOrderRef3List) && this.queryOrderRef3List.length > 0) {
list = this.queryOrderRef3List
} else {
list = [this.orderRef3]
}
const cache = new Set()
return list
.map(item => String(item || '').trim())
.filter(item => {
if (cache.has(item)) {
return false
}
cache.add(item)
return true
})
},
sortQueryRows(rows){
const sourceList = Array.isArray(rows) ? rows : []
return sourceList.sort((a, b) => {
const dateA = a && a.createDate ? new Date(a.createDate).getTime() : 0
const dateB = b && b.createDate ? new Date(b.createDate).getTime() : 0
if (dateA !== dateB) {
return dateB - dateA
}
const idA = a && a.id ? Number(a.id) : 0
const idB = b && b.id ? Number(b.id) : 0
return idB - idA
})
},
async handleQuery(){
if (!this.params.orderRef1 && !this.params.orderRef2){
return;
}
let params = {
this.queryLoading = true;
const ref3List = this.buildQueryOrderRef3List()
const finalRef3List = ref3List.length > 0 ? ref3List : ['']
try {
const requestList = finalRef3List.map(orderRef3 => {
const params = {
...this.params,
orderRef3: orderRef3
}
this.queryLoading = true;
queryOss(params).then(({data})=>{
return queryOss(params).then(({data}) => {
if (data && data.code === 0) {
this.dataList = data.rows;
return Array.isArray(data.rows) ? data.rows : []
}
this.$message.warning((data && data.msg) || '附件查询失败')
return []
})
})
const rowsGroup = await Promise.all(requestList)
const mergedRows = []
const rowMap = new Map()
rowsGroup.forEach(rows => {
;(rows || []).forEach(row => {
if (!row) {
return
}
const key = String(row.id || '')
if (key && rowMap.has(key)) {
return
}
const normalizedRow = {
...row,
orderRef3Label: this.resolveOrderRef3Label(row.orderRef3)
}
mergedRows.push(normalizedRow)
if (key) {
rowMap.set(key, true)
}
})
})
this.dataList = this.sortQueryRows(mergedRows)
if (this.rowClickSelect && this.currentSelectedRowId) {
const selectedRow = (this.dataList || []).find(item => item.id === this.currentSelectedRowId)
if (selectedRow) {
@ -178,14 +291,27 @@ export default {
this.resetRowSelection()
}
}
}else {
this.$message.warning(data.msg);
}
this.queryLoading = false;
}).catch((error)=>{
} catch (error){
this.$message.error(error);
} finally {
this.queryLoading = false;
})
}
},
resolveUploadOrderRef3(){
if (this.showOrderRef3Filter && Array.isArray(this.orderRef3FilterOptions) && this.orderRef3FilterOptions.length > 0) {
const selectedType = String(this.orderRef3FilterValue || '').trim()
if (!selectedType) {
this.$message.warning('请先选择附件类型')
return ''
}
const queryList = this.resolveFilterQueryOrderRef3(selectedType)
return queryList.length > 0 ? queryList[0] : selectedType
}
const queryList = this.buildQueryOrderRef3List()
if ((!this.orderRef3 || !String(this.orderRef3).trim()) && queryList.length > 0) {
return queryList[0]
}
return this.orderRef3
},
handleUpload(){
this.$nextTick(()=>{
@ -249,7 +375,11 @@ export default {
}
formData.append('orderRef1', this.orderRef1);
formData.append('orderRef2', this.ossForm.orderRef2);
formData.append('orderRef3', this.orderRef3);
const uploadOrderRef3 = this.resolveUploadOrderRef3()
if (!uploadOrderRef3) {
return
}
formData.append('orderRef3', uploadOrderRef3);
formData.append('fileRemark', this.ossForm.remark);
if (this.requireFileNoRev){
formData.append('fileNo', this.ossForm.fileNo);
@ -423,29 +553,42 @@ export default {
}
});
},
handleDownload(){
if (this.selectionDataList.length === 0){
async handleDownload(){
const selectedRows = Array.isArray(this.selectionDataList) ? [...this.selectionDataList] : []
if (selectedRows.length === 0){
this.$message.warning('请选择要下载的附件');
return;
}
for (let i = 0; i < this.selectionDataList.length; i++) {
let params = {
id:this.selectionDataList[i].id,
}
previewOssFileById(params).then((response) => {
const blob = new Blob([response.data], { type: response.headers['content-type'] });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.setAttribute('download', this.selectionDataList[i].fileName);
link.target = '_blank'; //
link.click();
URL.revokeObjectURL(link.href);
const failNames = []
const taskList = selectedRows.map(row => {
const params = {
id: row.id
}
const fileName = row.fileName || '附件'
return previewOssFileById(params).then((response) => {
const blob = new Blob([response.data], { type: response.headers['content-type'] })
const link = document.createElement('a')
link.href = URL.createObjectURL(blob)
link.setAttribute('download', fileName)
link.click()
URL.revokeObjectURL(link.href)
return true
}).catch(() => {
failNames.push(fileName)
return false
})
})
const resultList = await Promise.all(taskList)
const successCount = resultList.filter(item => item).length
if (failNames.length > 0) {
this.$message.warning('部分文件下载失败:' + failNames.join(','))
} else if (successCount > 0) {
this.$message.success('已下载 ' + successCount + ' 个附件')
}
if (this.rowClickSelect) {
this.resetRowSelection();
this.resetRowSelection()
} else if (this.$refs.table) {
this.$refs.table.clearSelection();
}
});
this.$refs.table.clearSelection()
}
}
},
@ -474,6 +617,10 @@ export default {
this.handleQuery();
}
},
orderRef3FilterValue(){
this.resetRowSelection()
this.handleQuery()
},
orderRef2(newVal) {
this.ossForm.orderRef2 = newVal;
},
@ -494,6 +641,17 @@ export default {
<template v-if="downloadVisible&&!readonly">
<el-button type="primary" @click="handleDownload">下载</el-button>
</template>
<template v-if="showOrderRef3Filter">
<span style="margin-left: 8px; margin-right: 6px;"></span>
<el-select v-model="orderRef3FilterValue" clearable style="width: 180px">
<el-option
v-for="(item, index) in orderRef3FilterOptions"
:key="index"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
<template v-if="enableUpgrade&&saveVisible&&effectiveVisibleFlag&&!readonly&&!disabled">
<el-button type="primary" @click="handleVersionUpgrade">升版</el-button>
</template>

186
src/views/modules/rohs/rohsRecord.vue

@ -162,12 +162,12 @@
:title="modalTitle"
:visible.sync="modalFlag"
width="1012px"
top="4vh"
top="3.8vh"
v-drag
:close-on-click-modal="false"
:showClose="false">
<el-tabs tab-position="left" type="border-card" v-model="activeName" style="width: 100%;height: 770px;">
<el-tabs tab-position="left" type="border-card" v-model="activeName" style="width: 100%;height: 777px;">
<!-- 基本信息 -->
<el-tab-pane label="基本信息" name="basicInfo">
<div style="height: 755px">
@ -526,7 +526,7 @@
:data="modalData.materialList"
@selection-change="materialSelectionChange"
:header-cell-style="materialDialogHeaderCellStyle"
:height="705"
:height="715"
style="width: 100%">
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
<el-table-column type="index" label="序号" width="50" header-align="center" align="center"></el-table-column>
@ -538,9 +538,71 @@
</el-tab-pane>
<el-tab-pane label="附件信息" name="attachmentInfo">
<div style="height: 755px">
<div style="height: 755px; overflow-y: auto;">
<el-form :inline="true" label-position="top" :model="modalData" style="margin-top: -5px;">
<el-form-item label="TDS" style="display: block;">
<oss-components
ref="modalAttachmentTdsOss"
:save-visible="authFileSave"
:download-visible="authFileDownLoad"
:remove-visible="authFileRemove"
:preview-visible="authFilePreview"
:row-click-select="true"
:disabled="modalData.status === '已完成'"
label="序列号"
:height="145"
style="margin-top: 2px"
:columns="fileColumnList"
:order-ref1="modalData.site || ''"
:order-ref2="modalData.referenceNo || ''"
order-ref3="rohsAttachmentTds">
</oss-components>
</el-form-item>
</el-form>
<el-form :inline="true" label-position="top" :model="modalData" style="margin-top: 150px;">
<el-form-item label="MSDS" style="display: block;">
<oss-components
ref="modalAttachmentMsdsOss"
:save-visible="authFileSave"
:download-visible="authFileDownLoad"
:remove-visible="authFileRemove"
:preview-visible="authFilePreview"
:row-click-select="true"
:disabled="modalData.status === '已完成'"
label="序列号"
:height="145"
style="margin-top: 2px"
:columns="fileColumnList"
:order-ref1="modalData.site || ''"
:order-ref2="modalData.referenceNo || ''"
order-ref3="rohsAttachmentMsds">
</oss-components>
</el-form-item>
</el-form>
<el-form :inline="true" label-position="top" :model="modalData" style="margin-top: 150px;">
<el-form-item label="测试报告/Test Report" style="display: block;">
<oss-components
ref="modalAttachmentTestReportOss"
:save-visible="authFileSave"
:download-visible="authFileDownLoad"
:remove-visible="authFileRemove"
:preview-visible="authFilePreview"
:row-click-select="true"
:disabled="modalData.status === '已完成'"
label="序列号"
:height="145"
style="margin-top: 2px"
:columns="fileColumnList"
:order-ref1="modalData.site || ''"
:order-ref2="modalData.referenceNo || ''"
order-ref3="rohsAttachmentTestReport">
</oss-components>
</el-form-item>
</el-form>
<el-form :inline="true" label-position="top" :model="modalData" style="margin-top: 150px;">
<el-form-item label="Other" style="display: block;">
<oss-components
ref="modalAttachmentOss"
ref="modalAttachmentOtherOss"
:save-visible="authFileSave"
:download-visible="authFileDownLoad"
:remove-visible="authFileRemove"
@ -548,13 +610,15 @@
:row-click-select="true"
:disabled="modalData.status === '已完成'"
label="序列号"
:height="705"
:height="145"
style="margin-top: 2px"
:columns="fileColumnList"
:order-ref1="modalData.site || ''"
:order-ref2="modalData.referenceNo || ''"
order-ref3="rohsAttachment">
order-ref3="rohsAttachmentOther">
</oss-components>
</el-form-item>
</el-form>
</div>
</el-tab-pane>
</el-tabs>
@ -1019,13 +1083,17 @@
:remove-visible="authFileRemove"
:preview-visible="authFilePreview"
:disabled="currentRow.status === '已完成'"
:show-order-ref3-filter="true"
:order-ref3-filter-options="rohsAttachmentTypeOptionList"
:query-order-ref3-list="rohsAttachmentQueryOrderRef3List"
:order-ref3-filter-query-map="rohsAttachmentTypeFilterQueryMap"
:order-ref3-label-map="rohsAttachmentTypeLabelMap"
label="序列号"
:height="secondHeight - 25"
style="margin-top: 2px"
:columns="fileColumnList"
:columns="rohsAttachmentSummaryColumnList"
:order-ref1="currentRow.site"
:order-ref2="currentRow.referenceNo"
order-ref3="rohsAttachment">
:order-ref2="currentRow.referenceNo">
</oss-components>
</el-tab-pane>
<el-tab-pane label="审批信息" name="approvalInformation">
@ -1151,6 +1219,94 @@ export default {
columnWidth: 120
}
],
rohsAttachmentTypeOptionList: [
{ value: 'rohsAttachmentTds', label: 'TDS' },
{ value: 'rohsAttachmentMsds', label: 'MSDS' },
{ value: 'rohsAttachmentTestReport', label: '测试报告' },
{ value: 'rohsAttachmentOther', label: 'Other' }
],
rohsAttachmentTypeLabelMap: {
rohsAttachmentTds: 'TDS',
rohsAttachmentMsds: 'MSDS',
rohsAttachmentTestReport: '测试报告',
rohsAttachmentOther: 'Other',
rohsAttachment: 'Other'
},
rohsAttachmentQueryOrderRef3List: [
'rohsAttachmentTds',
'rohsAttachmentMsds',
'rohsAttachmentTestReport',
'rohsAttachmentOther',
'rohsAttachment'
],
rohsAttachmentTypeFilterQueryMap: {
rohsAttachmentTds: ['rohsAttachmentTds'],
rohsAttachmentMsds: ['rohsAttachmentMsds'],
rohsAttachmentTestReport: ['rohsAttachmentTestReport'],
rohsAttachmentOther: ['rohsAttachmentOther', 'rohsAttachment']
},
rohsAttachmentSummaryColumnList: [
{
columnProp: 'orderRef3Label',
headerAlign: 'center',
align: 'center',
columnLabel: '类型',
columnHidden: false,
columnImage: false,
columnSortable: false,
status: true,
fixed: '',
columnWidth: 120
},
{
columnProp: 'fileName',
headerAlign: 'center',
align: 'center',
columnLabel: '文件名称',
columnHidden: false,
columnImage: false,
columnSortable: false,
status: true,
fixed: '',
columnWidth: 160
},
{
columnProp: 'fileRemark',
headerAlign: 'center',
align: 'center',
columnLabel: '备注',
columnHidden: false,
columnImage: false,
columnSortable: false,
status: true,
fixed: '',
columnWidth: 220
},
{
columnProp: 'createDate',
headerAlign: 'center',
align: 'center',
columnLabel: '上传时间',
columnHidden: false,
columnImage: false,
columnSortable: false,
status: true,
fixed: '',
columnWidth: 160
},
{
columnProp: 'createBy',
headerAlign: 'center',
align: 'center',
columnLabel: '上传人',
columnHidden: false,
columnImage: false,
columnSortable: false,
status: true,
fixed: '',
columnWidth: 120
}
],
tdsFileColumnList: [
{
columnProp: 'fileNo',
@ -1389,7 +1545,10 @@ export default {
if (val === 'attachmentInfo' || val === 'npdInfo') {
this.$nextTick(() => {
if (val === 'attachmentInfo') {
this.refreshOssRef('modalAttachmentOss')
this.refreshOssRef('modalAttachmentTdsOss')
this.refreshOssRef('modalAttachmentMsdsOss')
this.refreshOssRef('modalAttachmentTestReportOss')
this.refreshOssRef('modalAttachmentOtherOss')
}
if (val === 'npdInfo') {
this.refreshOssRef('modalTdsOss')
@ -2290,7 +2449,10 @@ export default {
})
},
refreshAttachmentPanels () {
this.refreshOssRef('modalAttachmentOss')
this.refreshOssRef('modalAttachmentTdsOss')
this.refreshOssRef('modalAttachmentMsdsOss')
this.refreshOssRef('modalAttachmentTestReportOss')
this.refreshOssRef('modalAttachmentOtherOss')
this.refreshOssRef('modalTdsOss')
this.refreshOssRef('bottomAttachmentOss')
this.refreshOssRef('bottomTdsOss')

Loading…
Cancel
Save