zhangwencui
2026-05-23 e39bf94b60de81df060cdcf460e57d19f50aa5d1
src/pages/qualityManagement/processInspection/add.vue
@@ -51,6 +51,7 @@
      </up-form-item>
      <up-form-item label="指标选择"
                    prop="testStandardId"
                    required
                    border-bottom>
        <up-input v-model="testStandardDisplay"
                  placeholder="请选择指标"
@@ -67,14 +68,32 @@
                  placeholder="请输入单位"
                  disabled />
      </up-form-item>
      <up-form-item label="数量"
      <up-form-item label="总数量"
                    prop="quantity"
                    required
                    border-bottom>
        <up-input v-model="form.quantity"
                  type="number"
                  placeholder="请输入数量"
                  placeholder="请输入总数量"
                  :disabled="processQuantityDisabled" />
      </up-form-item>
      <up-form-item label="合格数量"
                    prop="qualifiedQuantity"
                    required
                    border-bottom>
        <up-input v-model="form.qualifiedQuantity"
                  type="number"
                  placeholder="请输入合格数量"
                  clearable />
      </up-form-item>
      <up-form-item label="不合格数量"
                    prop="unqualifiedQuantity"
                    required
                    border-bottom>
        <up-input v-model="form.unqualifiedQuantity"
                  type="number"
                  placeholder="请输入不合格数量"
                  clearable />
      </up-form-item>
      <up-form-item label="检测单位"
                    prop="checkCompany"
@@ -82,19 +101,6 @@
        <up-input v-model="form.checkCompany"
                  placeholder="请输入检测单位"
                  clearable />
      </up-form-item>
      <up-form-item label="检测结果"
                    prop="checkResult"
                    required
                    border-bottom>
        <up-input v-model="form.checkResult"
                  placeholder="请选择检测结果"
                  readonly
                  @click="showResultSheet" />
        <template #right>
          <up-icon @click="showResultSheet = true"
                   name="arrow-right" />
        </template>
      </up-form-item>
      <up-form-item label="检验员"
                    prop="checkName"
@@ -184,11 +190,15 @@
      </up-button>
    </view>
    <!-- 日期选择器 -->
    <up-popup v-model:show="showDate"
              mode="date"
              :start-year="2020"
              :end-year="2030"
              @confirm="confirmDate" />
    <up-popup :show="showDate"
              mode="bottom"
              @close="showDate = false">
      <up-datetime-picker :show="true"
                          v-model="pickerValue"
                          @confirm="confirmDate"
                          @cancel="showDate = false"
                          mode="date" />
    </up-popup>
    <!-- 工序选择 -->
    <up-action-sheet :show="showprocessSheet"
                     :actions="processOptions"
@@ -207,12 +217,6 @@
                     @select="selectModel"
                     @close="showModelSheet = false"
                     title="选择规格型号" />
    <!-- 检测结果选择 -->
    <up-action-sheet :show="showResultSheet"
                     :actions="resultSheetOptions"
                     @select="selectResult"
                     @close="showResultSheet = false"
                     title="选择检测结果" />
    <!-- 检验员选择 -->
    <up-action-sheet :show="showInspectorSheet"
                     :actions="userSheetOptions"
@@ -302,7 +306,7 @@
<script setup>
  import { ref, computed, onMounted, nextTick } from "vue";
  import { onShow } from "@dcloudio/uni-app";
  import { onShow, onLoad } from "@dcloudio/uni-app";
  import PageHeader from "@/components/PageHeader.vue";
  import dayjs from "dayjs";
  import { getOptions } from "@/api/procurementManagement/procurementLedger.js";
@@ -313,8 +317,8 @@
    qualityInspectParamInfo,
    qualityInspectDetailByProductId,
    getQualityTestStandardParamByTestStandardId,
    list,
  } from "@/api/qualityManagement/materialInspection.js";
  import { getProcessList } from "@/api/productionManagement/processManagement.js";
  import { userListNoPage } from "@/api/system/user.js";
  // 显示提示信息
@@ -339,8 +343,6 @@
  const showProductTree = ref(false);
  // 规格型号选择
  const showModelSheet = ref(false);
  // 检测结果选择
  const showResultSheet = ref(false);
  // 检验员选择
  const showInspectorSheet = ref(false);
  // 指标选择
@@ -358,8 +360,9 @@
    testStandardId: "",
    unit: "",
    quantity: "",
    qualifiedQuantity: "",
    unqualifiedQuantity: "",
    checkCompany: "",
    checkResult: "",
    productMainId: null,
    purchaseLedgerId: null,
  });
@@ -379,11 +382,6 @@
  const modelOptions = ref([]);
  // 检验员列表
  const userList = ref([]);
  // 检测结果选项
  const resultOptions = ref([
    { label: "合格", value: "合格" },
    { label: "不合格", value: "不合格" },
  ]);
  // 指标选项
  const testStandardOptions = ref([]);
  // 当前产品ID
@@ -411,13 +409,6 @@
    }));
  });
  const resultSheetOptions = computed(() => {
    return resultOptions.value.map(item => ({
      name: item.label,
      value: item.value,
    }));
  });
  const userSheetOptions = computed(() => {
    return userList.value.map(item => ({
      name: item.nickName,
@@ -442,19 +433,18 @@
      { required: true, message: "请选择产品型号", trigger: "change" },
    ],
    testStandardId: [
      { required: false, message: "请选择指标", trigger: "change" },
      { required: true, message: "请选择指标", trigger: "change" },
    ],
    unit: [{ required: false, message: "请输入", trigger: "blur" }],
    quantity: [{ required: true, message: "请输入", trigger: "blur" }],
    qualifiedQuantity: [{ required: true, message: "请输入", trigger: "blur" }],
    unqualifiedQuantity: [{ required: true, message: "请输入", trigger: "blur" }],
    checkCompany: [{ required: false, message: "请输入", trigger: "blur" }],
    checkResult: [
      { required: true, message: "请选择检测结果", trigger: "change" },
    ],
  };
  // 是否为编辑模式
  const isEdit = computed(() => {
    const id = getPageId();
    const id = optionsId.value;
    return !!id;
  });
@@ -463,13 +453,6 @@
    const v = form.value || {};
    return !!(v.productMainId != null || v.purchaseLedgerId != null);
  });
  // 获取页面ID
  const getPageId = () => {
    const pages = getCurrentPages();
    const currentPage = pages[pages.length - 1];
    return currentPage.options.id;
  };
  // 返回上一页
  const goBack = () => {
@@ -563,12 +546,6 @@
      modelOptions.value.find(item => item.id == value)?.unit || "";
  };
  // 选择检测结果
  const selectResult = e => {
    form.value.checkResult = e.value;
    showResultSheet.value = false;
  };
  // 选择检验员
  const selectInspector = e => {
    form.value.checkName = e.value;
@@ -609,8 +586,8 @@
  // 获取工序列表
  const getprocessList = () => {
    list().then(res => {
      processList.value = res.data;
    getProcessList({ size: -1, current: -1 }).then(res => {
      processList.value = res.data?.records || res.data || [];
    });
  };
@@ -691,22 +668,29 @@
        return;
      }
      if (!form.value.quantity) {
        showToast("请输入数量");
        showToast("请输入总数量");
        return;
      }
      if (!form.value.qualifiedQuantity && form.value.qualifiedQuantity !== 0) {
        showToast("请输入合格数量");
        return;
      }
      if (!form.value.unqualifiedQuantity && form.value.unqualifiedQuantity !== 0) {
        showToast("请输入不合格数量");
        return;
      }
      if (!form.value.productId) {
        showToast("请选择产品");
        return;
      }
      if (!form.value.checkResult) {
        showToast("请选择检测结果");
      if (!form.value.testStandardId) {
        showToast("请选择指标");
        return;
      }
      loading.value = true;
      form.value.inspectType = 1;
      if (isEdit.value) {
      if (!isEdit.value) {
        tableData.value.forEach(item => {
          delete item.id;
        });
@@ -714,6 +698,8 @@
      const data = { ...form.value, qualityInspectParams: tableData.value };
      data.quantity = Number(data.quantity);
      data.qualifiedQuantity = Number(data.qualifiedQuantity);
      data.unqualifiedQuantity = Number(data.unqualifiedQuantity);
      if (isEdit.value) {
        const res = await qualityInspectUpdate(data);
        showToast("保存成功");
@@ -737,7 +723,7 @@
  // 初始化表单
  const initForm = async () => {
    const id = getPageId();
    const id = optionsId.value;
    if (id) {
      // 编辑模式,加载数据
      // 先重置表单数据
@@ -753,7 +739,8 @@
        unit: "",
        quantity: "",
        checkCompany: "",
        checkResult: "",
        qualifiedQuantity: "",
        unqualifiedQuantity: "",
        productMainId: null,
        purchaseLedgerId: null,
      };
@@ -775,7 +762,8 @@
        unit: "kg",
        quantity: 1000,
        checkCompany: "第三方检测机构",
        checkResult: "合格",
        qualifiedQuantity: 0,
        unqualifiedQuantity: 0,
        productMainId: null,
        purchaseLedgerId: null,
      };
@@ -854,8 +842,9 @@
        testStandardId: "",
        unit: "",
        quantity: "",
        qualifiedQuantity: "",
        unqualifiedQuantity: "",
        checkCompany: "",
        checkResult: "",
        productMainId: null,
        purchaseLedgerId: null,
      };
@@ -890,6 +879,11 @@
  onShow(() => {
    initForm();
  });
  const optionsId = ref("");
  onLoad(options => {
    optionsId.value = options.id || "";
    initForm();
  });
</script>
<style scoped lang="scss">