chengxiangling
2025-05-16 af1c9e588f1de0240390648f9bb56aa486870aff
src/views/basicData/processRouteDataPreparate/index.vue
@@ -1,375 +1,354 @@
<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-form
        :model="queryParams"
        ref="queryRef"
        :rules="rules"
        :inline="true"
        v-show="showSearch"
        label-width="68px"
      >
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="料号" prop="itemCode">
              <el-input
                style="width: 240px"
                v-model="queryParams.itemCode"
                placeholder="请输入料号"
                clearable
                @keyup.enter="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col :span="18" style="text-align: right">
            <el-form-item>
              <el-button type="primary" icon="Search" @click="handleQuery"
                >查询</el-button
    <el-form
      :model="queryParams"
      ref="queryRef"
      :rules="rules"
      :inline="true"
      v-show="showSearch"
      label-position="left"
    >
      <el-row type="flex" justify="left" :gutter="20">
        <el-col :span="locale === 'zh' ? 5 : 8">
          <el-form-item :label="$t('plan.query.itemNumber')" :label-width="locale === 'zh' ? '50px' : '110px'"  prop="itemCode">
            <el-input
              :style="{ width: locale === 'zh' ? '140px' : '220px' }"
              v-model="queryParams.itemCode"
              :placeholder="`${$t('common.common.placeholder')}${$t(
                'plan.query.itemNumber'
              )}`"
              clearable
              @keyup.enter="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="locale === 'zh' ? 7 : 10">
          <el-form-item
            :label="$t('plan.table.applicableFactories')"
            :label-width="locale === 'zh' ? '70px' : '150px'"
            prop="orgCode"
          >
            <el-select
              clearable
              v-model="queryParams.orgCode"
              :style="{ width: locale === 'zh' ? '180px' : '280px' }"
              :placeholder="`${$t('common.common.placeholder')}${$t(
                'plan.table.applicableFactories'
              )}`"
            >
              <el-option
                v-for="plant in plantList"
                :key="plant.id"
                :label="plant.plantName"
                :value="plant.plantCode"
              >
              <el-button icon="Refresh" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-row>
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <!-- <el-col :span="locale === 'zh' ? 11 : 6" style="text-align: right">
          <el-form-item class="column-with-margin">
            <el-button type="primary" icon="Search" @click="handleQuery">{{
              $t("common.common.query")
            }}</el-button>
            <el-button icon="Refresh" @click="resetQuery">{{
              $t("common.common.reset")
            }}</el-button>
          </el-form-item>
        </el-col> -->
      </el-row>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="Refresh"
          :disabled="loadingRefresh"
          @click="handleRefresh"
          v-hasPermi="['apsPartRouteStat:edit']"
          >更新</el-button
          v-hasPermi="['Aps:ApsStandardProcessRouteHeader:refreshProcessRouteData']"
          >{{ $t("common.common.update") }}</el-button
        >
      </el-col>
      <right-toolbar
        v-model:showSearch="showSearch"
        @queryTable="getList"
        @queryTable="handleQuery"
        @resetTable="resetQuery"
      ></right-toolbar>
    </el-row>
    <HxlhTable
      style="width: 100%"
      :columns="columns"
      :data="planList"
      :data="processRouteList"
      :loading="loading"
      :height="height"
      :virtualYConfig="virtualYConfig"
      :showOverflow="true"
      @on-checkbox="handleCheckboxChange"
      :page="page"
      @changePageNo="changePageNo"
      @changePageSize="changePageSize"
      :expand-config="expandConfig"
      :subGridOptions="subGridOptions"
    >
      <!--       :expand-config="expandConfig"
      :subGridOptions="subGridOptions" -->
      <template #buttons="{ row }">
        <el-button
          type="primary"
          link
          @click="handleCheckView(row)"
          v-hasPermi="['Aps:ApsStandardProcessRouteLine:list']"
          >{{ $t("common.common.view") }}</el-button
        >
      </template>
    </HxlhTable>
    <el-dialog
      :title="$t('common.common.viewDetails')"
      v-model="openDialog"
      width="900px"
      style="height: 400px; overflow: hidden"
      append-to-body
    >
      <HxlhTable
        style="width: 100%"
        :columns="subGridOptions"
        :data="subList"
        :loading="loading"
        :height="'280px;'"
      >
      </HxlhTable>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="openDialog = false">{{
            $t("common.common.close")
          }}</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>
<script setup name="ApsPlatePlan">
<script setup name="ProcessRouteDataPreparate">
import { listAll_plant } from "@/api/basicData/plant";
import {
  listPlan,
  examplePlan,
  confirmPart,
} from "@/api/mainPlan/apsPlatePlan.js";
import { listProcessRoute } from "@/api/basicData/processRoute.js";
  apsStandardProcessRouteHeaderList,
  apsStandardProcessRouteLineList,
  apsRefreshProcessRouteDataList
} from "@/api/basicData/processRoute.js";
import { listAll_shop } from "@/api/basicData/shop";
import HxlhTable from "@/components/HxlhTable/index.vue";
import { ref } from "vue";
import { getToken } from "@/utils/auth.js";
import { ElMessage } from "element-plus";
// import { ElMessage } from "element-plus";
import { useI18n } from "vue-i18n"; //要在js中使用国际化
const { t, locale } = useI18n();
const { proxy } = getCurrentInstance();
const virtualYConfig = {
  enabled: true,
  gt: 0,
  threshold: 50,
};
// 分页属性
const page = ref({
  total: 0,
  current: 1,
  size: 10
  size: 10,
});
const {
  aps_is_suspended,
  aps_document_status,
  aps_account,
  aps_business_type,
} = proxy.useDict(
  "aps_is_suspended",
  "aps_document_status",
  "aps_account",
  "aps_business_type"
);
const exampleList = ref([]);
const planList = ref([]);
const loading = ref(true);
const plantList = ref([]);
const shopList = ref([]);
const processRouteList = ref([]);
const subGridOptions = ref([]);
const subList = ref([]);
const loading = ref(false);
const loadingRefresh = ref(false);
const showSearch = ref(true);
const single = ref(true);
const total = ref(0);
const daterangePlanStartDay = ref([]);
const daterangePlanEndDay = ref([]);
const height = ref(document.documentElement.clientHeight - 270 + "px;");
const isVisible = ref(false);
const isError = ref(false);
const planned = ref(true);
const batchNumber = ref(null);
const exampleHeight = ref("500px");
const uploadRef = ref();
/*** 用户导入参数 */
const upload = reactive({
  // 是否显示弹出层(用户导入)
  open: false,
  // 弹出层标题(用户导入)
  title: "",
  // 是否禁用上传
  isUploading: false,
  // 是否更新已经存在的用户数据
  updateSupport: 0,
  // 设置上传的请求头部
  headers: { Authorization: "Bearer " + getToken(), local: "zhl" },
  // 上传的地址
  url: import.meta.env.VITE_APP_BASE_API + "/aps/apsPlatePlan/importData",
});
const height = ref(document.documentElement.clientHeight - 220 + "px;");
const heightSub = ref(document.documentElement.clientHeight - 320 + "px;");
// 表格配置
const exampleColumns = ref([
  { type: "seq", title: "序号", width: 60 },
  {
    title: "主计划员",
    field: "masterPlanner",
    width: 100,
  },
  {
    title: "周日",
    field: "weekDay",
    width: 100,
    formatter: ({ cellValue, row, column }) => {
      if (cellValue) {
        const weekDay = new Date(cellValue);
        const year = weekDay.getFullYear();
        const month = String(weekDay.getMonth() + 1).padStart(2, "0");
        const day = String(weekDay.getDate()).padStart(2, "0");
        return `${month}-${day}`;
      }
      return "";
    },
  },
  {
    title: "周度",
    field: "weekCycle",
    width: 80,
  },
  {
    title: "主件料号",
    field: "mainPartNumber",
    width: 150,
  },
  {
    title: "主件图号",
    field: "mainPartDrawingNumber",
    width: 150,
  },
  {
    title: "客户名称",
    field: "customer",
    width: 200,
  },
  {
    title: "业务类型",
    field: "businessType",
    width: 150,
  },
  {
    title: "单据号",
    field: "documentNumber",
    width: 150,
  },
  {
    title: "需求分类",
    field: "requirementType",
    width: 150,
  },
  {
    title: "单据状态",
    field: "documentStatus",
    width: 100,
  },
  {
    title: "料号",
    field: "itemNumber",
    width: 150,
  },
  {
    title: "图号",
    field: "drawingNo",
    width: 150,
  },
  {
    title: "版本号",
    field: "versionNumber",
    width: 100,
  },
  {
    title: "生产数量",
    field: "productionQuantity",
    width: 100,
  },
  {
    title: "良品数量",
    field: "goodProductsQuantity",
    width: 100,
  },
  {
    title: "工序号",
    field: "processNumber",
    width: 150,
  },
  {
    title: "工作中心",
    field: "workCenter",
    width: 150,
  },
  {
    title: "所属部门",
    field: "department",
    width: 100,
  },
  {
    title: "计划开工日",
    field: "planStartDay",
    width: 100,
  },
  {
    title: "计划完工日",
    field: "planEndDay",
    width: 100,
  },
  {
    title: "备料料号",
    field: "standbyNumber",
    width: 100,
  },
  {
    title: "备料名称",
    field: "standbyName",
    width: 200,
  },
  {
    title: "备料库存",
    field: "standbyStock",
    width: 100,
  },
  {
    title: "下道工序所属部门",
    field: "nextProcessDeparment",
    width: 180,
  },
  {
    title: "是否挂起",
    field: "isSuspended",
    width: 100,
  },
  {
    title: "外协标识",
    field: "isOutsourcing",
    width: 100,
  },
  {
    title: "账套",
    field: "account",
    width: 100,
  },
  // {
  //   title: '上阶物料',
  //   field: 'advancedMaterials',
  //   width: 100,
  // },
  // {
  //   title: '上阶单据号',
  //   field: 'advancedDocumentNumber',
  //   width: 100,
  // },
  // {
  //   title: '上阶需求日期',
  //   field: 'advancedRequirementDay',
  //   width: 150,
  // },
  // {
  //   title: '计划齐套',
  //   field: 'isPlanComplete',
  //   width: 100,
  // },
  // {
  //   title: '库存齐套',
  //   field: 'isStockComplete',
  //   width: 100,
  // },
  // {
  //   title: '是否有折返工序',
  //   field: 'hasTurnback',
  //   width: 150,
  // },
  // {
  //   title: '风险标识',
  //   field: 'hasRisk',
  //   width: 100,
  // },
]);
// 表格配置
const columns = ref([
  {
    field: "expand",
    type: "expand",
    width: 60,
    align: "center",
    slots: { content: "expandContent" },
  },
  { type: "checkbox", width: 60, align: "center" },
  {
    title: "工艺路线ID",
    field: "mainPartNumber",
  },
  {
    title: "工艺路线版本",
    field: "businessType",
  },
  {
    title: "料号",
    field: "documentNumber",
  },
  {
    title: "生效日期",
    field: "requirementType",
  },
  {
    title: "失效日期",
    field: "documentStatus",
  },
  {
    title: "集成日期",
    field: "itemNumber",
  },
  {
    title: "适用工厂",
    field: "drawingNo",
  },
]);
const columns = ref([]);
const openDialog = ref(false);
const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    customer: null,
    documentNumber: null,
    itemCode: null,
  },
  rules: {
    itemCode: [{ required: true, message: "请输入料号", trigger: "blur" }],
    itemCode: [],
  },
});
const { queryParams, form, rules } = toRefs(data);
watch(
  locale,
  (newLocale) => {
    rules.value = {
      itemCode: [
        {
          required: true,
          message: `${t("common.common.placeholder")}${t(
            "plan.query.itemNumber"
          )}`,
          trigger: "blur",
        },
      ],
    };
    columns.value = [
      // {
      //   field: "expand",
      //   type: "expand",
      //   width: 60,
      //   align: "center",
      //   slots: { content: "expandContent" },
      // },
      // { type: "checkbox", width: 60, align: "center" },
      {
        title: t("basic.table.processRouteID"),
        field: "routeId",
      },
      {
        title: t("basic.table.processRouteVersion"),
        field: "version",
      },
      {
        title: t("plan.table.itemNumber"),
        field: "itemCode",
      },
      {
        title: t("basic.table.effectiveDate"),
        field: "startDate",
      },
      {
        title: t("basic.table.expiringDate"),
        field: "endDate",
      },
      {
        title: t("basic.table.integrationDate"),
        field: "createTime",
      },
      {
        title: t("basic.table.applicableFactories"),
        field: "orgCode",
        formatter: ({ cellValue, row, column }) => {
          if (cellValue) {
            for (let i = 0; i < plantList.value.length; i++) {
              if (cellValue === plantList.value[i].plantCode) {
                return plantList.value[i].plantName;
              }
            }
          }
        },
      },
      {
        title: t("common.common.operate"),
        width: 100,
        fixed: "right",
        slots: { default: "buttons" },
        align: "center",
      },
    ];
    subGridOptions.value = [
      {
        title: t("basic.table.processRouteID"),
        field: "routeId",
        width: 150,
        align: "center",
      },
      {
        title: t("basic.table.operationSequence"),
        field: "routeNum",
        width: 150,
        align: "center",
      },
      {
        title: t("plan.table.processName"),
        field: "routeName",
        width: 150,
        align: "center",
      },
      {
        title: t("basic.table.effectiveDate"),
        field: "startDate",
        width: 230,
        align: "center",
      },
      {
        title: t("basic.table.expiringDate"),
        field: "endDate",
        width: 230,
        align: "center",
      },
      {
        title: t("basic.table.integrationDate"),
        field: "createTime",
        width: 230,
        align: "center",
      },
      {
        title: t("basic.table.applicableFactories"),
        field: "orgCode",
        width: 90,
        align: "center",
        formatter: ({ cellValue, row, column }) => {
          if (cellValue) {
            for (let i = 0; i < plantList.value.length; i++) {
              if (cellValue === plantList.value[i].plantCode) {
                return plantList.value[i].plantName;
              }
            }
          }
        },
      },
      {
        title: t("basic.table.applicableWorkshop"),
        field: "shopCode",
        width: 90,
        align: "center",
        formatter: ({ cellValue, row, column }) => {
          if (cellValue) {
            for (let i = 0; i < shopList.value.length; i++) {
              if (cellValue === shopList.value[i].id) {
                return shopList.value[i].shopName;
              }
            }
          }
          return "";
        },
      },
      {
        title: t("basic.table.productivityModel"),
        field: "productivityModel",
        width: 160,
        align: "center",
      },
      {
        title: t("basic.table.designCapacity"),
        field: "designCapacity",
        width: 160,
        align: "center",
      },
    ];
  },
  { immediate: true, deep: true }
);
async function handleRefresh() {
  loadingRefresh.value = true;
  const res = await apsRefreshProcessRouteDataList();
  if (res.code == 200) {
    ElMessage({
      message: t("plan.message.update"),
      type: "success",
    });
    loadingRefresh.value = false;
    getList();
  } else {
    loadingRefresh.value = false;
  }
}
function changePageNo(currentPage) {
  queryParams.value.pageNum = currentPage;
  page.value.current = currentPage;
@@ -381,36 +360,20 @@
  queryParams.value.pageSize = pageSize;
  getList();
}
/** 查询钣金计划临时管理列表 */
function getExampleList() {
  loading.value = true;
  queryParams.value = {};
  queryParams.value.batchNumber = batchNumber.value;
  examplePlan(queryParams.value).then((response) => {
    exampleList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}
/** 查询零件计划管理列表 */
function getList() {
  loading.value = true;
  queryParams.value.params = {};
  if (null != daterangePlanStartDay && "" !== daterangePlanStartDay) {
    queryParams.value.params["beginPlanStartDay"] =
      daterangePlanStartDay.value[0];
    queryParams.value.params["endPlanStartDay"] =
      daterangePlanStartDay.value[1];
  }
  if (null != daterangePlanEndDay && "" !== daterangePlanEndDay) {
    queryParams.value.params["beginPlanEndDay"] = daterangePlanEndDay.value[0];
    queryParams.value.params["endPlanEndDay"] = daterangePlanEndDay.value[1];
  }
  listPlan(queryParams.value).then((response) => {
    planList.value = response.rows;
    loading.value = false;
  });
  apsStandardProcessRouteHeaderList(queryParams.value)
    .then((response) => {
      processRouteList.value = response.rows;
      page.value.total = response.total;
      loading.value = false;
    })
    .catch(() => {
      loading.value = false;
    });
}
/** 搜索按钮操作 */
@@ -424,195 +387,49 @@
/** 重置按钮操作 */
function resetQuery() {
  daterangePlanStartDay.value = [];
  daterangePlanEndDay.value = [];
  page.value.current = 1;
  page.value.total = 0;
  queryParams.value.pageNum = 1;
  proxy.resetForm("queryRef");
  handleQuery();
  processRouteList.value = [];
  subList.value = [];
}
// 多选框选中数据
const handleCheckboxChange = (data) => {
  console.log(data);
};
/** 批量修改计划开工日按钮操作 */
function plannedStart() {}
/** 批量修改计划完工日按钮操作 */
function plannedEnd() {}
/** 导入按钮操作 */
function handleImport() {
  upload.title = "钣金计划数据上传";
  upload.open = true;
}
/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    "aps/apsPlatePlan/export",
    {
      ...queryParams.value,
    },
    `plan_${new Date().getTime()}.xlsx`
  );
}
/** 下载模板操作 */
function importTemplate() {
  proxy.download(
    "system/user/importTemplate",
    {},
    `user_template_${new Date().getTime()}.xlsx`
  );
}
/** buildEexample */
function buildEexample() {
  proxy.$refs["uploadRef"].submit();
}
/**文件上传中处理 */
const handleFileUploadProgress = (event, file, fileList) => {
  upload.isUploading = true;
};
/** 文件上传成功处理 */
const handleFileSuccess = (response, file, fileList) => {
  if (response.code == "200") {
    batchNumber.value = response.data;
    isVisible.value = true;
    planned.value = false;
    isError.value = false;
    getExampleList();
  } else {
    isError.value = true;
    proxy.$alert(
      "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
        response.msg +
        "</div>",
      "导入结果",
      { dangerouslyUseHTMLString: true }
    );
  }
  proxy.$refs["uploadRef"].handleRemove(file);
  upload.isUploading = false;
};
/** 上传并解析按钮操作 */
function uploadParse() {
  queryParams.value.params = {};
  queryParams.value.params["batchNumber"] = batchNumber.value;
  confirmPart(queryParams.value).then((response) => {
    exampleList.value = response.rows;
    loading.value = false;
    isVisible.value = false;
    isError.value = false;
    planned.value = true;
    upload.open = false;
    ElMessage({
      message: "气体管路计划数据已成功上传和解析",
      type: "success",
    });
    getList();
function handleCheckView(row) {
  openDialog.value = true;
  apsStandardProcessRouteLineList({
    routeId: row.routeId,
  }).then((data) => {
    subList.value = data.rows;
  });
}
/** dialog取消 */
function dialogCancel() {
  if (uploadRef.value) {
    uploadRef.value.clearFiles();
  }
  isVisible.value = false;
  isError.value = false;
  planned.value = true;
  upload.open = false;
  upload.isUploading = false;
}
/*定义下拉二级表*/
// /*定义下拉二级表*/
// const expandConfig = ref({
//   lazy: true,
//   loadMethod({ row }) {
//     // 调用接口
//     return listProcessRoute({ workOrderNo: row.documentNumber }).then(
//       (data) => {
//         row.subList = data.rows;
//       }
//     );
//   },
// });
const subGridOptions = reactive({
  border: true,
  showOverflow: true,
  columns: [
    {
      title: "工艺路线ID",
      field: "itemNo",
      width: 150,
      align: "center",
    },
    {
      title: "工序序号",
      field: "workOrderNo",
      width: 150,
      align: "center",
    },
    {
      title: "工序名称",
      field: "processNumber",
      width: 100,
      align: "center",
    },
    {
      title: "生效日期",
      field: "processName",
      width: 150,
      align: "center",
    },
    {
      title: "失效日期",
      field: "processPlanStartDay",
      width: 200,
      align: "center",
    },
    {
      title: "集成日期",
      field: "processPlanEndDay",
      width: 200,
      align: "center",
    },
    {
      title: "适用工厂",
      field: "standardTime",
      width: 90,
      align: "center",
    },
    {
      title: "适用车间",
      field: "processOrder",
      width: 90,
      align: "center",
    },
    {
      title: "产能模型",
      field: "integrationDay",
      width: 160,
      align: "center",
    },
    {
      title: "设计产能",
      field: "integrationDay",
      width: 160,
      align: "center",
    },
  ],
// getList();
onMounted(async () => {
  const res = await listAll_plant({});
  plantList.value = res.data;
  const shopres = await listAll_shop({});
  shopList.value = shopres.data;
});
const expandConfig = ref({
  lazy: true,
  loadMethod({ row }) {
    // 调用接口
    return listProcessRoute({ workOrderNo: row.documentNumber }).then(
      (data) => {
        row.subList = data.rows;
      }
    );
  },
});
getList();
</script>
<style lang="css" scoped>
h4 {
  font-weight: bold;
}
.column-with-margin {
  margin-right: 0px;
}
</style>