Bladeren bron

部门管理 部门人员

linweizeng 2 jaren geleden
bovenliggende
commit
04d08b4477

+ 58 - 54
src/views/platform/org/position/detail/index.vue

@@ -1,26 +1,26 @@
 <template>
 <template>
-  <div class="main-container">
-    <el-tabs
-      v-model="activeName"
-      @tab-click="handleTabClick"
-    >
-      <el-tab-pane label="部门明细" name="detail">
-        <detail :id="id" :readonly="readonly" />
-      </el-tab-pane>
-      <el-tab-pane label="归属组织" name="positionOrg">
-        <position-org :id="id" :height="height" :visible="activeName==='positionOrg'" />
-      </el-tab-pane>
-      <el-tab-pane label="部门人员" name="positionEmployee">
-        <position-employee :id="id" seeting-search-party-type="position" :height="height" :visible="activeName==='positionEmployee'" />
-      </el-tab-pane>
-      <el-tab-pane label="扩展属性" name="extraAttr">
-        <ext-attr :id="id" ref="attrForm" :height="height" :visible="activeName==='extraAttr'" party-type="position" />
-      </el-tab-pane>
-      <el-tab-pane label="已分配角色" name="positionRole">
-        <position-role :id="id" :height="height" :visible="activeName==='positionRole'" />
-      </el-tab-pane>
-    </el-tabs>
-  </div>
+    <div class="main-container">
+        <el-tabs
+            v-model="activeName"
+            @tab-click="handleTabClick"
+        >
+            <el-tab-pane label="部门明细" name="detail">
+                <detail :id="id" :readonly="readonly" />
+            </el-tab-pane>
+            <el-tab-pane label="归属组织" name="positionOrg">
+                <position-org :id="id" :height="height" :visible="activeName==='positionOrg'" />
+            </el-tab-pane>
+            <el-tab-pane label="部门人员" name="positionEmployee">
+                <position-employee :id="id" seeting-search-party-type="position" :height="height" :depth="depth" :visible="activeName==='positionEmployee'" />
+            </el-tab-pane>
+            <el-tab-pane label="扩展属性" name="extraAttr">
+                <ext-attr :id="id" ref="attrForm" :height="height" :visible="activeName==='extraAttr'" party-type="position" />
+            </el-tab-pane>
+            <el-tab-pane label="已分配角色" name="positionRole">
+                <position-role :id="id" :height="height" :visible="activeName==='positionRole'" />
+            </el-tab-pane>
+        </el-tabs>
+    </div>
 </template>
 </template>
 <script>
 <script>
 // 组件
 // 组件
@@ -30,39 +30,43 @@ import positionEmployee from './position-employee'
 import positionRole from './position-role'
 import positionRole from './position-role'
 import extAttr from '../../components/attr/ext-attr'
 import extAttr from '../../components/attr/ext-attr'
 export default {
 export default {
-  components: {
-    'detail': detail,
-    'position-org': positionOrg,
-    'position-employee': positionEmployee,
-    'position-role': positionRole,
-    'ext-attr': extAttr
-  },
-  props: {
-    id: {
-      type: [String, Number]
+    components: {
+        'detail': detail,
+        'position-org': positionOrg,
+        'position-employee': positionEmployee,
+        'position-role': positionRole,
+        'ext-attr': extAttr
     },
     },
-    readonly: {
-      type: Boolean,
-      default: false
-    }
-  },
-  data() {
-    return {
-      activeName: 'detail',
-      height: 500
-    }
-  },
-  watch: {
-    id() {
-      this.activeName = 'detail'
-    }
-  },
-  mounted() {
-    this.height = this.$parent.$el.offsetHeight - 75
-  },
-  methods: {
-    handleTabClick(tab) {
+    props: {
+        id: {
+            type: [String, Number]
+        },
+        readonly: {
+            type: Boolean,
+            default: false
+        },
+        depth: {
+            type: Number,
+            default: 0
+        }
+    },
+    data () {
+        return {
+            activeName: 'detail',
+            height: 500
+        }
+    },
+    watch: {
+        id () {
+            this.activeName = 'detail'
+        }
+    },
+    mounted () {
+        this.height = this.$parent.$el.offsetHeight - 75
+    },
+    methods: {
+        handleTabClick (tab) {
+        }
     }
     }
-  }
 }
 }
 </script>
 </script>

+ 263 - 189
src/views/platform/org/position/detail/position-employee.vue

@@ -1,34 +1,34 @@
 <template>
 <template>
-  <div :style="{height:height+'px'}">
-    <ibps-crud
-      v-if="visible"
-      ref="crud"
-      :data="listData"
-      :toolbars="listConfig.toolbars"
-      :search-form="listConfig.searchForm"
-      :pk-key="pkKey"
-      :columns="listConfig.columns"
-      :row-handle="listConfig.rowHandle"
-      :pagination="pagination"
-      :loading="loading"
-      @action-event="handleAction"
-      @sort-change="handleSortChange"
-      @pagination-change="handlePaginationChange"
-    />
-    <!-- 人员选择器 -->
-    <ibps-employee-selector-dialog
-      :visible="selectorVisible"
-      :value="[]"
-      :show-tree="false"
-      :party-type-id="id"
-      :seeting-search-party-type="seetingSearchPartyType"
-      title="人员选择器"
-      multiple
-      class="position-employee-dialog"
-      @close="visible => selectorVisible = visible"
-      @action-event="handleSelectorActionEvent"
-    />
-  </div>
+    <div :style="{height:height+'px'}">
+        <ibps-crud
+            v-if="visible"
+            ref="crud"
+            :data="listData"
+            :toolbars="listConfig.toolbars"
+            :search-form="listConfig.searchForm"
+            :pk-key="pkKey"
+            :columns="listConfig.columns"
+            :row-handle="listConfig.rowHandle"
+            :pagination="pagination"
+            :loading="loading"
+            @action-event="handleAction"
+            @sort-change="handleSortChange"
+            @pagination-change="handlePaginationChange"
+        />
+        <!-- 人员选择器 -->
+        <ibps-employee-selector-dialog
+            :visible="selectorVisible"
+            :value="[]"
+            :show-tree="false"
+            :party-type-id="id"
+            :seeting-search-party-type="seetingSearchPartyType"
+            title="人员选择器"
+            multiple
+            class="position-employee-dialog"
+            @close="visible => selectorVisible = visible"
+            @action-event="handleSelectorActionEvent"
+        />
+    </div>
 </template>
 </template>
 <script>
 <script>
 import IbpsEmployeeSelectorDialog from '@/business/platform/org/employee/dialog'
 import IbpsEmployeeSelectorDialog from '@/business/platform/org/employee/dialog'
@@ -37,177 +37,251 @@ import { queryWithOrg as queryPageList, addPositionUser, removePositionUser } fr
 
 
 import ActionUtils from '@/utils/action'
 import ActionUtils from '@/utils/action'
 import { statusOption } from '../constants'
 import { statusOption } from '../constants'
+import {
+    queryPageList as queryUserList
+} from '@/api/platform/org/employee'
 
 
 export default {
 export default {
-  components: {
-    IbpsEmployeeSelectorDialog
-  },
-  props: {
-    id: [String, Number],
-    seetingSearchPartyType: String,
-    height: Number,
-    visible: Boolean
-  },
-  data() {
-    return {
-      selectorVisible: false,
-
-      pkKey: 'id',
-      loading: false,
-      listData: [],
-      pagination: {},
-      sorts: {},
-      listConfig: {
-        toolbars: [
-          {
-            key: 'search'
-          },
-          {
-            key: 'add',
-            label: '加入',
-            icon: 'el-icon-plus'
-          },
-          {
-            key: 'remove',
-            label: '移除',
-            icon: 'el-icon-delete'
-          }
-        ],
-        searchForm: {
-          inline: true,
-          forms: [
-            { prop: 'Q^NAME_^SL', label: '姓名:' }
-          ]
-        },
-        // 表格字段配置
-        columns: [
-          { prop: 'name', label: '姓名' },
-          { prop: 'orgName', label: '归属组织' },
-          { prop: 'gender',
-            label: '性别',
-            options: [{
-              value: 'male',
-              label: '男'
+    components: {
+        IbpsEmployeeSelectorDialog
+    },
+    props: {
+        id: [String, Number],
+        seetingSearchPartyType: String,
+        height: Number,
+        visible: Boolean,
+        depth: {
+            type: Number,
+            default: 0
+        }
+    },
+    data () {
+        return {
+            selectorVisible: false,
+            pkKey: 'id',
+            loading: false,
+            listData: [],
+            pagination: {},
+            sorts: {},
+            listConfig: {
+                toolbars: [
+                    {
+                        key: 'search'
+                    },
+                    {
+                        key: 'add',
+                        label: '加入',
+                        icon: 'el-icon-plus'
+                    },
+                    {
+                        key: 'remove',
+                        label: '移除',
+                        icon: 'el-icon-delete'
+                    }
+                ],
+                searchForm: {
+                    inline: true,
+                    forms: [
+                        { prop: 'Q^NAME_^SL', label: '姓名:' }
+                    ]
+                },
+                // 表格字段配置
+                columns: [
+                    { prop: 'name', label: '姓名', width: '120' },
+                    { prop: 'positionsName', label: '归属部门', hidden: false },
+                    { prop: 'gender',
+                        label: '性别',
+                        options: [{
+                            value: 'male',
+                            label: '男'
+                        },
+                        {
+                            value: 'female',
+                            label: '女',
+                            type: 'danger'
+                        }], width: '80' },
+                    { prop: 'createTime', label: '创建时间', width: '150' },
+                    { prop: 'status', label: '状态', tags: statusOption, width: '120' }
+                ],
+                rowHandle: {
+                    actions: [
+                        {
+                            key: 'remove',
+                            label: '移除',
+                            icon: 'el-icon-delete'
+                        }
+                    ]
+                }
             },
             },
-            {
-              value: 'female',
-              label: '女',
-              type: 'danger'
-            }] },
-          { prop: 'createTime', label: '创建时间' },
-          { prop: 'status', label: '状态', tags: statusOption }
-        ],
-        rowHandle: {
-          actions: [
-            {
-              key: 'remove',
-              label: '移除',
-              icon: 'el-icon-delete'
-            }
-          ]
+            statusOptions: statusOption
         }
         }
-      },
-      statusOptions: statusOption
-    }
-  },
-  watch: {
-    visible: {
-      handler() {
-        if (this.visible && this.$utils.isNotEmpty(this.id)) {
-          this.loadData()
+    },
+    watch: {
+        visible: {
+            handler () {
+                if (this.visible && this.$utils.isNotEmpty(this.id)) {
+                    this.loadData()
+                }
+            },
+            immediate: true
+        },
+        depth: {
+            handler () {
+                if (!this.depth || this.depth > 3) {
+                    this.listConfig.columns[1].hidden = true
+                } else {
+                    this.listConfig.columns[1].hidden = false
+                }
+            },
+            immediate: true
         }
         }
-      },
-      immediate: true
-    }
-  },
-  methods: {
-    // 初始化数据
-    loadData() {
-      this.loading = true
-      queryPageList(this.getSearcFormData()).then(response => {
-        ActionUtils.handleListData(this, response.data)
-        this.loading = false
-      }).catch(() => {
-        this.loading = false
-      })
     },
     },
-    // 查询
-    getSearcFormData() {
-      const params = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
-      params['Q^POSITIONS_^SL'] = this.id
-      return ActionUtils.formatParams(
-        params,
-        this.pagination,
-        this.sorts)
+    created () {
+        this.getOrg()
     },
     },
-    /**
+    methods: {
+    // 初始化数据
+        loadData () {
+            this.loading = true
+            queryUserList(this.getSearcFormData()).then((response) => {
+                response.data.dataResult.forEach(item => {
+                    if (item.positions) {
+                        // 转换岗位名
+                        const name = this.getPositionsName(item.positions)
+                        this.$set(item, 'positionsName', name)
+                        // 转换岗位路径
+                        const path = this.getPositionsPath(item.positions)
+                        this.$set(item, 'positionsPath', path)
+                    }
+                })
+                ActionUtils.handleListData(this, response.data)
+                this.loading = false
+            }).catch(() => {
+                this.loading = false
+            })
+        },
+        getPositionsName (valueList) {
+            const postList = valueList.split(',')
+            const list = []
+            if (!postList.length) {
+                return ''
+            }
+            postList.forEach((item, index) => {
+                const dataItem = this.positionsList.find(i => i.ID_ === item)
+                list.push(`(${index + 1})${dataItem.NAME_}`)
+            })
+            return list.join(' ')
+        },
+        getPositionsPath (valueList) {
+            const postList = valueList.split(',')
+            const list = []
+            if (!postList.length) {
+                return ''
+            }
+            postList.forEach((item) => {
+                const temp = this.positionsList.find(i => i.ID_ === item)
+                const pathList = temp ? temp.PATH_.split('.') : []
+                let p = ''
+                pathList.filter(i => i).forEach(k => {
+                    const t = this.positionsList.find(i => i.ID_ === k)
+                    p += `${t.NAME_}.`
+                })
+                list.push(p)
+            })
+            return list.join('\r\n')
+        },
+        // 查询
+        getSearcFormData () {
+            const params = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
+            const res = ActionUtils.formatParams(params, this.pagination, this.sorts)
+            res.customs = {
+                position: this.id
+            }
+            return res
+        },
+        /**
      * 处理排序
      * 处理排序
      */
      */
-    handleSortChange(sort) {
-      ActionUtils.setSorts(this.sorts, sort)
-      this.loadData()
-    },
-    /**
+        handleSortChange (sort) {
+            ActionUtils.setSorts(this.sorts, sort)
+            this.loadData()
+        },
+        /**
      * 处理分页事件
      * 处理分页事件
      */
      */
-    handlePaginationChange(page) {
-      ActionUtils.setPagination(this.pagination, page)
-      this.loadData()
-    },
-    search() {
-      this.loadData()
-    },
-    handleAction(buttonKey, position, selection, data) {
-      switch (buttonKey) {
-        // 组织负责人
-        case 'search':// 查询
-          ActionUtils.setFirstPagination(this.pagination)
-          this.search()
-          break
-        case 'add':// 设置
-          this.handleAdd()
-          break
-        case 'remove':// 删除
-          ActionUtils.removeRecord(selection).then((ids) => {
-            this.handleRemove(ids)
-          }).catch(() => { })
-          break
-        default:
-          break
-      }
-    },
-    // 处理 加入人员
-    handleAdd() {
-      this.selectorVisible = true
-    },
-    handleSelectorActionEvent(buttonKey, data) {
-      switch (buttonKey) {
-        case 'confirm':// 确定
-          this.handleConfirm(data)
-          break
-      }
-    },
-    handleConfirm(data) {
-      this.selectorVisible = false
-      addPositionUser({
-        positionId: this.id,
-        userIds: data.map((d) => { return d.id }).join(',')
-      }).then(response => {
-        this.selectorVisible = false
-        ActionUtils.success('加入人员成功!')
-        this.search()
-      })
-    },
-    handleRemove(ids) {
-      removePositionUser({
-        positionId: this.id,
-        userIds: ids
-      }).then(response => {
-        ActionUtils.removeSuccessMessage()
-        this.search()
-      })
+        handlePaginationChange (page) {
+            ActionUtils.setPagination(this.pagination, page)
+            this.loadData()
+        },
+        search () {
+            this.loadData()
+        },
+        handleAction (buttonKey, position, selection, data) {
+            switch (buttonKey) {
+                // 组织负责人
+                case 'search':// 查询
+                    ActionUtils.setFirstPagination(this.pagination)
+                    this.search()
+                    break
+                case 'add':// 设置
+                    this.handleAdd()
+                    break
+                case 'remove':// 删除
+                    ActionUtils.removeRecord(selection).then((ids) => {
+                        this.handleRemove(ids)
+                    }).catch(() => { })
+                    break
+                default:
+                    break
+            }
+        },
+        // 处理 加入人员
+        handleAdd () {
+            this.selectorVisible = true
+        },
+        handleSelectorActionEvent (buttonKey, data) {
+            switch (buttonKey) {
+                case 'confirm':// 确定
+                    this.handleConfirm(data)
+                    break
+            }
+        },
+        handleConfirm (data) {
+            this.selectorVisible = false
+            addPositionUser({
+                positionId: this.id,
+                userIds: data.map((d) => { return d.id }).join(',')
+            }).then(response => {
+                this.selectorVisible = false
+                ActionUtils.success('加入人员成功!')
+                this.search()
+            })
+        },
+        handleRemove (ids) {
+            removePositionUser({
+                positionId: this.id,
+                userIds: ids
+            }).then(response => {
+                ActionUtils.removeSuccessMessage()
+                this.search()
+            })
+        },
+        // 获取组织的数据
+        getOrg () {
+            return new Promise((resolve, reject) => {
+                const sql = `select a.ID_ as ID_, a.NAME_ as NAME_, b.path_ as PATH_ FROM ibps_party_position a, ibps_party_entity b where a.id_ = b.id_`
+                this.$common.request('sql', sql).then((res) => {
+                    const datas = res.variables.data
+                    datas.forEach((item, index) => {
+                        this.$set(item, 'value', item.ID_)
+                        this.$set(item, 'label', item.NAME_)
+                    })
+                    this.positionsList = datas
+                    resolve()
+                })
+            })
+        }
     }
     }
-  }
 }
 }
 </script>
 </script>
 <style lang="scss">
 <style lang="scss">

+ 4 - 1
src/views/platform/org/position/manage.vue

@@ -22,6 +22,7 @@
                     v-if="show==='detail'"
                     v-if="show==='detail'"
                     :id="positionId"
                     :id="positionId"
                     :readonly="readonly"
                     :readonly="readonly"
+                    :depth="depth"
                 />
                 />
                 <edit
                 <edit
                     v-else-if="show==='edit'"
                     v-else-if="show==='edit'"
@@ -85,6 +86,7 @@ export default {
     mixins: [FixHeight],
     mixins: [FixHeight],
     data () {
     data () {
         return {
         return {
+            depth: 0,
             show: '',
             show: '',
             width: 230,
             width: 230,
             height: document.clientHeight,
             height: document.clientHeight,
@@ -231,11 +233,12 @@ export default {
             this.positionId = id
             this.positionId = id
         },
         },
         // 树点击
         // 树点击
-        handleNodeClick (data) {
+        handleNodeClick (data, node) {
             if (data.id === 0 || data.id === '0') {
             if (data.id === 0 || data.id === '0') {
                 this.show = 'empty'
                 this.show = 'empty'
                 return
                 return
             }
             }
+            this.depth = data.depth || 0
             this.readonly = true
             this.readonly = true
             this.positionId = data.id + ''
             this.positionId = data.id + ''
             this.show = 'detail'
             this.show = 'detail'