chengxiangling
2025-05-16 c9120650b03c477c27ce5c9c492a416be21df1b0
src/views/mainPlan/pipeProduceStatics/index.vue
@@ -101,7 +101,7 @@
import { useI18n } from "vue-i18n"; //要在js中使用国际化
const { t, locale } = useI18n();
const { proxy } = getCurrentInstance();
const { aps_factory } = proxy.useDict("aps_factory");
const loading = ref(false);
const gridRef = ref();
const height = ref(document.documentElement.clientHeight - 180 + "px;");
@@ -200,6 +200,19 @@
    eYearMonth: `${eYear}-${eMonth.toString().padStart(2, "0")}`,
  };
}
const formatTypeLabelPlant = (list) => {
  if (list) {
    return list
      .map((type) => {
        const item = aps_factory.value.find(
          (item) => item.value === type
        );
        return item ? item.label : type;
      })
      .join("");
  }
  return "";
};
/** 查询零件统计表列表 */
function getPipeList() {
  let rowKey = 0;
@@ -220,15 +233,15 @@
    major: "piping",
  }).then((response) => {
    const colList = [];
    let headersOne = [];
    let headersTwo = [];
    // let headersOne = [];
    // let headersTwo = [];
    if (response.code == "200") {
      if (!response.data.planTitle) {
        loading.value = false;
        return;
      }
      headersOne.push(t("plan.table.dateYearMonth"));
      headersTwo.push(t("plan.table.processName"));
      // headersOne.push(t("plan.table.dateYearMonth"));
      // headersTwo.push(t("plan.table.processName"));
      colList.push({
        field: "dateCol",
        title: t("plan.table.dateYearMonth"),
@@ -240,16 +253,16 @@
            width: 250,
            type: "html",
          },
          {
            field: `resourceGroupName`,
            title: t("plan.table.applicableFactories"),
            width: 250,
            type: "html",
          },
        ],
        width: 160,
      });
      response.data.planTitle.forEach((item) => {
        headersOne.push(item);
        headersOne.push("");
        headersOne.push("");
        headersTwo.push(t("plan.table.designWorkingHours"));
        headersTwo.push(t("plan.table.requiredWorkingHours"));
        headersTwo.push(t("plan.table.capacityLoad"));
        colKey++;
        colList.push({
          field: `dateColTime${colKey}`,
@@ -275,27 +288,16 @@
          width: 160,
        });
      });
      headers.value.push(headersOne);
      headers.value.push(headersTwo);
      const columnList = [...tableColumn, ...colList];
      const dataList = [];
      let startCol = 1;
      //获取map
      response.data.planTable.map((mapItem) => {
        rowKey++;
        let lastCol = startCol + 2;
        merges.push({ s: { r: 0, c: startCol }, e: { r: 0, c: lastCol } });
        startCol = lastCol + 1;
        let data = [];
        const item = {
          id: `${rowKey}`,
        };
        for (const [key, listValue] of Object.entries(mapItem)) {
          data.push(key);
          let tableKey = 0;
          let flag = false;
          listValue.forEach((listItem) => {
@@ -307,24 +309,14 @@
              listItem.requireTimes,
              listItem.capacityLoad
            );
            // 0-100 绿色,101-120黄色,大于120红色
            // listItem.capacityLoad <= 100
            //   ? `<font color="red">${listItem.capacityLoad}%</font>`
            //   : listItem.capacityLoad + "%";
            data.push(listItem.designTimes);
            data.push(listItem.requireTimes);
            data.push(listItem.capacityLoad + "%");
            // if (listItem.capacityLoad > 100) {
            //   flag = true;
            // }
          });
          // item[`resourceName`] = flag
          //   ? `<div class='el-badge'><sup class="el-badge__content is-fixed is-dot"></sup>${key}</div>`
          //   : key;
          item[`resourceName`] = key;
          item[`resourceName`] = key.split("_")[0];
          item[`resourceGroupName`] = formatTypeLabelPlant([key.split("_")[1]]);
        }
        exportData.value.push(data);
        dataList.push(item);
      });