修改bug

This commit is contained in:
‘937886381’
2024-02-01 16:48:58 +08:00
parent 39aaf82345
commit 5098555a5e
16 changed files with 296 additions and 122 deletions

View File

@@ -1,14 +1,14 @@
<!--
* @Author: zhp
* @Date: 2024-01-30 10:54:51
* @LastEditTime: 2024-01-30 16:53:35
* @LastEditTime: 2024-02-01 14:46:19
* @LastEditors: zhp
* @Description:
-->
<template>
<div>
<div class="bom-selection" v-for="item in list__inner" :key="item.id + randomKey">
<el-checkbox :label="item.name" :checked="item.id === selected" @change="(e) => handleChange(item, e)"
<el-checkbox :label="item.name" :checked="item.choose" @change="(e) => handleChange(item, e)"
class="sl__body-item"></el-checkbox>
</div>
</div>
@@ -25,8 +25,8 @@ export default {
// },
props: {
currentSelect: {
type: String | Number,
default: null,
type: Array,
default: ()=>[],
},
list: {
type: Array,
@@ -46,24 +46,29 @@ export default {
},
watch: {
list: {
handler(val) {
handler(val) {
console.log(val)
if (val) {
this.list__inner = val.map((item) => ({ ...item, disabled: false }));
this.list__inner = val.map((item) => ({ ...item, choose: false }));
}
},
deep: true,
immediate: true,
},
currentSelect: {
handler(val) {
handler(val) {
console.log(val)
// val: string
this.selected = val;
this.randomKey = Math.random();
// 更新选中状态
if (val) {
this.list__inner.forEach((item) => {
if (item.id == val) item.disabled = false;
else item.disabled = true;
this.list__inner.forEach((item,index) => {
val.forEach((ele) => {
console.log(ele)
if (item.id == ele.id) item.choose = true;console.log(ele.id)
// else item.choose = false;
})
});
}
},

View File

@@ -1,7 +1,7 @@
<!--
* @Author: zhp
* @Date: 2024-01-30 10:53:32
* @LastEditTime: 2024-01-30 17:51:13
* @LastEditTime: 2024-02-01 14:47:03
* @LastEditors: zhp
* @Description:
-->
@@ -36,7 +36,7 @@
<BomSelection ref="materialsBomList" :key="materialsBomList.equipmentId + 'materialsBomList'"
:list="materialsBomList" :equipment-id="materialsBomList.equipmentId"
:current-select="currentSelectedMaterialBomId" @change="handleMaterialBomChange" />
:current-select="currentSelectedIdList" @change="handleMaterialBomChange" />
</div>
</el-col>
<!-- <el-col :span="8" style="border-left: 1px solid #ccc">
@@ -78,7 +78,11 @@ export default {
value: {
type: Array,
default: () => [],
},
},
chooseList: {
type: Array,
default:() => []
}
},
data() {
return {
@@ -87,19 +91,20 @@ export default {
selected: [],
bomArr:[],
materialsBomList: [],
valuesBomList: [],
// valuesBomList: [],
refreshKey: Math.random(),
currentSelectedMaterialBomId: null,
currentSelectedIdList: [],
currentSelectedValueBomId: null,
};
},
watch: {
value: {
handler(val) {
handler(val) {
console.log('value', val);
if (val) {
this.selectedEquipments = val.map((item) => item.equipmentId);
this.selectedEquipments = val.map((item) => item.equipmentId)
console.log(this.selectedEquipments)
this.selected = val;
}
},
@@ -109,35 +114,55 @@ export default {
},
computed: {
filteredBomList() {
return this.bomList.filter((item) => {
return this.bomList.filter((item) => {
// console.log(item)
return item.name.includes(this.searchText);
});
},
},
mounted () {
// this.getList()
},
methods: {
commit() {
this.$emit('update', this.selected);
},
},
// getList() {
// this.selectedEquipments = this.chooseList
// console.log(this.selectedEquipments)
// console.log(this.chooseList);
// },
handleLoadDom(eq) {
// 只显示 dom 列表
this.currentEquipment = eq.id;
this.materialsBomList = eq.materialsBom;
this.valuesBomList = eq.valuesBom;
this.materialsBomList = eq.materialsBom;
console.log(this.materialsBomList)
// this.valuesBomList = eq.valuesBom;
// 回复选中的bom信息
if (this.selectedEquipments.includes(eq.id)) {
const selectedItem = this.selected.find(
(item) => item.equipmentId == eq.id
);
this.currentSelectedMaterialBomId =
selectedItem.equMaterialBomId ?? null;
this.currentSelectedValueBomId = selectedItem.equValueBomId ?? null;
)
// console.log(selectedItem)
let arr = []
console.log(selectedItem.children);
selectedItem.children.forEach((ele) => {
console.log(ele)
arr.push({ id: ele.id })
})
// console.log(arr)
this.currentSelectedIdList = arr
console.log(this.currentSelectedIdList);
// selectedItem.equMaterialBomId ?? null;
// this.currentSelectedValueBomId = selectedItem.equValueBomId ?? null;
}
},
handleEquipmentChange(eq, selected) {
this.currentEquipment = eq.id;
this.materialsBomList = eq.materialsBom;
this.materialsBomList = eq.materialsBom
console.log(this.value)
this.valuesBomList = eq.valuesBom;
if (selected) {
console.log(selected)
@@ -165,6 +190,7 @@ export default {
},
handleMaterialBomChange(equipmentId, bomId, selected) {
// console.log(this.chooseList)
const selectedItem = this.selected.find(
(item) => item.equipmentId == equipmentId
);
@@ -178,7 +204,7 @@ export default {
this.selectedEquipments.push(equipmentId);
console.log(this.selected.indexOf(equipmentId))
this.selected.forEach((ele,index) => {
if (ele.equipmentId === equipmentId) {
if (ele.equipmentId === equipmentId ) {
this.selected[index].children.push({ id: bomId })
}
})
@@ -192,8 +218,10 @@ export default {
// this.$emit('update', this.selected);
return;
} else {
console.log(selected);
this.selected.forEach((ele, index) => {
ele.children.forEach((e, i) => {
console.log(e)
if (ele.equipmentId === equipmentId && e.id == bomId) {
this.selected[index].children.splice(i,1)
}
@@ -201,8 +229,8 @@ export default {
})
}
// this.$emit('getData', this.dataForm)
selectedItem && (selectedItem.equMaterialBomId = selected ? bomId : null);
this.currentSelectedMaterialBomId = selected ? bomId : null;
// selectedItem && (selectedItem.equMaterialBomId = selected ? bomId : null);
// this.currentSelectedMaterialBomId = selected ? bomId : null;
console.log(this.selected)
},

View File

@@ -1,7 +1,7 @@
<!--
* @Author: zhp
* @Date: 2024-01-30 10:52:01
* @LastEditTime: 2024-01-30 18:03:08
* @LastEditTime: 2024-02-01 14:43:53
* @LastEditors: zhp
* @Description:
-->
@@ -84,8 +84,8 @@
</el-col>
</el-form>
</el-row>
<BomSelector ref="bomSelector" v-if="open" :bom-list="bomList" :value="selectedBoms"
@update="selectedBoms = $event" />
<BomSelector ref="bomSelector" v-if="open" :bom-list="bomList" :value="selectedBoms"
@update="selectedBoms = $event" />
<el-row slot="footer">
<el-button size="small" @click="cancel">取消</el-button>
@@ -100,8 +100,18 @@
<script>
import BomSelector from './BomSelector.vue';
import {
getUserList
getUserList,
getQualityInspectionBoxBtn,
} from '@/api/base/qualityInspectionBoxPermissions';
// import {
// createQualityInspectionBoxBtn,
// updateQualityInspectionBoxBtn,
// deleteQualityInspectionBoxBtn,
// getPage,
// exportQualityInspectionBoxBtnExcel,
// getUserList
// } from '@/api/base/qualityInspectionBoxPermissions';
export default {
name: 'ProcessBom',
components: { BomSelector },
@@ -127,7 +137,8 @@ export default {
],
list: [],
total: 0,
tableBtn: [],
tableBtn: [],
chooseList:[],
queryParams: {
pageNo: 1,
pageSize: 10,
@@ -159,10 +170,6 @@ export default {
// deep: true,
// },
// },
mounted () {
this.getData()
this.getDict()
},
methods: {
getDict() {
getUserList({
@@ -209,11 +216,11 @@ export default {
eq.materialsBom.chosen
// eq.valuesBom.chosen
) {
this.selectedBoms.push({
equipmentId: eq.id,
equMaterialBomId: eq.materialsBom.chosen,
// equValueBomId: eq.valuesBom.chosen,
});
// this.selectedBoms.push({
// equipmentId: eq.id,
// equMaterialBomId: eq.materialsBom.chosen,
// // equValueBomId: eq.valuesBom.chosen,
// });
}
// 设置设备id
eq.materialsBom.equipmentId = eq.id;
@@ -222,7 +229,6 @@ export default {
});
} else {
this.bomList.splice(0);
this.selectedBoms = [];
}
})
.catch((err) => {
@@ -278,7 +284,7 @@ export default {
}
})
console.log(this.dataForm);
if (this.selectedBoms.length) {
if (!this.dataForm.userId) {
const { code, data } = await this.http(
'base/quality-inspection-box-btn-auth/create',
'post',
@@ -294,7 +300,23 @@ export default {
this.btnLoading = false;
this.$message.error('操作失败');
}
}
} else {
const { code, data } = await this.http(
'base/quality-inspection-box-btn-auth/update',
'put',
this.dataForm
);
if (code == 0) {
this.$message.success('操作成功');
// this.getList(this.currentDet);
this.btnLoading = false;
this.$emit('getList')
this.cancel();
} else {
this.btnLoading = false;
this.$message.error('操作失败');
}
}
});
},
// async getList({
@@ -362,11 +384,46 @@ export default {
// // this.selectedBoms = [];
// // });
// },
async handleAddEquipment() {
this.open = true;
async handleAddEquipment(userId) {
this.open = true
this.selectedBoms = []
this.getData()
this.getDict()
if (userId) {
getQualityInspectionBoxBtn(userId).then((res) => {
// console.log(res)
this.$nextTick(() => {
this.dataForm.userId = userId
this.dataForm.nickname = res.data.nickName
this.dataList = res.data.datas
let arr = []
res.data.datas.forEach((item) => {
// console.log(item.children);
// item.children.forEach((ele) => {
// console.log(ele)
this.selectedBoms.push({
equipmentId: item.id,
children: Object.keys(item).length > 0 ? item.children.map((ele) => {
console.log(ele)
return {
id: ele.id
}
}) : []
})
// })
})
})
// console.log(arr)
// this.chooseList = arr
// console.log(this.chooseList)
})
}
},
cancel() {
this.open = false;
this.open = false
this.bomList = []
this.selectedBoms = []
this.$refs.dataForm.resetFields();
},
clearList() {
this.list = [];

View File

@@ -25,10 +25,7 @@
<script>
import {
createQualityInspectionBoxBtn,
updateQualityInspectionBoxBtn,
deleteQualityInspectionBoxBtn,
getQualityInspectionBoxBtn,
getPage,
exportQualityInspectionBoxBtnExcel,
getUserList
@@ -157,9 +154,10 @@ export default {
this.urlOptions.getDataListURL(this.listQuery).then(res => {
this.tableData = res.data.list.map((item) => {
return {
// datas: item.strList.toString(),
datas: item.strList.toString(),
nickName: item.nickName,
userName: item.userName,
userId: item.userId
// sectionId: item.sectionId,
// sectionName: item.sectionName
}
@@ -182,6 +180,7 @@ export default {
this.resetForm('form');
},
deleteHandle(id, name, index, data) {
console.log(data)
// console.log(data)
this.$confirm(`确认要删除产线名为${data.userName}的数据项?`, "提示", {
confirmButtonText: "确定",