From 02e63339ca097d62794caf8f2fd374c34b155b65 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期一, 28 十月 2024 22:23:53 +0800
Subject: [PATCH] 一些更改

---
 src/views/components/GeneralCrudModal.vue |   70 ++++++++++++++++++++++++++++++++--
 1 files changed, 65 insertions(+), 5 deletions(-)

diff --git a/src/views/components/GeneralCrudModal.vue b/src/views/components/GeneralCrudModal.vue
index 9defb6e..3611598 100644
--- a/src/views/components/GeneralCrudModal.vue
+++ b/src/views/components/GeneralCrudModal.vue
@@ -1,7 +1,7 @@
 <template>
   <BasicModal
     :width="width"
-    :height="650"
+    :height="750"
     v-bind="$attrs"
     @register="register"
     :title="title"
@@ -35,10 +35,10 @@
   } from '/@/components/Table';
   import { useI18n } from '/@/hooks/web/useI18n';
   import { createImgPreview } from '/@/components/Preview';
-  import { getListByPage, SaveEntity } from '/@/api/tigerapi/system';
+  import { DeleteEntity, getListByPage, SaveEntity } from '/@/api/tigerapi/system';
   import { useMessage } from '/@/hooks/web/useMessage';
   import { cloneDeep, isFunction } from 'lodash-es';
-  import { isNullOrUnDef } from '/@/utils/is';
+  import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is';
   import { CustModalParams } from '/@/api/tigerapi/model/systemModel';
   import { EntityCustFunctionType } from '/@/api/tigerapi/model/basModel';
 
@@ -80,7 +80,7 @@
       title: '鎿嶄綔',
       dataIndex: 'action',
       fixed: 'right',
-    }, //鑷畾涔夋搷浣滃垪
+    },
   });
   const { createMessage: msg } = useMessage();
   const currentEditKeyRef = ref('');
@@ -110,7 +110,25 @@
       console.log(`绗�${index + 1}寮犲浘鐗囧凡鍔犺浇锛孶RL涓猴細${url}`, dom);
     };
     // 鍙互浣跨敤createImgPreview杩斿洖鐨� PreviewActions 鏉ユ帶鍒堕瑙堥�昏緫锛屽疄鐜扮被浼煎够鐏墖銆佽嚜鍔ㄦ棆杞箣绫荤殑楠氭搷浣�
-    createImgPreview({ imageList: [dataSource[0].LABEL_VIEW_PATH], defaultWidth: 700, rememberState: true, onImgLoad });
+    const Keys = Object.getOwnPropertyNames(others.value);
+    let path = '';
+    dataSource.map((item) => {
+      for (const k in Keys) {
+        if (item[Keys[k]] == others.value[Keys[k]] && !isNullOrEmpty(others.value[Keys[k]])) {
+          path = item['LABEL_VIEW_PATH'];
+          return;
+        }
+      }
+    });
+    if(isNullOrEmpty(path)){
+      path = dataSource.filter((q) => isNullOrEmpty(q.WORK_ORDER) || isNullOrEmpty(q.PROD_CODE))[0].LABEL_VIEW_PATH;
+    }
+    createImgPreview({
+      imageList: [path],
+      defaultWidth: 700,
+      rememberState: true,
+      onImgLoad,
+    });
   }
 
   async function onDataReceive(data) {
@@ -154,6 +172,41 @@
   }
 
   /**
+   * @description: 鍒犻櫎琛�
+   * @param {*} record
+   * @return {*}
+   */
+  function handleDel(record: EditRecordRow) {
+    if (!isNullOrEmpty(record.WORK_ORDER) || !isNullOrEmpty(record.PROD_CODE)) {
+      //鍒犻櫎
+      DeleteEntity(record, ctype.value).then((action) => {
+        if (action.IsSuccessed) {
+          try {
+            const data = cloneDeep(record.editValueRefs);
+            console.log(data);
+            //TODO 姝ゅ灏嗘暟鎹彁浜ょ粰鏈嶅姟鍣ㄤ繚瀛�
+            const [{ CustFunc }] = isNullOrUnDef(custImport.value['default'])
+              ? EntityCustFunction.value
+              : custImport.value['default']();
+            if (CustFunc && isFunction(CustFunc)) {
+              CustFunc({
+                others: others.value,
+                ctype: 'delete',
+                values: record,
+              });
+            }
+          } catch (error) {
+            msg.error({ content: t('鍒犻櫎澶辫触'), key: 'saving' });
+          }
+          reload();
+        }
+      });
+    } else {
+      msg.error({ content: t('娌℃湁闇�瑕佸垹闄ょ殑鍙橀噺'), key: 'saving' });
+    }
+  }
+
+  /**
    * @description: 鍙栨秷缂栬緫
    * @param {*} record
    * @return {*}
@@ -177,6 +230,13 @@
           onClick: handleEdit.bind(null, record),
           name: '',
         },
+        {
+          label: '鍒犻櫎',
+          color: 'error',
+          disabled: currentEditKeyRef.value ? currentEditKeyRef.value !== record.key : false,
+          onClick: handleDel.bind(null, record),
+          name: '',
+        },
       ];
     }
     return [

--
Gitblit v1.9.3