Quellcode durchsuchen

系统管理-部门设置做数据过滤

linweizeng vor 2 Jahren
Ursprung
Commit
081d2b9348
2 geänderte Dateien mit 401 neuen und 390 gelöschten Zeilen
  1. 248 237
      src/views/platform/org/position/manage.vue
  2. 153 153
      src/views/platform/org/position/move-node.vue

+ 248 - 237
src/views/platform/org/position/manage.vue

@@ -1,68 +1,68 @@
 <template>
-  <ibps-layout ref="layout">
-    <div slot="west">
-      <ibps-tree
-        ref="tree"
-        :width="width"
-        :height="height"
-        :options="orgTreeoptions"
-        :contextmenus="orgTreeContextmenus"
-        :load="loadNode"
-        lazy
-        title="部门管理"
-        @action-event="handleTreeAction"
-        @node-click="handleNodeClick"
-        @expand-collapse="handleExpandCollapse"
-      />
-      <ibps-container
-        :margin-left="width+'px'"
-        class="page"
-      >
-        <detail
-          v-if="show==='detail'"
-          :id="positionId"
-          :readonly="readonly"
-        />
-        <edit
-          v-else-if="show==='edit'"
-          :id="positionId"
-          :level-id="levelId"
-          :parent-id="parentId"
-          @callback="loadTreeData"
-        />
+    <ibps-layout ref="layout">
+        <div slot="west">
+            <ibps-tree
+                ref="tree"
+                :width="width"
+                :height="height"
+                :options="orgTreeoptions"
+                :contextmenus="orgTreeContextmenus"
+                :load="loadNode"
+                lazy
+                title="部门管理"
+                @action-event="handleTreeAction"
+                @node-click="handleNodeClick"
+                @expand-collapse="handleExpandCollapse"
+            />
+            <ibps-container
+                :margin-left="width+'px'"
+                class="page"
+            >
+                <detail
+                    v-if="show==='detail'"
+                    :id="positionId"
+                    :readonly="readonly"
+                />
+                <edit
+                    v-else-if="show==='edit'"
+                    :id="positionId"
+                    :level-id="levelId"
+                    :parent-id="parentId"
+                    @callback="loadTreeData"
+                />
 
-        <edit-position
-          v-else-if="show==='addPosition'"
-          @callback="callback"
-        />
+                <edit-position
+                    v-else-if="show==='addPosition'"
+                    @callback="callback"
+                />
 
-        <el-alert
-          v-else
-          :closable="false"
-          title="尚未指定一个部门"
-          type="warning"
-          show-icon
-          style="height:50px;"
-        />
-      </ibps-container>
+                <el-alert
+                    v-else
+                    :closable="false"
+                    title="尚未指定一个部门"
+                    type="warning"
+                    show-icon
+                    style="height:50px;"
+                />
+            </ibps-container>
 
-      <move-node
-        :id="positionId"
-        :visible="moveNodeVisible"
-        :data="orgTreeData"
-        @callback="loadTreeData"
-        @close="visible => moveNodeVisible = visible"
-      />
-      <!--节点排序-->
-      <node-sort
-        :data="sortData"
-        :visible="nodeSortVisible"
-        title="岗位排序"
-        @close="visible => nodeSortVisible = visible"
-        @callback="search"
-      />
-    </div>
-  </ibps-layout>
+            <move-node
+                :id="positionId"
+                :visible="moveNodeVisible"
+                :data="orgTreeData"
+                @callback="loadTreeData"
+                @close="visible => moveNodeVisible = visible"
+            />
+            <!--节点排序-->
+            <node-sort
+                :data="sortData"
+                :visible="nodeSortVisible"
+                title="岗位排序"
+                @close="visible => nodeSortVisible = visible"
+                @callback="search"
+            />
+        </div>
+    </ibps-layout>
 </template>
 <script>
 import { remove } from '@/api/platform/org/position'
@@ -76,187 +76,198 @@ import MoveNode from './move-node'
 import NodeSort from './sort'
 
 export default {
-  components: {
-    Detail,
-    Edit,
-    MoveNode,
-    NodeSort
-  },
-  mixins: [FixHeight],
-  data() {
-    return {
-      show: '',
-      width: 230,
-      height: document.clientHeight,
-      positionId: '',
-      levelId: '',
-      editName: '',
-      // 移动节点
-      settingGradeAdminVisible: false,
-      moveNodeVisible: false,
-      // 节点排序
-      sortData: [],
-      nodeSortVisible: false,
-
-      // 组织树配置
-      orgTreeoptions: {
-        'default-expand-all': false,
-        'expand-on-click-node': false,
-        'default-expanded-keys': ['0'],
-        props: {
-          children: 'children',
-          label: 'name'
-        }},
-      orgTreeContextmenus: [
-        { icon: 'add', label: '添加', value: 'add' },
-        { icon: 'edit', label: '编辑', value: 'edit', rights: ['node'] },
-        { icon: 'remove', label: '删除', value: 'remove', rights: ['node'] },
-        { type: 'divided', rights: ['node'] },
-        { icon: 'arrows-v', label: '移动节点', value: 'moveNode', rights: ['node'] },
-        { type: 'divided' },
-        { icon: 'sort', label: '节点排序', value: 'nodeSort' }
-      ],
-      orgTreeData: []
-    }
-  },
-  methods: {
-    loadNode(node, resolve) {
-      this.loading = true
-      getTreeData({
-        type: 1,
-        posId: node.level === 0 ? null : node.data.id
-      }).then(res => {
-        let data = res.data
-        //岗位树改成部门树
-        data.forEach((item) => {
-            if (item.name === '岗位树') {
-                item.name = '部门树'
-            }
-        })
-        this.loading = false
-        resolve(this.toTree(res.data))
-      }).catch(res => {
-        this.loading = false
-        resolve([])
-      })
-    },
-    toTree(data) {
-      return TreeUtils.transformToTreeFormat(data, {
-        idKey: 'id',
-        pIdKey: 'parentId',
-        childrenKey: 'children'
-      })
-    },
-    refreshTree() {
-      this.parentId = '0'
-      this.search()
-    },
-    // 返回右明细模块未显示
-    back() {
-      this.positionId = ''
-      this.show = 'detail'
-    },
-    // 获取ID后显示右明细模块
-    showDetail() {
-      this.positionId = this.gainId
-      this.show = 'detail'
+    components: {
+        Detail,
+        Edit,
+        MoveNode,
+        NodeSort
     },
+    mixins: [FixHeight],
+    data () {
+        return {
+            show: '',
+            width: 230,
+            height: document.clientHeight,
+            positionId: '',
+            levelId: '',
+            editName: '',
+            // 移动节点
+            settingGradeAdminVisible: false,
+            moveNodeVisible: false,
+            // 节点排序
+            sortData: [],
+            nodeSortVisible: false,
 
-    handleTreeAction(command, position, selection, data) {
-      if (position === 'toolbar') {
-        if (command === 'refresh') {
-          this.refreshTree()
-        }
-      } else {
-        const id = data.id
-        switch (command) {
-        // 组织负责人
-          case 'add':// 添加
-            this.handleEdit('', id)
-            break
-          case 'edit':// 编辑
-            this.levelId = data.levelID
-            this.handleEdit(id)
-            break
-          case 'remove':// 删除
-            ActionUtils.removeRecord(id).then((ids) => {
-              this.handleRemove(ids, data)
-            }).catch(() => { })
-            break
-          case 'moveNode':// 移动节点
-            this.handleMoveNode(id)
-            break
-          case 'nodeSort':// 排序
-            this.handleNodeSort(data)
-            break
-          default:
-            break
+            // 组织树配置
+            orgTreeoptions: {
+                'default-expand-all': false,
+                'expand-on-click-node': false,
+                'default-expanded-keys': ['0'],
+                props: {
+                    children: 'children',
+                    label: 'name'
+                }},
+            orgTreeContextmenus: [
+                { icon: 'add', label: '添加', value: 'add' },
+                { icon: 'edit', label: '编辑', value: 'edit', rights: ['node'] },
+                { icon: 'remove', label: '删除', value: 'remove', rights: ['node'] },
+                { type: 'divided', rights: ['node'] },
+                { icon: 'arrows-v', label: '移动节点', value: 'moveNode', rights: ['node'] },
+                { type: 'divided' },
+                { icon: 'sort', label: '节点排序', value: 'nodeSort' }
+            ],
+            orgTreeData: []
         }
-      }
-    },
-    // 添加 编辑
-    handleEdit(id = '', parentId) {
-      this.show = 'edit'
-      this.positionId = id
-      this.parentId = parentId
-    },
-    // 处理删除
-    handleRemove(ids, data) {
-      if (data.children && data.children !== []) {
-        this.$message({
-          message: '请先删除子节点!',
-          type: 'warning'
-        })
-        return
-      }
-      remove({ positionIds: ids }).then(response => {
-        ActionUtils.removeSuccessMessage()
-        this.refreshTree()
-      }).catch(() => {})
     },
-    // 移动节点
-    handleMoveNode(id = '') {
-      this.moveNodeVisible = true
-      this.positionId = id
-    },
-    // 树点击
-    handleNodeClick(data) {
-      if (data.id === 0 || data.id === '0') {
-        this.show = 'empty'
-        return
-      }
-      this.readonly = true
-      this.positionId = data.id + ''
-      this.show = 'detail'
-    },
-    handleExpandCollapse(isExpand) {
-      this.width = isExpand ? 230 : 30
-    },
-    loadTreeData() {
-      this.search()
-    },
-    // 查询
-    search() {
-      this.$refs.tree.refreshNode(this.parentId)
-    },
-    handleNodeSort(data) {
-      getTreeData({
-        type: 1,
-        posId: data.id
-      }).then(res => {
-        const children = res.data
-        if (children && children.length > 0) {
-          if (children.length === 1) {
-            ActionUtils.warning('只有一个节点无需排序')
-          } else {
-            this.nodeSortVisible = true
-            this.sortData = children
-          }
-        } else {
-          ActionUtils.warning('无子节点排序')
+    methods: {
+        loadNode (node, resolve) {
+            this.loading = true
+            const first = this.$store.getters.level.first
+            const isSuper = this.$store.getters.isSuper
+            getTreeData({
+                type: 1,
+                posId: node.level === 0 ? null : node.data.id
+            }).then(res => {
+                const data = res.data
+                // 岗位树改成部门树
+                data.forEach((item) => {
+                    if (item.name === '岗位树') {
+                        item.name = '部门树'
+                    }
+                })
+                // 数据过滤 - 过滤本部门
+                const show = data.some(item => item.id === first)
+                let showData = []
+                if (show && !isSuper) {
+                    showData = data.filter(item => item.id === first)
+                } else {
+                    showData = data
+                }
+
+                this.loading = false
+                resolve(this.toTree(showData))
+            }).catch(res => {
+                this.loading = false
+                resolve([])
+            })
+        },
+        toTree (data) {
+            return TreeUtils.transformToTreeFormat(data, {
+                idKey: 'id',
+                pIdKey: 'parentId',
+                childrenKey: 'children'
+            })
+        },
+        refreshTree () {
+            this.parentId = '0'
+            this.search()
+        },
+        // 返回右明细模块未显示
+        back () {
+            this.positionId = ''
+            this.show = 'detail'
+        },
+        // 获取ID后显示右明细模块
+        showDetail () {
+            this.positionId = this.gainId
+            this.show = 'detail'
+        },
+
+        handleTreeAction (command, position, selection, data) {
+            if (position === 'toolbar') {
+                if (command === 'refresh') {
+                    this.refreshTree()
+                }
+            } else {
+                const id = data.id
+                switch (command) {
+                    // 组织负责人
+                    case 'add':// 添加
+                        this.handleEdit('', id)
+                        break
+                    case 'edit':// 编辑
+                        this.levelId = data.levelID
+                        this.handleEdit(id)
+                        break
+                    case 'remove':// 删除
+                        ActionUtils.removeRecord(id).then((ids) => {
+                            this.handleRemove(ids, data)
+                        }).catch(() => { })
+                        break
+                    case 'moveNode':// 移动节点
+                        this.handleMoveNode(id)
+                        break
+                    case 'nodeSort':// 排序
+                        this.handleNodeSort(data)
+                        break
+                    default:
+                        break
+                }
+            }
+        },
+        // 添加 编辑
+        handleEdit (id = '', parentId) {
+            this.show = 'edit'
+            this.positionId = id
+            this.parentId = parentId
+        },
+        // 处理删除
+        handleRemove (ids, data) {
+            if (data.children && data.children !== []) {
+                this.$message({
+                    message: '请先删除子节点!',
+                    type: 'warning'
+                })
+                return
+            }
+            remove({ positionIds: ids }).then(response => {
+                ActionUtils.removeSuccessMessage()
+                this.refreshTree()
+            }).catch(() => {})
+        },
+        // 移动节点
+        handleMoveNode (id = '') {
+            this.moveNodeVisible = true
+            this.positionId = id
+        },
+        // 树点击
+        handleNodeClick (data) {
+            if (data.id === 0 || data.id === '0') {
+                this.show = 'empty'
+                return
+            }
+            this.readonly = true
+            this.positionId = data.id + ''
+            this.show = 'detail'
+        },
+        handleExpandCollapse (isExpand) {
+            this.width = isExpand ? 230 : 30
+        },
+        loadTreeData () {
+            this.search()
+        },
+        // 查询
+        search () {
+            this.$refs.tree.refreshNode(this.parentId)
+        },
+        handleNodeSort (data) {
+            getTreeData({
+                type: 1,
+                posId: data.id
+            }).then(res => {
+                const children = res.data
+                if (children && children.length > 0) {
+                    if (children.length === 1) {
+                        ActionUtils.warning('只有一个节点无需排序')
+                    } else {
+                        this.nodeSortVisible = true
+                        this.sortData = children
+                    }
+                } else {
+                    ActionUtils.warning('无子节点排序')
+                }
+            }).catch(res => { })
         }
-      }).catch(res => { })
     }
-  }
 }
 </script>

+ 153 - 153
src/views/platform/org/position/move-node.vue

@@ -1,31 +1,31 @@
 <template>
-  <el-dialog
-    :title="title"
-    :visible.sync="dialogVisible"
-    :close-on-click-modal="false"
-    :close-on-press-escape="false"
-    append-to-body
-    top="5vh"
-    class="dialog"
-  >
-    <ibps-tree
-      ref="elTree"
-      v-loading.body="dialogLoading"
-      :element-loading-text="$t('common.loading')"
-      :width="width"
-      :height="height"
-      :data="treeData"
-      :options="treeOptions"
-      :load="loadNode"
-      lazy
-    />
-    <div slot="footer" style="text-align: center;">
-      <ibps-toolbar
-        :actions="toolbars"
-        @action-event="handleActionEvent"
-      />
-    </div>
-  </el-dialog>
+    <el-dialog
+        :title="title"
+        :visible.sync="dialogVisible"
+        :close-on-click-modal="false"
+        :close-on-press-escape="false"
+        append-to-body
+        top="5vh"
+        class="dialog"
+    >
+        <ibps-tree
+            ref="elTree"
+            v-loading.body="dialogLoading"
+            :element-loading-text="$t('common.loading')"
+            :width="width"
+            :height="height"
+            :data="treeData"
+            :options="treeOptions"
+            :load="loadNode"
+            lazy
+        />
+        <div slot="footer" style="text-align: center;">
+            <ibps-toolbar
+                :actions="toolbars"
+                @action-event="handleActionEvent"
+            />
+        </div>
+    </el-dialog>
 </template>
 <script>
 import { findTreeData, saveMove } from '@/api/platform/org/position'
@@ -33,137 +33,137 @@ import ActionUtils from '@/utils/action'
 import TreeUtils from '@/utils/tree'
 
 export default {
-  props: {
-    visible: Boolean,
-    id: [String, Number],
-    data: Array
-  },
-  data() {
-    return {
-      // tree 配置
-      width: 600,
-      height: document.clientHeight,
-      dialogVisible: this.visible,
-      treeOptions: {
-        'default-expand-all': false,
-        'expand-on-click-node': false,
-        'default-expanded-keys': ['0'],
-        props: {
-          children: 'children',
-          label: 'name'
-        }
-      },
-      treeData: [],
+    props: {
+        visible: Boolean,
+        id: [String, Number],
+        data: Array
+    },
+    data () {
+        return {
+            // tree 配置
+            width: 600,
+            height: document.clientHeight,
+            dialogVisible: this.visible,
+            treeOptions: {
+                'default-expand-all': false,
+                'expand-on-click-node': false,
+                'default-expanded-keys': ['0'],
+                props: {
+                    children: 'children',
+                    label: 'name'
+                }
+            },
+            treeData: [],
 
-      options: [],
-      // 弹窗配置
-      title: '移动节点',
-      dialogLoading: false,
-      editForm: {
-        name: '',
-        account: '',
-        wcAccount: '',
-        orgName: '',
-        gender: '',
-        createTime: ''
-      },
-      toolbars: [
-        { key: 'save', label: '保存' },
-        { key: 'cancel' }
-      ]
+            options: [],
+            // 弹窗配置
+            title: '移动节点',
+            dialogLoading: false,
+            editForm: {
+                name: '',
+                account: '',
+                wcAccount: '',
+                orgName: '',
+                gender: '',
+                createTime: ''
+            },
+            toolbars: [
+                { key: 'save', label: '保存' },
+                { key: 'cancel' }
+            ]
 
-    }
-  },
-  watch: {
-    visible: {
-      handler: function(val, oldVal) {
-        this.dialogVisible = this.visible
-      },
-      immediate: true
-    }
-  },
-  methods: {
-    handleActionEvent({ key }) {
-      switch (key) {
-        case 'save':
-          this.saveData()
-          break
-        case 'cancel':
-          this.closeDialog()
-          break
-        default:
-          break
-      }
-    },
-    // onOpen() {
-    //   this.treeData = JSON.parse(JSON.stringify(this.data))
-    //   this.$nextTick(() => {
-    //     this.$refs.elTree.remove(this.id)
-    //   })
-    // },
-    loadNode(node, resolve) {
-      this.loading = true
-      findTreeData({
-        type: 1,
-        posId: node.level === 0 ? null : node.data.id
-      }).then(res => {
-        this.loading = false
-        const data = res.data
-        const treeData = []
-        if (this.$utils.isNotEmpty(data)) {
-          data.forEach(d => {
-            if (d.id !== this.id) {
-              treeData.push(d)
-            }
-          })
         }
-
-        resolve(this.toTree(treeData))
-      }).catch(res => {
-        this.loading = false
-        resolve([])
-      })
     },
-    toTree(data) {
-      return TreeUtils.transformToTreeFormat(data, {
-        idKey: 'id',
-        pIdKey: 'parentId',
-        childrenKey: 'children'
-      })
-    },
-    // 保存数据
-    saveData() {
-      const destinationId = this.$refs.elTree.getCurrentKey()
-      if (this.$utils.isEmpty(destinationId)) {
-        ActionUtils.warning('请选择节点')
-        return
-      }
-      this.dialogLoading = true
-      saveMove({
-        positionId: this.id,
-        destinationId: destinationId
-      })
-        .then(response => {
-          this.dialogLoading = false
-          this.$emit('callback', this)
-          // ActionUtils.saveSuccessMessage(response.message, r => {
-          //   if (r) {
-          //     this.closeDialog()
-          //   }
-          // })
-          this.closeDialog()
-          ActionUtils.success('移动节点成功!')
-        })
-        .catch(() => {
-          this.$emit('callback', this)
-          this.dialogLoading = false
-        })
+    watch: {
+        visible: {
+            handler: function (val, oldVal) {
+                this.dialogVisible = this.visible
+            },
+            immediate: true
+        }
     },
-    // 关闭当前窗口
-    closeDialog() {
-      this.$emit('close', false)
-      this.editForm = {}
+    methods: {
+        handleActionEvent ({ key }) {
+            switch (key) {
+                case 'save':
+                    this.saveData()
+                    break
+                case 'cancel':
+                    this.closeDialog()
+                    break
+                default:
+                    break
+            }
+        },
+        // onOpen() {
+        //   this.treeData = JSON.parse(JSON.stringify(this.data))
+        //   this.$nextTick(() => {
+        //     this.$refs.elTree.remove(this.id)
+        //   })
+        // },
+        loadNode (node, resolve) {
+            this.loading = true
+            findTreeData({
+                type: 1,
+                posId: node.level === 0 ? null : node.data.id
+            }).then(res => {
+                this.loading = false
+                const data = res.data
+                const treeData = []
+                if (this.$utils.isNotEmpty(data)) {
+                    data.forEach(d => {
+                        if (d.id !== this.id) {
+                            treeData.push(d)
+                        }
+                    })
+                }
+
+                resolve(this.toTree(treeData))
+            }).catch(res => {
+                this.loading = false
+                resolve([])
+            })
+        },
+        toTree (data) {
+            return TreeUtils.transformToTreeFormat(data, {
+                idKey: 'id',
+                pIdKey: 'parentId',
+                childrenKey: 'children'
+            })
+        },
+        // 保存数据
+        saveData () {
+            const destinationId = this.$refs.elTree.getCurrentKey()
+            if (this.$utils.isEmpty(destinationId)) {
+                ActionUtils.warning('请选择节点')
+                return
+            }
+            this.dialogLoading = true
+            saveMove({
+                positionId: this.id,
+                destinationId: destinationId
+            })
+                .then(response => {
+                    this.dialogLoading = false
+                    this.$emit('callback', this)
+                    // ActionUtils.saveSuccessMessage(response.message, r => {
+                    //   if (r) {
+                    //     this.closeDialog()
+                    //   }
+                    // })
+                    this.closeDialog()
+                    ActionUtils.success('移动节点成功!')
+                })
+                .catch(() => {
+                    this.$emit('callback', this)
+                    this.dialogLoading = false
+                })
+        },
+        // 关闭当前窗口
+        closeDialog () {
+            this.$emit('close', false)
+            this.editForm = {}
+        }
     }
-  }
 }
 </script>