From 58f86a9b2bce04f940f03ca8c278026affa5d2b6 Mon Sep 17 00:00:00 2001 From: lb Date: Fri, 18 Aug 2023 11:02:01 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=8E=8B=E6=9C=BA=E6=8A=A5=E5=B7=A5?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ReportDialog.vue | 158 +++++++++++++++++++++-- src/main.js | 4 +- src/utils/validate.js | 33 +++-- src/views/atomViews/ListViewWithHead.vue | 1 + 4 files changed, 178 insertions(+), 18 deletions(-) diff --git a/src/components/ReportDialog.vue b/src/components/ReportDialog.vue index 05f2785..748499c 100644 --- a/src/components/ReportDialog.vue +++ b/src/components/ReportDialog.vue @@ -16,6 +16,14 @@ 报工预览 + +
+ + 预报工单 + 编辑 + +
+ -
-

编辑

- 返回 -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 预保存 + 取消 + + +
@@ -53,6 +113,18 @@ export default { loading: false, dataList: [], page: 1, + dataForm: { + id: null, + orderCate: null, + orderCode: null, + qty: null, + goodqty: null, + badqty: null, + badratio: null, + team: null, + }, + formLoading: false, + dataFormList: [], tableProps: [ { prop: "orderCode", label: "订单号" }, { prop: "orderCate", label: "订单子号" }, @@ -73,7 +145,7 @@ export default { width: 90, subcomponent: TableOperaionComponent, options: [ - { name: "edit", label: "编辑", icon: "edit-outline" }, + { name: "edit", label: "编辑", icon: "edit-outline", emitFull: true }, // { // name: "delete", // icon: "delete", @@ -84,6 +156,7 @@ export default { ], }, ], + currentEditing: null, }; }, computed: { @@ -91,6 +164,18 @@ export default { return this.dataList.length; }, }, + watch: { + "dataForm.goodqty"(val) { + const qty = +val + +this.dataForm.badqty; + this.dataForm.qty = qty; + this.dataForm.badratio = ((+this.dataForm.badqty / qty) * 100).toFixed(2); + }, + "dataForm.badqty"(val) { + const qty = +val + +this.dataForm.goodqty; + this.dataForm.qty = qty; + this.dataForm.badratio = ((+val / qty) * 100).toFixed(2); + }, + }, methods: { async init() { this.visible = true; @@ -100,32 +185,87 @@ export default { ids: this.ids, }); if (res.code === 0) { - this.dataList = res.data.map((item) => ({ + this.dataList = res.data.map((item, index) => ({ ...item, qty: item.goodqty + item.badqty, + // 该 __LOCAL_INDEX 用于更新本地缓存数据 + __LOCAL_INDEX: index, })); - console.log("this.datalist", this.dataList); } this.loading = false; }, + close() { this.visible = false; }, + handleOperate({ type, data }) { console.log("payload", type, data); switch (type) { case "edit": this.mode = "form"; + this.currentEditing = data.__LOCAL_INDEX; + const { id, orderCate, orderCode, qty, goodqty, badqty, badratio, team } = data; + this.dataForm = { + id, + orderCate, + orderCode, + qty, + goodqty, + badqty, + badratio, + team, + }; break; } }, - handleConfirm() {}, + + async handleConfirm() { + this.loading = true; + const { data: res } = await this.$http.post("/pms/workReport/pressReport", { + datas: this.dataList, + ids: this.ids, + }); + this.loading = false; + if (res.code === 0) { + this.$message.success("提交成功"); + this.$emit('refresh-list') + this.close(); + } + }, + + // 本地缓存编辑过的数据,保存时一并提交给服务器 + handleSaveEdit() { + Object.keys(this.dataForm).forEach((key) => { + this.dataList[this.currentEditing][key] = this.dataForm[key]; + }); + this.mode = "table"; + this.$nextTick(() => { + this.clearDataForm(); + }); + }, + + // 清空输入数据 + clearDataForm() { + this.currentEditing = null; + this.dataForm = { + id: null, + orderCate: null, + orderCode: null, + qty: null, + goodqty: null, + badqty: null, + badratio: null, + team: null, + }; + }, }, };