From 69a1b3bf45738f048361ee4ccb6bdc64fce35720 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期三, 12 三月 2025 11:31:46 +0800
Subject: [PATCH] 更新

---
 admin/src/components/system/role/OperaSystemRoleDataWindow.vue |  205 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 205 insertions(+), 0 deletions(-)

diff --git a/admin/src/components/system/role/OperaSystemRoleDataWindow.vue b/admin/src/components/system/role/OperaSystemRoleDataWindow.vue
new file mode 100644
index 0000000..1f81396
--- /dev/null
+++ b/admin/src/components/system/role/OperaSystemRoleDataWindow.vue
@@ -0,0 +1,205 @@
+<template>
+  <GlobalWindow :title="title" width="80%" :visible.sync="visible" :confirm-working="isWorking" @confirm="confirm">
+    <p class="tip">姝e湪涓鸿鑹层�� <em>{{ role.name || '-' }}</em>銆� 閰嶇疆鏁版嵁鏉冮檺</p>
+    <p class="tip-warn"><i class="el-icon-warning"></i>鎻愰啋锛氭潈闄愰厤缃悗闇�閲嶆柊鐧诲綍鍚庣敓鏁�</p>
+    <el-form :model="form" ref="form" style="margin-top:15px">
+      <el-form-item label="鏉冮檺绫诲瀷锛�" prop="type">
+        <el-select v-model="form.type" clearable filterable placeholder="璇烽�夋嫨鏉冮檺绫诲瀷">
+          <el-option v-for="(item, index) in options" :key="index" :label="item.name" :value="item.id">
+          </el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item v-if="form.type == 4" label="鑷畾涔夐儴闂細" prop="customData">
+        <el-cascader :options="departments" v-model="form.customData" :props=defaultProps clearable></el-cascader>
+      </el-form-item>
+
+    </el-form>
+  </GlobalWindow>
+</template>
+
+<script>
+import BaseOpera from '@/components/base/BaseOpera'
+import GlobalWindow from '@/components/common/GlobalWindow'
+import { createRoleDataPermission } from '@/api/system/role'
+import { fetchList } from '@/api/business/company'
+// import the styles
+import '@riophae/vue-treeselect/dist/vue-treeselect.css'
+export default {
+  name: 'OperaSystemRoleWindow',
+  extends: BaseOpera,
+  components: { GlobalWindow },
+  data() {
+    return {
+      options: [
+        { name: '鍏ㄩ儴', id: 0 },
+        { name: '鎵�灞為儴闂ㄥ強涓嬪睘閮ㄩ棬', id: 1 },
+        { name: '鎵�灞為儴闂ㄥ強鍏跺瓙瀛欓儴闂�', id: 2 },
+        { name: '浠呮墍灞為儴闂�', id: 3 },
+        { name: '鑷畾涔夐儴闂�', id: 4 },
+        { name: '鍙湅鑷繁', id: -1 },
+      ],
+      // 琛ㄥ崟鏁版嵁
+      form: {
+        businessCode: null,
+        createTime: null,
+        createUser: null,
+        customData: [],
+        id: null,
+        roleId: null,
+        type: 0
+      },
+      defaultProps: {
+        multiple: true,
+        checkStrictly: true,
+        // children: 'children',
+        label: 'name',
+        value: 'id',
+        emitPath: false
+      },
+      role: {},
+      departments: []
+    }
+  },
+  created() {
+    this.config({
+      api: '/system/role',
+      'field.id': 'id'
+    })
+    this.treeComList()
+  },
+  methods: {
+    // 閮ㄩ棬鏍戠姸缁撴瀯鏁版嵁
+    treeComList() {
+      fetchList()
+        .then(res => {
+          // this.departments = this.tree([res])
+          this.departments = this.newTree(res)
+        })
+    },
+    open(title, target, role) {
+      // console.log(title, target)
+      this.title = title
+      this.visible = true
+      this.role = role
+      // 鏂板缓
+      if (target == null) {
+        this.$nextTick(() => {
+          this.$refs.form.resetFields()
+          this.form[this.configData['field.id']] = null
+        })
+        return
+      }
+      // 缂栬緫
+      this.$nextTick(() => {
+        for (const key in this.form) {
+          this.form[key] = target[key]
+        }
+        console.log(target)
+        if (target.customData === undefined || target.customData === null || target.customData === '') {
+          this.form.customData = []
+        } else {
+          const customD = this.form.customData.split(',')
+          this.form.customData = customD.map((item) => { return parseInt(item) })
+        }
+      })
+    },
+    newTree(tree) {
+      if (tree == null) {
+        return []
+      }
+      return tree.map(item => {
+        let newItem = { ...item }
+        if (newItem) {
+          newItem.children = newItem.childList
+        }
+        if (item.children && item.children.length == 0) {
+          this.$delete(newItem, 'children')
+        } else {
+          newItem.children = this.newTree(newItem.children)
+        }
+        return newItem
+      })
+    },
+    __confirmCreate() {
+      // console.log(JSON.stringify(this.form.customData));
+      // return
+      this.$refs.form.validate((valid) => {
+        if (!valid) {
+          return
+        }
+
+        this.isWorking = true
+        let data = JSON.parse(JSON.stringify(this.form))
+        if (this.form.type === 4) {
+          data.customData = this.form.customData.join(',')
+        } else {
+          data.customData = ''
+        }
+        createRoleDataPermission(data)
+          .then(() => {
+            this.visible = false
+            this.$tip.apiSuccess('鏂板缓鎴愬姛')
+            this.$emit('success')
+          })
+          .catch(e => {
+            this.$tip.apiFailed(e)
+          })
+          .finally(() => {
+            this.isWorking = false
+          })
+      })
+    },
+    __confirmEdit() {
+      // console.log(JSON.stringify(this.form.customData));
+      // return
+      this.$refs.form.validate((valid) => {
+        if (!valid) {
+          return
+        }
+        // 璋冪敤鏇存柊鎺ュ彛
+        this.isWorking = true
+        let data = JSON.parse(JSON.stringify(this.form))
+        if (this.form.type === 4) {
+          data.customData = this.form.customData.join(',')
+        } else {
+          data.customData = ''
+        }
+        createRoleDataPermission(data)
+          .then(() => {
+            this.visible = false
+            this.$tip.apiSuccess('淇敼鎴愬姛')
+            this.$emit('success')
+          })
+          .catch(e => {
+            this.$tip.apiFailed(e)
+          })
+          .finally(() => {
+            this.isWorking = false
+          })
+      })
+    }
+  }
+}
+</script>
+<style scoped lang="scss">
+.transfer {
+  height: 600px;
+  width: 100%;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+
+  ::v-deep .el-transfer-panel {
+    flex: 1;
+    height: 100%;
+  }
+
+  ::v-deep .el-transfer-panel__body {
+    height: 500px;
+  }
+
+  ::v-deep .el-transfer-panel__list.is-filterable {
+    height: 480px;
+  }
+}
+</style>

--
Gitblit v1.9.3