代码优化
This commit is contained in:
parent
4dc002e9e6
commit
d48727429f
|
|
@ -927,9 +927,28 @@ export default {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.leaseApplyDetails = [...new Set(tempList)]
|
||||
const newDataList = [...this.leaseApplyDetails, ...tempList]
|
||||
const map = new Map()
|
||||
for (let item of newDataList) {
|
||||
if (!map.has(item.typeId)) {
|
||||
map.set(item.typeId, item)
|
||||
}
|
||||
}
|
||||
const newArray = [...map.values()]
|
||||
|
||||
let newArray_array = []
|
||||
items.forEach((e) => {
|
||||
newArray.forEach((j) => {
|
||||
if (e == j.typeId) {
|
||||
newArray_array.push(j)
|
||||
}
|
||||
})
|
||||
})
|
||||
this.leaseApplyDetails = newArray_array
|
||||
} else {
|
||||
this.leaseApplyDetails = []
|
||||
}
|
||||
|
||||
// const templateList = deviceTypeList.map((e) => {
|
||||
// let { num, companyId, id, unitName } = e.data
|
||||
|
|
|
|||
|
|
@ -884,9 +884,11 @@ export default {
|
|||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
this.deviceType.forEach((e, index) => {
|
||||
if (e[3] === row.typeId) {
|
||||
this.deviceType.splice(index, 1)
|
||||
this.propsKey++
|
||||
if (e[3] == row.typeId) {
|
||||
this.$nextTick(() => {
|
||||
this.deviceType.splice(index, 1)
|
||||
this.propsKey++
|
||||
})
|
||||
}
|
||||
})
|
||||
this.leaseApplyDetails.splice(row.index, 1)
|
||||
|
|
@ -913,6 +915,7 @@ export default {
|
|||
|
||||
/////// 设备类型树 切换
|
||||
async deviceTypeChange(val) {
|
||||
console.log(val, '*******************')
|
||||
// let nodes = null
|
||||
// console.log(
|
||||
// 'vall1211221122',
|
||||
|
|
@ -955,13 +958,14 @@ export default {
|
|||
// }
|
||||
// }
|
||||
let tempList = []
|
||||
|
||||
if (val.length > 0) {
|
||||
const items = val.map((e) => {
|
||||
return e[3]
|
||||
})
|
||||
for (let i in items) {
|
||||
for (let z in deviceTypeList) {
|
||||
if (deviceTypeList[z].data.typeId === items[i]) {
|
||||
if (deviceTypeList[z].data.typeId == items[i]) {
|
||||
let { num, companyId, typeId, unitNames } =
|
||||
deviceTypeList[z].data
|
||||
tempList.push({
|
||||
|
|
@ -979,9 +983,30 @@ export default {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.leaseApplyDetails = [...new Set(tempList)]
|
||||
const newDataList = [...this.leaseApplyDetails, ...tempList]
|
||||
const map = new Map()
|
||||
for (let item of newDataList) {
|
||||
if (!map.has(item.typeId * 1)) {
|
||||
map.set(item.typeId * 1, item)
|
||||
}
|
||||
}
|
||||
const newArray = [...map.values()]
|
||||
|
||||
console.log(newArray, 'newArray', items, 'items')
|
||||
|
||||
let newArray_array = []
|
||||
items.forEach((e) => {
|
||||
newArray.forEach((j) => {
|
||||
if (e == j.typeId) {
|
||||
newArray_array.push(j)
|
||||
}
|
||||
})
|
||||
})
|
||||
this.leaseApplyDetails = newArray_array
|
||||
} else {
|
||||
this.leaseApplyDetails = []
|
||||
}
|
||||
},
|
||||
//// 将数据处理成 表格中需要的数据
|
||||
handelTableItemData(node) {
|
||||
|
|
|
|||
|
|
@ -177,19 +177,14 @@
|
|||
></el-input-number>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
label="采购数量"
|
||||
prop="purchaseNum"
|
||||
type="number"
|
||||
maxlength="10"
|
||||
>
|
||||
<el-table-column align="center" label="采购数量" prop="purchaseNum">
|
||||
<template slot-scope="scope">
|
||||
<el-input-number
|
||||
v-model="scope.row.purchaseNum"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
type="number"
|
||||
:min="1"
|
||||
clearable
|
||||
v-model.number="scope.row.purchaseNum"
|
||||
style="width: 100%"
|
||||
></el-input-number>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
|
@ -775,36 +770,41 @@ export default {
|
|||
const items = val.map((e) => {
|
||||
return e[3]
|
||||
})
|
||||
for (let i in items) {
|
||||
for (let z in deviceTypeList) {
|
||||
if (deviceTypeList[z].data.typeId === items[i]) {
|
||||
this.$set(deviceTypeList[z].data, 'supplierId', '')
|
||||
this.$set(
|
||||
deviceTypeList[z].data,
|
||||
'createTime',
|
||||
null,
|
||||
)
|
||||
this.$set(
|
||||
deviceTypeList[z].data,
|
||||
'productionTime',
|
||||
'',
|
||||
)
|
||||
this.$set(
|
||||
deviceTypeList[z].data,
|
||||
'purchasePrice',
|
||||
0,
|
||||
)
|
||||
this.$set(deviceTypeList[z].data, 'purchaseNum', 1)
|
||||
|
||||
tempList.push(deviceTypeList[z].data)
|
||||
|
||||
for (let i of items) {
|
||||
for (let z of deviceTypeList) {
|
||||
if (z.data.typeId === i) {
|
||||
const obj = JSON.parse(JSON.stringify(z.data))
|
||||
obj.supplierId = ''
|
||||
obj.createTime = null
|
||||
obj.productionTime = ''
|
||||
obj.purchasePrice = 0
|
||||
obj.purchaseNum = ''
|
||||
tempList.push(obj)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.equipmentList = [...new Set(tempList)]
|
||||
const newDataListNew = [...this.equipmentList, ...tempList]
|
||||
const map = new Map()
|
||||
for (let item of newDataListNew) {
|
||||
if (!map.has(item.typeId)) {
|
||||
map.set(item.typeId, item)
|
||||
}
|
||||
}
|
||||
const newArray = [...map.values()]
|
||||
let newArray_array = []
|
||||
items.forEach((e) => {
|
||||
newArray.forEach((j) => {
|
||||
if (e == j.typeId) {
|
||||
newArray_array.push(j)
|
||||
}
|
||||
})
|
||||
})
|
||||
this.equipmentList = newArray_array
|
||||
} else {
|
||||
this.equipmentList = []
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue