| | |
| | | <script setup lang="ts"> |
| | | import {computed, onMounted, reactive, ref} from "vue"; |
| | | import {computed, onMounted, reactive, ref, watch} from "vue"; |
| | | import {userListNoPageByTenantId} from "@/api/system/user.js"; |
| | | import {ElMessage} from "element-plus"; |
| | | import {addProductMain} from "@/api/productionManagement/workOrder.js"; |
| | |
| | | row: { |
| | | type: Object, |
| | | default: () => ({}), |
| | | } |
| | | }, |
| | | /** 工单 BOM 投入重量,回显到「投入重量/数量」 */ |
| | | bomInputQty: { |
| | | type: Number, |
| | | default: null, |
| | | }, |
| | | }); |
| | | |
| | | const emits = defineEmits(["update:isShow", "refreshData"]); |
| | |
| | | startTime: undefined, |
| | | endTime: undefined, |
| | | weightRatio: undefined, // 重量比(水/料) |
| | | pva: undefined, // PVAn粘合剂重量 |
| | | pva: undefined, // PVA粘合剂重量 |
| | | dispersantWeight: undefined, // 分散剂重量 |
| | | releaseAgentWeight: undefined, // 脱模剂重量 |
| | | }, |
| | |
| | | confirmName: undefined, |
| | | }, |
| | | remark: undefined, // 备注 |
| | | inputWeight: undefined, // 投入重量/数量(KG) |
| | | } |
| | | }) |
| | | |
| | |
| | | formData.otherData.burningMaterial.userName = selectedUser.userName; |
| | | break; |
| | | case 'burningMaterialConfirmId': |
| | | formData.otherData.stirredMillIncludesMixing.confirmName = selectedUser.userName; |
| | | formData.otherData.burningMaterial.confirmName = selectedUser.userName; |
| | | break; |
| | | case 'stirredMillUserId': |
| | | formData.otherData.stirredMill.userName = selectedUser.userName; |
| | | break; |
| | | case 'stirredMillConfirmId': |
| | | formData.otherData.stirredMill.confirmName = selectedUser.userName; |
| | | break; |
| | | case 'granulationBUserId': |
| | | formData.otherData.granulationB.userName = selectedUser.userName; |
| | | break; |
| | | case 'granulationBConfirmId': |
| | | formData.otherData.granulationB.confirmName = selectedUser.userName; |
| | | break; |
| | | } |
| | | } else { |
| | |
| | | case 'stirredMillConfirmId': |
| | | formData.otherData.stirredMill.confirmName = ""; |
| | | break; |
| | | case 'granulationBUserId': |
| | | formData.otherData.granulationB.userName = ""; |
| | | break; |
| | | case 'granulationBConfirmId': |
| | | formData.otherData.granulationB.confirmName = ""; |
| | | break; |
| | | } |
| | | } |
| | | }; |
| | | // todo 修改作业员,在所有作业员中获取填入的值,如果没有则提示不提交 |
| | | |
| | | const handleReport = () => { |
| | | if (!formData.otherData.userId && !formData.otherData.surfaceCopperPasteUserId && !formData.otherData.underlyingCopperPasteUserId) { |
| | | if (!formData.otherData.stirredMillIncludesMixing.userId && !formData.otherData.stirredMill.userId && !formData.otherData.burningMaterial.userId && !formData.otherData.granulationB.userId) { |
| | | ElMessage.error('请选择作业员') |
| | | return; |
| | | } |
| | |
| | | ElMessage.error('请输入生产数量') |
| | | return; |
| | | } |
| | | formData.userId = formData.otherData.surfaceCopperPasteUserId || formData.otherData.underlyingCopperPasteUserId; |
| | | formData.userId = formData.otherData.stirredMillIncludesMixing.userId || formData.otherData.stirredMill.userId || formData.otherData.burningMaterial.userId || formData.otherData.granulationB.userId; |
| | | |
| | | const otherData = JSON.stringify(formData.otherData); |
| | | const submitData = { |
| | |
| | | }); |
| | | }; |
| | | |
| | | const resolveBomInputQty = () => { |
| | | const bom = props.bomInputQty ?? props.row?.bomInputQty; |
| | | if (bom === null || bom === undefined || bom === "") { |
| | | return null; |
| | | } |
| | | const n = Number(bom); |
| | | return Number.isFinite(n) ? n : null; |
| | | }; |
| | | |
| | | const applyBomInputWeight = () => { |
| | | const n = resolveBomInputQty(); |
| | | if (n !== null) { |
| | | formData.otherData.inputWeight = n; |
| | | } |
| | | }; |
| | | |
| | | const initData = () => { |
| | | if (!props.isEdit) { |
| | | formData.otherData = JSON.parse(props.row.otherData || '{}'); |
| | | formData.quantity = props.row.quantity; |
| | | if (formData.otherData.inputWeight === undefined || formData.otherData.inputWeight === null || formData.otherData.inputWeight === "") { |
| | | applyBomInputWeight(); |
| | | } |
| | | } else { |
| | | const row = props.row; |
| | | formData.planQuantity = row.planQuantity |
| | |
| | | formData.workOrderId = row.id |
| | | formData.reportWork = row.reportWork |
| | | formData.productMainId = row.productMainId |
| | | applyBomInputWeight(); |
| | | } |
| | | } |
| | | |
| | | watch( |
| | | () => props.isShow, |
| | | (show) => { |
| | | if (show) { |
| | | initData(); |
| | | } |
| | | } |
| | | ); |
| | | |
| | | watch( |
| | | () => [props.bomInputQty, props.row?.bomInputQty], |
| | | () => { |
| | | if (!props.isShow) return; |
| | | if (props.isEdit) { |
| | | applyBomInputWeight(); |
| | | return; |
| | | } |
| | | if (formData.otherData.inputWeight === undefined || formData.otherData.inputWeight === null || formData.otherData.inputWeight === "") { |
| | | applyBomInputWeight(); |
| | | } |
| | | } |
| | | ); |
| | | |
| | | const displayValue = (value: any) => { |
| | | return value === undefined || value === null || value === "" ? "-" : value; |
| | |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.burningMaterial.calcinationWeight) }}</span> |
| | | <span>KG</span> |
| | | </td> |
| | | <td class="label" colspan="2" rowspan="3"> |
| | | <td class="label" colspan="2" rowspan="2"> |
| | | <span>确认人:</span> |
| | | <el-select v-model="formData.otherData.burningMaterial.confirmId" |
| | | v-if="props.isEdit" |
| | |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.stirredMill.confirmName || formData.otherData.stirredMill.confirmId) }}</span> |
| | | </td> |
| | | </tr> |
| | | <!-- todo搅拌行开始,确认人行留空,已在上面表格预留 --> |
| | | <tr> |
| | | <td class="label" colspan="2" rowspan="2">搅拌</td> |
| | | <td class="label" colspan="4"> |
| | | <span>开始时间:</span> |
| | | <el-date-picker |
| | | v-if="props.isEdit" |
| | | v-model="formData.otherData.stir.startTime" |
| | | type="datetime" |
| | | value-format="YYYY-MM-DD HH:mm:ss" |
| | | format="YYYY-MM-DD HH:mm:ss" |
| | | placeholder="请选择" |
| | | style="width: 100%" |
| | | /> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.stir.startTime) }}</span> |
| | | </td> |
| | | <td class="label" colspan="4"> |
| | | <span>结束时间:</span> |
| | | <el-date-picker |
| | | v-if="props.isEdit" |
| | | v-model="formData.otherData.stir.endTime" |
| | | type="datetime" |
| | | value-format="YYYY-MM-DD HH:mm:ss" |
| | | format="YYYY-MM-DD HH:mm:ss" |
| | | placeholder="请选择" |
| | | style="width: 100%" |
| | | /> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.stir.endTime) }}</span> |
| | | </td> |
| | | <td class="label" colspan="4"> |
| | | <span>重量比(水/料):</span> |
| | | <el-input v-if="props.isEdit" v-model="formData.otherData.stir.weightRatio" placeholder="请输入"/> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.stir.weightRatio) }}</span> |
| | | </td> |
| | | </tr> |
| | | <tr> |
| | | <td class="label" colspan="4"> |
| | | <span>PVA粘合剂重量 :</span> |
| | | <el-input v-if="props.isEdit" v-model="formData.otherData.stir.pva" placeholder="请输入"/> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.stir.pva) }}</span> |
| | | </td> |
| | | <td class="label" colspan="4"> |
| | | <span>分散剂重量 :</span> |
| | | <el-input v-if="props.isEdit" v-model="formData.otherData.stir.dispersantWeight" placeholder="请输入"/> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.stir.dispersantWeight) }}</span> |
| | | </td> |
| | | <td class="label" colspan="4"> |
| | | <span>脱模剂重量 :</span> |
| | | <el-input v-if="props.isEdit" v-model="formData.otherData.stir.releaseAgentWeight" placeholder="请输入"/> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.stir.releaseAgentWeight) }}</span> |
| | | </td> |
| | | </tr> |
| | | <tr> |
| | | <td class="label" colspan="2" rowspan="5">造粒</td> |
| | | <td class="label" colspan="6"> |
| | | <span>开始时间:</span> |
| | | <el-date-picker |
| | | v-if="props.isEdit" |
| | | v-model="formData.otherData.granulationB.startTime" |
| | | type="datetime" |
| | | value-format="YYYY-MM-DD HH:mm:ss" |
| | | format="YYYY-MM-DD HH:mm:ss" |
| | | placeholder="请选择" |
| | | style="width: 100%" |
| | | /> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.granulationB.startTime) }}</span> |
| | | </td> |
| | | <td class="label" colspan="6"> |
| | | <span>结束时间:</span> |
| | | <el-date-picker |
| | | v-if="props.isEdit" |
| | | v-model="formData.otherData.granulationB.endTime" |
| | | type="datetime" |
| | | value-format="YYYY-MM-DD HH:mm:ss" |
| | | format="YYYY-MM-DD HH:mm:ss" |
| | | placeholder="请选择" |
| | | style="width: 100%" |
| | | /> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.granulationB.endTime) }}</span> |
| | | </td> |
| | | <td class="label" colspan="2" rowspan="2"> |
| | | <span>作业员:</span> |
| | | <el-select v-model="formData.otherData.granulationB.userId" |
| | | v-if="props.isEdit" |
| | | style="width: 100%" |
| | | placeholder="请选择作业员" |
| | | clearable |
| | | filterable |
| | | @change="handleUserChange($event, 'granulationBUserId')"> |
| | | <el-option v-for="user in userOptions" |
| | | :key="user.userId" |
| | | :label="user.userName" |
| | | :value="user.userId"/> |
| | | </el-select> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.granulationB.userName || formData.otherData.granulationB.userId) }}</span> |
| | | </td> |
| | | </tr> |
| | | |
| | | <tr> |
| | | <td class="label" colspan="4"> |
| | | <span>雾化器转速 :</span> |
| | | <el-input v-if="props.isEdit" v-model="formData.otherData.granulationB.atomizerRotationalSpeed" placeholder="请输入"> |
| | | <template #append>r/min</template> |
| | | </el-input> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.granulationB.atomizerRotationalSpeed) }}</span> |
| | | </td> |
| | | <td class="label" colspan="4"> |
| | | <span>进口速度 :</span> |
| | | <el-input v-if="props.isEdit" v-model="formData.otherData.granulationB.importSpeed" placeholder="请输入"/> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.granulationB.importSpeed) }}</span> |
| | | </td> |
| | | <td class="label" colspan="4"> |
| | | <span>出口速度 :</span> |
| | | <el-input v-if="props.isEdit" v-model="formData.otherData.granulationB.outSpeed" placeholder="请输入"/> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.granulationB.outSpeed) }}</span> |
| | | </td> |
| | | </tr> |
| | | <tr> |
| | | <td colspan="12"> |
| | | <span>投入重量(KG)/数量:</span> |
| | | <el-input-number |
| | | v-if="props.isEdit" |
| | | v-model="formData.otherData.inputWeight" |
| | | :controls="false" |
| | | style="width: 100%" |
| | | placeholder="请输入" |
| | | /> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.inputWeight) }}</span> |
| | | </td> |
| | | </tr> |
| | | <tr> |
| | | <td class="label" colspan="6"> |
| | | <span>产出总数 :</span> |
| | | <el-input v-if="props.isEdit" v-model="formData.quantity" placeholder="请输入"> |
| | | <template #append>KG</template> |
| | | </el-input> |
| | | <span v-else class="view-value">{{ displayValue(formData.quantity) }}</span> |
| | | </td> |
| | | <td class="label" colspan="6"> |
| | | <span>合格重量 :</span> |
| | | <el-input v-if="props.isEdit" v-model="formData.otherData.granulationB.qualifiedWeight" placeholder="请输入"> |
| | | <template #append>KG</template> |
| | | </el-input> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.granulationB.qualifiedWeight) }}</span> |
| | | </td> |
| | | <td class="label" colspan="2" rowspan="2"> |
| | | <span>确认人:</span> |
| | | <el-select v-model="formData.otherData.granulationB.confirmId" |
| | | v-if="props.isEdit" |
| | | style="width: 100%" |
| | | placeholder="请选择确认人" |
| | | clearable |
| | | filterable |
| | | @change="handleUserChange($event, 'granulationBConfirmId')"> |
| | | <el-option v-for="user in userOptions" |
| | | :key="user.userId" |
| | | :label="user.userName" |
| | | :value="user.userId"/> |
| | | </el-select> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.granulationB.confirmName || formData.otherData.granulationB.confirmId) }}</span> |
| | | </td> |
| | | </tr> |
| | | <tr> |
| | | <td class="label" colspan="6"> |
| | | <span>尾料 :</span> |
| | | <el-input v-if="props.isEdit" v-model="formData.otherData.granulationB.wasteMaterials" placeholder="请输入"> |
| | | <template #append>KG</template> |
| | | </el-input> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.granulationB.wasteMaterials) }}</span> |
| | | </td> |
| | | <td class="label" colspan="6"> |
| | | <span>壁料 :</span> |
| | | <el-input v-if="props.isEdit" v-model="formData.otherData.granulationB.wallMaterial" placeholder="请输入"> |
| | | <template #append>KG</template> |
| | | </el-input> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.granulationB.wallMaterial) }}</span> |
| | | </td> |
| | | </tr> |
| | | <tr> |
| | | <td class="label" colspan="16"> |
| | | <span>备注 :</span> |
| | | <el-input v-if="props.isEdit" v-model="formData.otherData.remark" placeholder="请输入"/> |
| | | <span v-else class="view-value">{{ displayValue(formData.otherData.remark) }}</span> |
| | | </td> |
| | | </tr> |
| | | </tbody> |
| | | </table> |
| | | </el-form> |