Compare commits
2 Commits
d931037347
...
68e6e55810
Author | SHA1 | Date | |
---|---|---|---|
|
68e6e55810 | ||
|
20d3c2b9ad |
|
@ -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>
|
||||||
|
@ -217,175 +217,248 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, ref, onMounted } from 'vue'
|
import { reactive, ref, onMounted } from "vue";
|
||||||
import { MessagePlugin } from 'tdesign-vue-next'
|
import { MessagePlugin } from "tdesign-vue-next";
|
||||||
import { AddIcon, LoadIcon } from 'tdesign-icons-vue-next'
|
import { AddIcon, LoadIcon } from "tdesign-icons-vue-next";
|
||||||
import { reqStockList } from '@/api/stockList'
|
import { reqStockList } from "@/api/stockList";
|
||||||
import { useStock } from '@/stores/billStock'
|
import { useStock } from "@/stores/billStock";
|
||||||
// import { number } from "echarts";
|
|
||||||
|
|
||||||
const loading = ref(false)
|
// 数据
|
||||||
const visiblePost = ref(false)
|
const loading = ref(false);
|
||||||
const stockList = useStock()
|
const visiblePost = ref(false);
|
||||||
const tableData = ref()
|
const stockList = useStock();
|
||||||
const data = ref()
|
const tableData = ref();
|
||||||
|
const data = ref();
|
||||||
|
// 表格表头
|
||||||
const columns = ref([
|
const columns = ref([
|
||||||
{
|
{
|
||||||
colKey: 'serial-number',
|
colKey: "serial-number",
|
||||||
title: '序号',
|
title: "序号",
|
||||||
width: 50
|
width: 50,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
colKey: 'billserial',
|
colKey: "billserial",
|
||||||
title: '票据编号',
|
title: "票据编号",
|
||||||
align: 'center',
|
align: "center",
|
||||||
width: '100'
|
width: "100",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
colKey: 'billType',
|
colKey: "billType",
|
||||||
title: '票据类型',
|
title: "票据类型",
|
||||||
align: 'center',
|
align: "center",
|
||||||
width: '100'
|
width: "100",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
colKey: 'stockNum',
|
colKey: "stockNum",
|
||||||
title: '入库数量',
|
title: "入库数量",
|
||||||
align: 'center',
|
align: "center",
|
||||||
width: '100'
|
width: "100",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
colKey: 'unit',
|
colKey: "unit",
|
||||||
title: '单位(如:本、张)',
|
title: "单位(如:本、张)",
|
||||||
align: 'center',
|
align: "center",
|
||||||
width: '100'
|
width: "100",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
colKey: 'stockDate',
|
colKey: "stockDate",
|
||||||
title: '入库日期',
|
title: "入库日期",
|
||||||
align: 'center',
|
align: "center",
|
||||||
width: '100'
|
width: "100",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
colKey: 'operator',
|
colKey: "operator",
|
||||||
title: '操作员',
|
title: "操作员",
|
||||||
align: 'center',
|
align: "center",
|
||||||
width: '100'
|
width: "100",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
colKey: 'remark',
|
colKey: "remark",
|
||||||
title: '备注',
|
title: "备注",
|
||||||
align: 'center',
|
align: "center",
|
||||||
width: '100'
|
width: "100",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
colKey: 'status',
|
colKey: "status",
|
||||||
title: '操作',
|
title: "操作",
|
||||||
width: 120,
|
width: 120,
|
||||||
align: 'center',
|
align: "center",
|
||||||
fixed: 'right'
|
fixed: "right",
|
||||||
}
|
},
|
||||||
])
|
]);
|
||||||
|
|
||||||
|
// 票据类型
|
||||||
const billType = ref([
|
const billType = ref([
|
||||||
{ label: '票据类型1', value: 0 },
|
{ label: "票据类型1", value: 0 },
|
||||||
{ label: '票据类型2', value: 1 },
|
{ label: "票据类型2", value: 1 },
|
||||||
{ label: '票据类型3', value: 2 },
|
{ label: "票据类型3", value: 2 },
|
||||||
{ label: '票据类型4', value: 3 },
|
{ label: "票据类型4", value: 3 },
|
||||||
{ label: '票据类型5', value: 4 }
|
{ label: "票据类型5", value: 4 },
|
||||||
])
|
]);
|
||||||
|
|
||||||
|
// 获取票据列表
|
||||||
const tableList = async () => {
|
const tableList = async () => {
|
||||||
tableData.value = await stockList.getStockList()
|
loading.value = true;
|
||||||
data.value = await stockList.getStockList()
|
tableData.value = await stockList.getStockList();
|
||||||
pagination.value.total = tableData.value.length
|
data.value = await stockList.getStockList();
|
||||||
}
|
pagination.value.total = tableData.value.length;
|
||||||
|
const timerId = setTimeout(() => {
|
||||||
|
loading.value = false;
|
||||||
|
clearInterval(timerId);
|
||||||
|
}, 300);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 刷新列表
|
||||||
|
const refresh = () => {
|
||||||
|
tableList();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 弹出框表单
|
||||||
const dialogData = ref({
|
const dialogData = ref({
|
||||||
billserial: '',
|
billserial: "",
|
||||||
stockNum: number,
|
stockNum: Number,
|
||||||
unit: '',
|
unit: "",
|
||||||
operator: '',
|
operator: "",
|
||||||
remark: '',
|
remark: "",
|
||||||
stockDate: ''
|
stockDate: "",
|
||||||
})
|
});
|
||||||
|
|
||||||
|
// 查询表单
|
||||||
const formData = ref({
|
const formData = ref({
|
||||||
billserial: '',
|
billserial: "",
|
||||||
billType: '',
|
billType: "",
|
||||||
stockDate: ''
|
stockDate: "",
|
||||||
})
|
});
|
||||||
|
|
||||||
|
// 分页
|
||||||
const pagination = ref({
|
const pagination = ref({
|
||||||
defaultCurrent: 1,
|
defaultCurrent: 1,
|
||||||
defaultPageSize: 10,
|
defaultPageSize: 10,
|
||||||
total: 50
|
total: 50,
|
||||||
})
|
});
|
||||||
|
|
||||||
|
// 查询表单重置
|
||||||
const resetting = () => {
|
const resetting = () => {
|
||||||
formData.value = {
|
formData.value = {
|
||||||
billserial: '',
|
billserial: "",
|
||||||
billType: '',
|
billType: "",
|
||||||
stockDate: ''
|
stockDate: "",
|
||||||
}
|
};
|
||||||
tableList()
|
tableList();
|
||||||
}
|
};
|
||||||
|
|
||||||
const headerQuery = ({ validateResult, firstError }) => {
|
// 查询
|
||||||
tableData.value = data.value
|
const headerQuery = () => {
|
||||||
|
tableData.value = data.value;
|
||||||
if (
|
if (
|
||||||
formData.value.billserial === '' &&
|
formData.value.billserial === "" &&
|
||||||
(formData.value.billType === undefined || formData.value.billType === '') &&
|
(formData.value.billType === undefined || formData.value.billType === "") &&
|
||||||
formData.value.stockDate === ''
|
formData.value.stockDate === ""
|
||||||
) {
|
) {
|
||||||
tableList()
|
tableList();
|
||||||
} else {
|
} else {
|
||||||
const list = tableData.value.filter(item => {
|
const list = tableData.value.filter((item) => {
|
||||||
console.log(item)
|
console.log(item);
|
||||||
let arrList
|
let arrList;
|
||||||
if (formData.value.billserial === item.billserial) {
|
if (formData.value.billserial === item.billserial) {
|
||||||
arrList = item
|
arrList = item;
|
||||||
}
|
}
|
||||||
if (formData.value.billType === item.billType) {
|
if (formData.value.billType === item.billType) {
|
||||||
arrList = item
|
arrList = item;
|
||||||
}
|
}
|
||||||
if (formData.value.stockDate === item.stockDate) {
|
if (formData.value.stockDate === item.stockDate) {
|
||||||
arrList = item
|
arrList = item;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
formData.value.billserial === '' &&
|
formData.value.billserial === "" &&
|
||||||
formData.value.billType === '' &&
|
formData.value.billType === "" &&
|
||||||
formData.value.stockDate === ''
|
formData.value.stockDate === ""
|
||||||
) {
|
) {
|
||||||
arrList = item
|
arrList = item;
|
||||||
}
|
}
|
||||||
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 = {
|
||||||
billserial: [{ required: true, message: '请输入票据编号', trigger: 'blur' }],
|
billserial: [{ required: true, message: "请输入票据编号", trigger: "blur" }],
|
||||||
billType: [
|
billType: [
|
||||||
{ required: true, message: '请选择票据类型', trigger: ['blur', 'change'] }
|
{ required: true, message: "请选择票据类型", trigger: ["blur", "change"] },
|
||||||
],
|
],
|
||||||
stockNum: [{ required: true, message: '请输入库存数量', trigger: 'blur' }],
|
stockNum: [{ required: true, message: "请输入库存数量", trigger: "blur" }],
|
||||||
unit: [{ required: true, message: '请输入单位', trigger: 'blur' }],
|
unit: [{ required: true, message: "请输入单位", trigger: "blur" }],
|
||||||
stockDate: [
|
stockDate: [
|
||||||
{ required: true, message: '请选择入库日期', trigger: ['blur', 'change'] }
|
{ required: true, message: "请选择入库日期", trigger: ["blur", "change"] },
|
||||||
],
|
],
|
||||||
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 = () => {};
|
||||||
|
|
||||||
|
// 判断menuManagement里面是否存在数据
|
||||||
|
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>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user