From 3d2c48733b86a03fc2e5a1f12ac3667ab0863b80 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期五, 08 十一月 2024 01:03:56 +0800
Subject: [PATCH] 标签模板,主页,默认工艺路线更新

---
 src/views/tigerprojects/system/lowcode/high/edit/editdtl.vue |  219 +++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 157 insertions(+), 62 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/high/edit/editdtl.vue b/src/views/tigerprojects/system/lowcode/high/edit/editdtl.vue
index ff9bca1..7f9a844 100644
--- a/src/views/tigerprojects/system/lowcode/high/edit/editdtl.vue
+++ b/src/views/tigerprojects/system/lowcode/high/edit/editdtl.vue
@@ -15,6 +15,7 @@
         @edit-end="
           ({ record, index, key, value }) => handleEditEnd({ record, index, key, value }, item.name)
         "
+        @edit-change="onEditChange"
       >
         <template #toolbar>
           <a-button
@@ -27,7 +28,7 @@
           >
             {{ d['FUNC_NAME'] }}
           </a-button>
-          <a-button v-if="item.showTbButton" @click="openImg" type="primary"> 棰勮 </a-button>
+          <!-- <a-button v-if="item.showTbButton" @click="openImg" type="primary"> 棰勮 </a-button> -->
         </template>
         <template #action="{ record }">
           <TableAction :actions="createActions(record, index, item)" />
@@ -54,25 +55,24 @@
   </div>
 </template>
 <script lang="ts" setup>
-  import { Ref, inject, onMounted, ref, watch } from 'vue';
-  import { BasicTable, TableAction } from '/@/components/Table';
-  import { useForm } from '/@/components/Form/index';
+  import { Ref, inject, onMounted, ref, unref, watch } from 'vue';
+  import { BasicTable, EditRecordRow, TableAction } from '/@/components/Table';
   import GeneralModal from '/@/views/components/GeneralModal.vue';
   import normalDrawer from '../../normalDrawer.vue';
   import { isFunction, isNullOrEmpty, isNullOrUnDef } from '/@/utils/is';
   import { useModal } from '/@/components/Modal';
   import { useGo } from '/@/hooks/web/usePage';
-  import { DeleteEntity, getEntity } from '/@/api/tigerapi/system';
+  import { DeleteEntity, getEntity, SaveEntity } from '/@/api/tigerapi/system';
   import { useI18n } from '/@/hooks/web/useI18n';
   import { Card } from 'ant-design-vue';
   import { EntityCustFunctionType } from '/@/api/tigerapi/model/basModel';
   import { useRouter } from 'vue-router';
   import { getRoleButtons } from '/@/api/sys/menu';
-  import { GenerateActionButton } from '../../data';
   import { CustModalParams } from '/@/api/tigerapi/model/systemModel';
   import { useWebSocketStore } from '/@/store/modules/websocket';
   import { useTabs } from '/@/hooks/web/useTabs';
-  import { createImgPreview } from '/@/components/Preview';
+  import { cloneDeep } from 'lodash-es';
+  import { useMessage } from '/@/hooks/web/useMessage';
 
   const { t } = useI18n();
   const ACard = Card;
@@ -89,28 +89,29 @@
   const _useTables = inject('useTables') as Ref<any>;
   const useFormData = inject('useFormData') as Ref<{}>;
   const keyFieldValues = inject('keyFieldValues') as Ref<Recordable[]>;
+  const others = ref({});
+  const ctype = ref('');
+  const { createMessage: msg } = useMessage();
 
   const go = useGo();
   const { currentRoute } = useRouter();
   const [registerItemAdd, { openModal: openItemModal }] = useModal();
-  const cType = ref('');
-  const dtlSlots = ref([] as any[]);
-  const useModalData = ref({}); //琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶
+  const currentEditKeyRef = ref('');
   const custImport = ref<any[]>([]);
   const EntityCustFunction = ref([
     {
-      ActionItem(params, data, ...args) {},
-      EditOperation(data, d, u, item) {},
-      GetCrudForm(type: string | undefined, ...args) {},
-      KeyFieldValues(val, id) {},
-      GetTitle(type: string | undefined) {},
-      GetUseTables(data: Ref<Recordable[]>, ...args) {},
+      ActionItem() {},
+      EditOperation() {},
+      GetCrudForm() {},
+      KeyFieldValues() {},
+      GetTitle() {},
+      GetUseTables() {},
       GetUseDrawers() {},
-      CustInitData(data: Ref<any[]>, keyFieldValues: Ref<{}>, type: string) {},
-      GetNewRow(type: string) {},
-      CreateAction(type: string, ...args) {},
-      CustEditEnd({ record, index, key, value }: Recordable, type, ...args) {},
-    } as EntityCustFunctionType,
+      CustInitData() {},
+      GetNewRow() {},
+      CreateAction() {},
+      CustEditEnd() {},
+    } as unknown as EntityCustFunctionType,
   ]);
   /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */
   try {
@@ -118,7 +119,6 @@
   } catch (e) {}
   const [
     {
-      ActionItem: nActionItem,
       EditOperation,
       GetCrudForm,
       KeyFieldValues,
@@ -213,13 +213,6 @@
   }
 
   const imgList = ['http://localhost:8800/files/Template/10浣嶆壒娆℃潯鐮�.png'];
-  function openImg() {
-    const onImgLoad = ({ index, url, dom }) => {
-      console.log(`绗�${index + 1}寮犲浘鐗囧凡鍔犺浇锛孶RL涓猴細${url}`, dom);
-    };
-    // 鍙互浣跨敤createImgPreview杩斿洖鐨� PreviewActions 鏉ユ帶鍒堕瑙堥�昏緫锛屽疄鐜扮被浼煎够鐏墖銆佽嚜鍔ㄦ棆杞箣绫荤殑楠氭搷浣�
-    createImgPreview({ imageList: imgList, defaultWidth: 700, rememberState: true, onImgLoad });
-  }
 
   /**
    * @description: 鐢熸垚鍒楄〃涓搷浣滈」鐨勬寜閽�
@@ -227,40 +220,45 @@
    * @return {*}
    */
   function createActions(record, index, item) {
-    const params = {
-      record,
-      isUpdate: true,
-      ifSave: objParams.value['ifSave'],
-      entityName: props.entityName,
-      formJson: [], //getFormSchema(`${entityName.value}_Crud`),
-      cType,
-      dtlSlots,
-      useModalData,
-      useFormData,
-      crudColSlots: props.crudColSlots,
-      data,
-      name: item.name, //drawers鍒楄〃閲岄潰鐨刵ame锛岃〃绀烘槸鍝竴涓疄浣擄紝涔熷氨鏄珮绾ц〃鍗曚腑琛ㄦ牸鐨勫悕瀛�
-      keyName: item.keyName,
-    };
-    const actionItem = GenerateActionButton(
-      params,
-      buttons,
-      useDrawers[index][item.name][1].openDrawer,
-      useTables[item.name][1].reload(),
-    );
-    if (isNullOrUnDef(custImport.value)) {
-      return actionItem;
+    if (!record.editable) {
+      const values = useFormData.value['BaseForm'][1].getFieldsValue();
+      const type = values['TEMP_TYPE'];
+      return [
+        {
+          label: '缂栬緫',
+          disabled: currentEditKeyRef.value ? currentEditKeyRef.value !== record.key : false,
+          onClick: handleEdit.bind(null, record),
+          name: '',
+        },
+        {
+          label: '鍒犻櫎',
+          color: 'error',
+          disabled:
+            type == 0
+              ? true
+              : currentEditKeyRef.value
+                ? currentEditKeyRef.value !== record.key
+                : false,
+          onClick: handleDel.bind(null, record, index, item),
+          name: '',
+        },
+      ];
     }
-    return nActionItem(
-      params,
-      actionItem,
-      useDrawers[index][item.name][1].openDrawer,
-      useTables,
-      null,
-      useForm,
-      useModal,
-      go,
-    );
+    return [
+      {
+        label: '淇濆瓨',
+        onClick: handleSave.bind(null, record, index, item),
+        name: '',
+      },
+      {
+        label: '鍙栨秷',
+        popConfirm: {
+          title: '鏄惁鍙栨秷缂栬緫',
+          confirm: handleCancel.bind(null, record, index, item),
+        },
+        name: '',
+      },
+    ];
   }
 
   /**
@@ -495,4 +493,101 @@
     console.log('鍗曞厓鏍兼暟鎹鍦ㄥ噯澶囨彁浜�', { record, index, key, value });
     return true;
   }
+
+  /**
+   * @description: 缂栬緫鏀瑰彉鏃朵簨浠�
+   * @param {*} column
+   * @param {*} value
+   * @param {*} record
+   * @return {*}
+   */
+  function onEditChange({ column, value, record }) {
+    // 鏈緥
+    if (column.dataIndex === 'id') {
+      record.editValueRefs.name4.value = `${value}`;
+    }
+    console.log(column, value, record);
+  }
+
+  /**
+   * @description: 缂栬緫琛�
+   * @param {*} record
+   * @return {*}
+   */
+  function handleEdit(record: EditRecordRow) {
+    currentEditKeyRef.value = record.key;
+    record.onEdit?.(true);
+  }
+
+  /**
+   * @description: 鍒犻櫎琛�
+   * @param {*} record
+   * @return {*}
+   */
+  function handleDel(record: EditRecordRow, index, item) {
+    data.value[item.name] = data.value[item.name].filter((q) => q.ID != record.ID);
+    useTables[item.name][1].setProps({
+      dataSource: [],
+    });
+    useTables[item.name][1].setProps({
+      dataSource: data.value[item.name],
+    });
+    useTables[item.name][1].reload();
+    // setData();
+  }
+
+  /**
+   * @description: 鍙栨秷缂栬緫
+   * @param {*} record
+   * @return {*}
+   */
+  function handleCancel(record: EditRecordRow, index, item) {
+    currentEditKeyRef.value = '';
+    record.onEdit?.(false, false);
+  }
+
+  /**
+   * @description: 淇濆瓨鎿嶄綔
+   * @param {*} record
+   * @return {*}
+   */
+  async function handleSave(record: EditRecordRow, index, item) {
+    // 鏍¢獙
+    msg.loading({ content: '姝e湪淇濆瓨...', duration: 0, key: 'saving' });
+    const valid = await record.onValid?.();
+    if (valid) {
+      try {
+        const _data = cloneDeep(record.editValueRefs);
+        console.log(_data);
+        //TODO 姝ゅ灏嗘暟鎹彁浜ょ粰鏈嶅姟鍣ㄤ繚瀛�
+        if (CustFunc && isFunction(CustFunc)) {
+          CustFunc({
+            others: others.value,
+            cType: item.name,
+            values: record,
+            data: data,
+            FnName: 'SaveRow',
+          });
+        } else {
+          /* 榛樿淇濆瓨鏂规硶 */
+          const action = await SaveEntity(
+            record,
+            true,
+            item.name, //瀹炰綋鍚�
+            // `${isExistSql.value}='${values[isExistSql.value]}'`,
+          );
+        }
+        // 淇濆瓨涔嬪悗鎻愪氦缂栬緫鐘舵��
+        const pass = await record.onEdit?.(false, true);
+        if (pass) {
+          currentEditKeyRef.value = '';
+        }
+        msg.success({ content: t('鏁版嵁宸叉殏瀛橈紝瑕佹渶缁堜繚瀛樺埌鏁版嵁搴撹鎻愪氦'), key: 'saving' });
+      } catch (error) {
+        msg.error({ content: t('淇濆瓨澶辫触'), key: 'saving' });
+      }
+    } else {
+      msg.error({ content: t('璇峰~鍐欐纭殑鏁版嵁'), key: 'saving' });
+    }
+  }
 </script>

--
Gitblit v1.9.3