diff --git a/src/pages/finance-bill-manage/billDestroy.vue b/src/pages/finance-bill-manage/billDestroy.vue index 499baed..018893e 100644 --- a/src/pages/finance-bill-manage/billDestroy.vue +++ b/src/pages/finance-bill-manage/billDestroy.vue @@ -206,6 +206,13 @@ const columns = ref([ align: "center", width: "100", }, + { + colKey: "breakInfo", + title: "报损原因", + ellipsis: true, + align: "center", + width: "100", + }, { colKey: "status", title: "操作", @@ -337,12 +344,13 @@ const FORM_RULES = { const breakSub = async ({ validateResult, firstError }) => { if (validateResult === true) { dialogData.value = { - ...rowItem.row.value, + ...rowItem.value.row, + breakStatus: Number(dialogData.value.Status), }; await destroyList.auditDestroyList(dialogData.value); getNewTable(); - MessagePlugin.success("提交成功"); visiblePost.value = false; + MessagePlugin.success("提交成功"); } else { console.log("Validate Errors: ", firstError, validateResult); } diff --git a/src/stores/billDestroy.js b/src/stores/billDestroy.js index d4a463e..9cd9510 100644 --- a/src/stores/billDestroy.js +++ b/src/stores/billDestroy.js @@ -8,15 +8,32 @@ export const useDestroy = defineStore("destroyList", { }, actions: { async getDestroyList() { - this.destroyList = JSON.parse( - localStorage.getItem("breakageList") - ).destroyList; - console.log(this.destroyList); + const storedData = localStorage.getItem("breakageList"); + if (storedData) { + const parsedData = JSON.parse(storedData); + this.destroyList = parsedData.destroyList; + } return this.destroyList; }, auditDestroyList(item) { - console.log(item); - // let arr = thisz + const storedData = localStorage.getItem("breakageList"); + if (storedData) { + const parsedData = JSON.parse(storedData); + parsedData.destroyList = parsedData.destroyList.filter( + (i) => i.id !== item.id + ); + parsedData.breakageList = parsedData.breakageList.map((i) => { + console.log(i.id, item.id); + if (i.id === item.id) { + console.log(item.breakStatus); + return { ...i, breakStatus: item.breakStatus }; // 返回更新后的对象 + } + return i; // 保持其他项不变 + }); + console.log(parsedData.breakageList); + localStorage.setItem("breakageList", JSON.stringify(parsedData)); + this.destroyList = parsedData.destroyList; // 更新store中的destroyList状态 + } }, }, persist: true,