| | |
| | | > |
| | | <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>--> |
| | | <el-table :data="tableData" border style="width: 100%" :summary-method="summarizeMainTable" show-summary :row-key="row => row.id"> |
| | | <el-table-column label="序号" width="60"> |
| | | <el-table-column label="序号" width="60" align="center"> |
| | | <template #default="scope"> |
| | | {{ scope.$index + 1 }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="工序" prop="process"> |
| | | <el-table-column label="工序" prop="process" width="150"> |
| | | <template #default="scope"> |
| | | <el-select v-model="scope.row.process" placeholder="请选择" clearable style="width: 100%"> |
| | | <el-option |
| | | v-for="dict in work_step" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | <el-select |
| | | v-model="scope.row.process" |
| | | placeholder="选择工序" |
| | | style="width: 100%;" |
| | | filterable |
| | | clearable |
| | | > |
| | | <el-option |
| | | v-for="process in processList" |
| | | :key="process.id" |
| | | :label="process.name" |
| | | :value="process.name" |
| | | /> |
| | | </el-select> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="单位" prop="unit"> |
| | | <el-table-column label="单位" prop="unit" width="90"> |
| | | <template #default="scope"> |
| | | <el-input v-model="scope.row.unit" placeholder="请输入单位" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="口味/品名/规格" prop="type" width="150"> |
| | | <template #default="scope"> |
| | | <el-input v-model="scope.row.type" placeholder="请输入" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="排产数量" width="200" prop="schedulingNum"> |
| | |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="工时定额" width="200" prop="workHours"> |
| | | <el-table-column label="工资" width="200" prop="workHours"> |
| | | <template #default="scope"> |
| | | <el-input-number |
| | | v-model="scope.row.workHours" |
| | |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="排产日期" prop="schedulingDate"> |
| | | <el-table-column label="排产日期" prop="schedulingDate" width="200"> |
| | | <template #default="scope"> |
| | | <el-date-picker v-model="scope.row.schedulingDate" type="date" placeholder="选择日期" style="width: 100%;" value-format="YYYY-MM-DD" format="YYYY-MM-DD"/> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="排产人" prop="schedulingUserId"> |
| | | <el-table-column label="排产人" prop="schedulingUserId" width="150"> |
| | | <template #default="scope"> |
| | | <el-select |
| | | v-model="scope.row.schedulingUserId" |
| | | placeholder="选择人员" |
| | | style="width: 100%;" |
| | | filterable |
| | | default-first-option |
| | | :reserve-keyword="false" |
| | | > |
| | | <el-option |
| | | v-for="user in userList" |
| | |
| | | :value="user.userId" |
| | | /> |
| | | </el-select> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="备注" prop="remark" width="200"> |
| | | <template #default="scope"> |
| | | <el-input v-model="scope.row.remark" placeholder="请输入备注" /> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" width="80"> |
| | |
| | | </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"; |
| | | import {laborConfListPage} from "@/api/lavorissce/issue.js"; |
| | | const { proxy } = getCurrentInstance() |
| | | const { work_step } = proxy.useDict("work_step") |
| | | const emit = defineEmits(['close']) |
| | | |
| | | const dialogFormVisible = ref(false); |
| | | const operationType = ref('') |
| | | const tableData = ref([ |
| | | { process: '', schedulingDate: '', schedulingNum: '', schedulingUserId: '', workHours: '', unit: '' } |
| | | ]); |
| | | const tableData = ref([]); |
| | | const unitFromRow = ref(''); |
| | | const idFromRow = ref(''); |
| | | const pendingNum = ref(''); |
| | | const specificationModelFromRow = ref(''); |
| | | const pendingNum = ref(0); |
| | | const userList = ref([]) |
| | | const processList = ref([]) |
| | | const receive = ref('') |
| | | const productionLineIdFromRow = ref(''); |
| | | const productionUserIdFromRow = ref(''); |
| | | |
| | | // 打开弹框 |
| | | const openDialog = (type, row) => { |
| | |
| | | userListNoPageByTenantId().then((res) => { |
| | | userList.value = res.data; |
| | | }); |
| | | 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 = ''; |
| | | } |
| | | // 根据选中数据的productionLineId查询工序列表 |
| | | if (row?.productionLineId) { |
| | | laborConfListPage({ id: row.productionLineId, current: -1, size: -1 }).then((res) => { |
| | | processList.value = res.data.records || []; |
| | | }); |
| | | } |
| | | pendingNum.value = row?.pendingNum ?? 0; |
| | | unitFromRow.value = row?.unit ?? ''; |
| | | idFromRow.value = row?.id ?? ''; |
| | | specificationModelFromRow.value = row?.specificationModel ?? ''; |
| | | productionLineIdFromRow.value = row?.productionLineId ?? ''; |
| | | productionUserIdFromRow.value = row?.productionUserId ?? ''; |
| | | tableData.value = [createRow()]; |
| | | } |
| | | |
| | | const createRow = () => ({ |
| | | id: idFromRow.value, |
| | | process: '', |
| | | schedulingDate: '', |
| | | schedulingNum: null, |
| | | schedulingUserId: '', |
| | | workHours: null, |
| | | unit: unitFromRow.value, |
| | | remark: '', |
| | | type: specificationModelFromRow.value, |
| | | }); |
| | | |
| | | const submitForm = () => { |
| | | // 1. 检查每一行是否填写完整 |
| | | for (let i = 0; i < tableData.value.length; i++) { |
| | |
| | | proxy.$modal.msgError('排产数量合计不能超过待排产数量'); |
| | | return; |
| | | } |
| | | processScheduling(tableData.value).then((res) => { |
| | | // 3. 将 receive、productionLineId、productionUserId 字段添加到每条数据中,并移除 loss 字段 |
| | | const submitData = tableData.value.map(row => { |
| | | const { loss, ...rest } = row; |
| | | return { |
| | | ...rest, |
| | | receive: receive.value, |
| | | productionLineId: productionLineIdFromRow.value, |
| | | productionUserId: productionUserIdFromRow.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: '', workHours: '', schedulingDate: '', schedulingUserId: '' }); |
| | | tableData.value.push(createRow()); |
| | | }; |
| | | const removeRow = (index) => { |
| | | tableData.value.splice(index, 1); |