You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
3.3 KiB
106 lines
3.3 KiB
import { queryEquipmentFolderLocationList } from '@/api/qc/qc.js'
|
|
|
|
export default {
|
|
data () {
|
|
return {
|
|
batchDeviceDialogVisible: false,
|
|
batchClassificationList: [],
|
|
batchEquipmentFolderList: [],
|
|
itemObjectEquipmentList: []
|
|
}
|
|
},
|
|
watch: {
|
|
ItemObjectModelFlag (val) {
|
|
if (val) {
|
|
this.loadItemObjectEquipmentList()
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
loadItemObjectEquipmentList () {
|
|
if (!this.actionData || !this.actionData.site) {
|
|
return Promise.resolve()
|
|
}
|
|
return queryEquipmentFolderLocationList({
|
|
site: this.actionData.site,
|
|
buNo: this.actionData.buNo,
|
|
page: 1,
|
|
pageCount: -1
|
|
}).then(({ data }) => {
|
|
if (data && data.code === 0) {
|
|
this.itemObjectEquipmentList = data.rows || []
|
|
this.batchEquipmentFolderList = this.itemObjectEquipmentList
|
|
}
|
|
})
|
|
},
|
|
getRowDeviceOptions (row) {
|
|
const options = [...(row.objectList || [])]
|
|
if (row.equipmentNo && !options.some(opt => opt.objectID === row.equipmentNo)) {
|
|
const selected = (this.itemObjectEquipmentList || []).find(
|
|
item => item.equipmentNo === row.equipmentNo
|
|
)
|
|
if (selected) {
|
|
options.unshift({
|
|
objectID: selected.equipmentNo,
|
|
objectDesc: selected.equipmentDesc || selected.equipmentNo
|
|
})
|
|
} else {
|
|
options.unshift({
|
|
objectID: row.equipmentNo,
|
|
objectDesc: row.equipmentNo
|
|
})
|
|
}
|
|
}
|
|
return options
|
|
},
|
|
openBatchDeviceDialog () {
|
|
const list = this.itemObjectList || []
|
|
this.batchClassificationList = [...new Set(
|
|
list.map(item => (item.equipmentClassification || '').trim()).filter(Boolean)
|
|
)]
|
|
if (!this.batchClassificationList.length) {
|
|
this.$message.warning(this.$t('qc.iqcPage.batchDeviceNoClassification'))
|
|
return
|
|
}
|
|
const openDialog = () => {
|
|
this.batchEquipmentFolderList = this.itemObjectEquipmentList || []
|
|
this.batchDeviceDialogVisible = true
|
|
}
|
|
if (this.itemObjectEquipmentList.length) {
|
|
openDialog()
|
|
} else {
|
|
this.loadItemObjectEquipmentList().then(() => openDialog())
|
|
}
|
|
},
|
|
applyBatchDevice (payload) {
|
|
const selections = payload && payload.selections
|
|
? payload.selections
|
|
: (payload && payload.classification ? [payload] : [])
|
|
let applied = 0
|
|
selections.forEach(({ classification, equipmentNo, equipmentDesc }) => {
|
|
this.itemObjectList.forEach(item => {
|
|
if ((item.equipmentClassification || '').trim() !== classification) {
|
|
return
|
|
}
|
|
if (!item.objectList) {
|
|
this.$set(item, 'objectList', [])
|
|
}
|
|
if (!item.objectList.some(opt => opt.objectID === equipmentNo)) {
|
|
item.objectList.push({
|
|
objectID: equipmentNo,
|
|
objectDesc: equipmentDesc
|
|
})
|
|
}
|
|
item.equipmentNo = equipmentNo
|
|
applied++
|
|
})
|
|
})
|
|
this.batchDeviceDialogVisible = false
|
|
if (applied > 0) {
|
|
this.$message.success(this.$t('qc.iqcPage.batchDeviceApplySuccess', { count: applied }))
|
|
} else {
|
|
this.$message.warning(this.$t('qc.iqcPage.batchDeviceApplyEmpty'))
|
|
}
|
|
}
|
|
}
|
|
}
|