| | |
| | | import {userListNoPageByTenantId} from "@/api/system/user.js"; |
| | | import {processScheduling} from "@/api/productionManagement/operationScheduling.js"; |
| | | const { proxy } = getCurrentInstance() |
| | | import dayjs from "dayjs"; |
| | | const { work_step } = proxy.useDict("work_step") |
| | | const emit = defineEmits(['close']) |
| | | |
| | |
| | | sunqianUserId.value = sunqianUser.userId; |
| | | } |
| | | // 在用户列表加载完成后创建行数据,并将产线数据带入 |
| | | tableData.value = [createRow(row)]; |
| | | tableData.value = [createRow(row, { defaultNum: pendingNum.value })]; |
| | | }); |
| | | } |
| | | |
| | | const createRow = (row) => ({ |
| | | const getToday = () => dayjs().format("YYYY-MM-DD"); |
| | | const getRemaining = () => { |
| | | const used = tableData.value.reduce((sum, row) => sum + Number(row.schedulingNum || 0), 0); |
| | | const remain = Number(pendingNum.value || 0) - used; |
| | | return remain > 0 ? remain : 0; |
| | | }; |
| | | |
| | | const createRow = (row, options = {}) => ({ |
| | | id: idFromRow.value, |
| | | process: '包装', |
| | | schedulingDate: '', |
| | | schedulingNum: null, |
| | | schedulingDate: getToday(), // 默认当天 |
| | | schedulingNum: options.defaultNum ?? null, // 默认用剩余数量填满 |
| | | schedulingUserId: sunqianUserId.value, // 默认设置为孙倩的用户ID |
| | | workHours: null, |
| | | unit: unitFromRow.value, |
| | |
| | | }); |
| | | |
| | | const addRow = () => { |
| | | tableData.value.push(createRow()); |
| | | const remaining = getRemaining(); |
| | | if (remaining <= 0) { |
| | | proxy.$modal.msgWarning('已排满,无剩余数量'); |
| | | return; |
| | | } |
| | | tableData.value.push(createRow({}, { defaultNum: remaining })); |
| | | }; |
| | | const removeRow = (index) => { |
| | | tableData.value.splice(index, 1); |