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">
<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 label="入库日期:" name="stockDate">
@ -80,14 +80,14 @@
theme="default"
variant="text"
size="small"
@click="look(slotProps)"
>查看</t-button
@click="stockEdit(slotProps)"
>修改</t-button
>
<t-button
theme="default"
variant="text"
size="small"
@click="deleteBtn(slotProps)"
@click="stockDelete(slotProps)"
>删除</t-button
>
</template>
@ -299,6 +299,9 @@ const tableList = async () => {
data.value = await stockList.getStockList();
pagination.value.total = tableData.value.length;
};
const refresh = () => {
tableList();
};
const dialogData = ref({
billserial: "",
@ -327,7 +330,7 @@ const resetting = () => {
tableList();
};
const headerQuery = ({ validateResult, firstError }) => {
const headerQuery = () => {
tableData.value = data.value;
if (
formData.value.billserial === "" &&
@ -357,16 +360,27 @@ const headerQuery = ({ validateResult, firstError }) => {
}
return arrList;
});
console.log(list);
tableData.value = list;
// @ts-expect-error
pagination.value.total = list.length;
}
};
//
const addStock = () => {
visiblePost.value = true;
dialogData.value = {
billserial: "",
stockNum: "",
unit: "",
operator: "",
remark: "",
stockDate: "",
};
};
//
const closePost = () => {
visiblePost.value = false;
};
//
const FORM_RULES = {
@ -381,10 +395,49 @@ const FORM_RULES = {
],
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(() => {
tableList();
getNewTable();
});
</script>

View File

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

View File

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