From de7e6c408b6209158b08991d729c4bcc72055eec Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期四, 20 六月 2024 00:30:52 +0800
Subject: [PATCH] 产品工艺路线

---
 src/views/tigerprojects/system/lowcode/composition/index.vue |  268 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 229 insertions(+), 39 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/composition/index.vue b/src/views/tigerprojects/system/lowcode/composition/index.vue
index 0b30ee7..079bbf6 100644
--- a/src/views/tigerprojects/system/lowcode/composition/index.vue
+++ b/src/views/tigerprojects/system/lowcode/composition/index.vue
@@ -1,49 +1,106 @@
 <template>
-  <div>
-    <BasicTable @register="registerTable">
+  <PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
+    <CustTree
+      class="w-1/4 xl:w-1/5"
+      @select="handleSelect"
+      :title="title"
+      :treeData="treeData"
+      :create-icon="createIcon"
+      :fieldNames="fieldNames"
+    /><!--
+      add
+      @handle-add="handleAdd" -->
+    <BasicTable class="w-3/4 xl:w-4/5" @register="registerTable">
       <template #toolbar>
-        <a-button type="primary" @click="handleCreate"> 鏂板閮ㄩ棬 </a-button>
+        <a-button type="primary" @click="handleCreate" preIcon="add_02|svg"> 鏂板 </a-button>
       </template>
       <template #bodyCell="{ column, record }">
         <template v-if="column.key === 'action'">
-          <TableAction
-            :actions="[
-              {
-                icon: 'clarity:note-edit-line',
-                onClick: handleEdit.bind(null, record),
-              },
-              {
-                icon: 'ant-design:delete-outlined',
-                color: 'error',
-                popConfirm: {
-                  title: '鏄惁纭鍒犻櫎',
-                  placement: 'left',
-                  confirm: handleDelete.bind(null, record),
-                },
-              },
-            ]"
-          />
+          <TableAction :actions="createActions(record)" />
         </template>
       </template>
     </BasicTable>
-    <DeptModal @register="registerModal" @success="handleSuccess" />
-  </div>
+    <normalDrawer @register="registerDrawer" @success="handleSuccess" />
+    <CustModal
+      @register="registerCust"
+      @success="custSuccess"
+      :type="cType"
+      :detailSlots="dtlSlots"
+    >
+      <!-- 鐢ㄦ彃妲借嚜瀹氫箟澶氳〃鍗� -->
+      <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]"
+            />
+            <NormalModal
+              @register="useModalData[name][0]"
+              @success="(d, u) => handleEntSuccess(d, u, item.name)"
+            />
+          </template>
+        </BasicForm>
+        <!-- 鑷畾涔夊唴瀹� -->
+      </template>
+    </CustModal>
+  </PageWrapper>
 </template>
 <script lang="ts" setup>
   import { BasicTable, useTable, TableAction } from '@/components/Table';
-  import { getDeptList } from '@/api/demo/system';
-
+  import { getEntity, getRoleListByPage, convertToTree } from '@/api/tigerapi/system';
+  import { PageWrapper } from '@/components/Page';
+  import CustTree from './CustTree.vue';
   import { useModal } from '@/components/Modal';
-  import DeptModal from './DeptModal.vue';
-
+  import normalDrawer from '../normalDrawer.vue';
+  import NormalModal from '/@/views/components/NormalModal.vue';
+  import CustModal from '/@/views/components/CustModal.vue';
   import { columns, searchFormSchema } from './dept.data';
+  import {
+    GetActionsData,
+    GetSelectSuccess,
+    OpenCustModal,
+    fetchTreeData,
+    getFormSchema,
+    getOthersValues,
+  } from '../data';
+  import { onMounted, reactive, ref } from 'vue';
+  import { useRoute } from 'vue-router';
+  import { useDrawer } from '/@/components/Drawer';
+  import { BasicForm, useForm } from '/@/components/Form/index';
+  import { TreeItem } from '/@/components/TigerTree';
+  import { createIconByType } from '../data';
+import { RouteToProd } from '/@/api/tigerapi/mes/router';
 
   defineOptions({ name: 'DeptManagement' });
 
-  const [registerModal, { openModal }] = useModal();
+  const route = useRoute();
+  const objParams = ref(JSON.parse(decodeURI(route.params?.id as string)));
+  const entityName = ref(objParams.value.Name);
+  const formSchemas = ref({}); //寮瑰嚭妗嗘垨楂樼骇椤甸潰澶氳〃鍗曠粨鏋�
+  const useModalData = ref({}); //琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶
+  const useFormData = ref({});
+  const colSlots = ref<any>(objParams.value.colSlots); //鎸夐挳鎻掓Ы
+  const crudColSlots = ref<any>(objParams.value.crudColSlots);
+  const cType = ref('');
+  const dtlSlots = ref([] as any[]);
+  const selectVals = ref({});
+  const baseCards = ref([] as any[]);
+  const otherCards = ref([] as any[]);
+  const searchInfo = reactive<Recordable>({});
+  const treeData = ref<TreeItem[]>([]);
+  const title = ref('');
+  const fieldNames = ref({});
+  const others = ref(getOthersValues(entityName.value, objParams.value.CODE, objParams.value.ID));
+  const [registerCust, { openModal: openCustomModal, closeModal }] = useModal();
+  const [registerItemAdd, { openModal: openItemModal }] = useModal();
+  const [registerDrawer, { openDrawer }] = useDrawer();
   const [registerTable, { reload }] = useTable({
-    title: '閮ㄩ棬鍒楄〃',
-    api: getDeptList,
+    title: '鍒楄〃淇℃伅',
+    api: getRoleListByPage,
     columns,
     formConfig: {
       labelWidth: 120,
@@ -65,24 +122,157 @@
     },
   });
 
+  /**
+   * @description: 鑾峰彇鏍戝舰鏁版嵁
+   * @param {*} type
+   * @return {*}
+   */ 
+  async function fetch(type: string) {
+    //鏍规嵁type鑾峰彇鏍戝舰鏁版嵁
+    const data = await fetchTreeData(type);
+    title.value = data.title;
+    treeData.value = data.treeData;
+    fieldNames.value = data.fieldNames;
+  }
+
+  // function handleAdd(){
+  //   console.log('handleAdd');
+  // }
+
+  /**
+   * @description: 鏍戝舰鑺傜偣鍥炬爣
+   * @param {*} params
+   * @param {*} type
+   * @return {*}
+   */  
+  function createIcon(params: Recordable<any>) {
+    return createIconByType(params, entityName.value);
+  }
+
+  onMounted(() => {
+    fetch(entityName.value);
+  });
+
+  /**
+   * @description: 鐢熸垚鍒楄〃涓搷浣滈」鐨勬寜閽�
+   * @param {*} record
+   * @return {*}
+   */
+  function createActions(record) {
+    return GetActionsData(
+      {
+        record,
+        isUpdate: true,
+        ifSave: true,
+        entityName: entityName.value,
+        formJson: getFormSchema(`${entityName.value}_Crud`),
+        cType,
+        dtlSlots,
+        useModalData,
+        useFormData,
+        crudColSlots,
+      },
+      openDrawer,
+      reload,
+      openCustomModal,
+      useForm,
+      useModal,
+    );
+  }
+
+  /**
+   * @description: 楠岃瘉琛ㄥ崟
+   * @return {*}
+   */
+  async function validate() {
+    let validates = {};
+    const Keys = Object.getOwnPropertyNames(useFormData.value);
+    let i;
+    for (i = 0; i < Keys.length; i++) {
+      validates[Keys[i]] = await useFormData.value[Keys[i]][1].validate();
+    }
+    return validates;
+  }
+
   function handleCreate() {
-    openModal(true, {
-      isUpdate: false,
+    // validate().then((res) => {
+    //   const Keys = Object.getOwnPropertyNames(useFormData.value);
+    //   let i;
+    //   for (i = 0; i < Keys.length; i++) {
+    //     others.value[objParams.value.pCode] = objParams.value.IsID
+    //       ? res[Keys[i]]['ID']
+    //       : res[Keys[i]][objParams.value.pCode];
+    //   }
+    //   openDrawer(true, {
+    //     isUpdate: false,
+    //     ifSave: true,
+    //     entityName: entityName.value,
+    //     formJson: getFormSchema(`${entityName.value}_Crud`),
+    //     crudColSlots,
+    //     others: others.value,
+    //   });
+    // });
+    RouteToProd({rotId: 'e4712192f75b465585107fdcd13d8003', prodCode: 'K5019AA013517'}).then(() => {
+
     });
   }
 
-  function handleEdit(record: Recordable) {
-    openModal(true, {
-      record,
-      isUpdate: true,
-    });
-  }
+  // function handleEdit(record: Recordable) {
+  //   openModal(true, {
+  //     record,
+  //     isUpdate: true,
+  //   });
+  // }
 
-  function handleDelete(record: Recordable) {
-    console.log(record);
+  // function handleDelete(record: Recordable) {
+  //   console.log(record);
+  // }
+
+  function handleSelect(deptId = '') {
+    searchInfo.deptId = deptId;
+    reload();
   }
 
   function handleSuccess() {
     reload();
   }
+
+  /**
+   * @description: 寮瑰嚭妗嗙‘瀹氳繑鍥�
+   * @param {*} d
+   * @return {*}
+   */
+  function custSuccess(d) {
+    reload();
+  }
+
+  /**
+   * @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];
+    useFormData.value[item][1].setFieldsValue(_val);
+  }
+
+  /**
+   * @description: 鎵撳紑鑷畾涔夋ā鎬佹
+   * @param {*} item
+   * @return {*}
+   */
+  function handleCustClick(item) {
+    OpenCustModal(
+      useModalData.value[item][1].openModal, //甯﹀叆openModal鏂规硶
+      cType.value,
+      item,
+      [],
+      // selectVals.value['ROUTE_CODE'],
+    ); //[openRvModal], selectVals.value['ID']杩欐槸鑷畾涔夊弬鏁帮紝鎸夊疄闄呴渶姹�
+  }
 </script>

--
Gitblit v1.9.3