From aa6f213ac00f69c8812b0d6a97232a1f1a9b7e44 Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期四, 14 十一月 2024 17:50:38 +0800
Subject: [PATCH] 修改action,添加tab浏览

---
 Source/plt-web/plt-web-ui/src/components/actions/base/ViewAction.js          |   35 +++----
 Source/plt-web/plt-web-ui/src/components/actions/handlers.js                 |    6 +
 Source/plt-web/plt-web-ui/src/components/actions/base/upRevisionAction.js    |    2 
 Source/plt-web/plt-web-ui/src/components/PLT-basic-component/basicForm.vue   |   16 +-
 Source/plt-web/plt-web-ui/src/components/actions/base/downloadFileAction.js  |    2 
 Source/plt-web/plt-web-ui/src/components/actions/base/uploadFileAction.js    |    2 
 Source/plt-web/plt-web-ui/src/store/index.js                                 |   20 ++++
 Source/plt-web/plt-web-ui/src/components/actions/base/ViewDialogAction.js    |  100 ++++++++++++++++++++
 Source/plt-web/plt-web-ui/src/components/actions/base/EditAction.js          |    2 
 Source/plt-web/plt-web-ui/src/views/base/ViewTab.vue                         |   67 +++++++++++++
 Source/plt-web/plt-web-ui/src/components/actions/base/StartWorkflowAction.js |    2 
 Source/plt-web/plt-web-ui/src/router/views/index.js                          |   15 ++
 Source/plt-web/plt-web-ui/src/components/actions/base/RevisionAction.js      |    2 
 13 files changed, 236 insertions(+), 35 deletions(-)

diff --git a/Source/plt-web/plt-web-ui/src/components/PLT-basic-component/basicForm.vue b/Source/plt-web/plt-web-ui/src/components/PLT-basic-component/basicForm.vue
index 5131082..630a90e 100644
--- a/Source/plt-web/plt-web-ui/src/components/PLT-basic-component/basicForm.vue
+++ b/Source/plt-web/plt-web-ui/src/components/PLT-basic-component/basicForm.vue
@@ -239,20 +239,20 @@
           col.display=false
         }
       }
-      if (col.type === "select") {
-        if(col.data && col.data.length>0){
+      if (col.type === "select" || col.type==='radio' || col.type==='checkbox') {
+        if (col.data && col.data.length > 0) {
           col.dicData = col.data.map((d) => {
             return {
               label: d.key,
               key: d.value,
               value: d.value,
-              attributes:d.attributes
+              attributes: d.attributes
             };
           });
-        }else if(!validatenull(col.dictCode)) {
+        } else if (!validatenull(col.dictCode)) {
           getDicts(col.dictCode).then((res) => {
-            if (res.data.success){
-              if(res.data.data && res.data.obj == null){
+            if (res.data.success) {
+              if (res.data.data && res.data.obj == null) {
                 res.data.obj = res.data.data
               }
               const dic = res.data.obj;
@@ -261,11 +261,13 @@
                   label: d.value,
                   key: d.key,
                   value: d.key,
-                  attributes:d.attributes
+                  attributes: d.attributes
                 };
               });
             }
           });
+        } else {
+          col.dicData = [];
         }
       }
       if (col.type==='refer') {
diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/EditAction.js b/Source/plt-web/plt-web-ui/src/components/actions/base/EditAction.js
index c28b911..39f343b 100644
--- a/Source/plt-web/plt-web-ui/src/components/actions/base/EditAction.js
+++ b/Source/plt-web/plt-web-ui/src/components/actions/base/EditAction.js
@@ -43,7 +43,7 @@
   }
   callPreEvent(options, doBefore, function (options) {
     doEdit(options, function (type,formData) {
-      callPostEvent(options, doAfter,type, callback);
+      callPostEvent(options, doAfter,callback,type);
     });
   });
 };
diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/RevisionAction.js b/Source/plt-web/plt-web-ui/src/components/actions/base/RevisionAction.js
index 341592c..a4d5198 100644
--- a/Source/plt-web/plt-web-ui/src/components/actions/base/RevisionAction.js
+++ b/Source/plt-web/plt-web-ui/src/components/actions/base/RevisionAction.js
@@ -43,7 +43,7 @@
   }
   callPreEvent(options, doBefore, function (options) {
     doRev(options, function (formData) {
-      callPostEvent(options, doAfter,'rev', callback);
+      callPostEvent(options, doAfter,callback,'rev');
     });
   });
 };
diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/StartWorkflowAction.js b/Source/plt-web/plt-web-ui/src/components/actions/base/StartWorkflowAction.js
index f13002d..c75adb8 100644
--- a/Source/plt-web/plt-web-ui/src/components/actions/base/StartWorkflowAction.js
+++ b/Source/plt-web/plt-web-ui/src/components/actions/base/StartWorkflowAction.js
@@ -42,7 +42,7 @@
 
   callPreEvent(options, doBefore, function (options) {
     showStartWindow(options, function () {
-      callPostEvent(options, doAfter, callback,type);
+      callPostEvent(options, doAfter, callback,'startwork');
     });
   });
 };
diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/ViewAction.js b/Source/plt-web/plt-web-ui/src/components/actions/base/ViewAction.js
index 604862e..344364c 100644
--- a/Source/plt-web/plt-web-ui/src/components/actions/base/ViewAction.js
+++ b/Source/plt-web/plt-web-ui/src/components/actions/base/ViewAction.js
@@ -1,10 +1,12 @@
 /**
- * 鎸夐挳澶勭悊 椤甸潰灞曠ず涓簍ab閫夐」鍗�
+ * 鎸夐挳澶勭悊 寮圭獥灞曠ず璇︽儏
  */
 import {paramLow,callPreEvent,callPostEvent,replaceFreeMarker} from '../BaseAction';
 import {validatenull} from "@/util/validate";
 import Vue from "vue";
-import ViewDialog from "@/components/actions/base/ViewDialog";
+import ViewTab from "@/views/base/ViewTab";
+import router from "@/router/router"
+import store from "@/store/index"
 
 export const doAction = (options,callback) => {
   const paramVOS = Object.assign({
@@ -26,7 +28,6 @@
     Vue.prototype.$message.error("浠呰兘閫夋嫨涓�鏉℃暟鎹潵鎿嶄綔");
     return false;
   }
-
   callPreEvent(options, doBefore, function (options) {
     doView(options, function (type,formData) {
       callPostEvent(options, doAfter,type, callback);
@@ -57,25 +58,19 @@
     name="鏌ョ湅銆�"+replaceFreeMarker(paramVOS.showname,options.dataStore,options.sourceData)+"銆�"
   }
   paramVOS.title=name;
-  const dialogConstructor = Vue.extend(ViewDialog);
-  let instance = new dialogConstructor();
-  instance.sourceData = options.sourceData;
-  instance.dataStore = options.dataStore;
-  instance.paramVOS = paramVOS
-
-  instance.dialogClose = function () {
-    vm.visible = false;
-    document.body.removeChild(vm.$el);
-    instance.$destroy();
-    instance = null;
-  };
-  if (callback) {
-    instance.saveCallback = callback;
+  const params= {
+    options:options,
+    paramVOS:paramVOS,
+    saveCallback:callback
   }
-  let vm = instance.$mount();
-  document.body.appendChild(vm.$el);
-  instance.visible = true;
+
+  store.dispatch("setViewtabparams", params);
+  router.push({
+    name: "鏌ョ湅璇︽儏",
+    params:params,
+  });
 }
+
 /**
  * 鍓嶇疆浜嬩欢
  * @param options 鎸夐挳鐨勯厤缃俊鎭�
diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/ViewDialogAction.js b/Source/plt-web/plt-web-ui/src/components/actions/base/ViewDialogAction.js
new file mode 100644
index 0000000..d63fb9d
--- /dev/null
+++ b/Source/plt-web/plt-web-ui/src/components/actions/base/ViewDialogAction.js
@@ -0,0 +1,100 @@
+/**
+ * 鎸夐挳澶勭悊 寮圭獥灞曠ず璇︽儏
+ */
+import {paramLow,callPreEvent,callPostEvent,replaceFreeMarker} from '../BaseAction';
+import {validatenull} from "@/util/validate";
+import Vue from "vue";
+import ViewDialog from "@/components/actions/base/ViewDialog";
+
+export const doAction = (options,callback) => {
+  const paramVOS = Object.assign({
+    getdataurl: '/api/uiDataController/dataFormQuery',
+    getdatamethod: 'post',
+    url: '/api/uiDataController/editSave',
+    method: 'put',
+    uploadfileurl: 'vciFileUploadController/uploadFile'
+  }, options.paramVOS)
+  options.paramVOS = paramVOS;
+
+  options.sourceData = options.sourceData || {};
+  options.dataStore = options.dataStore || [];
+  if (!options.dataStore || options.dataStore.length < 1) {
+    Vue.prototype.$message.error("璇烽�夋嫨闇�瑕佹祻瑙堢殑鏁版嵁");
+    return false;
+  }
+  if (!paramVOS.multi && options.dataStore.length > 1) {
+    Vue.prototype.$message.error("浠呰兘閫夋嫨涓�鏉℃暟鎹潵鎿嶄綔");
+    return false;
+  }
+  callPreEvent(options, doBefore, function (options) {
+    doView(options, function (type,formData) {
+      callPostEvent(options, doAfter,type, callback);
+    });
+  });
+};
+
+/**
+ * 鎵ц
+ * @param options 鎸夐挳鐨勯厤缃俊鎭�
+ * @param callback 鍥炶皟
+ */
+export const doView = (options,callback)=> {
+  const paramVOS = options.paramVOS;
+  let component = 'base/UIContentViewerInDialog';
+  if (!validatenull(paramVOS.customurl)) {
+    //鑷畾涔塲s
+    component = `custom-ui/` + paramVOS.customurl;
+  }else{
+    if (!paramVOS['type'] || !paramVOS['context']) {
+      Vue.prototype.$message.error("鎸夐挳閰嶇疆涓嶆纭�");
+      return false;
+    }
+  }
+  paramVOS.component=component;
+  let name="鏌ョ湅璇︽儏"
+  if(paramVOS.showname){
+    name="鏌ョ湅銆�"+replaceFreeMarker(paramVOS.showname,options.dataStore,options.sourceData)+"銆�"
+  }
+  paramVOS.title=name;
+  const dialogConstructor = Vue.extend(ViewDialog);
+  let instance = new dialogConstructor();
+  instance.sourceData = options.sourceData;
+  instance.dataStore = options.dataStore;
+  instance.paramVOS = paramVOS
+
+  instance.dialogClose = function () {
+    vm.visible = false;
+    document.body.removeChild(vm.$el);
+    instance.$destroy();
+    instance = null;
+  };
+  if (callback) {
+    instance.saveCallback = callback;
+  }
+  let vm = instance.$mount();
+  document.body.appendChild(vm.$el);
+  instance.visible = true;
+}
+
+/**
+ * 鍓嶇疆浜嬩欢
+ * @param options 鎸夐挳鐨勯厤缃俊鎭�
+ * @param callback 鍥炶皟
+ */
+export const doBefore = (options,callback)=> {
+  console.log('鎵ц鏌ョ湅鍓嶇疆浜嬩欢');
+  if(callback){
+    callback(options);
+  }
+}
+/**
+ * 鍚庣疆浜嬩欢
+ * @param options 鎸夐挳鐨勯厤缃俊鎭�
+ * @param callback 鍥炶皟
+ */
+export const doAfter = (options,callback,actionType)=> {
+  console.log('鎵ц鏌ョ湅鍚庣疆浜嬩欢');
+  if(callback){
+    callback(actionType);
+  }
+}
diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/downloadFileAction.js b/Source/plt-web/plt-web-ui/src/components/actions/base/downloadFileAction.js
index da79423..6653a21 100644
--- a/Source/plt-web/plt-web-ui/src/components/actions/base/downloadFileAction.js
+++ b/Source/plt-web/plt-web-ui/src/components/actions/base/downloadFileAction.js
@@ -23,7 +23,7 @@
 
   callPreEvent(options, doBefore, function (options) {
     showStartWindow(options, function () {
-      callPostEvent(options, doAfter, callback,type);
+      callPostEvent(options, doAfter, callback,'downloadfile');
     });
   });
 };
diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/upRevisionAction.js b/Source/plt-web/plt-web-ui/src/components/actions/base/upRevisionAction.js
index 3c59f46..738885c 100644
--- a/Source/plt-web/plt-web-ui/src/components/actions/base/upRevisionAction.js
+++ b/Source/plt-web/plt-web-ui/src/components/actions/base/upRevisionAction.js
@@ -18,7 +18,7 @@
 
   callPreEvent(options, doBefore, function (options) {
     showStartWindow(options, function () {
-      callPostEvent(options, doAfter, callback,type);
+      callPostEvent(options, doAfter, callback,'uprevision');
     });
   });
 };
diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFileAction.js b/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFileAction.js
index 72318a6..8789035 100644
--- a/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFileAction.js
+++ b/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFileAction.js
@@ -17,7 +17,7 @@
   }
   callPreEvent(options, doBefore, function (options) {
     showStartWindow(options, function () {
-      callPostEvent(options, doAfter, callback,type);
+      callPostEvent(options, doAfter, callback,'uploadfile');
     });
   });
 };
diff --git a/Source/plt-web/plt-web-ui/src/components/actions/handlers.js b/Source/plt-web/plt-web-ui/src/components/actions/handlers.js
index e67f42a..c2c1361 100644
--- a/Source/plt-web/plt-web-ui/src/components/actions/handlers.js
+++ b/Source/plt-web/plt-web-ui/src/components/actions/handlers.js
@@ -3,10 +3,14 @@
 
 export const handlerAction=function (type,options, callback) {
   const handlers = {
-    //鏌ョ湅
+    //鏌ョ湅锛宼ab灞曠ず璇︽儏
     view: () => {import("@/components/actions/base/ViewAction").then(module => {
       module.doAction(options,callback);
     })},
+    //鏌ョ湅锛屽脊绐楀睍绀鸿鎯�
+    viewdialog: () => {import("@/components/actions/base/ViewDialogAction").then(module => {
+      module.doAction(options,callback);
+    })},
     //鍒涘缓
     add: () => {import("@/components/actions/base/AddAction").then(module => {
       module.doAction(options,callback);
diff --git a/Source/plt-web/plt-web-ui/src/router/views/index.js b/Source/plt-web/plt-web-ui/src/router/views/index.js
index 383242e..92e7775 100644
--- a/Source/plt-web/plt-web-ui/src/router/views/index.js
+++ b/Source/plt-web/plt-web-ui/src/router/views/index.js
@@ -103,4 +103,17 @@
     component: () =>
       import( /* webpackChunkName: "views" */ '@/views/work/process/leave/detail')
   }]
-}]
+},{
+  path: '/viewTab',
+  component: Layout,
+  redirect: '/viewTab/index',
+  children: [{
+    path: 'index',
+    name: '鏌ョ湅璇︽儏',
+    meta: {
+      i18n: 'viewTab'
+    },
+    component: () =>
+      import('@/views/base/ViewTab')
+  }]
+} ]
diff --git a/Source/plt-web/plt-web-ui/src/store/index.js b/Source/plt-web/plt-web-ui/src/store/index.js
index bb38457..cbeb5d1 100644
--- a/Source/plt-web/plt-web-ui/src/store/index.js
+++ b/Source/plt-web/plt-web-ui/src/store/index.js
@@ -7,6 +7,7 @@
 import dict from './modules/dict'
 import getters from './getters'
 import flow from './modules/LifeFlow'
+import { setStore } from "@/util/store.js";
 
 Vue.use(Vuex)
 const store = new Vuex.Store({
@@ -19,6 +20,25 @@
     flow
   },
   getters,
+  state: {
+    viewtabparams:undefined, //鏌ョ湅tab Action鍙傛暟
+  },
+  mutations: {
+    // 瑙勭▼璇︽儏鍙傛暟
+    getViewtabparams(state, obj) {
+      state.viewtabparams = obj;
+    },
+  },
+  actions: {
+    setViewtabparams({ commit }, obj){
+      commit("getViewtabparams", obj);
+      setStore({
+        name:'viewtabparams',
+        content:obj,
+        type:'session'
+      });
+    }
+  }
 })
 
 export default store
diff --git a/Source/plt-web/plt-web-ui/src/views/base/ViewTab.vue b/Source/plt-web/plt-web-ui/src/views/base/ViewTab.vue
new file mode 100644
index 0000000..b948b58
--- /dev/null
+++ b/Source/plt-web/plt-web-ui/src/views/base/ViewTab.vue
@@ -0,0 +1,67 @@
+<template>
+  <!--Action 鏌ョ湅Tab鐨勫疄鐜�-->
+  <component :is="currentComponent"
+             ref="uiViewRef"
+             key="ViewTab"
+             :btmType="paramVOS.type"
+             :context="paramVOS.context"
+             :inDialog="false"
+             :canEdit="false"
+             actionType="view"
+             :sourceData="sourceData"
+             :dataStore="dataStore"
+             :paramVOS="paramVOS"></component>
+</template>
+
+<script>
+import {validatenull} from "@/util/validate";
+import { getStore } from "@/util/store.js";
+
+export default {
+  name: "ViewTab",
+  components:{},
+  data(){
+    return {
+      sourceData:{},
+      dataStore:[],
+      paramVOS:{},
+      currentComponent: null,
+    }
+  },
+  computed:{
+    title(){
+      return this.paramVOS.title || "鏌ョ湅璇︽儏"
+    }
+  },
+  created() {
+    let config = {};
+    if (!validatenull(this.$store.state.viewtabparams)) {
+      config = this.$store.state.viewtabparams;
+    } else {
+      config = getStore('viewtabparams');
+    }
+    this.sourceData = config.options.sourceData;
+    this.dataStore = config.options.dataStore;
+    this.paramVOS = config.paramVOS;
+  },
+  mounted() {
+    this.loadCompoent();
+  },
+  methods: {
+    loadCompoent(){
+      // 鍔ㄦ�佸鍏ョ粍浠�
+      import(`@/views/${this.paramVOS.component}.vue`).then((module) => {
+        // 鎴愬姛瀵煎叆鍚庯紝灏嗙粍浠舵敞鍐屽埌Vue瀹炰緥涓�
+        this.currentComponent = module.default;
+      }).catch((error) => {
+        // 澶勭悊瀵煎叆澶辫触鐨勬儏鍐�
+        console.log('缁勪欢鍔犺浇澶辫触:', error);
+      });
+    }
+  }
+}
+</script>
+
+<style scoped>
+
+</style>

--
Gitblit v1.9.3