From 5506edbe54883b31db3cc8e4a1d9d0795a18a3c9 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 27 十二月 2024 14:37:54 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/2.0.1' into 2.0.1

---
 company/src/components/system/role/Permissions.vue |  127 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 127 insertions(+), 0 deletions(-)

diff --git a/company/src/components/system/role/Permissions.vue b/company/src/components/system/role/Permissions.vue
new file mode 100644
index 0000000..d7bed0a
--- /dev/null
+++ b/company/src/components/system/role/Permissions.vue
@@ -0,0 +1,127 @@
+<template>
+    <GlobalWindow
+        :title="title"
+        :visible.sync="visible"
+        :confirm-working="isWorking"
+        @confirm="confirm"
+    >
+        <el-form :model="form" ref="form" :rules="rules">
+            <el-form-item label="鏉冮檺绫诲瀷" prop="type">
+                <el-select v-model="form.type" @change="form.customData === []" placeholder="璇烽�夋嫨">
+                    <el-option
+                        v-for="item in options"
+                        :key="item.value"
+                        :label="item.label"
+                        :value="item.value">
+                    </el-option>
+                </el-select>
+            </el-form-item>
+            <el-form-item label="鑷畾涔夐儴闂�" prop="customData" v-if="form.type === 4">
+                <el-cascader
+                    :options="organization"
+                    v-model="form.customData"
+                    placeholder="璇烽�夋嫨涓婄骇缁勭粐"
+                    :props="{ label: 'name', value: 'id', multiple: true, checkStrictly: true }"
+                    clearable />
+            </el-form-item>
+        </el-form>
+    </GlobalWindow>
+</template>
+
+<script>
+  import BaseOpera from '@/components/base/BaseOpera'
+  import GlobalWindow from '@/components/common/GlobalWindow'
+  import { tree } from '@/api/business/companyDepartment'
+  import { createRoleDataPermission } from '@/api/system/role'
+  export default {
+    name: 'Permissions',
+    extends: BaseOpera,
+    components: { GlobalWindow },
+    data () {
+      return {
+        // 琛ㄥ崟鏁版嵁
+        form: {
+          roleId: null,
+          type: '',
+          customData: []
+        },
+        // 楠岃瘉瑙勫垯
+        rules: {
+          type: [
+            { required: true, message: '璇烽�夋嫨鏉冮檺绫诲瀷' }
+          ],
+          customData: [
+            { required: true, message: '璇烽�夋嫨閮ㄩ棬' }
+          ]
+        },
+        organization: [],
+        options: [
+          { label: '鍏ㄩ儴', value: 0 },
+          { label: '鎵�灞為儴闂ㄥ強涓嬪睘閮ㄩ棬', value: 1 },
+          { label: '鎵�灞為儴闂ㄥ強鍏跺瓙瀛欓儴闂�', value: 2 },
+          { label: '浠呮墍灞為儴闂�', value: 3 },
+          { label: '鑷畾涔夐儴闂�', value: 4 },
+          { label: '浠呰嚜宸�', value: -1 }
+        ]
+      }
+    },
+    methods: {
+      confirm () {
+        this.$refs.form.validate((valid) => {
+          if (!valid) {
+            return
+          }
+          this.isWorking = true
+          let obj = JSON.parse(JSON.stringify(this.form))
+          if (obj.customData.length > 0) {
+            obj.customData = obj.customData.flat().join(',')
+          } else {
+            obj.customData = ''
+          }
+          createRoleDataPermission(obj)
+            .then(() => {
+              this.visible = false
+              this.$tip.apiSuccess('鎿嶄綔鎴愬姛')
+              this.$emit('success')
+            })
+            .catch(e => {
+              this.$tip.apiFailed(e)
+            })
+            .finally(() => {
+              this.isWorking = false
+            })
+        })
+      },
+      getTree() {
+        tree()
+          .then(records => {
+            this.organization = records
+          })
+      },
+      open (title, target) {
+        this.title = title
+        this.visible = true
+        this.getTree()
+        // 鏂板缓
+        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]
+          }
+        })
+      }
+    },
+    created () {
+      this.config({
+        api: '/system/role'
+      })
+    }
+  }
+</script>

--
Gitblit v1.9.3