瀏覽代碼

岗位配置

shenqilong 6 月之前
父節點
當前提交
2a337ac21b

+ 15 - 0
src/api/platform/org/duty.js

@@ -0,0 +1,15 @@
+import request from '@/utils/request'
+import { ORG_URL } from '@/api/baseUrl'
+import ActionUtils from '@/utils/action'
+
+/**
+ * 获取数据
+ * @param {*} params
+ */
+export function getTreeData(params) {
+  return request({
+    url: ORG_URL() + '/position/findDutiesData',
+    method: 'post',
+    data: ActionUtils.formatParams(params)
+  })
+}

+ 71 - 3
src/layout/header-aside/components/header-user/index.vue

@@ -100,8 +100,34 @@
               >
             </div>
           </template>
+          <template v-if="dutys.length">
+            <div class="title512">
+              <i class="el-icon-office-building" />岗位
+              <el-tooltip
+                effect="light"
+                content="双击下方岗位可切换主岗位"
+                placement="top"
+                style="z-index: 9999"
+              >
+                <i class="el-icon-info" style="color: #dd5b44" />
+              </el-tooltip>
+            </div>
+            <div
+              v-for="item in dutys"
+              :key="item.positionName"
+              class="div512"
+              @dblclick="handleMainDutyChange(item)"
+            >
+              <el-tag
+                class="item512"
+                :type="item.dataType === 'mainResp' ? 'primary' : 'info'"
+                size="small"
+                >{{ item.positionName }}</el-tag
+              >
+            </div>
+          </template>
           <template v-if="roleName.length">
-            <div class="title512"><i class="el-icon-postcard" />岗位</div>
+            <div class="title512"><i class="el-icon-postcard" />角色</div>
             <el-tag
               v-for="(item, index) in roleName"
               :key="Date.now() + Math.random() + index"
@@ -167,6 +193,8 @@ export default {
       locationName,
       roleName,
       positions: userInfo.positions || [],
+      dutys: userInfo.positionUsers || [],
+      mainDuty: userInfo.mainPositionUser || {},
       users: userInfo.user || [],
       mainPosition,
       tenants: this.$store.getters.tenants,
@@ -184,8 +212,8 @@ export default {
       return this.info && this.info.employee
         ? this.info.employee.id
         : this.info && this.info.user && this.info.user.id
-          ? this.info.user.id
-          : ''
+        ? this.info.user.id
+        : ''
     },
     avatar() {
       const photo =
@@ -310,6 +338,46 @@ export default {
         this.updateMainPosition(this.mainPosition.id, item.id)
       })
     },
+    handleMainDutyChange(item) {
+      getUserInfo(this.users.account).then(async (response) => {
+        if (!response) {
+          reject(response)
+        }
+
+        const info = response.data
+        if (info.positionUsers.length !== this.dutys.length) {
+          this.$message.warning('岗位信息更新,请在刷新后重新选择!')
+          location.reload()
+          return
+        } else {
+          info.positionUsers.forEach((element, i) => {
+            if (
+              element.id !== this.dutys[i].id ||
+              element.dataType !== this.dutys[i].dataType
+            ) {
+              this.$message.warning('岗位信息更新,请在刷新后重新选择!')
+              location.reload()
+              return
+            }
+          })
+        }
+        if (this.mainDuty && this.mainDuty.id === item.id) {
+          return
+        }
+        request({
+          url: '/platform/v3/positionUser/savePositionUser',
+          method: 'post',
+          isLoading: true,
+          data: {
+            oldId: this.mainDuty?.id || '',
+            newId: item.id
+          }
+        }).then((res) => {
+          this.$message.success('设置主岗位成功!')
+          location.reload()
+        })
+      })
+    },
     setMainPosition(mid) {
       // const sql = `select * from ibps_party_rel where biz_ = 'mainPost' and SUB_PID_ = '${this.userId}'`
       this.$common

+ 235 - 0
src/views/platform/org/employee/edit/duty-info.vue

@@ -0,0 +1,235 @@
+<template>
+  <el-row :gutter="10">
+    <el-col v-if="!readonly" :span="8" border>
+      <div class="grid-content">
+        <tree
+          ref="elTree"
+          :height="height"
+          :data="treeData"
+          :check-strictly="checkStrictly"
+          node-key="name"
+          @action-event="handleTreeAction"
+        />
+      </div>
+    </el-col>
+    <el-col v-if="!readonly" :span="3">
+      <el-button
+        type="primary"
+        icon="el-icon-d-arrow-right"
+        class="ibps-ml-10"
+        @click="handleBelongTo"
+        >分配</el-button
+      >
+      <el-button
+        type="info"
+        icon="el-icon-d-arrow-left"
+        class="ibps-ml-10 ibps-mt-10"
+        style="margin-top: 10px"
+        @click="handleClear(newDutyData)"
+        >清空</el-button
+      >
+    </el-col>
+    <el-col :span="spanNumber" border>
+      <el-table :data="dutyItemList" style="width: 100%" border>
+        <el-table-column label="岗位名称">
+          <template slot-scope="scope">
+            <span style="margin-left: 10px">{{ scope.row.name }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column label="是否主岗位" width="100">
+          <template slot-scope="scope">
+            <el-radio
+              :disabled="readonly"
+              :value="check(scope.row)"
+              :label="scope.row.id"
+              @change.native="changeMainPost(scope.$index, scope.row)"
+              @click.native.prevent="clickitem(scope.row)"
+            >
+              <span>&nbsp;</span>
+            </el-radio>
+          </template>
+        </el-table-column>
+
+        <el-table-column v-if="!readonly" label="管理" width="100">
+          <template slot-scope="scope">
+            <el-button
+              size="mini"
+              type="danger"
+              @click.native.prevent="deleteRow(scope.$index, dutyItemList)"
+              >删除</el-button
+            >
+          </template>
+        </el-table-column>
+      </el-table>
+    </el-col>
+  </el-row>
+</template>
+<script>
+import { findAllSubsystem } from '@/api/platform/auth/subsystem'
+import { getTreeData } from '@/api/platform/org/duty'
+
+import Tree from '../../components/tree'
+import { concat } from '../utils'
+
+export default {
+  components: {
+    Tree
+  },
+  props: {
+    data: Array,
+    readonly: {
+      type: Boolean,
+      default: false
+    },
+    span: [Number, String]
+  },
+  data() {
+    return {
+      subsystemList: [],
+      checkStrictly: true,
+      pkKey: 'id',
+      nameKey: 'name',
+      treeData: [],
+      dutyItemList: [],
+      height: document.clientHeight,
+      newDutyData: [],
+      defaultTreeData: []
+    }
+  },
+  computed: {
+    spanNumber() {
+      return this.span
+    }
+  },
+  watch: {
+    data: {
+      handler: function (val, oldVal) {
+        this.dutyItemList = val
+        const arr = JSON.parse(JSON.stringify(val))
+
+        arr.forEach((item) => {
+          this.defaultTreeData.push(item.name)
+        })
+        if (this.$refs.elTree) {
+          this.$refs.elTree.setCheckedKeys(this.defaultTreeData, true)
+        }
+      },
+      deep: true
+    },
+    dutyItemList: {
+      handler: function (val, oldVal) {
+        if (val !== oldVal) {
+          this.handleEmitEvent()
+        }
+      },
+      deep: true
+    }
+  },
+  created() {
+    this.loadSubsystemData()
+  },
+  methods: {
+    init() {
+      if (this.$refs.elTree) {
+        this.$refs.elTree.setCheckedNodes([])
+      }
+      this.defaultTreeData = []
+    },
+    loadSubsystemData() {
+      findAllSubsystem()
+        .then((response) => {
+          this.subsystemList = response.data
+          this.loadTreeData()
+        })
+        .catch(() => {
+          // 异常
+        })
+    },
+    // 树[数据]获取
+    loadTreeData() {
+      getTreeData()
+        .then((response) => {
+          const data = response.data || []
+          const tree = []
+          tree.push({
+            id: '0',
+            name: '岗位树',
+            disabled: true
+          })
+          data.forEach((item) => {
+            item.parentId = '0'
+            item.name = item.positionName
+            tree.push(item)
+          })
+          this.treeData = tree
+        })
+        .catch(() => {
+          // 异常
+        })
+    },
+    // 组织树事件
+    handleTreeAction(command, position, selection, data) {
+      if (position === 'toolbar') {
+        if (command === 'refresh') {
+          this.loadTreeData()
+        }
+      }
+    },
+    // 分配
+    handleBelongTo() {
+      const tree = this.$refs.elTree
+      const postInfo = tree.getCheckedNodes() // 勾选
+      if (this.$utils.isEmpty(postInfo)) {
+        return
+      }
+      const objs = []
+      for (let i = 0; i < postInfo.length; i++) {
+        const hadData = this.dutyItemList.find(
+          (fid) => fid.name === postInfo[i].name
+        )
+
+        const obj = {
+          name: postInfo[i].name,
+          id: postInfo[i].id,
+          isMainPost: hadData ? hadData.isMainPost : 'N'
+        }
+        objs.push(obj)
+      }
+      // this.dutyItemList = concat(this.dutyItemList, objs)
+      this.dutyItemList = concat(objs)
+    },
+
+    handleClear(data) {
+      this.dutyItemList = []
+      this.init()
+    },
+    deleteRow(index, row) {
+      row.splice(index, 1)
+    },
+    handleEmitEvent() {
+      this.$emit('input', this.dutyItemList)
+    },
+    // 是否主岗位 变更事件
+    changeMainPost(index, row) {
+      // for (const item of this.dutyItemList) {
+      //   item.isMainPost = 'N'
+      // }
+      // row.isMainPost = 'Y'
+    },
+
+    clickitem(row) {
+      const list = JSON.parse(JSON.stringify(row))
+      for (const item of this.dutyItemList) {
+        item.isMainPost = 'N'
+      }
+      if (list.isMainPost == 'N') {
+        row.isMainPost = 'Y'
+      }
+    },
+    // 回填显示单选、多选框的value
+    check(row) {
+      return row.isMainPost === 'Y' ? row.id : false
+    }
+  }
+}
+</script>

+ 47 - 4
src/views/platform/org/employee/edit/index.vue

@@ -61,6 +61,16 @@
           @input="(data) => (employee.posItemList = data)"
         />
       </el-tab-pane>
+      <el-tab-pane v-if="isDuty" label="岗位信息" name="duty-info">
+        <duty-info
+          ref="dutyInfo"
+          :span="span"
+          :readonly="readonly"
+          :org-id="dutyId"
+          :data="employee.dutyItemList"
+          @input="(data) => (employee.dutyItemList = data)"
+        />
+      </el-tab-pane>
       <el-tab-pane
         v-if="!infoIncludes('role-info')"
         label="角色信息"
@@ -119,6 +129,7 @@ import ExtAttr from './ext-attr'
 import OrgInfo from './org-info'
 import PositionInfo from './position-info'
 import RoleInfo from './role-info'
+import DutyInfo from './duty-info'
 import GroupInfo from './group-info'
 import PersonalCode from './personal-qrcode'
 import { encryptByAes } from '@/utils/encrypt'
@@ -130,6 +141,7 @@ export default {
     OrgInfo,
     PositionInfo,
     RoleInfo,
+    DutyInfo,
     GroupInfo,
     PersonalCode
   },
@@ -152,11 +164,13 @@ export default {
     span: [Number, String]
   },
   data() {
-    const { isSuper } = this.$store.getters
+    const { isSuper, setting } = this.$store.getters
     return {
       isSuper,
       info: [],
       orgId: '',
+      dutyId: '',
+      isDuty: setting?.duty?.use || false,
       dialogLoading: false,
       dialogVisible: false,
       activeName: 'basic-info',
@@ -175,6 +189,7 @@ export default {
         attrItemList: [], // 扩展属性
         groupID: '', // 组织ID
         posItemList: [],
+        dutyItemList: [],
         roleItemList: [],
         userGroupItemList: [],
         orgItem: {}, // 组织全部信息
@@ -216,7 +231,7 @@ export default {
     },
     ceroParams: {
       handler(val, oldVal) {
-        if (val && val !== {}) {
+        if (val && val != {}) {
           this.orgId = val.groundId
         }
       },
@@ -414,6 +429,7 @@ export default {
           }
         ]
       }
+      // console.log(this.formId, vo)
 
       if (this.formId) {
         update(vo)
@@ -554,6 +570,9 @@ export default {
           this.employee.orgItem = response.variables.partyOrg || {}
           this.employee.attrItemList = response.variables.partyAttrs || []
           this.employee.posItemList = response.variables.partyPositions || []
+          this.employee.dutyItemList = this.getDutyData(
+            response.variables.partyUserPosition || []
+          )
           this.employee.roleItemList = response.variables.partyRoles || []
           this.employee.userGroupItemList = response.variables.partyGroups || []
           if (this.isSuper) {
@@ -593,14 +612,15 @@ export default {
           ? this.employee.password
           : this.defaultEmployee.password
       vo.partyEmployeePo.groupID =
-        this.ceroParams !== {} && this.ceroParams
+        this.ceroParams != {} && this.ceroParams
           ? this.ceroParams.groundId
           : this.formatOrgData()
       vo.positionVoList = this.formatPositionData()
+      vo.partyPositionUser = this.formatDutyData()
       vo.roleVoList = this.formatRoleData()
       vo.attrValueVoList = this.employee.attrItemList
       vo.userGroupPoList = this.formatUserGroupData()
-      if (this.ceroParams !== {} && this.ceroParams) {
+      if (this.ceroParams != {} && this.ceroParams) {
         vo.partyEmployeePo.prem = this.ceroParams.prem
       }
       return vo
@@ -620,6 +640,18 @@ export default {
       }
       return result
     },
+    formatDutyData() {
+      const result = []
+      const list = this.employee.dutyItemList
+      if (this.$utils.isEmpty(list)) return result
+      for (const variable of list) {
+        const tmp = { positionName: variable.name }
+        tmp['positionType'] = 'responsibility'
+        tmp['dataType'] = variable.isMainPost === 'Y' ? 'mainResp' : ''
+        result.push(tmp)
+      }
+      return result
+    },
     formatRoleData() {
       const result = []
       const list = this.employee.roleItemList
@@ -678,6 +710,17 @@ export default {
         updList: [obj]
       }
       this.$common.request('update', params)
+    },
+    getDutyData(data) {
+      const result = []
+
+      if (this.$utils.isEmpty(data)) return result
+      for (const variable of data) {
+        const tmp = { name: variable.positionName, id: variable.id }
+        tmp['isMainPost'] = variable.dataType === 'mainResp' ? 'Y' : 'N'
+        result.push(tmp)
+      }
+      return result
     }
   }
 }