From d79160ac533dffa25e2d96cd01559a11370eeca7 Mon Sep 17 00:00:00 2001 From: xiaofajia <1665375861@qq.com> Date: Thu, 17 Oct 2024 12:10:33 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B3=E8=AF=B7=E8=BD=AC=E9=87=87=E8=B4=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repair/stockOperate/Components/SoSow.vue | 2 +- .../stockOperate/Components/SoiTable.vue | 2 +- .../stockOperate/Components/WaresItem.vue | 276 +++++++++++++++++- 3 files changed, 273 insertions(+), 7 deletions(-) diff --git a/src/views/repair/stockOperate/Components/SoSow.vue b/src/views/repair/stockOperate/Components/SoSow.vue index a0ad199..1bfc489 100644 --- a/src/views/repair/stockOperate/Components/SoSow.vue +++ b/src/views/repair/stockOperate/Components/SoSow.vue @@ -164,7 +164,7 @@ export default { this.loading = false }, getWareHoseName(value){ - return this.warehouseList.find(item => item.id === value).name + return this.warehouseList?.find(item => item.id === value)?.name } } } diff --git a/src/views/repair/stockOperate/Components/SoiTable.vue b/src/views/repair/stockOperate/Components/SoiTable.vue index 9aae4e6..36e83f4 100644 --- a/src/views/repair/stockOperate/Components/SoiTable.vue +++ b/src/views/repair/stockOperate/Components/SoiTable.vue @@ -161,7 +161,7 @@ export default { }, getWareHoseName(value){ if (!(this.warehouseList && this.warehouseList.length > 0)) return '' - return this.warehouseList.find(item => item.id === value).name + return this.warehouseList.find(item => item.id === value)?.name } } } diff --git a/src/views/repair/stockOperate/Components/WaresItem.vue b/src/views/repair/stockOperate/Components/WaresItem.vue index 46b4e1e..4f21de6 100644 --- a/src/views/repair/stockOperate/Components/WaresItem.vue +++ b/src/views/repair/stockOperate/Components/WaresItem.vue @@ -59,6 +59,85 @@ 全部生成采购单 + + + + + + + + + +
+ + {{ scope.row.code }} +
+
+ +
+ + {{ scope.row.warehouseName }} +
+
+ + + + + +
+ + {{ scope.row.count }} +
+
+ + +
+ + {{ scope.row.newPrice }} +
+
+ + +
+ + {{ scope.row.remark }} +
+
+ + + +
+ + + + + + +
@@ -67,9 +146,14 @@ import {getPage, pass} from "@/api/repair/tickets/TicketWares"; import {listTwItem} from "@/api/repair/tickets/TWItem"; import {createUniqueCodeByHead} from "@/utils/createUniqueCode"; import {parseTime} from "@/utils/ruoyi"; +import SoTable from "@/views/repair/stockOperate/Components/SoTable.vue"; +import WarehouseChoose from "@/views/repair/Components/WarehouseChoose.vue"; +import {createRepairSo} from "@/api/repair/stockOperate/stockOperate"; +import {getUserProfile} from "@/api/system/user"; export default { name: "WaresItem", + components: {WarehouseChoose, SoTable}, props:{ type: Boolean, }, @@ -89,7 +173,15 @@ export default { items:[], dialogLoading: false, selections:[], - formData:{} + formData:{}, + inStockDialog: false, + partList: [], + includeColumn: ['count', 'totalPrice'], + // 保存进入编辑的cell + clickCellMap: {}, + // 需要编辑的属性 + editProp: ['warehouse', 'count', 'newPrice', 'remark', 'code'], + remark: null, } }, mounted() { @@ -145,13 +237,29 @@ export default { this.dialogVisible = false } }, - // todo 生成采购 true是全部、false是选择 + // 生成采购 true是全部、false是选择 async handleCreate(flag){ + this.inStockDialog = true if (flag){ - + this.partList = [...this.items.map(item => { + return { + ...item.wares, + count: item.waresCount, + newPrice: item.wares.purPrice, + totalPrice: item.waresCount * item.wares.purPrice + } + })] }else { - + this.partList = [...this.selections.map(item => { + return { + ...item.wares, + count: item.waresCount, + newPrice: item.wares.price, + totalPrice: item.waresCount * item.wares.price + } + })] } + this.dialogVisible = false }, async getList(){ try { @@ -206,7 +314,133 @@ export default { }, handleSelect(row){ this.selections = row - } + }, + // 设置不统计的字段 + getSummaries(param) { + const {columns, data} = param + const sums = [] + columns.forEach((column, index) => { + if (index === 0) { + sums[index] = '合计'; + return; + } + const values = data.map(item => Number(item[column.property])); + if (this.includeColumn.includes(column.property)) { + sums[index] = values.reduce((prev, curr) => { + const value = Number(curr); + if (!isNaN(value)) { + return prev + curr; + } else { + return prev; + } + }, 0); + sums[index]; + } + }); + return sums + }, + /** 鼠标移入cell */ + handleCellEnter(row, column, cell, event) { + const property = column.property + if (this.editProp.includes(property)) { + cell.querySelector('.item__txt').classList.add('item__txt--hover') + } + }, + /** 鼠标移出cell */ + handleCellLeave(row, column, cell, event) { + const property = column.property + if (this.editProp.includes(property)) { + cell.querySelector('.item__txt').classList.remove('item__txt--hover') + } + }, + /** 点击cell */ + handleCellClick(row, column, cell, event) { + const property = column.property + if (this.editProp.includes(property)) { + // 保存cell + this.saveCellClick(row, cell) + cell.querySelector('.item__txt').style.display = 'none' + cell.querySelector('.item__input').style.display = 'inline' + cell.querySelector('input').focus() + } + }, + /** 取消编辑状态 */ + cancelEditable(cell) { + cell.querySelector('.item__txt').style.display = 'inline' + cell.querySelector('.item__input').style.display = 'none' + }, + /** 保存进入编辑的cell */ + saveCellClick(row, cell) { + const id = row.id + if (this.clickCellMap[id] !== undefined) { + if (!this.clickCellMap[id].includes(cell)) { + this.clickCellMap[id].push(cell) + } + } else { + this.clickCellMap[id] = [cell] + } + }, + /** 保存数据 */ + save(row) { + // 更新表格的数据 + row.totalPrice = row.count * row.newPrice + const id = row.id + // 取消本行所有cell的编辑状态 + this.clickCellMap[id].forEach(cell => { + this.cancelEditable(cell) + }) + this.clickCellMap[id] = [] + }, + changeWare(row) { + if (row.ware) { + row['wareId'] = row.ware.id + row['warehouse'] = row.ware.id + row['warehouseName'] = row.ware.name + } + }, + // 通知父组件,删除数据 + deleteItem(index) { + this.partList.splice(index, 1) + }, + // 提交 + async handleSubmit(){ + try { + await this.createInit() + await createRepairSo(this.formData) + this.inStockDialog = false + this.$modal.msgSuccess("新增成功") + await this.getList() + }catch{ + } + }, + // 提交前的构建 + async createInit(){ + const res = await getUserProfile() + this.formData = {} + this.formData = { + soType: '01', + purchaseType: '01', + soNo: createUniqueCodeByHead("CG"), + 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) => {return x + y.totalPrice}, 0), + soStatus: "03", + remark: this.remark, + } + this.formData.goodsList = [...this.partList.map(item => { + return { + soiType: '01', + goodsId: item.id, + goodsType: '0', + wareId: item?.wareId, + goodsCount: item.count, + goodsPrice: item.newPrice, + remark: item.remark + } + })] + }, } } @@ -215,4 +449,36 @@ export default { ::v-deep .el-table .stock td{ background-color: #ff0000 !important; /* 红色背景 */ } +.item { + .item__input { + display: none; + width: 100px; + /* 调整elementUI中样式 如果不需要调整请忽略 */ + .el-input__inner { + height: 24px !important; + } + + /* 调整elementUI中样式 如果不需要调整请忽略 */ + .el-input__suffix { + i { + font-size: 12px !important; + line-height: 26px !important; + } + } + } + + .item__txt { + box-sizing: border-box; + border: 1px solid transparent; + width: 100px; + line-height: 24px; + padding: 0 8px; + } + + .item__txt--hover { + border: 1px solid #dddddd; + border-radius: 4px; + cursor: text; + } +}