spring
2026-05-20 7465eb431e134576b4c9c43103c9fc6f918d1696
fix: 每个工序添加投入重量字段
已修改5个文件
328 ■■■■■ 文件已修改
src/views/productionManagement/workOrder/components/CopperPrintingForm.vue 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productionManagement/workOrder/components/GranulationForm.vue 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productionManagement/workOrder/components/ProductionRecordForm.vue 102 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productionManagement/workOrder/components/VoltageSortingForm.vue 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productionManagement/workOrder/index.vue 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productionManagement/workOrder/components/CopperPrintingForm.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
import {computed, onMounted, reactive, ref} from "vue";
import {computed, onMounted, reactive, ref, watch} from "vue";
import dayjs from "dayjs";
import {userListNoPageByTenantId} from "@/api/system/user.js";
import {getDeviceLedger} from "@/api/equipmentManagement/ledger.js";
@@ -22,7 +22,12 @@
  row: {
    type: Object,
    default: () => ({}),
  }
  },
  /** 工单 BOM 投入重量,回显到「投入重量」 */
  bomInputQty: {
    type: Number,
    default: null,
  },
});
const emits = defineEmits(["update:isShow", "refreshData"]);
@@ -83,6 +88,7 @@
    copperFiringTime: undefined, // 烧铜进炉时间
    steelFiringTime: undefined, // 烧钢出炉时间
    weight: undefined, // 重量(kg/pos)
    inputWeight: undefined, // 投入重量(KG)
    copperSmeltingTemperatureProfile: undefined, // 烧铜温度曲线
    remark: undefined, // 备注
  }
@@ -183,11 +189,30 @@
  });
};
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;
    formData.scrapQty = props.row.scrapQty;
    if (formData.otherData.inputWeight === undefined || formData.otherData.inputWeight === null || formData.otherData.inputWeight === "") {
      applyBomInputWeight();
    }
  } else {
    const row = props.row;
    formData.planQuantity = row.planQuantity
@@ -195,8 +220,32 @@
    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;
@@ -446,6 +495,19 @@
            <span v-else class="view-value">{{ displayValue(formData.otherData.steelFiringTime) }}</span>
          </td>
        </tr>
        <tr class="report-row report-row--double">
          <td class="label" colspan="2">投入重量(KG)</td>
          <td colspan="19" class="cell-field">
            <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 class="report-row report-row--triple">
          <td class="label" colspan="2">烧铜产出</td>
          <td colspan="5" class="cell-field">
src/views/productionManagement/workOrder/components/GranulationForm.vue
@@ -1,5 +1,5 @@
<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";
@@ -20,7 +20,12 @@
  row: {
    type: Object,
    default: () => ({}),
  }
  },
  /** 工单 BOM 投入重量,回显到「投入重量」 */
  bomInputQty: {
    type: Number,
    default: null,
  },
});
const emits = defineEmits(["update:isShow", "refreshData"]);
@@ -121,6 +126,7 @@
      confirmName: undefined,
    },
    remark: undefined, // 备注
    inputWeight: undefined, // 投入重量(KG)
  }
})
@@ -228,10 +234,29 @@
  });
};
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
@@ -239,8 +264,32 @@
    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;
@@ -771,7 +820,7 @@
          </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
@@ -836,6 +885,19 @@
          </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="请输入">
src/views/productionManagement/workOrder/components/ProductionRecordForm.vue
@@ -16,6 +16,21 @@
  labelWidth: {
    type: Number,
    default: 120
  },
  /** 本次生产数量(成型工序用于计算投入重量) */
  quantity: {
    type: Number,
    default: null
  },
  /** 当前工序是否为「成型」 */
  isFormingProcess: {
    type: Boolean,
    default: false
  },
  /** 工单 BOM 投入重量,非成型工序回显到「投入重量」 */
  bomInputQty: {
    type: Number,
    default: null
  }
});
@@ -49,6 +64,55 @@
  deviceOptions.value = data;
};
const normalizeUnit = (unit) => String(unit ?? "").trim().toLowerCase();
const isInputWeightItem = (item) =>
  String(item?.parameterItem ?? "").includes("投入重量") &&
  normalizeUnit(item?.unit) === "kg";
const isBlankCoeffItem = (item) =>
  String(item?.parameterItem ?? "").includes("生坯系数") &&
  normalizeUnit(item?.unit) === "g";
/** 投入重量(KG) = 本次生产数量 × 生坯系数(g) / 1000 */
const syncFormingInputWeight = () => {
  if (!props.isFormingProcess) return;
  const weightItem = formData.list.find(isInputWeightItem);
  if (!weightItem) return;
  const qty = Number(props.quantity);
  const coeffItem = formData.list.find(isBlankCoeffItem);
  const coeff = coeffItem?.value === null || coeffItem?.value === undefined || coeffItem?.value === ""
    ? NaN
    : Number(coeffItem.value);
  if (!Number.isFinite(qty) || qty < 1 || !Number.isFinite(coeff)) {
    return;
  }
  weightItem.value = Number(((qty * coeff) / 1000).toFixed(4));
};
/** 非成型:投入重量取工单 bomInputQty */
const syncBomInputWeight = () => {
  if (props.isFormingProcess) return;
  const weightItem = formData.list.find(isInputWeightItem);
  if (!weightItem) return;
  const bom = props.bomInputQty;
  if (bom === null || bom === undefined || Number.isNaN(Number(bom))) {
    return;
  }
  weightItem.value = Number(bom);
};
const syncInputWeight = () => {
  if (props.isFormingProcess) {
    syncFormingInputWeight();
  } else {
    syncBomInputWeight();
  }
};
const initData = () => {
  formData.list = props.list || [];
  formData.list.forEach(item => {
@@ -56,7 +120,8 @@
      item.value = null;
    }
  });
  loadDeviceName()
  loadDeviceName();
  syncInputWeight();
};
const submitData = async () => {
@@ -77,8 +142,41 @@
    {immediate: true, deep: true}
);
watch(
    () => [props.quantity, props.isFormingProcess],
    () => {
      if (props.isFormingProcess) {
        syncFormingInputWeight();
      }
    }
);
watch(
    () => {
      const coeffItem = formData.list.find(isBlankCoeffItem);
      return coeffItem?.value;
    },
    () => {
      if (props.isFormingProcess) {
        syncFormingInputWeight();
      }
    }
);
watch(
    () => [props.bomInputQty, props.isFormingProcess],
    () => {
      if (!props.isFormingProcess) {
        syncBomInputWeight();
      }
    }
);
defineExpose({
  submitData
  submitData,
  syncFormingInputWeight,
  syncBomInputWeight,
  syncInputWeight
})
</script>
src/views/productionManagement/workOrder/components/VoltageSortingForm.vue
@@ -22,7 +22,12 @@
  row: {
    type: Object,
    default: () => ({}),
  }
  },
  /** 工单 BOM 投入重量,回显到「投入重量」 */
  bomInputQty: {
    type: Number,
    default: null,
  },
});
const emits = defineEmits(["update:isShow", "refreshData"]);
@@ -56,6 +61,7 @@
    userId: undefined, // 作业员
    userName: undefined, // 作业员
    exceptionDealResult: undefined, // 异常处理结果
    inputWeight: undefined, // 投入重量(KG)
  }
})
@@ -183,12 +189,31 @@
  otherData.quantity = normalizeGearArray(otherData.quantity);
};
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 || '{}');
    initGearArrays();
    formData.quantity = props.row.quantity;
    formData.scrapQty = props.row.scrapQty;
    if (formData.otherData.inputWeight === undefined || formData.otherData.inputWeight === null || formData.otherData.inputWeight === "") {
      applyBomInputWeight();
    }
  } else {
    const row = props.row;
    formData.planQuantity = row.planQuantity
@@ -198,8 +223,32 @@
    formData.productMainId = row.productMainId
    initGearArrays();
    syncOutputQuantity();
    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();
    }
  }
);
watch(
  () => formData.otherData.quantity.map((val) => val),
@@ -376,6 +425,19 @@
          </td>
        </tr>
        <tr>
          <td class="label" colspan="2">投入重量(KG)</td>
          <td colspan="16" class="cell-field">
            <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="2">有无工程异常</td>
          <td colspan="10">
            <div v-if="props.isEdit" style="display: flex; align-items: center; width: 100%;">
src/views/productionManagement/workOrder/index.vue
@@ -297,6 +297,9 @@
        <ProductionRecordForm
          ref="productionRecordFormRef"
          :list="processParamList"
          :quantity="reportForm.quantity"
          :is-forming-process="isFormingProcess"
          :bom-input-qty="reportBomInputQty"
        />
      </el-form>
      <template #footer>
@@ -312,6 +315,7 @@
      v-model:isShow="copperPrintingFormVisible"
      :isEdit="true"
      :row="currentReportRowData"
      :bom-input-qty="reportBomInputQty"
      @refreshData="getList"
    />
    <VoltageSortingForm
@@ -319,6 +323,7 @@
      v-model:isShow="voltageSortingFormVisible"
      :isEdit="true"
      :row="currentReportRowData"
      :bom-input-qty="reportBomInputQty"
      @refreshData="getList"
    />
    <GranulationForm
@@ -326,13 +331,14 @@
      v-model:isShow="granulationFormVisible"
      :isEdit="true"
      :row="currentReportRowData"
      :bom-input-qty="reportBomInputQty"
      @refreshData="getList"
    />
  </div>
</template>
<script setup>
import { onMounted, ref, nextTick } from "vue";
import { onMounted, ref, nextTick, computed } from "vue";
import { ElMessageBox } from "element-plus";
import dayjs from "dayjs";
import {
@@ -592,6 +598,9 @@
    return;
  }
  reportForm.quantity = num;
  nextTick(() => {
    productionRecordFormRef.value?.syncInputWeight?.();
  });
};
// 处理报废数量
@@ -619,6 +628,20 @@
  reportForm.scrapQty = num;
};
const currentReportRowData = ref(null);
const isFormingProcess = computed(
  () => currentReportRowData.value?.processName === "成型"
);
const reportBomInputQty = computed(() => {
  const bom = currentReportRowData.value?.bomInputQty;
  if (bom === null || bom === undefined || bom === "") {
    return null;
  }
  const n = Number(bom);
  return Number.isFinite(n) ? n : null;
});
const page = reactive({
  current: 1,
  size: 100,
@@ -812,6 +835,9 @@
    });
  reportDialogVisible.value = true;
  nextTick(() => {
    productionRecordFormRef.value?.syncInputWeight?.();
  });
};
const openWorkOrderFiles = (row) => {