From ccebd227e4f3bfaab7a27c5b8dcc55b642a4006b Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期三, 21 八月 2024 10:22:22 +0800
Subject: [PATCH] 工艺路线更新

---
 src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue |  388 +++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 288 insertions(+), 100 deletions(-)

diff --git a/src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue b/src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue
index 3da904a..b252f3c 100644
--- a/src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue
+++ b/src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue
@@ -1,8 +1,16 @@
+<!--
+ * @Description: 宸ュ崟绠$悊椤甸潰
+ * @Author: Ben Lin
+ * @version: 
+ * @Date: 2024-05-25 00:27:00
+ * @LastEditors: Ben Lin
+ * @LastEditTime: 2024-07-21 18:07:27
+-->
 <template>
   <div>
     <BasicTable @register="registerTable">
       <template #toolbar>
-        <a-button color="primary" @click="addWo" preIcon="add_02|svg"> 鏂板 </a-button>
+        <a-button type="primary" @click="addWo" preIcon="add_02|svg"> 鏂板 </a-button>
         <a-button ghost color="success" @click="ExcelToDb" preIcon="excel-import|svg">
           瀵煎叆
         </a-button>
@@ -15,7 +23,7 @@
           @click="handleSelectItem"
           preIcon="search|svg"
         />
-        <NormalModal @register="registerItemAdd" @success="handleItemSuccess" />
+        <GeneralModal @register="registerItemAdd" @success="handleItemSuccess" />
       </template>
       <template #action="{ record }">
         <TableAction
@@ -24,6 +32,7 @@
               icon: 'clarity:note-edit-line',
               tooltip: '淇敼',
               onClick: handleEdit.bind(null, record),
+              name: undefined
             },
             {
               icon: 'ant-design:delete-outlined',
@@ -34,27 +43,30 @@
                 placement: 'left',
                 confirm: handleDelete.bind(null, record),
               },
+              name: undefined
             },
             {
               icon: 'config|svg',
               tooltip: '閰嶇疆宸ヨ壓',
               onClick: handleConfig.bind(null, record),
+              name: undefined
             },
             {
               icon: 'release|svg',
               tooltip: '涓嬪彂',
               onClick: handleRelease.bind(null, record),
+              name: undefined
             },
-            {
-              icon: 'unrelease|svg',
-              tooltip: '鍙栨秷涓嬪彂',
-              onClick: handleUnRelease.bind(null, record),
-            },
-            {
-              icon: 'suspend-blue|svg',
-              tooltip: '鏆傚仠',
-              onClick: handlePause.bind(null, record),
-            },
+            // {
+            //   icon: 'unrelease|svg',
+            //   tooltip: '鍙栨秷涓嬪彂',
+            //   onClick: handleUnRelease.bind(null, record),
+            // },
+            // {
+            //   icon: 'suspend-blue|svg',
+            //   tooltip: '鏆傚仠',
+            //   onClick: handlePause.bind(null, record),
+            // },
           ]"
         />
       </template>
@@ -62,45 +74,54 @@
     <Loading :loading="compState.loading" :tip="compState.tip" />
     <WoDrawer @register="registerDrawer" @success="handleSuccess" />
     <WoModal @register="registerWo" @success="handleSuccess" :title="title" :mtitle="mtitle" />
-    <CustModal
-      @register="registerCust"
-      @success="handleSuccess"
-      :type="cType"
-      :detailSlots="dtlSlots"
-    >
-      <template #[item.name] v-for="item in dtlSlots" :key="item.name">
-        <BasicForm
-          :schemas="formSchema"
-          :ref="item.name"
-          :labelWidth="100"
-          :showActionButtonGroup="false"
-        >
-          <template #[sitem]="{ field }" v-for="sitem in item.slots" :key="sitem">
-            <a-button
-              class="mt-1 ml-1"
-              size="small"
-              @click="handleCustClick(field)"
-              :preIcon="item.preIcons[sitem]"
-            />
-          </template>
-        </BasicForm>
-        <NormalModal
-          @register="registerEntity"
-          @success="(d, u) => handleEntSuccess(d, u, item.name)"
-        />
-      </template>
-    </CustModal>
+    <Suspense>
+      <!-- 鑷畾涔夋ā鎬佹锛屽彲浠ヨ嚜瀹氫箟澶氳〃鍗� -->
+      <CustModal
+        @register="registerCust"
+        @success="custSuccess"
+        :type="cType"
+        :detailSlots="dtlSlots"
+        :entityName="entityName"
+      >
+        <!-- 鐢ㄦ彃妲借嚜瀹氫箟澶氳〃鍗� -->
+        <template #[item.name] v-for="item in dtlSlots" :key="item.name">
+          <BasicForm @register="useFormData[item.name][0]" v-if="useFormData[item.name]">
+            <!-- 鐢ㄦ彃妲借嚜瀹氫箟寮瑰嚭閫夋嫨妗� -->
+            <template #[name]="{ field }" v-for="name in item.slots" :key="name">
+              <a-button
+                class="mt-1 ml-1"
+                size="small"
+                @click="handleCustClick(field)"
+                :preIcon="item.preIcons[name]"
+              />
+              <GeneralModal
+                @register="useModalData[name][0]"
+                @success="(d, u) => handleEntSuccess(d, u, item.name)"
+              />
+            </template>
+          </BasicForm>
+          <!-- 鑷畾涔夊唴瀹� -->
+          <!-- <div style="height: 200px" id="lfContainer" v-if="isCustEl[item.name]"></div> -->
+          <div class="h-full" style="height: 380px" v-if="isCustEl[item.name]">
+            <FlowChartView :data="routeData" @init="init" />
+          </div>
+        </template>
+      </CustModal>
+      <!-- <template #fallback> Loading... </template> -->
+    </Suspense>
     <RouteViewModal @register="registerRv" @success="RvItemSuccess" />
   </div>
 </template>
 <script lang="ts" setup>
-  import { reactive, unref, h, onMounted, ref, nextTick } from 'vue';
+  import { reactive, unref, h, onMounted, ref, nextTick, Ref } from 'vue';
+  import { Steps, Step, Layout, LayoutContent } from 'ant-design-vue';
   import { BasicTable, useTable, TableAction } from '/@/components/Table';
-  import { BasicForm, FormSchema, FormActionType, FormProps } from '/@/components/Form/index';
+  import { BasicForm, FormSchema, FormActionType, useForm } from '/@/components/Form/index';
   import WoDrawer from './WoDrawer.vue';
   import WoModal from './WoModal.vue';
-  import NormalModal from '/@/views/components/NormalModal.vue';
+  import GeneralModal from '/@/views/components/GeneralModal.vue';
   import RouteViewModal from '/@/views/components/RouteViewModal.vue';
+  import { FlowChartView } from '/@/components/FlowChart';
   import CustModal from '/@/views/components/CustModal.vue';
   import { useDrawer } from '/@/components/Drawer';
   import { columns, searchFormSchema } from './biz_mes_wo.data';
@@ -109,31 +130,45 @@
   import { useMessage } from '/@/hooks/web/useMessage';
   import { useI18n } from '/@/hooks/web/useI18n';
   import { useModal } from '/@/components/Modal';
-  import { getListByPage } from '/@/api/tigerapi/system';
+  import { SaveEntity, getListByPage } from '/@/api/tigerapi/system';
   import { GetSelectSuccess, OpenSelectItem, getFormSchema } from '/@/views/components/data';
+  import LogicFlow from '@logicflow/core';
+  import { initRoute } from '../../../system/lowcode/data';
+  import BIZ_MES_WO from '../../../system/lowcode/entityts/BIZ_MES_WO';
+  import { useUserStore } from '/@/store/modules/user';
 
   const { t } = useI18n();
+  const ASteps = Steps;
+  const AStep = Step;
   const cType = ref('');
   const title = ref('宸ュ崟瀵煎叆');
-  const ctitle = ref('宸ュ崟涓嬪彂閰嶇疆');
   const mtitle = ref('宸ュ崟鍒楄〃');
   const dtlSlots = ref([] as any[]);
   const selectVals = ref({});
-  const { createMessage } = useMessage();
+  const { createMessage, createErrorModal } = useMessage();
   const [registerDrawer, { openDrawer }] = useDrawer();
   const compState = reactive({
     absolute: false,
     loading: false,
     tip: '鍔犺浇涓�...',
   });
-  const [registerEntity, { openModal: openEntModal }] = useModal();
-  const [registerRv, { openModal: openRvModal }] = useModal();
+  const lfInstance = ref(null) as Ref<LogicFlow | null>;
+  const [registerRv, { openModal: openRvModal, closeModal }] = useModal();
   const [registerWo, { openModal: openWoModal }] = useModal();
   const [registerItemAdd, { openModal: openItemModal }] = useModal();
-  const [registerCust, { openModal: openCustModal, closeModal }] = useModal();
+  const [registerCust, { openModal: openCustModal }] = useModal();
   const [registerTable, { getForm, reload }] = useTable({
     title: '宸ュ崟淇℃伅',
     api: getListByPage,
+    searchInfo: {
+      TABLE_NAME: 'BIZ_MES_WO',
+      option: {
+        //鏍规嵁鎹偣鏌ヨ锛屽繀闇�甯﹁繖涓弬鏁�
+        UserId: useUserStore().getUserInfo.userId,
+        ByOrg: true,
+        CurOrg: useUserStore().getUserInfo.orgCode,
+      },
+    },
     columns,
     formConfig: {
       labelWidth: 120,
@@ -152,12 +187,43 @@
     bordered: true,
     showIndexColumn: false,
   });
+  const routeData = ref({
+    nodes: [],
+    edges: [],
+  });
+  const entityName = ref('BIZ_MES_WO');
   const formSchema = ref([] as FormSchema[]);
-  const woinfo = ref<Nullable<FormActionType>>(null);
-  const forminfo = ref<Nullable<FormActionType>>(null);
-  const prodinfo = ref<Nullable<FormActionType>>(null);
+  const woSchema = ref<FormSchema[]>(getFormSchema('woinfo'));
+  const prodSchema = ref<FormSchema[]>(getFormSchema('prodinfo'));
+  const isCustEl = ref({
+    forminfo: false,
+    woinfo: false,
+    prodinfo: false,
+    rotinfo: true,
+  });
+  //琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶
+  const useModalData = ref({
+    add: useModal(),
+    set: useModal(),
+    addRot: useModal(),
+    setRot: useModal(),
+  });
 
-  onMounted(() => {});
+  /* 鑾峰彇澶氳〃鍗曞疄渚� */
+  const [{ GetUseForm }] = BIZ_MES_WO();
+  const useFormData = ref<any>(GetUseForm());
+
+  onMounted(async () => {});
+
+  const currlf = ref(null) as Ref<LogicFlow | null>;
+  /**
+   * @description: 宸ヨ壓璺嚎鍒濆鍖�
+   * @param {*} lf
+   * @return {*}
+   */
+  async function init(lf, rotId) {
+    initRoute(lf, rotId, routeData, currlf);
+  }
 
   //鏂板
   function addWo() {
@@ -187,58 +253,136 @@
     cType.value = 'BIZ_MES_WO_Config';
     dtlSlots.value = [
       { name: 'woinfo', slots: [], preIcons: {}, title: '宸ュ崟淇℃伅' },
-      { name: 'prodinfo', slots: [], preIcons: {}, title: '浜у搧淇℃伅' },
+      {
+        name: 'prodinfo',
+        slots: ['addRot', 'setRot'],
+        preIcons: { addRot: 'search|svg', setRot: 'config|svg' },
+        title: '浜у搧淇℃伅',
+      },
+      { name: 'rotinfo', slots: ['add'], preIcons: { add: 'search|svg' }, title: '宸ヨ壓淇℃伅' },
     ];
-    formSchema.value = getFormSchema(cType.value);
+    // rotSchema.value = getFormSchema('rotinfo');
+    routeData.value = {
+      nodes: [],
+      edges: [],
+    };
+    initRoute(currlf, record.ROUTE_CODE, routeData, currlf);
+    selectVals.value['ROUTE_CODE'] = record.ROUTE_CODE;
     openCustModal(true, {
       isUpdate: true,
       ctype: cType,
       title: '宸ヨ壓閰嶇疆',
-      width: '1000px',
+      width: '1200px',
+      formEl: useFormData.value, //濡傛灉鏄涓〃鍗曪紝澧炲姞澶氫釜鎻掓Ы
+      formElName: ['woinfo', 'prodinfo', 'rotinfo'], //琛ㄥ崟鎻掓Ы鍚嶇О锛屾敮鎸佸涓〃鍗�
       RowKey: '',
-      formEl: { woinfo: woinfo.value, prodinfo: prodinfo.value }, //濡傛灉鏄涓〃鍗曪紝澧炲姞澶氫釜鎻掓Ы
-      // preIcons: { add: 'search|svg', set: 'config|svg' },
-      // slots: ['add', 'set'], //缁欏脊鍑烘澧炲姞鎻掓Ы鏍囩鏁扮粍
-      ...record,
+      fnName: 'SaveCofig', //淇濆瓨鏂规硶鍚�
+      // initFnName: { BIZ_MES_WO_Config: 'initRoute' }, //鍒濆鍖栨柟娉曞悕
+      // isCustEl: isCustEl.value,
+      others: routeData.value,
+      values: record, //琛ㄥ崟璁板綍
     });
   }
-  //涓嬪彂
+
+  /**
+   * @description: 涓嬪彂
+   * @param {*} record
+   * @return {*}
+   */
   function handleRelease(record: Recordable) {
+    // if (record.STATUS == 2) {
+    //   createErrorModal({
+    //     title: t('璀﹀憡'),
+    //     content: t('宸ュ崟宸茬粡涓嬪彂锛屼笉鑳藉啀涓嬪彂锛�'),
+    //     getContainer: () => document.body,
+    //   });
+    //   return;
+    // }
     cType.value = 'BIZ_MES_WO';
     dtlSlots.value = [
       {
         name: 'forminfo',
         slots: ['add', 'set'],
-        preIcons: { add: 'search|svg', set: 'config|svg' },
+        preIcons: { add: 'search|svg', set: 'config|svg' }, //濡傛灉鏄涓〃鍗曪紝澧炲姞澶氫釜鎻掓Ы銆俿lots鏄脊鍑烘鎸夐挳鐨勬彃妲斤紝preIcons鏄彃妲藉搴旂殑鎸夐挳鍥炬爣
         title: '涓嬪彂閰嶇疆',
       },
-    ]; //濡傛灉鏄涓〃鍗曪紝澧炲姞澶氫釜鎻掓Ы銆俿lots鏄脊鍑烘鎸夐挳鐨勬彃妲斤紝preIcons鏄彃妲藉搴旂殑鎸夐挳鍥炬爣
-    formSchema.value = getFormSchema(cType.value);
-    nextTick(() => {
-      setTimeout(() => {
-        openCustModal(true, {
-          isUpdate: true, //鏄惁鏇存柊鎿嶄綔
-          ctype: cType, //鏄摢涓〉闈�
-          title: '宸ュ崟涓嬪彂', //鏍囬
-          width: '900px', //寮瑰嚭妗嗗搴�
-          formEl: { forminfo: forminfo.value },
-          formElName: 'forminfo',
-          RowKeys: { add: 'ROUTE_CODE', set: 'ROUTE_CODE' }, //鎻掓Ы鐨勫脊鍑烘閫夋嫨鐨刢ode
-          ...record,
-        });
-      }, 100);
-      closeModal();
-      openCustModal(true, {});
+    ];
+    // formSchema.value = getFormSchema(cType.value);
+    openCustModal(true, {
+      isUpdate: true, //鏄惁鏇存柊鎿嶄綔
+      ctype: cType, //鏄摢涓〉闈�
+      title: '宸ュ崟涓嬪彂', //鏍囬
+      width: '900px', //寮瑰嚭妗嗗搴�
+      formEl: useFormData.value,
+      formElName: ['forminfo'], //琛ㄥ崟鎻掓Ы鍚嶇О
+      RowKeys: { add: 'ROUTE_CODE', set: 'ROUTE_CODE' }, //鎻掓Ы鐨勫脊鍑烘閫夋嫨鐨刢ode
+      fnName: 'SaveWoBatch', //淇濆瓨鏂规硶鍚�
+      initFnName: {}, //鍒濆鍖栨柟娉曞悕锛屾病鏈夊氨鐣欑┖{}
+      isCustEl: isCustEl.value,
+      values: record, //琛ㄥ崟璁板綍
     });
   }
-  //鍙栨秷涓嬪彂
-  function handleUnRelease(record: Recordable) {}
+
+  /**
+   * @description: 鍙栨秷涓嬪彂
+   * @param {*} record
+   * @return {*}
+   */
+  function handleUnRelease(record: Recordable) {
+    if (record.STATUS == 0) {
+      createErrorModal({
+        title: t('璀﹀憡'),
+        content: t('宸ュ崟鏄垵濮嬪寲鐘舵�侊紝涓嶈兘鍙栨秷涓嬪彂锛�'),
+        getContainer: () => document.body,
+      });
+      return;
+    }
+    record.STATUS = 0;
+    SaveEntity(record, true, 'BIZ_MES_WO').then((action) => {
+      if (action.IsSuccessed) {
+        createMessage.success(t('宸插彇娑堜笅鍙�'));
+        reload();
+      } else {
+        createMessage.success(t('鍙栨秷涓嬪彂鎿嶄綔澶辫触'));
+      }
+    });
+  }
   //鏆傚仠
-  function handlePause(record: Recordable) {}
-  //鍒犻櫎
+  function handlePause(record: Recordable) {
+    if (record.STATUS == 0) {
+      createErrorModal({
+        title: t('璀﹀憡'),
+        content: t('宸ュ崟鏄垵濮嬪寲鐘舵�侊紝涓嶈兘鏆傚仠锛�'),
+        getContainer: () => document.body,
+      });
+      return;
+    }
+    if (record.STATUS == 5) {
+      createErrorModal({
+        title: t('璀﹀憡'),
+        content: t('宸ュ崟鏄畬鎴愮姸鎬侊紝涓嶈兘鏆傚仠锛�'),
+        getContainer: () => document.body,
+      });
+      return;
+    }
+    record.STATUS = 4;
+    SaveEntity(record, true, 'BIZ_MES_WO').then((action) => {
+      if (action.IsSuccessed) {
+        createMessage.success(t('宸叉殏鍋�'));
+        reload();
+      } else {
+        createMessage.success(t('鏆傚仠鎿嶄綔澶辫触'));
+      }
+    });
+  }
+
+  /**
+   * @description: 鍒犻櫎
+   * @param {*} record
+   * @return {*}
+   */
   function handleDelete(record: Recordable) {
-    const apiAction = DeleteMesWo(record.ID);
-    apiAction.then((action) => {
+    DeleteMesWo(record.ID).then((action) => {
       if (action.IsSuccessed) {
         createMessage.success(t('宸插垹闄�'));
         reload();
@@ -247,7 +391,20 @@
       }
     });
   }
-  //鐐瑰嚮鎵撳紑鐗╂枡鍒楄〃妗�
+
+  /**
+   * @description: 寮瑰嚭妗嗙‘瀹氳繑鍥�
+   * @param {*} d
+   * @return {*}
+   */
+  function custSuccess(d) {
+    reload();
+  }
+
+  /**
+   * @description: 鐐瑰嚮鎵撳紑鐗╂枡鍒楄〃妗�
+   * @return {*}
+   */
   function handleSelectItem() {
     openItemModal(true, {
       title: '鐗╂枡鍒楄〃',
@@ -279,35 +436,66 @@
       ],
       tableName: 'BAS_ITEM',
       rowKey: 'ITEM_CODE',
+      searchInfo: { TABLE_NAME: 'BAS_ITEM' },
     });
   }
 
+  /**
+   * @description: 寮瑰嚭閫夋嫨鐗╂枡妗嗚繑鍥炴垚鍔熸柟娉�
+   * @param {*} d
+   * @param {*} u
+   * @return {*}
+   */
   function handleItemSuccess(d, u) {
     getForm().setFieldsValue({
       ITEM_CODE: d.values['val'],
     });
   }
-  /* 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庝簨浠� */
+
+  /**
+   * @description: 鍚勮〃鍗曞唴寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庢柟娉�
+   * @param {*} d
+   * @param {*} u
+   * @param {*} item
+   * @return {*}
+   */
   function handleEntSuccess(d, u, item) {
     var values = GetSelectSuccess(d, u, cType.value);
     selectVals.value = values; //淇濆瓨寮瑰嚭妗嗛�夋嫨鐨勭粨鏋�
     let _val = {};
-    _val[d.returnFieldName] = values[d.returnFieldName];
-    if (item == 'forminfo') {
-      forminfo.value.setFieldsValue(_val);
-    }
-    if (item == 'prodinfo') {
-      prodinfo.value.setFieldsValue(_val);
-    }
-    if (item == 'woinfo') {
-      woinfo.value.setFieldsValue(_val);
+    d.returnFieldName.map((x) => {
+          _val[x] = values[x];
+        });
+    useFormData.value[item][1].setFieldsValue(_val);
+    if (d.returnFieldName == 'ROUTE_CODE' && cType.value == 'BIZ_MES_WO_Config') {
+      routeData.value = {
+        nodes: [],
+        edges: [],
+      };
+
+      init(currlf, selectVals.value['ROUTE_CODE']);
+      const { transformModel, width, height } = unref(currlf).graphModel;
+      transformModel.focusOn(300, 200, width, height);
     }
   }
 
-  /* 寮瑰嚭閫夋嫨妗� */
+  /**
+   * @description: 寮瑰嚭閫夋嫨妗�
+   * @param {*} item
+   * @return {*}
+   */
   function handleCustClick(item) {
-    // openRvModal(true, {});
-    OpenSelectItem(openEntModal, cType.value, item, [openRvModal], selectVals.value['ID']);
+    //鎵撳紑鑷畾涔夋ā鎬佹
+    OpenSelectItem(
+      useModalData.value[item][1].openModal, //甯﹀叆openModal鏂规硶
+      cType.value,
+      item,
+      [openRvModal],
+      selectVals.value['ROUTE_CODE'],
+    ); //[openRvModal], selectVals.value['ID']杩欐槸鑷畾涔夊弬鏁帮紝鎸夊疄闄呴渶姹�
   }
-  function RvItemSuccess(d, u) {}
+
+  function RvItemSuccess(d, u) {
+    closeModal();
+  }
 </script>

--
Gitblit v1.9.3