From fb7d3e496f91b43c111a3356e265dadbb89787f7 Mon Sep 17 00:00:00 2001 From: xiaofajia <1665375861@qq.com> Date: Tue, 19 Nov 2024 15:24:32 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E8=B4=AD=E5=8D=95=EF=BC=8C=E6=AF=8F?= =?UTF-8?q?=E4=B8=AA=E5=95=86=E5=93=81=E5=8F=AF=E4=BB=A5=E5=BD=95=E5=85=A5?= =?UTF-8?q?=20=E8=BF=9B=E8=B4=A7=E4=BB=B7=E3=80=81=E6=94=B6=E4=BB=B7?= =?UTF-8?q?=E3=80=81=E5=88=86=E7=B1=BB=E3=80=81=E8=AE=A1=E9=87=8F=E5=8D=95?= =?UTF-8?q?=E4=BD=8D=EF=BC=8C=E9=9D=9E=E5=BF=85=E5=A1=AB=EF=BC=8C=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=97=B6=E6=8C=89=E5=88=86=E7=B1=BB=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E5=88=86=E7=BB=84=E5=B1=95=E7=A4=BA=EF=BC=8C=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E6=8C=89=E5=88=86=E7=B1=BB=E8=BF=9B=E8=A1=8C=E5=B1=95=E5=BC=80?= =?UTF-8?q?=E6=94=B6=E8=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stockOperate/Components/WaresItem.vue | 290 ++++++++++++------ 1 file changed, 191 insertions(+), 99 deletions(-) diff --git a/src/views/repair/stockOperate/Components/WaresItem.vue b/src/views/repair/stockOperate/Components/WaresItem.vue index ec4bf77..c50fda8 100644 --- a/src/views/repair/stockOperate/Components/WaresItem.vue +++ b/src/views/repair/stockOperate/Components/WaresItem.vue @@ -114,105 +114,134 @@ - {{carInfo.licenseNumber}} + {{ carInfo.licenseNumber }} - {{carInfo.carBrand}} + {{ carInfo.carBrand }} - {{carInfo.carModel}} + {{ carInfo.carModel }} - - - - - -
- - {{ scope.row.wares.model }} -
-
- -
- - {{ scope.row.wares.code }} -
-
- -
- - {{ scope.row.wares.warehouseName }} -
-
- - -
- - - - + :data="value" + :stripe="true" + :show-overflow-tooltip="true" + show-summary + :summary-method="getSummaries" + @cell-mouse-enter="handleCellEnter" + @cell-mouse-leave="handleCellLeave" + @cell-click="handleCellClick" + > + + + + + +
+ + {{ scope.row.wares.model }} +
+
+ +
+ + + + + {{ getTypeById(scope.row.wares.type) }} +
+
+ +
+ + {{ scope.row.wares.code }} +
+
+ +
+ + {{ scope.row.wares?.ware?.name }} +
+
+ + +
+ + + + -
-
- -
- - {{ scope.row.waresCount }} -
-
- - -
- - {{ scope.row.wares.newPrice }} -
-
- - -
- - {{ scope.row.remark }} -
-
- - - - +
+
+ +
+ + {{ scope.row.waresCount }} +
+
+ +
+ + {{ scope.row.wares.purPrice }} +
+
+ +
+ + {{ scope.row.wares.price }} +
+
+ + +
+ + {{ scope.row.remark }} +
+
+ + + +
+ @@ -231,6 +260,8 @@ import {getUserProfile} from "@/api/system/user"; import TicketWaresShow from "@/views/repair/tickets/Components/TicketWaresShow.vue"; import {getCusAndCarById} from "@/api/repair/tickets/Tickets"; import {getCarBrand} from "@/api/base/carbrand"; +import {listGoods} from "@/views/partner/api/workOrder"; +import {getBaseTypeList} from "@/api/base/type"; export default { name: "WaresItem", @@ -258,24 +289,64 @@ export default { formData: {}, inStockDialog: false, partList: [], - includeColumn: ['count', 'totalPrice'], + includeColumn: ['waresCount', 'totalPrice'], // 保存进入编辑的cell clickCellMap: {}, // 需要编辑的属性 - editProp: ['warehouse', 'count', 'newPrice', 'remark', 'code', 'waresCount', 'wares.model', 'unit'], + editProp: ['wares.warehouse', 'wares.type', 'waresCount', 'wares.purPrice', 'wares.price', 'remark', 'wares.code', 'waresCount', 'wares.model', 'wares.unit'], remark: null, tableKey: 0, query: null, twId: null, carInfo: {}, ticketId: null, + serverSelected: undefined, + expandOnClickNode: true, + serverList: [], + treeProps:{ + label: "name", + children: "children" + }, + typeMap: null, } }, mounted() { this.getList() }, methods: { - searchByQuery(){ + getTypeById(id){ + return this.typeMap.get(id) + }, + async listServer(){ + if (!this.serverList || this.serverList.length === 0){ + const res = await getBaseTypeList({type: "02"}) + this.serverList = this.handleTree(res.data, 'id', 'parentId',"children","0") + this.typeMap = new Map() + this.extractNodesToMap(this.serverList, this.typeMap) + } + }, + extractNodesToMap(nodes, map) { + nodes.forEach(node => { + map.set(node.id, node.name); + if (node.children && node.children.length > 0) { + this.extractNodesToMap(node.children, map); + } + }); + }, + handleNodeClick(data, scopeRow){ + scopeRow.wares.type = data.id; + this.save(scopeRow) + }, + optionData(array, result=[]){ + array.forEach(item => { + result.push({label: item.name, value: item.id}) + if (item.children && item.children.length !== 0){ + this.optionData(item.children, result) + } + }) + return JSON.parse(JSON.stringify(result)) + }, + searchByQuery() { const data = { twId: this.twId, query: this.query @@ -340,16 +411,23 @@ export default { try { const carRes = await getCusAndCarById(this.ticketId) this.carInfo = carRes.data.carInfo - if (this.carInfo.carBrand){ + if (this.carInfo.carBrand) { const brandRes = await getCarBrand(this.carInfo.carBrand) this.carInfo.carBrand = brandRes.data.brandName } const ids = this.selections.map(item => item.id) const res = await getByIds(ids) this.partList = Object.entries(res.data) + const values = this.partList.map(([key, value]) => value) + values.forEach(item => { + item.forEach(i => { + i.totalPrice = i.waresCount * i.wares.price + }) + }) this.inStockDialog = true this.dialogVisible = false - }catch{} + } catch { + } }, async getList() { try { @@ -372,6 +450,7 @@ export default { this.handleQuery() }, handleDispose(row) { + this.listServer() this.formData = {} this.formData = { ...row @@ -404,7 +483,7 @@ export default { }, handleSelect(row) { this.selections = row - if (row && row.length > 0){ + if (row && row.length > 0) { this.selectionIds = row.map(item => item.id); } }, @@ -483,7 +562,13 @@ export default { this.$modal.msgWarning("退料数量不能超过领取数量") row.waresCount = row.waresAlreadyCount } - row.totalPrice = row.count * row.newPrice + this.partList.forEach(([key, value]) => { + const flag = value.findIndex(f => f.id === row.id) + if (flag !== -1){ + row.totalPrice = row.waresCount * row.wares.price + this.$set(value, flag, row) + } + }) const id = row.id // 取消本行所有cell的编辑状态 this.clickCellMap[id].forEach(cell => { @@ -494,11 +579,11 @@ export default { this.tableKey++ }, changeWare(row) { - if (row.ware) { - row['wareId'] = row.ware.id - row['warehouse'] = row.ware.id - row['warehouseName'] = row.ware.name - } + // if (row.wares.ware) { + // row['wareId'] = row.ware.id + // row['warehouse'] = row.ware.id + // row['warehouseName'] = row.ware.name + // } }, // 通知父组件,删除数据 deleteItem(index) { @@ -523,6 +608,7 @@ export default { }, // 提交前的构建 async createInit() { + const values = this.partList.map(([key, value]) => value).reduce((acc, value) => acc.concat(value)) const res = await getUserProfile() this.formData = {} this.formData = { @@ -532,24 +618,30 @@ export default { userId: res.data.id, userName: res.data.nickname, soTime: parseTime(Date.now(), '{y}-{m}-{d}'), - itemCount: this.partList.length, - totalPrice: this.partList.reduce((x, y) => { + itemCount: values.length, + totalPrice: values.reduce((x, y) => { return x + y.totalPrice }, 0), soStatus: "02", remark: this.remark, } - this.formData.goodsList = [...this.partList.map(item => { + this.formData.goodsList = [...values.map(item => { return { soiType: '01', - goodsId: item.id, + goodsId: item.wares.id, goodsType: '0', - wareId: item?.wareId, - goodsCount: item.count, - goodsPrice: item.newPrice, + wareId: item.wares?.ware?.id, + goodsCount: item.waresCount, + goodsPrice: item.wares.price, remark: item.remark } })] + this.formData.waresList = [...values.map(item => { + if (item.wares.ware){ + item.wares.warehouse = item.wares.ware.id + } + return item.wares + })] }, validateNull() { const flag = this.partList.map(item => {