| | |
| | | > |
| | | <el-button type="primary" @click="addRow" style="margin-bottom: 10px;">新增</el-button> |
| | | <span style="font-size: 18px;margin-left: 10px">待排产数量:{{pendingNum}}</span> |
| | | <div style="margin-bottom: 10px; margin-left: 10px;"> |
| | | <el-form-item label="领用:" style="margin-bottom: 0;"> |
| | | <el-input v-model="receive" placeholder="请输入领用" style="width: 200px;" /> |
| | | </el-form-item> |
| | | </div> |
| | | <!-- <div style="margin-bottom: 10px; margin-left: 10px;">--> |
| | | <!-- <el-form-item label="领用:" style="margin-bottom: 0;">--> |
| | | <!-- <el-input v-model="receive" placeholder="请输入领用" style="width: 200px;" />--> |
| | | <!-- </el-form-item>--> |
| | | <!-- </div>--> |
| | | <el-table :data="tableData" border style="width: 100%" :summary-method="summarizeMainTable" show-summary :row-key="row => row.id"> |
| | | <el-table-column label="序号" width="60" align="center"> |
| | | <template #default="scope"> |
| | |
| | | <el-table-column label="工序" prop="process" width="150"> |
| | | <template #default="scope"> |
| | | <el-input v-model="scope.row.process" placeholder="请输入工序" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="产线" prop="productionLine" width="150"> |
| | | <template #default="scope"> |
| | | <el-select |
| | | v-model="scope.row.productionLine" |
| | | placeholder="选择产线" |
| | | style="width: 100%;" |
| | | clearable |
| | | > |
| | | <el-option |
| | | v-for="line in productionLines" |
| | | :key="line.value" |
| | | :label="line.label" |
| | | :value="line.value" |
| | | /> |
| | | </el-select> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="单位" prop="unit" width="90"> |
| | |
| | | clearable |
| | | style="width: 100%" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="损耗" prop="loss" width="150"> |
| | | <template #default="scope"> |
| | | <el-input v-model="scope.row.loss" placeholder="请输入损耗" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="工时定额" width="200" prop="workHours"> |
| | |
| | | v-model="scope.row.schedulingUserId" |
| | | placeholder="选择人员" |
| | | style="width: 100%;" |
| | | filterable |
| | | default-first-option |
| | | :reserve-keyword="false" |
| | | > |
| | | <el-option |
| | | v-for="user in userList" |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import {ref} from "vue"; |
| | | import {ref, getCurrentInstance} from "vue"; |
| | | import {userListNoPageByTenantId} from "@/api/system/user.js"; |
| | | import {processScheduling} from "@/api/productionManagement/operationScheduling.js"; |
| | | const { proxy } = getCurrentInstance() |
| | |
| | | |
| | | const dialogFormVisible = ref(false); |
| | | const operationType = ref('') |
| | | const tableData = ref([ |
| | | { process: '', schedulingDate: '', schedulingNum: null, schedulingUserId: '', workHours: null, unit: '', remark: '', loss: '', type: '' } |
| | | ]); |
| | | const tableData = ref([]); |
| | | const unitFromRow = ref(''); |
| | | const idFromRow = ref(''); |
| | | const pendingNum = ref(''); |
| | | const specificationModelFromRow = ref(''); |
| | | const pendingNum = ref(0); |
| | | const userList = ref([]) |
| | | const receive = ref('') |
| | | const sunqianUserId = ref('') |
| | | // 产线选项 |
| | | const productionLines = ref([ |
| | | { label: '产线1', value: '产线1' }, |
| | | { label: '产线2', value: '产线2' }, |
| | | { label: '产线3', value: '产线3' }, |
| | | { label: '产线4', value: '产线4' } |
| | | ]) |
| | | |
| | | // 打开弹框 |
| | | const openDialog = (type, row) => { |
| | | operationType.value = type; |
| | | dialogFormVisible.value = true; |
| | | pendingNum.value = row?.pendingNum ?? 0; |
| | | unitFromRow.value = row?.unit ?? ''; |
| | | idFromRow.value = row?.id ?? ''; |
| | | specificationModelFromRow.value = row?.specificationModel ?? ''; |
| | | |
| | | userListNoPageByTenantId().then((res) => { |
| | | userList.value = res.data; |
| | | // 找到孙倩的用户ID并设置为默认值 |
| | | const sunqianUser = userList.value.find(user => user.nickName === '孙倩'); |
| | | if (sunqianUser) { |
| | | sunqianUserId.value = sunqianUser.userId; |
| | | } |
| | | // 在用户列表加载完成后创建行数据,并将产线数据带入 |
| | | tableData.value = [createRow(row)]; |
| | | }); |
| | | pendingNum.value = row.pendingNum |
| | | if (row && row.unit !== undefined) { |
| | | unitFromRow.value = row.unit; |
| | | idFromRow.value = row.id; |
| | | tableData.value.forEach(item => { |
| | | item.unit = row.unit; |
| | | item.id = row.id; |
| | | }); |
| | | } else { |
| | | unitFromRow.value = ''; |
| | | } |
| | | } |
| | | |
| | | const createRow = (row) => ({ |
| | | id: idFromRow.value, |
| | | process: '包装', |
| | | schedulingDate: '', |
| | | schedulingNum: null, |
| | | schedulingUserId: sunqianUserId.value, // 默认设置为孙倩的用户ID |
| | | workHours: null, |
| | | unit: unitFromRow.value, |
| | | remark: '', |
| | | type: specificationModelFromRow.value, |
| | | productionLine: row?.productionLine ?? '', // 从行数据中获取产线信息 |
| | | }); |
| | | |
| | | const submitForm = () => { |
| | | // 1. 检查每一行是否填写完整 |
| | | for (let i = 0; i < tableData.value.length; i++) { |
| | |
| | | row.schedulingNum === '' || row.schedulingNum === null || |
| | | !row.schedulingUserId || |
| | | row.workHours === '' || row.workHours === null || |
| | | !row.unit |
| | | !row.unit || |
| | | !row.productionLine |
| | | ) { |
| | | proxy.$modal.msgError(`第${i + 1}行数据未填写完整`); |
| | | return; |
| | |
| | | proxy.$modal.msgError('排产数量合计不能超过待排产数量'); |
| | | return; |
| | | } |
| | | // 3. 将 receive 字段添加到每条数据中 |
| | | const submitData = tableData.value.map(row => ({ |
| | | ...row, |
| | | receive: receive.value |
| | | })); |
| | | // 3. 将 receive 字段添加到每条数据中,并移除 loss 字段 |
| | | const submitData = tableData.value.map(row => { |
| | | const { loss, ...rest } = row; |
| | | return { |
| | | ...rest, |
| | | receive: receive.value |
| | | }; |
| | | }); |
| | | processScheduling(submitData).then((res) => { |
| | | proxy.$modal.msgSuccess("提交成功"); |
| | | closeDia(); |
| | |
| | | const closeDia = () => { |
| | | dialogFormVisible.value = false; |
| | | receive.value = ''; |
| | | tableData.value = []; |
| | | unitFromRow.value = ''; |
| | | idFromRow.value = ''; |
| | | specificationModelFromRow.value = ''; |
| | | pendingNum.value = 0; |
| | | emit('close') |
| | | }; |
| | | defineExpose({ |
| | |
| | | }); |
| | | |
| | | const addRow = () => { |
| | | tableData.value.push({ id: idFromRow.value, process: '', unit: unitFromRow.value, schedulingNum: null, workHours: null, schedulingDate: '', schedulingUserId: '', remark: '', loss: '', type: '' }); |
| | | tableData.value.push(createRow()); |
| | | }; |
| | | const removeRow = (index) => { |
| | | tableData.value.splice(index, 1); |