Преглед изворни кода

curd 双击查看改为表头查看

liuyanpeng пре 1 година
родитељ
комит
b52e1ae2f5

+ 6 - 4
src/window1/tabGridView/GridBody.vue

@@ -380,6 +380,7 @@ export default {
 
     clickModelData: function () {
       this.$emit('clickModelData');
+      this.$emit('readRecord', false);
     },
 
     // 值发生改变
@@ -449,11 +450,12 @@ export default {
       return validateResults;
     },
     clickRecord: function () {
+    // 暂时取消双击打开
       var now = new Date().getTime();
-      if (now - this.lastClickTime < 500) {
-        this.readRecord();
-      }
-      this.lastClickTime = now;
+      // if (now - this.lastClickTime < 500) {
+      //   this.readRecord();
+      // }
+      // this.lastClickTime = now;
     },
     /**
      * 执行Callout

+ 11 - 5
src/window1/tabGridView/NewTabButton.vue

@@ -5,7 +5,7 @@
         <a-button v-if="item.action === 'CREATE'" :icon="h(PlusSquareTwoTone)" @click="create">
           {{ item.name }}
         </a-button>
-        <a-button v-else-if="item.action === 'EDIT'" :icon="h(EditTwoTone)">
+        <a-button v-else-if="item.action === 'SAVE' || item.action === 'EDIT'" :icon="h(EditTwoTone)" @click="viewOrEdit">
           {{ item.name }}
         </a-button>
         <a-button v-else-if="item.action === 'DELETE'" :icon="h(DeleteTwoTone)" @click="deleteData">
@@ -30,7 +30,7 @@
           {{ item.name }}
         </a-button>
         <a-button
-          v-else-if="item.action === 'OPEN_REMOTE_COMPONENT_MODULE_IN_MODAL'" :icon="h(HddOutlined)"
+          v-else-if="item.action === 'OPEN_REMOTE_COMPONENT_MODULE_IN_MODAL'" :icon="h(ProfileTwoTone)"
           @click="openRemoteComponentModule(item)"
         >
           {{ item.name }}
@@ -49,7 +49,7 @@
         <a-button v-if="item.action === 'CREATE'" :icon="h(PlusSquareTwoTone)" @click="create">
           {{ item.name }}
         </a-button>
-        <a-button v-else-if="item.action === 'EDIT'" :icon="h(EditTwoTone)">
+        <a-button v-else-if="item.action === 'SAVE' || item.action === 'EDIT'" :icon="h(EditTwoTone)" @click="viewOrEdit">
           {{ item.name }}
         </a-button>
         <a-button v-else-if="item.action === 'DELETE'" :icon="h(DeleteTwoTone)" @click="deleteData">
@@ -74,7 +74,7 @@
           {{ item.name }}
         </a-button>
         <a-button
-          v-else-if="item.action === 'OPEN_REMOTE_COMPONENT_MODULE_IN_MODAL'" :icon="h(HddOutlined)"
+          v-else-if="item.action === 'OPEN_REMOTE_COMPONENT_MODULE_IN_MODAL'" :icon="h(ProfileTwoTone)"
           @click="openRemoteComponentModule(item)"
         >
           {{ item.name }}
@@ -166,7 +166,7 @@ import {
   EditTwoTone,
   BookTwoTone,
   BellTwoTone,
-  HddOutlined,
+  ProfileTwoTone,
   FileTextTwoTone,
   ContainerTwoTone,
   ControlTwoTone,
@@ -231,6 +231,7 @@ const emit = defineEmits([
   'deleteRecords',
   'refreshDatas',
   'judgeIsHaveButtons',
+  'readRecord',
 ]);
 
 const selectDatas = ref([]);
@@ -260,6 +261,11 @@ const deleteData = () => {
   emit('deleteRecords');
 };
 
+// 查看或编辑
+const viewOrEdit = () => {
+  emit('readRecord',true);
+};
+
 // 刷新
 const refresh = () => {
   emit('refreshDatas', false);

+ 86 - 100
src/window1/tabGridView/TabGridEdit.vue

@@ -9,9 +9,7 @@
       " :tab-props="tab.tabDataSource.tabDataSourceGroupDtos" @get-now-tab="getNowTab"
     >
       <GridColumnDef
-        :window-no="windowNo"
-        :tab-index="tabIndex"
-        :tab-grid-fields="tabGridFields"
+        :window-no="windowNo" :tab-index="tabIndex" :tab-grid-fields="tabGridFields"
         @property-changed="propertyChanged($event)"
       />
     </WindowTab>
@@ -43,9 +41,9 @@
           :window="window" :now-tab="nowTab" :simple-filter-params="searchText"
           :complex-filter-params="complexFilterParams" :uuid="uuid" :show-tab-dto="tab" :model-datas="modelDatas"
           :view-type="'Grid'" :curd-window-function-access="curdWindowFunctionAccess"
-          :select-model-datas="selectModelDatas"
-          @create-record-in-window-edit="createRecordInWindowEdit" @delete-records="deleteRecords"
-          @refresh-datas="refreshDatas" @judge-is-have-buttons="judgeIsHaveButtons"
+          :select-model-datas="selectModelDatas" @create-record-in-window-edit="createRecordInWindowEdit"
+          @delete-records="deleteRecords" @refresh-datas="refreshDatas" @judge-is-have-buttons="judgeIsHaveButtons"
+          @read-record="readRecord($event)"
         />
       </div>
 
@@ -59,9 +57,9 @@
               <table class="curd-table table-striped table-bordered" :width="tableWidth">
                 <thead>
                   <GridHeader
-                    :is-show-edit="false" :tab-grid-fields="tabGridFields"
-                    :window-no="windowNo" :tab-index="tabIndex" :is-chinese-english="window.isChineseEnglish"
-                    height="40px" @on-sort="onSort($event)" @property-changed="propertyChanged($event)"
+                    :is-show-edit="false" :tab-grid-fields="tabGridFields" :window-no="windowNo"
+                    :tab-index="tabIndex" :is-chinese-english="window.isChineseEnglish" height="40px"
+                    @on-sort="onSort($event)" @property-changed="propertyChanged($event)"
                     @select-all="selectAll($event)" @multiple-select="changeSelectMode($event)"
                   />
                 </thead>
@@ -72,16 +70,13 @@
                         1 +
                         (pagination.current_page - 1) * pagination.per_page
                       " :is-show-edit="false" :tab-grid-fields="tabGridFields"
-                      :tab-grid-title-fields="tabGridTitleFields"
-                      :model-data="modelData" 
-                      :simple-filter-params="searchText"
-                      :complex-filter-params="complexFilterParams"
-                      :class-name="tab.tabDataSource.className"
-                      :scroll-object="scrollObject" :js-url="jsUrl" :model-datas="modelDatas"
-                      @delete-record="deleteRecord(modelData, true)" @edit-record="editRecord(modelData, index)"
-                      @click-model-data="clickModelData(modelData)" @read-record="readRecord(modelData, index)"
-                      @refresh-datas="refreshDatas" @value-changed="valueChanged($event, modelData, index)"
-                      @execute-callout="
+                      :tab-grid-title-fields="tabGridTitleFields" :model-data="modelData"
+                      :simple-filter-params="searchText" :complex-filter-params="complexFilterParams"
+                      :class-name="tab.tabDataSource.className" :scroll-object="scrollObject" :js-url="jsUrl"
+                      :model-datas="modelDatas" @delete-record="deleteRecord(modelData, true)"
+                      @edit-record="editRecord(modelData, index)" @click-model-data="clickModelData(modelData)"
+                      @read-record="readRecord($event, modelData, index)" @refresh-datas="refreshDatas"
+                      @value-changed="valueChanged($event, modelData, index)" @execute-callout="
                         executeCallout($event, modelData, index)
                       "
                     />
@@ -122,11 +117,9 @@
     <Loading v-if="loading" />
   </div>
 
-  
+
   <component
-    :is="dynamicComponent"
-    v-if="dynamicComponentOpen" 
-    v-model:open="dynamicComponentOpen" 
+    :is="dynamicComponent" v-if="dynamicComponentOpen" v-model:open="dynamicComponentOpen"
     v-bind="dynamicComponentParam"
   />
 </template>
@@ -263,7 +256,8 @@ export default {
       dynamicComponent: null,
       dynamicComponentParam: null,
       dynamicComponentOpen: true,
-      selectModelDatas:[],
+      selectModelDatas: [],
+      checkDatas: null,
     };
   },
   computed: {
@@ -407,14 +401,14 @@ export default {
         console.log(this.modelDatas.length);
       },
     },
-    
+
     /**
      * 如果模态框关闭,那么刷新一下表格的数据
      * @param currentValue 
      * @param oldValue 
      */
-    dynamicComponentOpen: function(currentValue, oldValue){
-      if(currentValue == false){
+    dynamicComponentOpen: function (currentValue, oldValue) {
+      if (currentValue == false) {
         this.queryGridData(false);
       }
     },
@@ -512,12 +506,12 @@ export default {
 
   beforeMount: function () { },
 
-  mounted: function () { 
+  mounted: function () {
 
   },
 
   methods: {
-    getContext: Context,    
+    getContext: Context,
 
     // 获取当前tab为哪个阶段
     getNowTab: function (tab) {
@@ -903,7 +897,7 @@ export default {
           _self.dynamicComponent = 'CurdWindowModal';
           _self.dynamicComponentOpen = true;
 
-        
+
           // this.$router.push(
           //   'window-edit/create/' +
           //   this.windowNo +
@@ -922,8 +916,8 @@ export default {
             function (response) {
               _self.loading = false;
 
-              
-              if(response.errorCode != 0){
+
+              if (response.errorCode != 0) {
                 Notify.error('数据新建异常', response.errorMessage, false);
                 return;
               }
@@ -1045,7 +1039,7 @@ export default {
           var currIndex = (currPage - 1) * Common.pageSize + index + 1;
           var totalCount = _self.pagination.total;
 
-          
+
           _self.dynamicComponentParam = {
             viewType: 'edit',
             curdWindowNo: _self.windowNo,
@@ -1060,7 +1054,7 @@ export default {
           _self.dynamicComponent = 'CurdWindowModal';
           _self.dynamicComponentOpen = true;
 
-        
+
           // this.$router.push(
           //   'window-edit/edit/' +
           //   this.windowNo +
@@ -1101,74 +1095,66 @@ export default {
     },
 
     // 只读
-    readRecord: function (modelData, index) {
-      if (modelData.editMode == true) {
+    readRecord: function (isRead, modelData, index) {
+      var _self = this;
+      const readModelData = !_self.checkDatas ? modelData : _self.checkDatas.modelData;
+      if (readModelData.editMode == true) {
         return;
       }
+      if (isRead) {
+        var currPage = _self.pagination.current_page;
+        var currIndex = (currPage - 1) * Common.pageSize + _self.checkDatas.index + 1;
+        var totalCount = _self.pagination.total;
 
-      var _self = this;
-
-      var currPage = _self.pagination.current_page;
-      var currIndex = (currPage - 1) * Common.pageSize + index + 1;
-      var totalCount = _self.pagination.total;
+        var customerWindowUrl = _self.tab.customerWindowUrl;
+        if (customerWindowUrl != undefined && customerWindowUrl != '') {
+          this.$router.push(
+            customerWindowUrl +
+            '/view/' +
+            this.windowNo +
+            '/' +
+            this.tabIndex +
+            '/' +
+            readModelData.id +
+            '?currPage=' +
+            currPage +
+            '&currIndex=' +
+            currIndex +
+            '&totalCount=' +
+            totalCount +
+            '&uuid=' +
+            this.uuid,
+          );
+        } else {
+          let categoryNo; let categoryValue; let displayValue;
+
+          if (readModelData.data['category']) {
+            categoryValue = readModelData.data['category'];
+            displayValue = categoryValue['displayValue'];
+          } else if (readModelData.data['assetCategory']) {
+            categoryValue = readModelData.data['assetCategory'];
+            displayValue = categoryValue['displayValue'];
+          } else {
+            categoryNo = this.windowNo;
+          }
+          categoryNo = displayValue[displayValue.length - 1];
 
-      var customerWindowUrl = _self.tab.customerWindowUrl;
-      if (customerWindowUrl != undefined && customerWindowUrl != '') {
-
-        
-
-
-
-        this.$router.push(
-          customerWindowUrl +
-          '/view/' +
-          this.windowNo +
-          '/' +
-          this.tabIndex +
-          '/' +
-          modelData.id +
-          '?currPage=' +
-          currPage +
-          '&currIndex=' +
-          currIndex +
-          '&totalCount=' +
-          totalCount +
-          '&uuid=' +
-          this.uuid,
-        );
+          _self.dynamicComponentParam = {
+            viewType: 'view',
+            curdWindowNo: categoryNo,
+            tabIndex: this.tabIndex,
+            modelDataId: readModelData.id,
+            currentPage: currPage,
+            currentIndex: currIndex,
+            totalRecords: totalCount,
+            isRestoreData: false,
+            uuid: this.uuid,
+          };
+          _self.dynamicComponent = 'CurdWindowModal';
+          _self.dynamicComponentOpen = true;
+        }
       } else {
-
-        _self.dynamicComponentParam = {
-          viewType: 'view',
-          curdWindowNo: this.windowNo,
-          tabIndex: this.tabIndex,
-          modelDataId: modelData.id,
-          currentPage: currPage,
-          currentIndex: currIndex,
-          totalRecords: totalCount,
-          isRestoreData: false,
-          uuid: this.uuid,
-        };
-        _self.dynamicComponent = 'CurdWindowModal';
-        _self.dynamicComponentOpen = true;
-
-
-        // this.$router.push(
-        //   'window-read/view/' +
-        //   this.windowNo +
-        //   '/' +
-        //   this.tabIndex +
-        //   '/' +
-        //   modelData.id +
-        //   '?currPage=' +
-        //   currPage +
-        //   '&currIndex=' +
-        //   currIndex +
-        //   '&totalCount=' +
-        //   totalCount +
-        //   '&uuid=' +
-        //   this.uuid,
-        // );
+        _self.checkDatas = { modelData, index };
       }
     },
 
@@ -1434,9 +1420,9 @@ export default {
       if (modelData.select === true) {
         this.selectModelDatas.push(modelData);
       } else {
-        this.selectModelDatas.forEach((item,index) =>{
-          if(item.id=== modelData.id) {
-            this.selectModelDatas.splice(index,1);
+        this.selectModelDatas.forEach((item, index) => {
+          if (item.id === modelData.id) {
+            this.selectModelDatas.splice(index, 1);
           }
         });
       }