From cc80ef9656d4144ca6255d2a7dcbb19816888166 Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期四, 10 十月 2024 16:23:18 +0800
Subject: [PATCH] ui定义克隆功能

---
 Source/plt-web/plt-web-ui/src/views/modelingMenu/ui/uiDefine/rightRegion/cloneDialog.vue |  155 ++++++++++++++++++++++++++++-----------------------
 1 files changed, 85 insertions(+), 70 deletions(-)

diff --git a/Source/plt-web/plt-web-ui/src/views/modelingMenu/ui/uiDefine/rightRegion/cloneDialog.vue b/Source/plt-web/plt-web-ui/src/views/modelingMenu/ui/uiDefine/rightRegion/cloneDialog.vue
index bc6767a..ba6cc76 100644
--- a/Source/plt-web/plt-web-ui/src/views/modelingMenu/ui/uiDefine/rightRegion/cloneDialog.vue
+++ b/Source/plt-web/plt-web-ui/src/views/modelingMenu/ui/uiDefine/rightRegion/cloneDialog.vue
@@ -1,16 +1,16 @@
 <template>
   <el-dialog v-dialogDrag
+             :append-to-body="true"
+             :close-on-click-modal="false"
+             :destroy-on-close="true"
              :title="dialog.title"
              :visible.sync="dialog.showDialog"
-             width="1200px"
-             :append-to-body="true"
              class="avue-dialog"
-             :destroy-on-close="true"
-             :close-on-click-modal="false"
+             width="1200px"
              @close="cancelDialog">
     <el-container style="height: 580px">
       <el-aside style="width: 380px">
-        <basic-container style="height: 530px">
+        <basic-container v-loading="leftLoading" style="height: 530px">
           <h3 style="margin: 0 0 10px 0">涓氬姟绫诲瀷</h3>
           <div style="height: 435px">
             <avue-tree ref="tree" :data="treeData" :option="treeOption" @node-click="nodeClick">
@@ -25,9 +25,9 @@
       </el-aside>
 
       <el-main>
-        <basic-container style="height: 530px">
-          <div style="height: 520px;">
-            <avue-tree ref="uiTree" :data="uiTreeData" :option="uiTreeOption">
+        <basic-container v-loading="rightLoading" style="height: 530px">
+          <div style="height: 490px;">
+            <avue-tree ref="uiTree" :data="uiTreeData" :option="uiTreeOption" @check-change="checkChange">
               <span slot-scope="{ node, data }" class="el-tree-node__label">
                 <span style="font-size: 15px">
                   <i :class="data.icon"></i>
@@ -40,7 +40,7 @@
       </el-main>
     </el-container>
     <div class="dialog-footer avue-dialog__footer">
-      <el-button type="primary" plain size="small" @click="submitDialog" >淇� 瀛�</el-button>
+      <el-button plain size="small" type="primary" @click="submitDialog">淇� 瀛�</el-button>
       <el-button size="small" @click="cancelDialog">鍙� 娑�</el-button>
     </div>
   </el-dialog>
@@ -48,12 +48,15 @@
 
 <script>
 import {getUIAuthor} from "@/api/authority/ui/uiAuthor";
-import {getBizTree} from "@/api/UI/uiDefine";
+import {getBizTree, getAllLevelTreeByBtm, clonePageDef, clonetabPage, cloneTabButton} from "@/api/UI/uiDefine";
 
 export default {
-name: "cloneDialog",
-  data(){
+  name: "cloneDialog",
+  props: ['fromOid', 'type', 'sourceOId','paramsType'],
+  data() {
     return {
+      leftLoading: false,
+      rightLoading: false,
       dialog: {
         showDialog: false,
         title: "鍏嬮殕鐩爣",
@@ -71,17 +74,17 @@
       },
       nodeRow: {},
       treeData: [],
-      defaultExpandKeys:[],
+      defaultExpandKeys: [],
       uiTreeOption: {
-        nodeKey:'oid',
-        checkOnClickNode:true,
-        defaultExpandedKeys:this.defaultExpandKeys,
-        multiple: true,
+        nodeKey: 'oid',
+        checkOnClickNode: true,
+        defaultExpandedKeys: [],
+        multiple: false,
         menu: false,
         addBtn: false,
-        filter:false,
+        filter: false,
         props: {
-          label: 'label',
+          label: 'text',
           value: 'oid',
           children: 'children'
         }
@@ -90,84 +93,96 @@
     };
   },
   methods: {
-    openDialog( data) {
+    openDialog(data) {
       this.dialog.showDialog = true;
       this.getTreeList()
-      this.uiTreeData=[];
+      this.uiTreeData = [];
     },
     cancelDialog() {
       this.dialog.loading = false;
       this.dialog.showDialog = false;
     },
     submitDialog() {
-      linkSave({}).then(res => {
-        if (res.data.success) {
-          this.$message.success("鍏嬮殕鎴愬姛");
-          this.cancelDialog();
-          this.$emit("refresh");
+      const node = this.$refs.uiTree.getCurrentNode();
+      console.log(node);
+      if (!node.leaf) {
+        this.$message.error('璇烽�夋嫨鏈�涓嬪眰瀛愯妭鐐硅繘琛屽厠闅�');
+        return;
+      }
+      let params = {};
+      if (node) {
+        params = {
+          fromOid: this.fromOid,
+          toOid: node.oid,
+          cloneParam: {
+            sourceOId: this.sourceOId
+          }
         }
-      });
+      }
+      console.log(params);
+      const saveFunction = {
+        'pageDef': clonePageDef,
+        'tabPage': clonetabPage,
+        'tabButton': cloneTabButton
+      };
+      saveFunction[this.type](params).then(res => {
+        if(res.data.code == 200){
+          this.$message.success(res.data.obj);
+          this.cancelDialog();
+        }
+      })
     },
     getTreeList() {
-      const loading = this.$loading({});
+      this.leftLoading = true;
       getBizTree().then(res => {
-        this.treeData =res.data.obj.children;
-        loading.close();
-      }).catch(error=>{
-        loading.close();
+        this.treeData = res.data.obj.children;
+        this.leftLoading = false;
+      }).catch(error => {
+        this.leftLoading = false;
       })
     },
     // 瑙掕壊鐐瑰嚮
-    nodeClick(row,node) {
+    nodeClick(row, node) {
       this.nodeRow = row;
-      const loading = this.$loading({});
+      this.rightLoading = true;
       const params = {
-        'conditionMap[roleId]': this.nodeRow.oid,
-        'conditionMap[type]': this.type,
-        'conditionMap[context]': this.context
+        btmName: this.nodeRow.attributes.name,
+        level: this.paramsType
       }
-      this.defaultExpandKeys=['root'];
-      getUIAuthor(params).then(res => {
-        this.processChildren(res.data.data[0]); // 澶勭悊姣忎釜鑺傜偣
-        this.uiTreeOption.defaultExpandedKeys=this.defaultExpandKeys;
-        this.uiTreeData = [{
-          attributes: {},
-          checked: false,
-          expanded: true,
-          data: "root",
-          level: 0,
-          icon: 'el-icon-s-home',
-          oid: res.data.data[0].oid,
-          label: 'UI涓婁笅鏂囬�夐」',
-          children: res.data.data[0].children
-        }];
-        loading.close();
+      this.defaultExpandKeys = ['root'];
+      console.log(row);
+      getAllLevelTreeByBtm(params).then(res => {
+        this.uiTreeOption.defaultExpandedKeys = [res.data.obj.oid];
+        this.uiTreeData = [res.data.obj];
+        console.log(res);
+        this.rightLoading = false;
       }).catch(error => {
-        loading.close();
+        this.rightLoading = false;
       })
     },
+
     //澶勭悊鏍�
     processChildren(item) {
       if (item.children && item.children.length > 0) {
         item.children = item.children.map(child => {
-          if(child.level<4){
+          if (child.level < 4) {
             this.defaultExpandKeys.push(child.oid)
           }
-          if(child.level==1){
-            child.icon='el-icon-s-promotion';
-            child.label=child.data.label+'('+child.data.name+')'
-          }else if(child.level==2){
-            child.icon='el-icon-s-order';
-            child.label=child.text
-          }else if(child.level==3){
-            child.icon='el-icon-office-building';
-            child.label=child.text
-          }else if(child.level==4){
-            child.icon='el-icon-document';
-            child.label=child.text
-          }else if(child.level==5){
-            child.icon='el-icon-s-tools';
-            child.label=child.text
+          if (child.level == 1) {
+            child.icon = 'el-icon-s-promotion';
+            child.label = child.data.label + '(' + child.data.name + ')'
+          } else if (child.level == 2) {
+            child.icon = 'el-icon-s-order';
+            child.label = child.text
+          } else if (child.level == 3) {
+            child.icon = 'el-icon-office-building';
+            child.label = child.text
+          } else if (child.level == 4) {
+            child.icon = 'el-icon-document';
+            child.label = child.text
+          } else if (child.level == 5) {
+            child.icon = 'el-icon-s-tools';
+            child.label = child.text
           }
           this.processChildren(child); // 閫掑綊澶勭悊姣忎釜瀛愯妭鐐�
           return child; // 鍙繑鍥炲瓙鑺傜偣鐨� attributes

--
Gitblit v1.9.3