<template>
|
<div class="app-container">
|
<div class="search_form">
|
<div>
|
<span class="search_title">客户名称:</span>
|
<el-input
|
v-model="searchForm.customerName"
|
style="width: 240px"
|
placeholder="请输入"
|
@change="handleQuery"
|
clearable
|
prefix-icon="Search"
|
/>
|
<span class="search_title ml10">项目名称:</span>
|
<el-input
|
v-model="searchForm.customerName"
|
style="width: 240px"
|
placeholder="请输入"
|
@change="handleQuery"
|
clearable
|
prefix-icon="Search"
|
/>
|
<span class="search_title ml10">录入日期:</span>
|
<el-date-picker v-model="searchForm.entryDate" value-format="YYYY-MM-DD" format="YYYY-MM-DD" type="daterange"
|
placeholder="请选择" clearable @change="changeDaterange" />
|
<el-button type="primary" @click="handleQuery" style="margin-left: 10px">搜索</el-button>
|
</div>
|
<div>
|
<el-button type="primary" @click="openForm('add')">生产派工</el-button>
|
</div>
|
</div>
|
<div class="table_list">
|
<PIMTable
|
rowKey="id"
|
:column="tableColumn"
|
:tableData="tableData"
|
:page="page"
|
:isSelection="true"
|
@selection-change="handleSelectionChange"
|
:tableLoading="tableLoading"
|
@pagination="pagination"
|
:total="page.total"
|
></PIMTable>
|
</div>
|
<form-dia ref="formDia" @close="handleQuery"></form-dia>
|
</div>
|
</template>
|
|
<script setup>
|
import {onMounted, ref} from "vue";
|
import FormDia from "@/views/productionManagement/productionDispatching/components/formDia.vue";
|
import dayjs from "dayjs";
|
import {schedulingListPage} from "@/api/productionManagement/productionOrder.js";
|
|
const data = reactive({
|
searchForm: {
|
staffName: "",
|
entryDate: [
|
dayjs().format("YYYY-MM-DD"),
|
dayjs().add(1, "day").format("YYYY-MM-DD"),
|
], // 录入日期
|
entryDateStart: dayjs().format("YYYY-MM-DD"),
|
entryDateEnd: dayjs().add(1, "day").format("YYYY-MM-DD"),
|
},
|
});
|
const { searchForm } = toRefs(data);
|
const tableColumn = ref([
|
{
|
label: "录入日期",
|
prop: "entryDate",
|
width: 120,
|
},
|
{
|
label: "合同号",
|
prop: "salesContractNo",
|
width: 220,
|
},
|
{
|
label: "客户合同号",
|
prop: "customerContractNo",
|
width: 250,
|
},
|
{
|
label: "客户名称",
|
prop: "customerName",
|
width: 250,
|
},
|
{
|
label: "项目名称",
|
prop: "projectName",
|
width:300
|
},
|
{
|
label: "产品大类",
|
prop: "productCategory",
|
width: 160,
|
},
|
{
|
label: "规格型号",
|
prop: "specificationModel",
|
width: 220,
|
},
|
{
|
label: "单位",
|
prop: "unit",
|
width:90
|
},
|
{
|
label: "数量",
|
prop: "quantity",
|
},
|
{
|
label: "排产数量",
|
prop: "schedulingNum",
|
width: 100,
|
},
|
{
|
label: "待排数量",
|
prop: "pendingQuantity",
|
width: 100,
|
},
|
]);
|
const tableData = ref([]);
|
const selectedRows = ref([]);
|
const tableLoading = ref(false);
|
const page = reactive({
|
current: 1,
|
size: 100,
|
total: 0,
|
});
|
const formDia = ref()
|
const { proxy } = getCurrentInstance()
|
|
// 查询列表
|
/** 搜索按钮操作 */
|
const handleQuery = () => {
|
page.current = 1;
|
getList();
|
};
|
const changeDaterange = (value) => {
|
if (value) {
|
searchForm.value.entryDateStart = value[0];
|
searchForm.value.entryDateEnd = value[1];
|
} else {
|
searchForm.value.entryDateStart = undefined;
|
searchForm.value.entryDateEnd = undefined;
|
}
|
handleQuery();
|
};
|
const pagination = (obj) => {
|
page.current = obj.page;
|
page.size = obj.limit;
|
getList();
|
};
|
const getList = () => {
|
tableLoading.value = true;
|
// 构造一个新的对象,不包含entryDate字段
|
const params = { ...searchForm.value, ...page };
|
params.entryDate = undefined
|
schedulingListPage(params).then((res) => {
|
tableLoading.value = false;
|
// 处理每条数据,增加pendingQuantity字段
|
tableData.value = res.data.records.map(item => ({
|
...item,
|
pendingQuantity: (Number(item.quantity) || 0) - (Number(item.schedulingNum) || 0)
|
}));
|
page.total = res.data.total;
|
}).catch(() => {
|
tableLoading.value = false;
|
})
|
};
|
// 表格选择数据
|
const handleSelectionChange = (selection) => {
|
selectedRows.value = selection;
|
};
|
|
// 打开弹框
|
const openForm = (type) => {
|
if (selectedRows.value.length !== 1) {
|
proxy.$message.error("请选择一条数据");
|
return;
|
}
|
if (selectedRows.value[0].pendingQuantity == 0) {
|
proxy.$message.warning("无需再派工");
|
return;
|
}
|
nextTick(() => {
|
formDia.value?.openDialog(type, selectedRows.value[0])
|
})
|
};
|
|
onMounted(() => {
|
searchForm.value.entryDate = [
|
dayjs().format("YYYY-MM-DD"),
|
dayjs().add(1, "day").format("YYYY-MM-DD"),
|
]
|
searchForm.value.entryDateStart = dayjs().format("YYYY-MM-DD")
|
searchForm.value.entryDateEnd = dayjs().add(1, "day").format("YYYY-MM-DD")
|
getList();
|
});
|
</script>
|
|
<style scoped></style>
|