| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div> |
| | | <el-dialog |
| | | v-model="dialogFormVisible" |
| | | title="èªå¨æ´¾å·¥" |
| | | width="80%" |
| | | @close="closeDia" |
| | | > |
| | | <el-form :model="form" label-width="140px" label-position="top" ref="formRef"> |
| | | <el-divider content-position="left">派工å表</el-divider> |
| | | |
| | | <el-table |
| | | :data="dispatchList" |
| | | border |
| | | style="width: 100%; margin-top: 20px;" |
| | | :row-class-name="tableRowClassName" |
| | | > |
| | | <el-table-column label="åºå·" type="index" width="60" align="center" /> |
| | | <el-table-column label="ååå·" prop="salesContractNo" width="200" /> |
| | | <el-table-column label="客æ·åç§°" prop="customerName" width="200" /> |
| | | <el-table-column label="项ç®åç§°" prop="projectName" width="250" /> |
| | | <el-table-column label="产å大类" prop="productCategory" width="150" /> |
| | | <el-table-column label="è§æ ¼åå·" prop="specificationModel" width="200" /> |
| | | <el-table-column label="ç»å®æºå¨" prop="speculativeTradingName" width="120" /> |
| | | <el-table-column label="æ»æ°é" prop="quantity" width="100" align="right" /> |
| | | <el-table-column label="å·²æäº§" prop="schedulingNum" width="100" align="right" fixed="right" /> |
| | | <el-table-column label="å¾
æäº§" prop="pendingQuantity" width="100" align="right" fixed="right" /> |
| | | <el-table-column label="æ¬æ¬¡æäº§" width="150" align="center" fixed="right"> |
| | | <template #default="{ row }"> |
| | | <el-input-number |
| | | v-model="row.schedulingNum" |
| | | :min="0" |
| | | :max="row.pendingQuantity" |
| | | :step="1" |
| | | :precision="0" |
| | | size="small" |
| | | style="width: 120px" |
| | | @change="(value) => changeCurrentNum(value, row)" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-form> |
| | | |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确认派工</el-button> |
| | | <el-button @click="closeDia">åæ¶</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import {ref, reactive, toRefs, computed} from "vue"; |
| | | import {productionDispatch, productionDispatchList} from "@/api/productionManagement/productionOrder.js"; |
| | | |
| | | const { proxy } = getCurrentInstance() |
| | | const emit = defineEmits(['close']) |
| | | |
| | | const dialogFormVisible = ref(false); |
| | | const operationType = ref('') |
| | | |
| | | const data = reactive({ |
| | | form: {}, |
| | | dispatchList: [], // 派工åè¡¨æ°æ® |
| | | }); |
| | | |
| | | const { form, dispatchList } = toRefs(data); |
| | | |
| | | |
| | | // è¡¨æ ¼è¡æ ·å¼ |
| | | const tableRowClassName = ({ rowIndex }) => { |
| | | if (rowIndex % 2 === 1) { |
| | | return 'even-row' |
| | | } |
| | | return '' |
| | | } |
| | | |
| | | // ä¿®æ¹æ¬æ¬¡æäº§æ°é |
| | | const changeCurrentNum = (value, row) => { |
| | | if (value > row.pendingQuantity) { |
| | | row.schedulingNum = row.pendingQuantity |
| | | proxy.$modal.msgWarning('æäº§æ°éä¸å¯å¤§äºå¾
æäº§æ°é') |
| | | } |
| | | } |
| | | |
| | | // æå¼å¼¹æ¡ |
| | | const openDialog = (type, rows) => { |
| | | operationType.value = type; |
| | | dialogFormVisible.value = true; |
| | | |
| | | // å¤çä¼ å
¥çæ°æ® |
| | | dispatchList.value = rows.map(row => ({ |
| | | ...row, |
| | | schedulingNum: 0, // åå§åæ¬æ¬¡æäº§æ°é为0 |
| | | pendingQuantity: (Number(row.quantity) || 0) - (Number(row.schedulingNum) || 0) // 计ç®å¾
æäº§æ°é |
| | | })) |
| | | } |
| | | |
| | | // æäº¤è¡¨å |
| | | const submitForm = () => { |
| | | // æ£æ¥æ¯å¦ææäº§æ°æ® |
| | | const hasSchedulingData = dispatchList.value.some(item => item.schedulingNum > 0) |
| | | if (!hasSchedulingData) { |
| | | proxy.$modal.msgWarning('请è³å°ä¸ºä¸æ¡è®°å½è®¾ç½®æäº§æ°é') |
| | | return |
| | | } |
| | | |
| | | // æé æäº¤æ°æ® - ç´æ¥ä¼ éæ°ç»ï¼ä¸è¿æ»¤ |
| | | const submitData = dispatchList.value |
| | | |
| | | console.log('æäº¤èªå¨æ´¾å·¥æ°æ®:', submitData) |
| | | |
| | | // è°ç¨APIï¼è¿ééè¦æ ¹æ®å®é
æ¥å£è°æ´ï¼ |
| | | productionDispatchList(submitData).then(res => { |
| | | proxy.$modal.msgSuccess(res.msg); |
| | | closeDia(); |
| | | }).catch(err => { |
| | | proxy.$modal.msgError("派工失败"); |
| | | console.error('派工失败:', err); |
| | | }) |
| | | } |
| | | |
| | | // å
³éå¼¹æ¡ |
| | | const closeDia = () => { |
| | | proxy.resetForm("formRef"); |
| | | dialogFormVisible.value = false; |
| | | dispatchList.value = [] |
| | | emit('close') |
| | | }; |
| | | |
| | | defineExpose({ |
| | | openDialog, |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped> |
| | | :deep(.even-row) { |
| | | background-color: #fafafa; |
| | | } |
| | | |
| | | :deep(.el-table .cell) { |
| | | padding: 8px 12px; |
| | | } |
| | | |
| | | :deep(.el-table th) { |
| | | background-color: #f5f7fa; |
| | | color: #606266; |
| | | font-weight: 600; |
| | | } |
| | | </style> |