Quellcode durchsuchen

增加表格单元格自定义渲染的功能。

YangZhiJie vor 1 Jahr
Ursprung
Commit
8a5e8618d4
1 geänderte Dateien mit 183 neuen und 150 gelöschten Zeilen
  1. 183 150
      src/window1/tabGridView/CellTextItem.vue

+ 183 - 150
src/window1/tabGridView/CellTextItem.vue

@@ -73,8 +73,11 @@
     <component
       :is="customerComponentName" v-else-if="fieldUtil.isCustomerRender(gridFieldItem)" :field="gridFieldItem"
       :field-value="fieldValue" :class-name="className"
+      :model-data="modelData"
+      @refresh-data="refreshDatas"
     />
-    <div v-if="fieldUtil.isGridButtonEditor(gridFieldItem)">
+
+    <div v-else-if="fieldUtil.isGridButtonEditor(gridFieldItem)">
       <template v-for="(tabGridButtonItem, index) in gridFieldItem.tabGridButtonDtos" :key="tabGridButtonItem.name">
         <template v-if="visible[index]">
           <a-button
@@ -312,6 +315,13 @@ export default {
       },
     },
 
+    gridFieldItem: {
+      immediate: true,
+      handler(curVal, oldVal) {
+        this.renderRemoteComponentModule();
+      },
+    },
+
     'gridFieldItem.tabGridButtonDtos': {
 
       immediate: true,
@@ -563,6 +573,22 @@ export default {
       }
     },
 
+    /**
+     * 获取字符串的哈希值
+     * @param input
+     */
+    getHash: function (input) {
+      let hash = 0;
+      if (input.length === 0) {
+        return hash;
+      }
+      for (let i = 0; i < input.length; i++) {
+        const char = input.charCodeAt(i);
+        hash = (hash << 5) - hash + char;
+        hash = hash & hash; // 确保返回值是一个32位有符号整数
+      }
+      return Math.abs(hash).toString();
+    },    
     
     /**
      * 远程加载ES VUE组件模块。
@@ -571,6 +597,13 @@ export default {
      */
     renderRemoteComponentModule: async function () {
       const _self = this;
+
+      console.log('renderRemoteComponentModule');
+      
+      if(this.gridFieldItem == null || !FieldUtil.isCustomerRender(this.gridFieldItem)){
+        return;
+      }
+
       let jsUrl = this.gridFieldItem.remoteComponentModuleJsUrl;
       let cssUrl = this.gridFieldItem.remoteComponentModuleCssUrl;
 
@@ -608,174 +641,174 @@ export default {
         console.log(_self.customerComponentName);
       }
     },
-  },
   
-  //跳转或执行流程
-  execute: function (tabButton) {
-    var _self = this;
-    _self.tabButtonModel = tabButton;
-    if (tabButton.customerWindowNo != undefined && tabButton.customerWindowNo != '') {
-      CustomerWindowResource.uniqueByNo(tabButton.customerWindowNo).then(
-        successData => {
-          tabButton.customerWindowRouteUrl = successData.routeUrl;
-          if (tabButton.customerWindowNo == '20221101_151823') {
-            localStorage.setItem('AssetInstance_ComplexFilterParams', JSON.stringify(_self.complexFilterParams));
-            localStorage.setItem('AssetInstance_SimpleFilterParams', _self.simpleFilterParams);
-          }
-          //跳转到tabButton.routeUrl
-          _self.switchFormRoute(tabButton);
-        },
-        errorData => {
-          Common.processException(errorData);
-        },
-      );
-    } else if (
-      tabButton.processReportNo != undefined &&
+    //跳转或执行流程
+    execute: function (tabButton) {
+      var _self = this;
+      _self.tabButtonModel = tabButton;
+      if (tabButton.customerWindowNo != undefined && tabButton.customerWindowNo != '') {
+        CustomerWindowResource.uniqueByNo(tabButton.customerWindowNo).then(
+          successData => {
+            tabButton.customerWindowRouteUrl = successData.routeUrl;
+            if (tabButton.customerWindowNo == '20221101_151823') {
+              localStorage.setItem('AssetInstance_ComplexFilterParams', JSON.stringify(_self.complexFilterParams));
+              localStorage.setItem('AssetInstance_SimpleFilterParams', _self.simpleFilterParams);
+            }
+            //跳转到tabButton.routeUrl
+            _self.switchFormRoute(tabButton);
+          },
+          errorData => {
+            Common.processException(errorData);
+          },
+        );
+      } else if (
+        tabButton.processReportNo != undefined &&
       tabButton.processReportNo != ''
-    ) {
+      ) {
       // 判断流程报表是否有参数
       // 如果有参数则直接跳转到流程和报表的界面。
-      if (tabButton.routerRedirect == undefined || tabButton.routerRedirect == false) {
-        if (tabButton.tipsTitle == undefined || tabButton.tipsTitle.length == 0) {
-          _self.executeProcess();
+        if (tabButton.routerRedirect == undefined || tabButton.routerRedirect == false) {
+          if (tabButton.tipsTitle == undefined || tabButton.tipsTitle.length == 0) {
+            _self.executeProcess();
+          } else {
+            _self.titleModal = true;
+          }
         } else {
-          _self.titleModal = true;
+          this.$router.push({
+            path: '/desktop/process-report/' + tabButton.processReportNo,
+          });
         }
-      } else {
-        this.$router.push({
-          path: '/desktop/process-report/' + tabButton.processReportNo,
-        });
-      }
-    } else if (tabButton.htmlWindowNo != undefined) {
-      HtmlWindowResource.uniqueByNo(tabButton.htmlWindowNo).then(
-        htmlWindowDto => {
-          if (htmlWindowDto != undefined) {
-            var htmlWindowUrl = htmlWindowDto.htmlFileName;
-            var autoCloseInterval = htmlWindowDto.autoCloseInterval;
-            var regExp = new RegExp('[{].*?[}]', 'g');
-            var result = htmlWindowUrl.match(regExp);
-            if (htmlWindowUrl != undefined && htmlWindowUrl != '') {
-              for (var index = 0, len = result.length; index < len; index++) {
-                var tempResult = result[index];
-                console.log('{' + tempResult + '}匹配');
-                if (tempResult == '{URL}') {
-                  htmlWindowUrl = htmlWindowUrl.replace(
-                    '{URL}',
-                    Common.getHostPageBaseURL(),
-                  );
-                } else if (tempResult == '{RecordIds}') {
-                  var recordId = _self.modelData.id;
-                  htmlWindowUrl = htmlWindowUrl.replace('{RecordIds}', recordId);
-                } else if (tempResult == '{Token}') {
-                  htmlWindowUrl = htmlWindowUrl.replace('{Token}', Common.getToken());
-                } else {
-                  if (_self.selectedModelDatas.length == 0) {
-                    Notify.error(_self.$t('lang.Notify.error'), _self.$t('lang.tabButton.describe3'), true);
-                    return;
-                  } else if (_self.selectedModelDatas.length > 1) {
-                    Notify.error(_self.$t('lang.Notify.error'), _self.$t('lang.tabButton.describe2'), true);
-                    return;
+      } else if (tabButton.htmlWindowNo != undefined) {
+        HtmlWindowResource.uniqueByNo(tabButton.htmlWindowNo).then(
+          htmlWindowDto => {
+            if (htmlWindowDto != undefined) {
+              var htmlWindowUrl = htmlWindowDto.htmlFileName;
+              var autoCloseInterval = htmlWindowDto.autoCloseInterval;
+              var regExp = new RegExp('[{].*?[}]', 'g');
+              var result = htmlWindowUrl.match(regExp);
+              if (htmlWindowUrl != undefined && htmlWindowUrl != '') {
+                for (var index = 0, len = result.length; index < len; index++) {
+                  var tempResult = result[index];
+                  console.log('{' + tempResult + '}匹配');
+                  if (tempResult == '{URL}') {
+                    htmlWindowUrl = htmlWindowUrl.replace(
+                      '{URL}',
+                      Common.getHostPageBaseURL(),
+                    );
+                  } else if (tempResult == '{RecordIds}') {
+                    var recordId = _self.modelData.id;
+                    htmlWindowUrl = htmlWindowUrl.replace('{RecordIds}', recordId);
+                  } else if (tempResult == '{Token}') {
+                    htmlWindowUrl = htmlWindowUrl.replace('{Token}', Common.getToken());
+                  } else {
+                    if (_self.selectedModelDatas.length == 0) {
+                      Notify.error(_self.$t('lang.Notify.error'), _self.$t('lang.tabButton.describe3'), true);
+                      return;
+                    } else if (_self.selectedModelDatas.length > 1) {
+                      Notify.error(_self.$t('lang.Notify.error'), _self.$t('lang.tabButton.describe2'), true);
+                      return;
+                    }
+                    var tempResult1 = tempResult.replace('{', '').replace('}', '');
+                    htmlWindowUrl = htmlWindowUrl.replace(
+                      tempResult,
+                      _self.getFirstSelectModelDataFieldValue(tempResult1),
+                    );
                   }
-                  var tempResult1 = tempResult.replace('{', '').replace('}', '');
-                  htmlWindowUrl = htmlWindowUrl.replace(
-                    tempResult,
-                    _self.getFirstSelectModelDataFieldValue(tempResult1),
-                  );
                 }
-              }
 
-              var openWindow = window.open(htmlWindowUrl);
+                var openWindow = window.open(htmlWindowUrl);
 
-              // 自动关闭
-              if (autoCloseInterval != undefined) {
-                setTimeout(function () {
-                  openWindow.close();
-                  openWindow = undefined;
-                }, autoCloseInterval * 1000);
+                // 自动关闭
+                if (autoCloseInterval != undefined) {
+                  setTimeout(function () {
+                    openWindow.close();
+                    openWindow = undefined;
+                  }, autoCloseInterval * 1000);
+                }
               }
             }
+          },
+          errorData => {
+            Common.processException(errorData);
+          },
+        );
+      }
+    },
+    // 切换到Form表单的路由
+    switchFormRoute: function (tabButton) {
+      const _self = this;
+      var routeDate = {
+        path: tabButton.customerWindowRouteUrl,
+        params: {
+          modelData: this.modelData,
+        },
+      };
+      // 请勿修改,会影响生单的功能
+      var uuid = _self.uuid;
+      if (uuid != undefined) {
+        routeDate.path = routeDate.path + '/' + uuid;
+      }
+
+      const frameUrl = Common.getRedirectUrl(
+        '#' + routeDate.path,
+      );
+
+      // 供子页面iframe调用,修改modelData,(举例:生单界面修改参数)。
+      // window.modelDataChanged = this.modelDataChanged;
+
+      // window.getModelData = this.getModelData;
+      let modelData = JSON.stringify(this.modelData);
+      console.log(modelData);
+      localStorage.setItem(_self.uuid + '#GenerateDocumentTool', modelData);
+
+      var iWidth = 1280;//弹出窗口的宽度;
+      var iHeight = 720; //弹出窗口的高度;
+      var iTop = (window.screen.availHeight - 30 - iHeight) / 2;//获得窗口的垂直位置;
+      var iLeft = (window.screen.availWidth - 10 - iWidth) / 2; //获得窗口的水平位置;
+      window.open(frameUrl, '_blank', 'height=' + iHeight + ',innerHeight=' + iHeight + ',width=' + iWidth + ',innerWidth=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
+    // window.open(frameUrl);
+    },
+    // 执行流程
+    executeProcess: function () {
+      var _self = this;
+      var ids = [_self.modelData.id];
+      ProcessReportResource.runProcessByIds(_self.tabButtonModel.processReportNo, ids).then(
+        successData => {
+          _self.modal = true;
+          _self.processReportResult = successData;
+
+          if (
+            _self.processReportResult.reportResults != undefined &&
+          _self.processReportResult.reportResults.length > 0
+          ) {
+            _self.processReportResult.reportResults.forEach(function (item, index) {
+              if (item.reportDefinitionType !== 'ExcelReport') {
+                item.previewIndex = 1;
+              } else {
+                item.previewIndex = 2;
+              }
+              if (index == 0) {
+                item.showPreview = true;
+              } else {
+                item.showPreview = false;
+              }
+            });
           }
+          _self.titleModal = false;
         },
         errorData => {
+          _self.titleModal = false;
           Common.processException(errorData);
         },
       );
-    }
-  },
-  // 切换到Form表单的路由
-  switchFormRoute: function (tabButton) {
-    const _self = this;
-    var routeDate = {
-      path: tabButton.customerWindowRouteUrl,
-      params: {
-        modelData: this.modelData,
-      },
-    };
-    // 请勿修改,会影响生单的功能
-    var uuid = _self.uuid;
-    if (uuid != undefined) {
-      routeDate.path = routeDate.path + '/' + uuid;
-    }
-
-    const frameUrl = Common.getRedirectUrl(
-      '#' + routeDate.path,
-    );
-
-    // 供子页面iframe调用,修改modelData,(举例:生单界面修改参数)。
-    // window.modelDataChanged = this.modelDataChanged;
-
-    // window.getModelData = this.getModelData;
-    let modelData = JSON.stringify(this.modelData);
-    console.log(modelData);
-    localStorage.setItem(_self.uuid + '#GenerateDocumentTool', modelData);
-
-    var iWidth = 1280;//弹出窗口的宽度;
-    var iHeight = 720; //弹出窗口的高度;
-    var iTop = (window.screen.availHeight - 30 - iHeight) / 2;//获得窗口的垂直位置;
-    var iLeft = (window.screen.availWidth - 10 - iWidth) / 2; //获得窗口的水平位置;
-    window.open(frameUrl, '_blank', 'height=' + iHeight + ',innerHeight=' + iHeight + ',width=' + iWidth + ',innerWidth=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
-    // window.open(frameUrl);
-  },
-  // 执行流程
-  executeProcess: function () {
-    var _self = this;
-    var ids = [_self.modelData.id];
-    ProcessReportResource.runProcessByIds(_self.tabButtonModel.processReportNo, ids).then(
-      successData => {
-        _self.modal = true;
-        _self.processReportResult = successData;
-
-        if (
-          _self.processReportResult.reportResults != undefined &&
-          _self.processReportResult.reportResults.length > 0
-        ) {
-          _self.processReportResult.reportResults.forEach(function (item, index) {
-            if (item.reportDefinitionType !== 'ExcelReport') {
-              item.previewIndex = 1;
-            } else {
-              item.previewIndex = 2;
-            }
-            if (index == 0) {
-              item.showPreview = true;
-            } else {
-              item.showPreview = false;
-            }
-          });
-        }
-        _self.titleModal = false;
-      },
-      errorData => {
-        _self.titleModal = false;
-        Common.processException(errorData);
-      },
-    );
-    _self.refreshDatas();
+      _self.refreshDatas();
     // }
-  },
-  //关闭表头按钮提示框
-  titleModalClose: function () {
-    var _self = this;
-    _self.titleModal = false;
+    },
+    //关闭表头按钮提示框
+    titleModalClose: function () {
+      var _self = this;
+      _self.titleModal = false;
+    },
   },
 };