yuan
2026-09-24 4f71e431f112442e522a863f706ceeff9ca840cd
feat: 优化工序列表展示,增加已配置参数的工序排序及刷新功能
已修改1个文件
46 ■■■■■ 文件已修改
src/views/productionManagement/productionProcess/index.vue 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productionManagement/productionProcess/index.vue
@@ -309,8 +309,18 @@
  import { getDeviceLedger } from "@/api/equipmentManagement/ledger";
  import { getBaseParamList } from "@/api/basicData/parameterMaintenance.js";
  // 工序列表数据
  const processValueList = ref([]);
  // 工序列表原始数据
  const processListRaw = ref([]);
  // 已配置参数的工序ID集合(统一转成字符串比较,避免ID类型不一致)
  const processIdsWithParam = ref(new Set());
  // 工序列表:已配置参数的工序排在前面,其余保持原有顺序排在后面
  const processValueList = computed(() => {
    return [...processListRaw.value].sort((a, b) => {
      const aRank = processIdsWithParam.value.has(String(a.id)) ? 0 : 1;
      const bRank = processIdsWithParam.value.has(String(b.id)) ? 0 : 1;
      return aRank - bRank;
    });
  });
  const selectedProcess = ref(null);
  const processLoading = ref(false);
  const deviceOptions = ref([]);
@@ -487,16 +497,32 @@
    },
  ]);
  // 刷新“已配置参数”的工序标记
  const refreshProcessParamFlags = () => {
    return getProcessParamList({})
      .then(res => {
        const list = res.data || [];
        processIdsWithParam.value = new Set(
          (Array.isArray(list) ? list : [])
            .map(item => item.technologyOperationId)
            .filter(id => id !== null && id !== undefined)
            .map(id => String(id))
        );
      })
      .catch(error => {
        console.error("获取工序参数列表失败", error);
      });
  };
  // 获取工序列表
  const getProcessList = () => {
    processLoading.value = true;
    getProcessListApi({ size: -1, current: -1 })
      .then(res => {
        processValueList.value = res.data.records || [];
        console.log(
          processValueList.value,
          "reprocessValueList.value==========s"
        );
    Promise.all([
      getProcessListApi({ size: -1, current: -1 }),
      refreshProcessParamFlags(),
    ])
      .then(([res]) => {
        processListRaw.value = res.data.records || [];
      })
      .catch(() => {
        ElMessage.error("获取工序列表失败");
@@ -726,6 +752,7 @@
        .then(() => {
          ElMessage.success("删除成功");
          getParamList(selectedProcess.value.id);
          refreshProcessParamFlags();
        })
        .catch(() => {
          ElMessage.error("删除失败");
@@ -773,6 +800,7 @@
        ElMessage.success("添加成功");
        paramDialogVisible.value = false;
        getParamList(selectedProcess.value.id);
        refreshProcessParamFlags();
      })
      .catch(() => {
        ElMessage.error("添加失败");