feat: 票据退领管理

This commit is contained in:
ycy 2024-04-08 14:08:50 +08:00
parent 61ea10ecf3
commit c03aed34df
5 changed files with 146 additions and 96 deletions

View File

@ -67,6 +67,60 @@ const ReceiptList = Mock.mock([
],
},
]);
const quitneckList = Mock.mock([
{
list: [
{
"id|+1": 0,
billserial: "@integer(100000000,199999999)1",
proposer: "孙东宇",
billType: "@integer(0,4)",
receiptNum: "@integer(1,10)",
receiptDate: "@date",
useInfo: "@csentence",
},
],
},
{
list: [
{
"id|+1": 0,
billserial: "@integer(100000000,199999999)1",
proposer: "杨春宇",
billType: "@integer(0,4)",
receiptNum: "@integer(1,10)",
receiptDate: "@date",
useInfo: "@csentence",
},
],
},
{
list: [
{
"id|+1": 0,
billserial: "@integer(100000000,199999999)1",
proposer: "吕才卓",
billType: "@integer(0,4)",
receiptNum: "@integer(1,10)",
receiptDate: "@date",
useInfo: "@csentence",
},
],
},
{
list: [
{
"id|+1": 0,
billserial: "@integer(100000000,199999999)1",
proposer: "刘欣宇",
billType: "@integer(0,4)",
receiptNum: "@integer(1,10)",
receiptDate: "@date",
useInfo: "@csentence",
},
],
},
]);
const personName = () => {
return [

View File

@ -36,8 +36,8 @@
></t-input>
</t-form-item>
<t-form-item label="退领时间:" name="receiptDate">
<t-date-picker v-model="scarchData.receiptDate" clearable />
<t-form-item label="退领时间:" name="quitneckDate">
<t-date-picker v-model="scarchData.quitneckDate" clearable />
</t-form-item>
<t-form-item
label="票据类型:"
@ -97,8 +97,8 @@
}}</span>
</div>
</template>
<template #receiptNum="{ row }">
{{ `${row.receiptNum}` }}
<template #quitneckNum="{ row }">
{{ `${row.quitneckNum}` }}
</template>
</t-base-table>
</t-content>
@ -112,14 +112,16 @@
import { ref, onMounted, nextTick } from "vue";
import { MessagePlugin } from "tdesign-vue-next";
import { LoadIcon } from "tdesign-icons-vue-next";
import { useQuitneckList } from "@/stores/billQuitneck";
import { useReceiptList } from "@/stores/billReceipt";
const quitneckList = useQuitneckList();
const receiptList = useReceiptList();
const personName = ref([]);
const tableData = ref([]);
const data = ref([]);
const rowItem = ref({});
const loading = ref(false);
const visiblePost = ref(false);
const columns = ref([
{
colKey: "serial-number",
@ -157,8 +159,8 @@ const columns = ref([
width: 100,
},
{
colKey: "quitneckInfo",
title: "退领原",
colKey: "quitneckReason",
title: "退领原",
ellipsis: true,
align: "center",
width: 200,
@ -172,16 +174,9 @@ const billType = ref([
{ label: "票据类型4", value: 3 },
{ label: "票据类型5", value: 4 },
]);
const dialogData = ref({
quitneckDate: "",
quitneckReason: "",
quitneckNum: "",
});
//
const scarchData = ref({
billserial: "",
});
const scarchData = ref({});
//
const pagination = ref({
@ -195,33 +190,23 @@ const personList = async () => {
personName.value = await receiptList.getPersonNameList();
};
//
const FORM_RULES = {
quitneckNum: [{ required: true, message: "请输入退领张数", trigger: "blur" }],
quitneckDate: [
{ required: true, message: "请选择退领日期", trigger: "change" },
],
quitneckReason: [
{ required: true, message: "请输入退领原因", trigger: "blur" },
],
};
//
const headerQuery = () => {
tableData.value = data.value;
console.log(
scarchData.value.billserial,
scarchData.value.billType,
scarchData.value.receiptDate
scarchData.value.quitneckDate
);
if (
scarchData.value.billserial === "" &&
(scarchData.value.billType === undefined ||
scarchData.value.billType === "") &&
(scarchData.value.receiptDate === undefined ||
scarchData.value.receiptDate === "")
(scarchData.value.quitneckDate === undefined ||
scarchData.value.quitneckDate === "")
) {
getNewTable();
tableData.value = data.value;
pagination.value.total = tableData.value.length;
} else {
const list = tableData.value.filter((item) => {
let arrList;
@ -231,16 +216,17 @@ const headerQuery = () => {
if (scarchData.value.billType === item.billType) {
arrList = item;
}
if (scarchData.value.receiptDate === item.receiptDate) {
if (scarchData.value.quitneckDate === item.quitneckDate) {
arrList = item;
}
if (
scarchData.value.billserial === "" &&
scarchData.value.billType === "" &&
scarchData.value.receiptDate === ""
scarchData.value.quitneckDate === ""
) {
arrList = item;
}
console.log(arrList);
return arrList;
});
tableData.value = list;
@ -252,11 +238,13 @@ const resetting = () => {
scarchData.value = {
billserial: "",
billType: "",
receiptDate: "",
quitneckDate: "",
};
getNewTable();
tableData.value = data.value;
pagination.value.total = tableData.value.length;
};
const rowItem = ref({});
//
const Quitneck = (value) => {
dialogData.value = {
quitneckDate: "",
@ -266,23 +254,6 @@ const Quitneck = (value) => {
visiblePost.value = true;
rowItem.value = value;
};
//
const quitneckAdd = async ({ validateResult, firstError }) => {
if (validateResult === true) {
if (rowItem.value.row.receiptNum - dialogData.value.quitneckNum < 0) {
return MessagePlugin.error("退领数量不能大于领用数量");
}
dialogData.value.quitneckNum =
rowItem.value.row.receiptNum - dialogData.value.quitneckNum;
dialogData.value.id = rowItem.value.row.id;
await receiptList.getquitneckNum(dialogData.value);
getTableData();
MessagePlugin.success("提交成功");
visiblePost.value = false;
} else {
console.log("Validate Errors: ", firstError, validateResult);
}
};
const onClick = async (context) => {
//
if (context.node.value === "t1") {
@ -290,12 +261,8 @@ const onClick = async (context) => {
}
loading.value = true;
//
tableData.value = await receiptList.getReceiptList({
name: context.node.label,
});
data.value = await receiptList.getReceiptList({
name: context.node.label,
});
tableData.value = await quitneckList.getQuitneckList(context.node.label);
data.value = await quitneckList.getQuitneckList(context.node.label);
pagination.value.total = tableData.value.length;
const timerId = setTimeout(() => {
loading.value = false;
@ -305,8 +272,9 @@ const onClick = async (context) => {
//
const refresh = () => {
getTableData();
pagination.value.total = tableData.value.length;
};
// menuManagement
// ReceiptList
const getPersonName = () => {
let arr = JSON.parse(localStorage.getItem("ReceiptList"));
if (arr) {
@ -315,38 +283,8 @@ const getPersonName = () => {
personList();
}
};
// menuManagement
const getTableData = async () => {
let arr = JSON.parse(localStorage.getItem("ReceiptList"));
if (arr.receiptList.length > 0) {
loading.value = true;
tableData.value = arr.receiptList;
pagination.value.total = tableData.value.length;
const timerId = setTimeout(() => {
loading.value = false;
clearInterval(timerId);
}, 300);
} else {
await nextTick();
//
const firstNodeWithChildren = personName.value.find(
(node) => Array.isArray(node.children) && node.children.length > 0
);
if (firstNodeWithChildren) {
const simulatedContext = {
node: {
label: "孙东宇",
},
};
onClick(simulatedContext);
}
}
};
onMounted(async () => {
getPersonName();
getTableData();
// personName
});
</script>

View File

@ -196,6 +196,8 @@ const tableData = ref([]);
const data = ref([]);
const loading = ref(false);
const visiblePost = ref(false);
const rowItem = ref({});
const columns = ref([
{
colKey: "serial-number",
@ -339,7 +341,6 @@ const resetting = () => {
};
getNewTable();
};
const rowItem = ref({});
const Quitneck = (value) => {
dialogData.value = {
quitneckDate: "",
@ -355,9 +356,10 @@ const quitneckAdd = async ({ validateResult, firstError }) => {
if (rowItem.value.row.receiptNum - dialogData.value.quitneckNum < 0) {
return MessagePlugin.error("退领数量不能大于领用数量");
}
dialogData.value.quitneckNum =
rowItem.value.row.receiptNum - dialogData.value.quitneckNum;
dialogData.value.id = rowItem.value.row.id;
dialogData.value.billserial = rowItem.value.row.billserial;
dialogData.value.billType = rowItem.value.row.billType;
dialogData.value.proposer = rowItem.value.row.proposer;
await receiptList.getquitneckNum(dialogData.value);
getTableData();
MessagePlugin.success("提交成功");
@ -429,7 +431,6 @@ const getTableData = async () => {
onMounted(async () => {
getPersonName();
getTableData();
// personName
});
</script>

View File

@ -0,0 +1,56 @@
import { defineStore } from "pinia";
export const useQuitneckList = defineStore("QuitneckList", {
state: () => {
return {
sdyList: [],
ycyList: [],
lczList: [],
lxyList: [],
};
},
actions: {
getQuitneckList(name) {
this.sdyList = [];
this.ycyList = [];
this.lczList = [];
this.lxyList = [];
const allArr = JSON.parse(
localStorage.getItem("ReceiptList")
).quitneckList;
if (name === "孙东宇") {
allArr.forEach((item) => {
if (item.proposer === "孙东宇") {
this.sdyList.push(item);
}
});
return this.sdyList;
}
if (name === "杨春宇") {
allArr.forEach((item) => {
if (item.proposer === "杨春宇") {
this.ycyList.push(item);
}
});
return this.ycyList;
}
if (name === "吕才卓") {
allArr.forEach((item) => {
if (item.proposer === "吕才卓") {
this.lczList.push(item);
}
});
return this.lczList;
}
if (name === "刘欣宇") {
allArr.forEach((item) => {
if (item.proposer === "刘欣宇") {
this.lxyList.push(item);
}
});
return this.lxyList;
}
},
},
persist: true,
});

View File

@ -9,6 +9,7 @@ export const useReceiptList = defineStore("ReceiptList", {
return {
personName: [],
receiptList: [],
quitneckList: [],
};
},
actions: {
@ -25,12 +26,12 @@ export const useReceiptList = defineStore("ReceiptList", {
return this.receiptList;
},
async getquitneckNum(obj) {
console.log(obj);
const index = this.receiptList.findIndex((item) => item.id === obj.id);
if (index !== -1) {
this.receiptList[index].receiptNum = obj.quitneckNum;
this.receiptList[index].receiptNum =
this.receiptList[index].receiptNum - obj.quitneckNum;
}
console.log(this.receiptList);
this.quitneckList.push(obj);
},
},
persist: true,