From c329fa58643dc22653bac1aa04553983a79b9d52 Mon Sep 17 00:00:00 2001 From: xiaofajia <1665375861@qq.com> Date: Tue, 26 Nov 2024 16:53:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E8=B4=AD=E5=88=97=E8=A1=A8=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=EF=BC=8C=E9=83=A8=E5=88=86=E6=89=8B=E6=9C=BA=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E8=BE=93=E5=85=A5=E4=BB=B7=E6=A0=BC=E3=80=81=E6=95=B0?= =?UTF-8?q?=E9=87=8F=EF=BC=9A=E5=94=AE=E4=BB=B7=E3=80=81=E8=BF=9B=E4=BB=B7?= =?UTF-8?q?=EF=BC=8C=E9=9C=80=E8=A6=81=E6=8E=92=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .hbuilderx/launch.json | 25 +++--- config.js | 3 +- pages-warehouse/inOutWarehouse/part.vue | 103 ++++++++++++------------ 3 files changed, 66 insertions(+), 65 deletions(-) diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json index 69faf69..07d9281 100644 --- a/.hbuilderx/launch.json +++ b/.hbuilderx/launch.json @@ -4,22 +4,19 @@ "version" : "0.0", "configurations" : [ { - "app-plus" : - { - "launchtype" : "local" - }, - "default" : - { - "launchtype" : "local" - }, - "mp-weixin" : - { - "launchtype" : "local" - }, - "type" : "uniCloud" + "app-plus" : { + "launchtype" : "local" + }, + "default" : { + "launchtype" : "local" + }, + "mp-weixin" : { + "launchtype" : "local" + }, + "type" : "uniCloud" }, { - "playground" : "custom", + "playground" : "standard", "type" : "uni-app:app-android" } ] diff --git a/config.js b/config.js index bca4a04..df7b558 100644 --- a/config.js +++ b/config.js @@ -3,7 +3,8 @@ module.exports = { // baseUrl: 'https://www.nuoyunr.com', // baseUrl: 'http://124.222.105.7:48080', // baseUrl: 'http://192.168.1.4:48080', - baseUrl: "http://localhost:48080", + // baseUrl: "http://localhost:48080", + baseUrl: "http://rzqhb7.natappfree.cc", imagesUrl: 'http://shequ.0315e.com/static/images/pages/', baseImageUrl: 'https://www.nuoyunr.com/minio/', shareUrl: 'https://www.lighting-it.cn/share?inviteId=', diff --git a/pages-warehouse/inOutWarehouse/part.vue b/pages-warehouse/inOutWarehouse/part.vue index 889de05..66ccb0b 100644 --- a/pages-warehouse/inOutWarehouse/part.vue +++ b/pages-warehouse/inOutWarehouse/part.vue @@ -11,7 +11,7 @@ 关键字 - 查询 + 查询 备注 @@ -35,8 +35,8 @@ - - + + 进价 - + 售价 - + 分类 - + {{ getServerName(item.wares.type) }} @@ -63,7 +66,8 @@ 计量单价 - + {{ getUnitName(item.wares.unit) }} @@ -71,30 +75,23 @@ 数量 - + 数量 - + 仓库 - + - - - - - - - - - - @@ -151,6 +148,8 @@ export default { subLoading: false, waresTree: [], chooseWares: null, + keys: [], + values: null }; }, onLoad(data) { @@ -173,7 +172,7 @@ export default { }, computed: {}, methods: { - listWarehouse(){ + listWarehouse() { request({ url: '/admin-api/conf/baseWarehouse/list', method: 'get' @@ -182,29 +181,29 @@ export default { }) }, chooseItem(item) { - const parentIndex = this.partList.map(([key, value]) => value).reduce((acc, value) => acc.concat(value)).findIndex(i => i.id === item.id) - const index = this.selectRows.findIndex(i => i.id === item.id) - if (index === -1){ - this.$set(item, 'isSelected', true) - this.selectRows.push(item) - }else { - this.$set(item, 'isSelected', false) - this.selectRows.splice(index, 1) + const index = this.selectRows.findIndex(i => i.id === item.id); + if (index === -1) { + item.isSelected = true; + this.selectRows.push(item); + } else { + item.isSelected = false; + this.selectRows.splice(index, 1); } - if (parentIndex !== -1){ - const partListFlat = this.partList - .map(([key, value]) => value) - .reduce((acc, value) => acc.concat(value), []); - this.$set(partListFlat, parentIndex, { ...partListFlat[parentIndex], isSelected: item.isSelected }); - const updatedPartList = this.partList.map(([key, value]) => { - const newValue = value.map(v => { - const foundItem = partListFlat.find(f => f.id === v.id); - return foundItem ? { ...v, ...foundItem } : v; - }); - return [key, newValue]; + + // 将 Map 中的所有值展平成一个数组 + const partListFlat = Array.from(this.values.values()).flat(); + + // 更新 Map 中的值 + const updatedValues = new Map(); + for (const [key, value] of this.values) { + const newValue = value.map(v => { + const foundItem = partListFlat.find(f => f.id === v.id); + return foundItem ? { ...v, ...foundItem } : v; }); - this.$set(this, 'partList', updatedPartList); + updatedValues.set(key, newValue); } + + this.values = updatedValues; }, searchQuery() { this.getSoiId() @@ -214,7 +213,7 @@ export default { const index = this.unitList.findIndex(item => item.value === id) if (index !== -1) { return this.unitList[index].label - }else { + } else { return "请选择" } } @@ -325,6 +324,8 @@ export default { i.totalPrice = i.waresCount * i.wares.purPrice }) }) + this.keys = this.partList.map(([key, value]) => key) + this.values = new Map(this.partList) }) }, /** @@ -360,7 +361,7 @@ export default { */ submit() { const userInfo = getUserInfo() - const values = this.partList.map(([key, value]) => value).reduce((acc, value) => acc.concat(value)) + const values = Array.from(this.values.values()).flat(); const data = { soType: '01', purchaseType: '01', @@ -388,7 +389,7 @@ export default { } })] data.waresList = [...values.map(item => item.wares)] - if (this.twId){ + if (this.twId) { data.twId = this.twId } request({ @@ -426,38 +427,40 @@ export default { }) }) const values = this.partList.map(([key, value]) => value) - if (!this.selectRows || this.selectRows.length === 0){ + if (!this.selectRows || this.selectRows.length === 0) { values.forEach(item => { item.forEach(i => { i.isSelected = false }) }) - }else { + } else { values.forEach(item => { item.forEach(i => { i.isSelected = this.selectRows.findIndex(j => j.id === i.id) !== -1 }) }) } + this.keys = this.partList.map(([key, value]) => key) + this.values = new Map(this.partList) }) }, /** * 入库 */ inWare() { - if (!this.subLoading){ + if (!this.subLoading) { this.subLoading = true const data = { id: this.soId, soNo: createUniqueCodeByHead("RK") } - const values = this.partList.map(([key, value]) => value).reduce((acc, item) => acc.concat(item)) - if (this.selectRows && this.selectRows.length > 0){ + const values = Array.from(this.values.values()).flat(); + if (this.selectRows && this.selectRows.length > 0) { const ids = this.selectRows.map(item => item.id) const newSelect = values.filter(item => ids.includes(item.id)) data.soiList = [...newSelect] data.waresList = [...newSelect.map(item => item.wares)] - }else { + } else { data.soiList = [...values] data.waresList = [...values.map(item => item.wares)] }