Ben Lin
2024-08-05 16257dd099d9811fb5caf78047ffc2425c401e0e
src/views/tigerprojects/mes/eng/route/index.vue
@@ -47,7 +47,12 @@
<script lang="ts" setup>
  import { FlowChart } from '/@/components/FlowChart';
  import { PageWrapper } from '/@/components/Page';
  import { SaveRouteData, getRouteData } from '/@/api/tigerapi/mes/router';
  import {
    SaveRouteData,
    SaveWoRouteData,
    getRouteData,
    getWoRouteData,
  } from '/@/api/tigerapi/mes/router';
  import { useModal } from '/@/components/Modal';
  import RouteModal from './RouteModal.vue';
  import { onMounted, ref, unref, Ref, provide, reactive, nextTick, watch } from 'vue';
@@ -94,6 +99,7 @@
    currentAct: {} as MES_ROUTE_NODE_ACT,
    routeData: {} as RouteData,
    activeKey: 1,
    isWorkOrder: false,
  });
  const currRoute = ref({} as MES_ROUTE);
  const routeData = ref({
@@ -109,6 +115,7 @@
  const entityName = ref<any>('MES_POSITION');
  const props = defineProps({
    rotId: { type: String, default: '' },
    rotType: { type: String, default: 'Route' },
  });
  const IsOperation = ref(false);
  const title = ref('');
@@ -118,7 +125,7 @@
  watch(
    () => props.rotId,
    (v) => {
      if (v !== currRotId.value) {
      if (!isNullOrEmpty(v) && v !== currRotId.value) {
        currRotId.value = v;
        if (!isNullOrUnDef(unref(currlf))) {
          unref(currlf).render({});
@@ -145,7 +152,11 @@
  async function init(lf) {
    currlf.value = unref(lf);
    //通过工艺路线ID获取图形数据,并渲染
    var _data = await getRouteData(currRotId.value);
    routeConfig.isWorkOrder = props.rotType == 'Wo';
    var _data =
      props.rotType == 'Route'
        ? await getRouteData(currRotId.value)
        : await getWoRouteData(currRotId.value);
    console.log('组件已挂载', _data);
    //工艺路线全信息,包括Node、Edge和Act
    routeConfig.routeData = _data.Data;
@@ -174,6 +185,11 @@
    }
  }
  /**
   * @description: 获取工艺路线图数据
   * @param {*} lf
   * @return {*}
   */
  const GetRotData = (lf) => {
    var currRotData: RouteData = {
      route: {
@@ -192,6 +208,9 @@
        AUTH_ORG: useUserStore().getUserInfo.orgCode,
        AUTH_PROD: '',
        AUTH_WH: '',
        WORK_ORDER: currRoute.value.WORK_ORDER,
        PROD_CODE: currRoute.value.PROD_CODE,
        CUST_CODE: currRoute.value.CUST_CODE,
      },
      nodes: [],
      edges: [],
@@ -244,6 +263,9 @@
              // DO_IF_FAIL: a.DO_IF_FAIL,
              node: {} as node,
              IS_ACTIVE: a.IS_ACTIVE,
              WORK_ORDER: a.WORK_ORDER,
              PROD_CODE: a.PROD_CODE,
              CUST_CODE: a.CUST_CODE,
            };
            var pnode = [n];
            while (pnode[0].properties.operType == 'Action') {
@@ -279,6 +301,7 @@
              GPH_TEXT: n.text.value,
              IS_ACTIVE: nd.IS_ACTIVE,
              IS_CALC_FPY: nd.IS_CALC_FPY,
              ALLOW_DFT_IN: nd.ALLOW_DFT_IN,
              CAN_SKIP: nd.CAN_SKIP,
              REMARK: nd.REMARK,
              AUTH_ORG: useUserStore().getUserInfo.orgCode,
@@ -293,6 +316,9 @@
              OPTION_4: '',
              OPTION_5: '',
              node: {} as node,
              WORK_ORDER: nd.WORK_ORDER,
              PROD_CODE: nd.PROD_CODE,
              CUST_CODE: nd.CUST_CODE,
            };
            nd.GPH_TYPE = n.type;
            nd.GPH_PROP = JSON.stringify(n.properties);
@@ -341,6 +367,9 @@
        OPTION_4: '',
        OPTION_5: '',
        edge: {} as edge,
        WORK_ORDER: routeConfig.routeData.route.WORK_ORDER,
        PROD_CODE: routeConfig.routeData.route.PROD_CODE,
        CUST_CODE: routeConfig.routeData.route.CUST_CODE,
      };
      routeConfig.routeData.edges.push(edge);
      currRotData.edges.push(edge);
@@ -354,7 +383,10 @@
   */
  async function handleSave(lf) {
    console.log('handleSave', unref(lf).getGraphData().nodes[0]);
    if (isNullOrEmpty(currRoute.value.ROT_CODE)) {
    if (
      isNullOrEmpty(currRoute.value.ROT_CODE) ||
      (props.rotType == 'Wo' && isNullOrEmpty(currRoute.value.WORK_ORDER))
    ) {
      createErrorModal({
        title: t('未选择'),
        content: t('未选择工艺路线或者新增工艺路线'),
@@ -379,7 +411,10 @@
          getContainer: () => document.body,
        });
      } else {
        var action = await SaveRouteData(GetRotData(lf));
        var action =
          props.rotType == 'Wo'
            ? await SaveWoRouteData(GetRotData(lf))
            : await SaveRouteData(GetRotData(lf));
        if (action.IsSuccessed) {
          await refreshPage();
        }
@@ -445,6 +480,7 @@
        AUTH_PROD: '',
        AUTH_WH: '',
        IS_FIRST_NODE: '',
        ALLOW_DFT_IN: '',
        IS_INPUT: '',
        IS_OUTPUT: '',
        OPTION_1: '',
@@ -453,6 +489,9 @@
        OPTION_4: '',
        OPTION_5: '',
        node: {} as node,
        WORK_ORDER: currRoute.value.WORK_ORDER,
        PROD_CODE: currRoute.value.PROD_CODE,
        CUST_CODE: currRoute.value.CUST_CODE,
      };
      routeConfig.routeData.nodes.push(_node);
      _num++;
@@ -502,6 +541,9 @@
          OPTION_5: '',
          REMARK: '',
          node: {} as node,
          WORK_ORDER: currRoute.value.WORK_ORDER,
          PROD_CODE: currRoute.value.PROD_CODE,
          CUST_CODE: currRoute.value.CUST_CODE,
        };
        routeConfig.routeData.acts.push(_act);
        _numEdge++;
@@ -540,6 +582,9 @@
        OPTION_5: '',
        REMARK: '',
        node: {} as node,
        WORK_ORDER: currRoute.value.WORK_ORDER,
        PROD_CODE: currRoute.value.PROD_CODE,
        CUST_CODE: currRoute.value.CUST_CODE,
      };
      const actModel = lf.getNodeModelById(selectnode.value.id);
      actModel.updateText(routeConfig.currentAct?.ACT_NAME);
@@ -569,13 +614,20 @@
        IS_CALC_FPY: _node.IS_CALC_FPY,
        CAN_SKIP: _node.CAN_SKIP,
        IS_INPUT: _node.IS_INPUT,
        ALLOW_DFT_IN: _node.ALLOW_DFT_IN,
        IS_OUTPUT: _node.IS_OUTPUT,
        REMARK: _node.REMARK,
        WORK_ORDER: currRoute.value.WORK_ORDER,
        PROD_CODE: currRoute.value.PROD_CODE,
        CUST_CODE: currRoute.value.CUST_CODE,
        node: {} as node,
      };
      const nodeModel = lf.getNodeModelById(selectnode.value.id);
      nodeModel.updateText(_node.NODE_NAME);
      routeConfig.isCalcFpy = _node.IS_CALC_FPY == 'Y';
      routeConfig.canSkip = _node.CAN_SKIP == 'Y';
      routeConfig.isActive = _node.IS_ACTIVE == 'Y';
      routeConfig.allowDftIn = _node.ALLOW_DFT_IN == 'Y';
      routeConfig.isInput = _node.IS_INPUT == 'Y';
      routeConfig.isOutput = _node.IS_OUTPUT == 'Y';
      setTimeout(() => {