feat: 完成票据入库管理

This commit is contained in:
ycy 2024-04-07 10:17:43 +08:00
parent 0176354677
commit 20d3c2b9ad
3 changed files with 68 additions and 11 deletions

View File

@ -13,7 +13,7 @@
> >
<div style="margin-left: 1rem"> <div style="margin-left: 1rem">
<t-form-item label="票据编号:" name="billserial"> <t-form-item label="票据编号:" name="billserial">
<t-input v-model="formData.billserial"></t-input> <t-input v-model="formData.billserial" maxlength="10"></t-input>
</t-form-item> </t-form-item>
<t-form-item label="入库日期:" name="stockDate"> <t-form-item label="入库日期:" name="stockDate">
@ -80,14 +80,14 @@
theme="default" theme="default"
variant="text" variant="text"
size="small" size="small"
@click="look(slotProps)" @click="stockEdit(slotProps)"
>查看</t-button >修改</t-button
> >
<t-button <t-button
theme="default" theme="default"
variant="text" variant="text"
size="small" size="small"
@click="deleteBtn(slotProps)" @click="stockDelete(slotProps)"
>删除</t-button >删除</t-button
> >
</template> </template>
@ -299,6 +299,9 @@ const tableList = async () => {
data.value = await stockList.getStockList(); data.value = await stockList.getStockList();
pagination.value.total = tableData.value.length; pagination.value.total = tableData.value.length;
}; };
const refresh = () => {
tableList();
};
const dialogData = ref({ const dialogData = ref({
billserial: "", billserial: "",
@ -327,7 +330,7 @@ const resetting = () => {
tableList(); tableList();
}; };
const headerQuery = ({ validateResult, firstError }) => { const headerQuery = () => {
tableData.value = data.value; tableData.value = data.value;
if ( if (
formData.value.billserial === "" && formData.value.billserial === "" &&
@ -357,16 +360,27 @@ const headerQuery = ({ validateResult, firstError }) => {
} }
return arrList; return arrList;
}); });
console.log(list);
tableData.value = list; tableData.value = list;
// @ts-expect-error // @ts-expect-error
pagination.value.total = list.length; pagination.value.total = list.length;
} }
}; };
//
const addStock = () => { const addStock = () => {
visiblePost.value = true; visiblePost.value = true;
dialogData.value = {
billserial: "",
stockNum: "",
unit: "",
operator: "",
remark: "",
stockDate: "",
};
};
//
const closePost = () => {
visiblePost.value = false;
}; };
// //
const FORM_RULES = { const FORM_RULES = {
@ -381,10 +395,49 @@ const FORM_RULES = {
], ],
operator: [{ required: true, message: "请输入操作员", trigger: "blur" }], operator: [{ required: true, message: "请输入操作员", trigger: "blur" }],
}; };
const stockAdd = () => {};
//
const stockAdd = async ({ validateResult, firstError }) => {
if (validateResult === true) {
await stockList.addStockList(dialogData.value);
getNewTable();
MessagePlugin.success("提交成功");
visiblePost.value = false;
} else {
console.log("Validate Errors: ", firstError, validateResult);
}
};
//
const stockEdit = (item) => {
visiblePost.value = true;
tableData.value.forEach((itemTable) => {
if (itemTable.id === item.row.id) {
dialogData.value = itemTable;
}
});
};
//
const stockDelete = async (itme) => {
await stockList.deleteStockList(itme.row);
getNewTable();
};
const onReset = () => {};
const getNewTable = () => {
let arr = JSON.parse(localStorage.getItem("menuManagement"));
if (arr) {
tableData.value = arr.stockList;
pagination.value.total = tableData.value.length;
} else {
tableList();
}
};
onMounted(() => { onMounted(() => {
tableList(); getNewTable();
}); });
</script> </script>

View File

@ -15,12 +15,16 @@ export const useStock = defineStore("menuManagement", {
}, },
addStockList(arr) { addStockList(arr) {
const index = this.stockList.findIndex((item) => item.id === arr.id); const index = this.stockList.findIndex((item) => item.id === arr.id);
console.log(arr);
if (index !== -1) { if (index !== -1) {
this.stockList[index] = arr; this.stockList[index] = arr;
console.log(this.stockList, "222");
} else { } else {
arr.id = new Date().getTime(); arr.id = new Date().getTime();
this.stockList.unshift(arr); this.stockList.unshift(arr);
localStorage.setItem("stockList", JSON.stringify(this.stockList));
} }
return this.stockList;
}, },
deleteStockList(item) { deleteStockList(item) {
let arr = this.stockList.filter((i) => i.id !== item.id); let arr = this.stockList.filter((i) => i.id !== item.id);

View File

@ -186,7 +186,7 @@ pre {
.back-color { .back-color {
background-color: #f5f7fb; background-color: #f5f7fb;
padding: 16px 24px; padding: 16px 24px;
height: calc(94vh - 64px); height: calc(94vh - 50px);
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
} }