From ba77fdc6a30c9ad0941e40319f8c4f6fe6fdf9f1 Mon Sep 17 00:00:00 2001
From: cuilei <ray_tsu1@163.com>
Date: 星期四, 07 八月 2025 10:30:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/views/mdc/base/modules/deviceCalendar/DeviceCalendarAddTree.vue |  256 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 256 insertions(+), 0 deletions(-)

diff --git a/src/views/mdc/base/modules/deviceCalendar/DeviceCalendarAddTree.vue b/src/views/mdc/base/modules/deviceCalendar/DeviceCalendarAddTree.vue
new file mode 100644
index 0000000..fb238f0
--- /dev/null
+++ b/src/views/mdc/base/modules/deviceCalendar/DeviceCalendarAddTree.vue
@@ -0,0 +1,256 @@
+<template>
+  <div>
+
+
+  <a-drawer
+    :title="title"
+    :maskClosable="true"
+    width=650
+    placement="right"
+    :closable="true"
+    @close="close"
+    :visible="visible"
+    style="overflow: auto;padding-bottom: 53px;">
+
+    <a-form>
+      <a-form-item label='鎵�鎷ユ湁鐨勬潈闄�'>
+        <a-tree
+          checkable
+          @check="onCheck"
+          :checkedKeys="checkedKeys"
+          :treeData="treeData"
+          @expand="onExpand"
+          @select="onTreeNodeSelect"
+          :selectedKeys="selectedKeys"
+          :expandedKeys="expandedKeysss"
+          :checkStrictly="checkStrictly">
+          <span slot="hasDatarule" slot-scope="{slotTitle,ruleFlag}">
+            {{ slotTitle }}<a-icon v-if="ruleFlag" type="align-left" style="margin-left:5px;color: red;"></a-icon>
+          </span>
+        </a-tree>
+      </a-form-item>
+    </a-form>
+
+    <!--<div class="drawer-bootom-button">-->
+      <!--<a-dropdown style="float: left" :trigger="['click']" placement="topCenter">-->
+        <!--<a-menu slot="overlay">-->
+          <!--<a-menu-item key="1" @click="switchCheckStrictly(1)">鐖跺瓙鍏宠仈</a-menu-item>-->
+          <!--<a-menu-item key="2" @click="switchCheckStrictly(2)">鍙栨秷鍏宠仈</a-menu-item>-->
+          <!--<a-menu-item key="3" @click="checkALL">鍏ㄩ儴鍕鹃��</a-menu-item>-->
+          <!--<a-menu-item key="4" @click="cancelCheckALL">鍙栨秷鍏ㄩ��</a-menu-item>-->
+          <!--<a-menu-item key="5" @click="expandAll">灞曞紑鎵�鏈�</a-menu-item>-->
+          <!--<a-menu-item key="6" @click="closeAll">鍚堝苟鎵�鏈�</a-menu-item>-->
+        <!--</a-menu>-->
+        <!--<a-button>-->
+          <!--鏍戞搷浣� <a-icon type="up" />-->
+        <!--</a-button>-->
+      <!--</a-dropdown>-->
+      <!--<a-popconfirm title="纭畾鏀惧純缂栬緫锛�" @confirm="close" okText="纭畾" cancelText="鍙栨秷">-->
+        <!--<a-button style="margin-right: .8rem">鍙栨秷</a-button>-->
+      <!--</a-popconfirm>-->
+      <!--<a-button @click="handleSubmit(false)" type="primary" :loading="loading" ghost style="margin-right: 0.8rem">浠呬繚瀛�</a-button>-->
+      <!--<a-button @click="handleSubmit(true)" type="primary" :loading="loading">淇濆瓨骞跺叧闂�</a-button>-->
+    <!--</div>-->
+
+    <!--<role-datarule-modal ref="datarule"></role-datarule-modal>-->
+
+  </a-drawer>
+  </div>
+</template>
+<script>
+  // import {queryTreeListForRole,queryRolePermission,saveRolePermission} from '@/api/api'
+  // import RoleDataruleModal from './RoleDataruleModal.vue'
+  import {
+    getAction,
+    postAction,
+    requestPut
+  } from '@/api/manage'
+  export default {
+    name: "DeviceCalendarAddTree",
+    components:{
+      // RoleDataruleModal
+    },
+    data(){
+      return {
+        roleId:"",
+        treeData: [],
+        defaultCheckedKeys:[],
+        checkedKeys:[],
+        expandedKeysss:[],
+        allTreeKeys:[],
+        autoExpandParent: true,
+        checkStrictly: true,
+        title:"瑙掕壊鏉冮檺閰嶇疆",
+        visible: false,
+        loading: false,
+        selectedKeys:[],
+        url: {
+          getBaseTree: '/mdc/mdcequipment/loadTree',
+          deleteBatch: '/mdc/mdcequipment/deleteBatch'
+        },
+      }
+    },
+    created(){
+      this.queryTreeData()
+    },
+    methods: {
+      queryTreeData() {
+        this.loading = true
+        this.cardLoading = true
+        getAction(this.url.getBaseTree).then((res) => {
+          if (res.success) {
+            this.dataList = []
+            this.allTreeKeys = []
+            this.treeDataSource = res.result
+            this.generateList(res.result)
+          } else {
+            // this.$message.warn(res.message)
+            this.$notification.warning({
+              message:'娑堟伅',
+              description:res.message
+            });
+          }
+        }).finally(() => {
+          this.loading = false
+          this.cardLoading = false
+        })
+      },
+      generateList(data) {
+        for (let i = 0; i < data.length; i++) {
+          const node = data[i]
+          const key = node.key
+          const title = node.title
+          this.dataList.push({
+            key,
+            title: title
+          })
+          this.allTreeKeys.push(key)
+          if (node.children) {
+            this.generateList(node.children)
+          }
+        }
+      },
+      onTreeNodeSelect(id){
+        if(id && id.length>0){
+          this.selectedKeys = id
+        }
+        this.$refs.datarule.show(this.selectedKeys[0],this.roleId)
+      },
+      onCheck (o) {
+        if(this.checkStrictly){
+          this.checkedKeys = o.checked;
+        }else{
+          this.checkedKeys = o
+        }
+      },
+      show(roleId){
+        this.roleId=roleId
+        this.visible = true;
+      },
+      close () {
+        this.reset()
+        this.$emit('close');
+        this.visible = false;
+      },
+      onExpand(expandedKeys){
+        this.expandedKeysss = expandedKeys;
+        this.autoExpandParent = false
+      },
+      reset () {
+        this.expandedKeysss = []
+        this.checkedKeys = []
+        this.defaultCheckedKeys = []
+        this.loading = false
+      },
+      expandAll () {
+        this.expandedKeysss = this.allTreeKeys
+      },
+      closeAll () {
+        this.expandedKeysss = []
+      },
+      checkALL () {
+        this.checkedKeys = this.allTreeKeys
+      },
+      cancelCheckALL () {
+        //this.checkedKeys = this.defaultCheckedKeys
+        this.checkedKeys = []
+      },
+      switchCheckStrictly (v) {
+        if(v==1){
+          this.checkStrictly = false
+        }else if(v==2){
+          this.checkStrictly = true
+        }
+      },
+      handleCancel () {
+        this.close()
+      },
+      handleSubmit(exit) {
+        let that = this;
+        let params =  {
+          roleId:that.roleId,
+          permissionIds:that.checkedKeys.join(","),
+          lastpermissionIds:that.defaultCheckedKeys.join(","),
+        };
+        that.loading = true;
+        saveRolePermission(params).then((res)=>{
+          if(res.success){
+            // that.$message.success(res.message);
+            that.$notification.warning({
+              message:'娑堟伅',
+              description:res.message
+            });
+            that.loading = false;
+            if (exit) {
+              that.close()
+            }
+          }else {
+            // that.$message.error(res.message);
+            that.$notification.error({
+              message:'娑堟伅',
+              description:res.message
+            });
+            that.loading = false;
+            if (exit) {
+              that.close()
+            }
+          }
+          this.loadData();
+        })
+      },
+      loadData(){
+        queryTreeListForRole().then((res) => {
+          this.treeData = res.result.treeList
+          this.allTreeKeys = res.result.ids
+          queryRolePermission({roleId:this.roleId}).then((res)=>{
+            this.checkedKeys = [...res.result];
+            this.defaultCheckedKeys = [...res.result];
+            this.expandedKeysss = this.allTreeKeys;
+          })
+        })
+      }
+    },
+    watch: {
+      visible () {
+        if (this.visible) {
+          this.loadData();
+        }
+      }
+    }
+  }
+
+</script>
+<style lang="less" scoped>
+  .drawer-bootom-button {
+    position: absolute;
+    bottom: 0;
+    width: 100%;
+    border-top: 1px solid #e8e8e8;
+    padding: 10px 16px;
+    text-align: right;
+    left: 0;
+    background: #fff;
+    border-radius: 0 0 2px 2px;
+  }
+
+</style>
\ No newline at end of file

--
Gitblit v1.9.3