This commit is contained in:
sundongyu 2024-04-09 13:08:07 +08:00
commit 5651aed6b7
2 changed files with 33 additions and 8 deletions

View File

@ -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);
}

View File

@ -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,