From cf2389121671bc8d09f32175acae80b074e21fc3 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期四, 10 十月 2024 01:23:08 +0800
Subject: [PATCH] 一些更改

---
 src/views/tigerprojects/system/lowcode/composition/CarGridNav.vue |  258 ++++++++++++++++++++++++++++++---------------------
 1 files changed, 152 insertions(+), 106 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/composition/CarGridNav.vue b/src/views/tigerprojects/system/lowcode/composition/CarGridNav.vue
index d59402e..f3daf6c 100644
--- a/src/views/tigerprojects/system/lowcode/composition/CarGridNav.vue
+++ b/src/views/tigerprojects/system/lowcode/composition/CarGridNav.vue
@@ -1,138 +1,184 @@
 <!--
- * @Description: 宸ヨ壓璺嚎娣诲姞椤甸潰
+ * @Description: 瀵艰埅椤甸潰
  * @Author: Ben Lin
  * @version: 
  * @Date: 2024-06-20 12:13:27
  * @LastEditors: Ben Lin
- * @LastEditTime: 2024-06-26 16:00:06
+ * @LastEditTime: 2024-10-07 16:52:03
 -->
 <template>
-  <Card title="娣诲姞宸ヨ壓">
-    <CardGrid v-for="item in navItems" :key="item.title" @click="changeItem(item.action)">
-      <span class="flex flex-col items-center">
+  <Card :title="GetTitle(props.configType)['navTitle']">
+    <CardGrid
+      v-for="item in GetNavItems(props.configType)"
+      :key="item.title"
+      @click="
+        navChangeItem(
+          item.action,
+          !item.isCustEl ? useModalData[item.action][1].openModal : null,
+          openRvModal,
+          selectedNodes,
+          keyCode,
+        )
+      "
+    >
+      <Form class="properties-body" label-align="left" layout="vertical" v-if="item.isCustEl">
+        <FormItem label="鏄惁榛樿" name="鏄惁榛樿">
+          <Switch
+            v-model:checked="isDefault[selectedNodes[0]['code']]"
+            @change="(e) => switchChange(e, selectedNodes[0])"
+          />
+        </FormItem>
+      </Form>
+      <span v-if="!item.isCustEl" class="flex flex-col items-center">
         <Icon :icon="item.icon" :color="item.color" size="20" />
         <span class="text-md mt-2 truncate">{{ item.title }}</span>
       </span>
+      <GeneralModal
+        v-if="!item.isStep && !item.isCustEl"
+        @register="useModalData[item.action][0]"
+        @success="(d, u) => handleSuccess(d, u, item.action, objParams, refreshPage)"
+      ></GeneralModal>
+      <StepModal
+        v-if="item.isStep"
+        @register="useModalData[item.action][0]"
+        @success="(d, u) => handleSuccess(d, u, item.action, objParams, refreshPage)"
+      />
     </CardGrid>
   </Card>
-  <GeneralModal @register="register" @success="handleSuccess"></GeneralModal>
+  <!-- 鍏朵粬鑷畾涔夊崱鐗囧唴瀹� -->
+  <a-card
+    :title="item.title"
+    :bordered="false"
+    class="!mt-2"
+    v-for="(item, index) in otherSlots"
+    :key="item.name"
+  >
+    <slot :name="item.name" :index="index"></slot>
+  </a-card>
+  <RouteViewModal @register="registerRv" @success="RvItemSuccess" />
 </template>
 <script lang="ts" setup>
-  import { Card, CardGrid } from 'ant-design-vue';
+  import { Card, CardGrid, Switch, Form, FormItem } from 'ant-design-vue';
   import Icon from '@/components/Icon/Icon.vue';
-  import { RouteToCust, RouteToProd } from '/@/api/tigerapi/mes/router';
   import GeneralModal from '/@/views/components/GeneralModal.vue';
-  import { useModal } from '/@/components/Modal';
-  import { useI18n } from '/@/hooks/web/useI18n';
-  import { Ref, inject, ref, watch } from 'vue';
-  import { isNullOrEmpty } from '/@/utils/is';
+  import RouteViewModal from '/@/views/components/RouteViewModal.vue';
+  import StepModal from '/@/views/components/StepModal.vue';
+  import { Ref, inject, nextTick, onMounted, ref, watch } from 'vue';
+  import { isNullOrUnDef } from '/@/utils/is';
   import { useTabs } from '/@/hooks/web/useTabs';
-  import { useMessage } from '/@/hooks/web/useMessage';
+  import { EntityCustFunctionType } from '/@/api/tigerapi/model/basModel';
+  import { useModal } from '/@/components/Modal';
+  import { CustModalParams } from '/@/api/tigerapi/model/systemModel';
 
+  const ACard = Card;
   const objParams = inject('objParams') as Ref<any>;
-  const custImport = ref<any[]>(await import(`../entityts/${objParams.value['Name']}.ts`));
-  const [{ EditeOperation, GetBaseColumns, GetSearchForm, GetCrudForm, OthersValues }] =
-    custImport.value['default']();
+  const selectedNodes = inject('selectedNodes') as Ref<any>;
+  const props = defineProps({
+    configType: { type: String },
+    nodes: { type: Array as PropType<any[]> },
+  });
+  const keyCode = ref(objParams.value['CODE']);
+  const isDefault = ref({});
+  isDefault[selectedNodes.value[0]['code']] = false;
+  const custImport = ref<any[]>([]);
+  const EntityCustFunction = ref([
+    {
+      GetTitle(type: string | undefined) {},
+      GetNavItems(type: string) {},
+      navChangeItem(action: any, ...args) {},
+      GetUseModals() {},
+      GetBaseCards(type: string | undefined) {},
+      GetSelectSuccess(d, u, ...args) {},
+      GenerateHtml(ype: string | null) {},
+      CustFunc(param: CustModalParams) {},
+    } as EntityCustFunctionType,
+  ]);
+  /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */
+  try {
+    custImport.value = await import(`../entityts/${objParams.value['Name']}.ts`);
+  } catch (e) {}
+  const [
+    {
+      GetTitle,
+      GetNavItems,
+      navChangeItem,
+      GetUseModals,
+      GetSelectSuccess,
+      GetBaseCards,
+      GenerateHtml,
+      CustFunc,
+    },
+  ] = isNullOrUnDef(custImport.value['default'])
+    ? EntityCustFunction.value
+    : custImport.value['default']();
+
+  const useModalData = ref(GetUseModals());
+  const otherSlots = ref<any[]>(GetBaseCards(props.configType));
   const { refreshPage } = useTabs();
-  const { createErrorModal } = useMessage();
-  const { t } = useI18n();
-  const [register, { openModal }] = useModal();
-  interface NavItem {
-    title: string;
-    icon: string;
-    color: string;
-    url: string;
-    action: string;
-  }
+  const [registerRv, { openModal: openRvModal }] = useModal();
 
-  // watch(
-  //   () => Prod_Code,
-  //   (v) => {
-  //     if (v !== Prod_Code.value) {
-  //       Prod_Code.value = isNullOrEmpty(v) ? Prod_Code.value : v;
-  //     }
-  //   },
-  //   { deep: true },
-  // );
+  watch(
+    [() => props.configType, () => props.nodes],
+    (v) => {
+      otherSlots.value = GetBaseCards(v[0]);
+      nextTick(() => {
+        // var div = document.getElementById('container') as HTMLElement;
+        // div.innerHTML = '';
+        // div.appendChild(GenerateHtml(v[0]));
+        // setTimeout(() => {
+        //   if (!isNullOrUnDef(v[1])) {
+        //     CustFunc(v[0], v[1][0]['id'], '#lfContainer');
+        //   }
+        // }, 100);
+      });
+    },
+    { deep: true },
+  );
 
-  // 蹇嵎瀵艰埅
-  const navItems: NavItem[] = [
-    {
-      title: '娣诲姞浜у搧宸ヨ壓璺嚎',
-      icon: 'add_green|svg',
-      color: '#1fdaca',
-      url: '/addRoute',
-      action: 'addRoute',
-    },
-    {
-      title: '娣诲姞瀹㈡埛宸ヨ壓璺嚎',
-      icon: 'add_customer|svg',
-      color: '#bf0c2c',
-      url: '/addCustomer',
-      action: 'addCustomer',
-    },
-  ];
-  function changeItem(action) {
-    openModal(true, {
-      title: '宸ヨ壓璺嚎鍒楄〃',
-      schemas: [
-        {
-          field: 'ROT_CODE',
-          component: 'Input',
-          label: '宸ヨ壓璺嚎缂栫爜',
-          colProps: {
-            span: 12,
-          },
-        },
-      ],
-      ItemColumns: [
-        {
-          title: t('宸ヨ壓璺嚎缂栫爜'),
-          dataIndex: 'ROT_CODE',
-          resizable: true,
-          sorter: true,
-          width: 200,
-        },
-        {
-          title: t('宸ヨ壓璺嚎鍚嶇О'),
-          dataIndex: 'ROT_NAME',
-          resizable: true,
-          sorter: true,
-          width: 180,
-        },
-      ],
-      tableName: 'MES_ROUTE',
-      rowKey: 'ROT_CODE',
-      returnFieldName: 'ROUTE_CODE', //杩斿洖鍊艰璧嬪�肩殑瀛楁鍚嶇О
-      searchInfo: { TABLE_NAME: 'MES_ROUTE' },
-      which: action,
+  onMounted(() => {
+    nextTick(() => {
+      //   var div = document.getElementById('container') as HTMLElement;
+      //   if (!isNullOrUnDef(div)) {
+      //     div.innerHTML = '';
+      //     div.appendChild(GenerateHtml(props.configType));
+      //     setTimeout(() => {
+      //       if (!isNullOrUnDef(props.nodes) && props.nodes.length > 0) {
+      //         CustFunc(props.configType, props.nodes[0]['id'], '#lfContainer');
+      //       }
+      //     }, 100);
+      //   }
     });
-  }
+  });
 
   /**
-   * @description: 閫夋嫨宸ヨ壓璺嚎鎴愬姛杩斿洖鏂规硶
+   * @description: 寮瑰嚭閫夋嫨妗嗘垚鍔熻繑鍥炴柟娉�
    * @param {*} d
    * @param {*} u
    * @return {*}
    */
-  async function handleSuccess(d, u) {
-    if (isNullOrEmpty(objParams.value['CODE'])) {
-      createErrorModal({
-        title: t('sys.api.errorTip'),
-        content: '浜у搧涓虹┖锛屼笉鑳芥坊鍔犲伐鑹鸿矾绾匡紝璇风偣鍑诲乏渚ч�夋嫨浜у搧',
-      });
-      return;
-    }
-    let codes = d.values.id.split(',');
-    var i;
-    for (i = 0; i < codes.length; i++) {
-      if (d.which == 'addRoute') {
-        await RouteToProd({ rotId: codes[i], prodCode: objParams.value['CODE'] });
-      } else {
-        await RouteToCust({ rotId: codes[i], prodCode: objParams.value['CODE'], custCode: '' });
-      }
-    }
+  async function handleSuccess(d, u, item, objParams, refreshPage) {
+    GetSelectSuccess(d, u, item, objParams, refreshPage);
+  }
 
-    await refreshPage();
+  function RvItemSuccess(d, u) {}
+
+  /**
+   * @description: 寮�鍏虫敼鍙樹簨浠�
+   * @param {*} d
+   * @return {*}
+   */
+  function switchChange(e, d) {
+    CustFunc({
+      ctype: 'isDefault',
+      others: { ...d, ...{ isDefault: e } },
+      keyCode: keyCode.value,
+    }).then((res) => {
+      console.log(res,isDefault);
+      if(res.IsSuccessed){
+        if(e){
+          
+        }
+      }
+    });
   }
 </script>

--
Gitblit v1.9.3