| | |
| | | <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"]); |
| | |
| | | confirmName: undefined, |
| | | }, |
| | | remark: undefined, // 备注 |
| | | inputWeight: undefined, // 投入重量(KG) |
| | | } |
| | | }) |
| | | |
| | |
| | | }); |
| | | }; |
| | | |
| | | 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; |
| | |
| | | </td> |
| | | </tr> |
| | | <tr> |
| | | <td class="label" colspan="2" rowspan="4">造粒</td> |
| | | <td class="label" colspan="2" rowspan="5">造粒</td> |
| | | <td class="label" colspan="6"> |
| | | <span>开始时间:</span> |
| | | <el-date-picker |
| | |
| | | </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="请输入"> |