Browse Source

2026-07-01

RoHS优化
master
fengyuan_yang 4 weeks ago
parent
commit
cc602b106c
  1. 9
      src/views/modules/rohs/rohsRecord.vue
  2. 86
      src/views/modules/sys/dict-data-select.vue

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

@ -12,6 +12,12 @@
<el-option label="已完成" value="已完成"></el-option> <el-option label="已完成" value="已完成"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="RoHS状态">
<el-select v-model="searchData.rohsStatus" clearable style="width: 120px">
<el-option label="Active" value="Active"></el-option>
<el-option label="Dead" value="Dead"></el-option>
</el-select>
</el-form-item>
<el-form-item label="节点审批人"> <el-form-item label="节点审批人">
<el-input v-model="searchData.currentApprover" clearable style="width: 120px"></el-input> <el-input v-model="searchData.currentApprover" clearable style="width: 120px"></el-input>
</el-form-item> </el-form-item>
@ -109,6 +115,7 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="sgsReportNumber" header-align="center" align="center" label="SGS报告编号" width="190" :show-overflow-tooltip="true"></el-table-column> <el-table-column prop="sgsReportNumber" header-align="center" align="center" label="SGS报告编号" width="190" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="rohsStatus" header-align="center" align="center" label="RoHS状态" width="130"></el-table-column>
<el-table-column prop="expiredDate" header-align="center" align="center" label="报告日期" width="165"></el-table-column> <el-table-column prop="expiredDate" header-align="center" align="center" label="报告日期" width="165"></el-table-column>
<el-table-column prop="validUntilDisplay" header-align="center" align="center" label="有效期" width="170" :show-overflow-tooltip="true"> <el-table-column prop="validUntilDisplay" header-align="center" align="center" label="有效期" width="170" :show-overflow-tooltip="true">
<template slot-scope="scope"> <template slot-scope="scope">
@ -1070,6 +1077,7 @@ export default {
site: this.$store.state.user.site, site: this.$store.state.user.site,
referenceNo: '', referenceNo: '',
status: '', status: '',
rohsStatus: '',
currentApprover: '', currentApprover: '',
nodeId: '' nodeId: ''
}, },
@ -2384,6 +2392,7 @@ export default {
menuId: this.menuId, menuId: this.menuId,
referenceNo: this.searchData.referenceNo, referenceNo: this.searchData.referenceNo,
status: this.searchData.status, status: this.searchData.status,
rohsStatus: this.searchData.rohsStatus,
currentApprover: this.searchData.currentApprover, currentApprover: this.searchData.currentApprover,
nodeId: this.searchData.nodeId nodeId: this.searchData.nodeId
} }

86
src/views/modules/sys/dict-data-select.vue

@ -11,7 +11,7 @@
</div> </div>
</template> </template>
<script> <script>
import {selectDictDataList} from "../../../api/dict";
import {selectDictDataList, selectDictTypeList} from "../../../api/dict";
export default { export default {
name:'dictDataSelect', name:'dictDataSelect',
model:{ model:{
@ -33,6 +33,10 @@ export default {
type:Boolean, type:Boolean,
default:true, default:true,
}, },
useTypeMultiDefaultValue: {
type: Boolean,
default: false,
},
useSite:{ useSite:{
type:Boolean, type:Boolean,
default:true, default:true,
@ -48,21 +52,92 @@ export default {
}, },
data () { data () {
return { return {
options: []
options: [],
dictTypeMultiDefaultValue: ''
} }
}, },
created () { created () {
this.initOption() this.initOption()
}, },
methods: { methods: {
hasCurrentValue () {
if (Array.isArray(this.value)) {
return this.value.length > 0
}
return this.value !== null && this.value !== undefined && String(this.value).trim() !== ''
},
isMultipleMode () {
if (Array.isArray(this.value)) {
return true
}
const multiple = this.$attrs ? this.$attrs.multiple : false
if (multiple === '' || multiple === true || multiple === 'multiple') {
return true
}
if (typeof multiple === 'string') {
return multiple !== 'false'
}
return !!multiple
},
parseMultiDefaultValue (value) {
if (value === null || value === undefined) {
return []
}
const cache = new Set()
return String(value)
.split(/[;,\n]/)
.map(item => String(item || '').trim())
.filter(item => {
if (!item || cache.has(item)) {
return false
}
cache.add(item)
return true
})
},
async loadDictTypeMultiDefaultValue () {
this.dictTypeMultiDefaultValue = ''
const currentDictType = String(this.dictType || '').trim()
if (!this.useTypeMultiDefaultValue || !currentDictType) {
return
}
const site = this.site ? this.site : (this.useSite ? this.$store.state.user.site : '*')
if (!site) {
return
}
try {
let {data} = await selectDictTypeList({ site, dictType: currentDictType })
if (data && data.code === 0 && Array.isArray(data.rows)) {
const matched = data.rows.find(item => String(item.dictType || '').trim() === currentDictType)
this.dictTypeMultiDefaultValue = matched ? String(matched.multiDefaultValue || '').trim() : ''
}
} catch (e) {}
},
dictDefaultValue(){ dictDefaultValue(){
// value ,value // value ,value
if (!this.value && this.options.length > 0){
if (this.hasCurrentValue() || this.options.length === 0){
return
}
if (this.isMultipleMode()) {
const enabledValueSet = new Set(
this.options.filter(item => item.status === 'Y').map(item => item.dictValue)
)
let defaultValues = this.parseMultiDefaultValue(this.dictTypeMultiDefaultValue)
.filter(item => enabledValueSet.has(item))
if (defaultValues.length === 0) {
defaultValues = this.options
.filter(item => item.isDefault === 'Y' && item.status === 'Y')
.map(item => item.dictValue)
}
if (defaultValues.length > 0) {
this.$emit("change", defaultValues)
}
return
}
let find = this.options.find(item=>item.isDefault === 'Y'); let find = this.options.find(item=>item.isDefault === 'Y');
if (find && find.status === 'Y'){ if (find && find.status === 'Y'){
this.$emit("change",find.dictValue); this.$emit("change",find.dictValue);
} }
}
}, },
//options //options
async initOption () { async initOption () {
@ -83,9 +158,10 @@ export default {
if (data && data.code === 0){ if (data && data.code === 0){
this.options = data.rows; this.options = data.rows;
if (this.options.length === 0){ if (this.options.length === 0){
this.$emit("change",'')
this.$emit("change", this.isMultipleMode() ? [] : '')
} }
} }
await this.loadDictTypeMultiDefaultValue()
if (this.useDefaultValue){ if (this.useDefaultValue){
this.dictDefaultValue(); this.dictDefaultValue();
} }

Loading…
Cancel
Save