Ben Lin
2024-06-12 078f603f7686c274067028bd23032625e6eee3ce
src/views/tigerprojects/mes/eng/route/index.vue
@@ -20,7 +20,13 @@
        style="background: #fafafa; border-left: 1px solid #d9d9d9; padding: 10px"
        :zeroWidthTriggerStyle="{ 'margin-top': '-70px', 'background-color': 'gray' }"
      >
        <PropsPanel ref="propsPanel" :activeKey="routeConfig.activeKey">
        <PropsPanel ref="propsPanel"
          :activeKey="routeConfig.activeKey"
          :IsOperation="IsOperation"
          :title="title"
          :colSlots="colSlots"
          :crudColSlots="crudColSlots"
          :entityName="entityName">
          <!-- <template v-for="item of formConfig.schemas" #[`${item.component}Props`]="data">
            <slot
              :name="`${item.component}Props`"
@@ -35,13 +41,13 @@
  </PageWrapper>
</template>
<script lang="ts" setup>
<script lang="ts" setup name="Route_View">
  import { FlowChart } from '/@/components/FlowChart';
  import { PageWrapper } from '/@/components/Page';
  import { SaveRouteData, getRouteData } from '/@/api/tigerapi/mes/router';
  import { useModal } from '/@/components/Modal';
  import RouteModal from './RouteModal.vue';
  import { onMounted, ref, unref, Ref, provide, reactive, nextTick } from 'vue';
  import { onMounted, ref, unref, Ref, provide, reactive, nextTick, watch } from 'vue';
  import { Layout, LayoutContent, LayoutSider } from 'ant-design-vue';
  import {
    RouteData,
@@ -62,6 +68,8 @@
  import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is';
  import { useRoute } from 'vue-router';
  import { useTabs } from '/@/hooks/web/useTabs';
  import LogicFlow from '@logicflow/core';
import { getEntity } from '/@/api/tigerapi/system';
  const [registerDrawer, { openDrawer }] = useDrawer();
  const [registerModal, { openModal }] = useModal();
@@ -91,9 +99,58 @@
  provide<Ref<MES_ROUTE>>('mesRoute', currRoute);
  const selectnode = ref({} as node);
  const currRotId = ref(route.params?.id);
  const colSlots = ref<any>([]);
  const crudColSlots = ref<any>([]);
  const entityName = ref<any>('MES_POSITION');
  const props = defineProps({
    rotId: { type: String, default: '' },
  });
  const IsOperation = ref(false);
  const title = ref('行为');
  watch(
    () => props.rotId,
    (v) => {
      if (v !== currRotId.value) {
        currRotId.value = v;
        if (!isNullOrUnDef(unref(currlf))) {
          unref(currlf).render({});
          routeData.value = {
            nodes: [],
            edges: [],
          };
          init(currlf);
        }
      }
    },
    { deep: true },
  );
  const currlf = ref(null) as Ref<LogicFlow | null>;
  console.log(currRotId.value);
  onMounted(() => {
    getEntity({
            sqlcmd: `ASSEMBLY_NAME ='MES_POSITION'`,
            entityName: 'SYS_LOW_CODE',
          }).then((data) => {
            var searchForms = JSON.parse(data.Data.Items[0].SEARCH_FORM_JSON);
            for (const i in searchForms) {
              if(!isNullOrUnDef(searchForms[i]['colSlot'])){
                colSlots.value.push('form-'+searchForms[i]['colSlot']);
              }
            }
            var _cruds = JSON.parse(data.Data.Items[0].FORM_JSON);
            for (const i in _cruds) {
              if(!isNullOrUnDef(_cruds[i]['colSlot'])){
                crudColSlots.value.push(_cruds[i]['colSlot']);
              }
            }
            entityName.value = 'MES_POSITION';
          });
  });
  async function init(lf) {
    currlf.value = unref(lf);
    //通过工艺路线ID获取图形数据,并渲染
    var _data = await getRouteData(currRotId.value);
    console.log('组件已挂载', _data);
@@ -102,7 +159,7 @@
    if (_data.Data != null) {
      //工艺路线主信息
      currRoute.value = _data.Data.route;
      if (!isNullOrEmpty(currRotId.value)) {
      if (!isNullOrEmpty(currRotId.value) && isNullOrEmpty(props.rotId)) {
        setTitle('设计:工艺路线-' + currRoute.value.ROT_CODE);
      }
      _data.Data.nodes.forEach((n) => {
@@ -152,50 +209,58 @@
    const diffnodes = routeConfig.routeData.nodes.filter((itemA) =>
      _nodes.some((itemB) => itemB.id === itemA.ID),
    );
    routeConfig.routeData.acts = [];
    const diffacts = routeConfig.routeData.acts.filter((itemA) =>
      _nodes.some((itemB) => itemB.id === itemA.ID),
    );
    _nodes.forEach((n) => {
      if (n.properties.operType && n.properties.operType == 'Action') {
        var act: MES_ROUTE_NODE_ACT = {
          ID: n.id,
          CREATE_TIME: routeConfig.routeData.route.CREATE_TIME,
          CREATE_USER: useUserStore().getUserInfo.userId as string,
          UPDATE_TIME: routeConfig.routeData.route.UPDATE_TIME,
          UPDATE_USER: useUserStore().getUserInfo.userId as string,
          GHOST_ROW: false,
          ROT_ID: routeConfig.routeData.route.ID,
          GPH_TYPE: n.type,
          GPH_X: n.x,
          GPH_Y: n.y,
          GPH_PROP: JSON.stringify(n.properties),
          GPH_TEXT: n.text.value,
          REMARK: '',
          AUTH_ORG: '',
          AUTH_PROD: '',
          AUTH_WH: '',
          OPTION_1: '',
          OPTION_2: '',
          OPTION_3: '',
          OPTION_4: '',
          OPTION_5: '',
          ACT_NAME: `${routeConfig.routeData.route.ROT_CODE}_${n.text.value}_${_num}`,
          NODE_ID: '',
          ACT_TYPE: 0,
          DO_TYPE: 0,
          DO_METHOD: '',
          DO_IF_PASS: '',
          DO_IF_FAIL: '',
          node: {} as node,
        };
        var pnode = [n];
        while (pnode[0].properties.operType == 'Action') {
          pnode = unref(lf).getNodeIncomingNode(pnode[0].id);
          if (pnode[0].properties.operType != 'Action') {
            act.NODE_ID = pnode[0].id;
            break;
        var _diffacts = diffacts.length > 0 ? diffacts : routeConfig.routeData.acts;
        _diffacts.forEach((a) => {
          if (a.ID == n.id) {
            var act: MES_ROUTE_NODE_ACT = {
              ID: n.id,
              CREATE_TIME: routeConfig.routeData.route.CREATE_TIME,
              CREATE_USER: useUserStore().getUserInfo.userId as string,
              UPDATE_TIME: routeConfig.routeData.route.UPDATE_TIME,
              UPDATE_USER: useUserStore().getUserInfo.userId as string,
              GHOST_ROW: false,
              ROT_ID: routeConfig.routeData.route.ID,
              GPH_TYPE: n.type,
              GPH_X: n.x,
              GPH_Y: n.y,
              GPH_PROP: JSON.stringify(n.properties),
              GPH_TEXT: n.text.value,
              REMARK: a.REMARK,
              AUTH_ORG: '',
              AUTH_PROD: '',
              AUTH_WH: '',
              OPTION_1: '',
              OPTION_2: '',
              OPTION_3: '',
              OPTION_4: '',
              OPTION_5: '',
              ACT_NAME: `${routeConfig.routeData.route.ROT_CODE}_${n.text.value}_${_num}`,
              NODE_ID: a.NODE_ID,
              ACT_TYPE: a.ACT_TYPE,
              DO_TYPE: a.DO_TYPE,
              DO_METHOD: a.DO_METHOD,
              DO_IF_PASS: a.DO_IF_PASS,
              DO_IF_FAIL: a.DO_IF_FAIL,
              node: {} as node,
              IS_ACTIVE: a.IS_ACTIVE,
            };
            var pnode = [n];
            while (pnode[0].properties.operType == 'Action') {
              pnode = unref(lf).getNodeIncomingNode(pnode[0].id);
              if (pnode[0].properties.operType != 'Action') {
                act.NODE_ID = pnode[0].id;
                break;
              }
            }
            currRotData.acts.push(act);
          }
        }
        currRotData.acts.push(act);
        routeConfig.routeData.acts.push(act);
        });
        routeConfig.routeData.acts = _diffacts;
      } else {
        var _diffnodes = diffnodes.length > 0 ? diffnodes : routeConfig.routeData.nodes;
        _diffnodes.forEach((nd) => {
@@ -209,8 +274,8 @@
              GHOST_ROW: false,
              NODE_NAME: `${currRotData.route.ROT_CODE}_${n.text.value}_${_num}`,
              ROT_ID: currRotData.route.ID,
              SEGMENT: '',
              OPER_CODE: '',
              SEGMENT: nd.SEGMENT,
              OPER_CODE: nd.OPER_CODE,
              GPH_TYPE: n.type,
              GPH_X: n.x,
              GPH_Y: n.y,
@@ -359,6 +424,7 @@
      //再返回具体数据
      routeConfig.routeData = GetRotData(lf);
    }
    var _node = routeConfig.routeData.nodes.filter((x) => x.ID == selectnode.value.id)[0];
    if (isNullOrUnDef(_node)) {
      _node = {
@@ -396,9 +462,46 @@
      };
      routeConfig.routeData.nodes.push(_node);
    }
    //是行为
    if (selectnode.value.properties.operType && selectnode.value.properties.operType == 'Action') {
      var _act = routeConfig.routeData.acts.filter((x) => x.ID == selectnode.value.id)[0];
      routeConfig.activeKey = 3;
      IsOperation.value = false;
      title.value = '行为';
      routeConfig.currentAct = {
        ID: selectnode.value.id,
        CREATE_TIME: currRoute.value.CREATE_TIME,
        CREATE_USER: useUserStore().getUserInfo.userId as string,
        UPDATE_TIME: currRoute.value.UPDATE_TIME,
        UPDATE_USER: useUserStore().getUserInfo.userId as string,
        GHOST_ROW: false,
        AUTH_ORG: '',
        AUTH_PROD: '',
        AUTH_WH: '',
        ACT_NAME: _act.ACT_NAME,
        ROT_ID: currRoute.value.ID,
        NODE_ID: _act.NODE_ID,
        ACT_TYPE: _act.ACT_TYPE,
        GPH_TYPE: selectnode.value.type,
        GPH_X: selectnode.value.x,
        GPH_Y: selectnode.value.y,
        GPH_PROP: JSON.stringify(selectnode.value.properties),
        GPH_TEXT: selectnode.value.text.value,
        DO_TYPE: _act.DO_TYPE,
        DO_METHOD: _act.DO_METHOD,
        DO_IF_PASS: _act.DO_IF_PASS,
        DO_IF_FAIL: _act.DO_IF_FAIL,
        IS_ACTIVE: _act.IS_ACTIVE,
        OPTION_1: '',
        OPTION_2: '',
        OPTION_3: '',
        OPTION_4: '',
        OPTION_5: '',
        REMARK: '',
        node: {} as node,
      };
    } else {
      //是工序
      routeConfig.currentItem = {
        ID: selectnode.value.id,
        CREATE_TIME: currRoute.value.CREATE_TIME,
@@ -429,6 +532,8 @@
      console.log(routeConfig.currentItem);
      routeConfig.activeKey = 2;
      IsOperation.value = true;
      title.value = '岗位';
    }
  }