浏览代码

员工管理

zhengnaiwen_citu 4 月之前
父节点
当前提交
b57b8c3e22

+ 27 - 0
src/api/dictionary.js

@@ -0,0 +1,27 @@
+// 字典
+import http from '@/utils/request'
+
+//  员工职务层级字典
+export function getJobLevel (data) {
+  return http.get('/employee/job/level/dict', data)
+}
+
+//  员工岗位类别字典
+export function getPositionCategory (data) {
+  return http.get('/employee/position/category/dict', data)
+}
+
+//  员工人员类别字典
+export function getPersonnelCategory (data) {
+  return http.get('/employee/personnel/category/dict', data)
+}
+
+//  员工岗位序列字典
+export function getPositionSequence (data) {
+  return http.get('/employee/position/sequence/dict', data)
+}
+
+//  员工岗位名称字典
+export function getJobName (data) {
+  return http.get('/employee/job/name/dict', data)
+}

+ 3 - 4
src/views/humanResources/roster/index.vue

@@ -19,7 +19,7 @@
         <el-upload class="el-button pa-0" action="#" :show-file-list="false" :http-request="onImport">
           <m-button type="orange" size="small" icon="el-icon-upload2" :loading="importLoading">上传</m-button>
         </el-upload>
-        <m-button type="orange" size="small" icon="el-icon-download" @click="onExport" :loading="exportLoading">导出</m-button>
+        <!-- <m-button type="orange" size="small" icon="el-icon-download" @click="onExport" :loading="exportLoading">导出</m-button> -->
         <m-button type="orange" size="small" icon="el-icon-download" @click="onDownload" :loading="downloadLoading">下载模板</m-button>
         <m-button type="orange" size="small" icon="el-icon-setting" @click="onChange">变更记录</m-button>
       </template>
@@ -106,17 +106,16 @@ export default {
     },
     headers () {
       const header = [
-        // { text: '一级机构', align: 'start', value: 'secondLevelBranch' },
         { label: '上级机构', prop: 'parentOrganizationName' },
         { label: '部门', prop: 'deptName' },
+        { label: '通行证号', prop: 'passes' },
         { label: '员工名称', prop: 'employeeName' },
+        { label: '工行时间', prop: 'tradeUnionsTime' },
         { label: '人员类别', prop: 'personnelCategory' },
         { label: '岗位名称', prop: 'postName' },
         { label: '岗位序列', prop: 'positionSequence' },
         { label: '岗位类别', prop: 'positionCategory' },
         { label: '职务层级', prop: 'jobLevel' },
-        { label: '通行证号', prop: 'passes' },
-        { label: '工行时间', prop: 'tradeUnionsTime' },
         { label: '薪酬档次', align: 'center', prop: 'salaryCategory' },
         { label: '薪酬级别', align: 'center', prop: 'salaryLevel' }
       ]

+ 150 - 21
src/views/humanResources/roster/rosterEdit.vue

@@ -1,16 +1,30 @@
 <template>
-  <m-dialog ref="editDialog" v-bind="$attrs" @sure="handleSaveEdit">
-    <m-form ref="formRef" :items="items" v-model="query"></m-form>
+  <m-dialog ref="editDialog" :title="title" v-bind="$attrs" @sure="handleSaveEdit">
+    <m-form ref="formRef" :items="items" v-model="query" v-loading="loading"></m-form>
   </m-dialog>
 </template>
 
 <script>
 import { saveRoster } from '@/api/system'
+import { mapGetters } from 'vuex'
 import {
   getSalaryLevelDict
 } from '@/api/salary'
+import {
+  getJobLevel,
+  getPositionCategory,
+  getPersonnelCategory,
+  getPositionSequence,
+  getJobName
+} from '@/api/dictionary'
 export default {
   name: 'roster-edit',
+  props: {
+    title: {
+      type: String,
+      default: '新增'
+    }
+  },
   data () {
     return {
       query: {},
@@ -20,23 +34,42 @@ export default {
     }
   },
   computed: {
+    ...mapGetters(['organizationTree']),
     items () {
       return [
-        { label: '上级机构', prop: 'parentOrganizationName', type: 'input', options: { placeholder: '请输入上级机构' }, rules: { required: true, message: '请输入上级机构', trigger: 'blur' } },
-        { label: '部门名称', prop: 'deptName', type: 'input', options: { placeholder: '请输入部门名称' }, rules: { required: true, message: '请输入部门名称', trigger: 'blur' } },
         {
-          label: '员工名称',
-          prop: 'employeeName',
-          type: 'input',
-          options: { disabled: this.isEdit, placeholder: '请输入员工名称' },
-          rules: { required: true, message: '请输入员工名称', trigger: 'blur' }
+          prop: 'parentOrganizationName',
+          hidden: true
         },
         {
-          label: '人员类别',
-          prop: 'personnelCategory',
-          type: 'input',
-          options: { disabled: this.isEdit, placeholder: '请输入人员类别' },
-          rules: { required: true, message: '请输入人员类别', trigger: 'blur' }
+          prop: 'parentOrganizationNo',
+          hidden: true
+        },
+        {
+          prop: 'deptName',
+          hidden: true
+        },
+        {
+          label: '部门名称',
+          prop: 'organizationNo',
+          type: 'cascader',
+          options: {
+            ref: 'organizationNo',
+            filterable: true,
+            clearable: true,
+            placeholder: '请选择部门',
+            options: this.organizationTree,
+            showAllLevels: false,
+            props: {
+              emitPath: false,
+              value: 'organizationNo',
+              label: 'organizationName',
+              children: 'child'
+            }
+          },
+          handles: {
+            change: this.onChange
+          }
         },
         {
           label: '通行证号',
@@ -45,6 +78,13 @@ export default {
           options: { disabled: this.isEdit, placeholder: '请输入通行证号' },
           rules: [{ required: true, message: '请输入通行证号', trigger: 'blur' }]
         },
+        {
+          label: '员工名称',
+          prop: 'employeeName',
+          type: 'input',
+          options: { disabled: this.isEdit, placeholder: '请输入员工名称' },
+          rules: { required: true, message: '请输入员工名称', trigger: 'blur' }
+        },
         {
           label: '工行时间',
           prop: 'tradeUnionsTime',
@@ -52,10 +92,62 @@ export default {
           options: { disabled: this.isEdit, placeholder: '请选择工行时间' },
           rules: [{ required: true, message: '请选择工行时间', trigger: 'blur' }]
         },
-        { label: '岗位名称', prop: 'postName', type: 'input', options: { placeholder: '请输入岗位名称' }, rules: { required: true, message: '请输入岗位名称', trigger: 'blur' } },
-        { label: '岗位序列', prop: 'positionSequence', type: 'input', options: { placeholder: '请输入岗位序列' }, rules: [{ required: true, message: '请输入岗位序列', trigger: 'blur' }] },
-        { label: '岗位类别', prop: 'positionCategory', type: 'input', options: { placeholder: '请输入岗位类别' }, rules: [{ required: true, message: '请输入岗位类别', trigger: 'blur' }] },
-        { label: '职务层级', prop: 'jobLevel', type: 'input', options: { placeholder: '请输入职务层级' }, rules: [{ required: true, message: '请输入职务层级', trigger: 'blur' }] },
+        {
+          label: '人员类别',
+          prop: 'personnelCategory',
+          type: 'select',
+          options: {
+            disabled: this.isEdit,
+            placeholder: '请输入人员类别',
+            filterable: true,
+            items: this.dict.personnelCategory
+          },
+          rules: { required: true, message: '请输入人员类别', trigger: 'change' }
+        },
+        {
+          label: '岗位名称',
+          prop: 'postName',
+          type: 'select',
+          options: {
+            placeholder: '请输入岗位名称',
+            filterable: true,
+            items: this.dict.jobName
+          },
+          rules: { required: true, message: '请输入岗位名称', trigger: 'change' }
+        },
+        {
+          label: '岗位序列',
+          prop: 'positionSequence',
+          type: 'select',
+          options: {
+            placeholder: '请输入岗位序列',
+            filterable: true,
+            items: this.dict.positionSequence
+          },
+          rules: [{ required: true, message: '请输入岗位序列', trigger: 'change' }]
+        },
+        {
+          label: '岗位类别',
+          prop: 'positionCategory',
+          type: 'select',
+          options: {
+            placeholder: '请输入岗位类别',
+            filterable: true,
+            items: this.dict.positionCategory
+          },
+          rules: [{ required: true, message: '请输入岗位类别', trigger: 'change' }]
+        },
+        {
+          label: '职务层级',
+          prop: 'jobLevel',
+          type: 'select',
+          options: {
+            placeholder: '请输入职务层级',
+            filterable: true,
+            items: this.dict.jobLevel
+          },
+          rules: [{ required: true, message: '请输入职务层级', trigger: 'change' }]
+        },
         {
           label: '薪酬档次',
           prop: 'salaryCategory',
@@ -87,15 +179,19 @@ export default {
         res[item.prop] = null
         return res
       }, {})
+      this.$nextTick(() => {
+        this.$refs.formRef.clearValidate()
+      })
       this.isEdit = Boolean(item)
       await this.getDict()
-      this.loading = false
+      await this.getOtherDict()
       if (item) {
         Object.keys(this.query).forEach(key => {
           this.query[key] = item[key]
         })
         this.query.personnelCode = item.personnelCode
       }
+      this.loading = false
     },
     handleSaveEdit () {
       this.$refs.formRef.validate(async valid => {
@@ -121,10 +217,22 @@ export default {
         }
       })
     },
+    onChange () {
+      const nodes = this.$refs.formRef.$refs.organizationNo.getCheckedNodes()
+      const node = nodes[0].data
+      const parent = nodes[0].parent.data
+      Object.assign(this.query, {
+        organizationNo: node.organizationNo,
+        deptName: node.organizationName,
+        parentOrganizationName: parent.organizationName,
+        parentOrganizationNo: parent.organizationNo
+      })
+    },
     async getDict () {
       try {
         const { data } = await getSalaryLevelDict()
-        this.dict = {
+        const dict = { ...this.dict }
+        Object.assign(dict, {
           gradeDict: data.gradeDict.map(e => {
             return {
               label: e,
@@ -137,7 +245,28 @@ export default {
               value: e
             }
           })
-        }
+        })
+        this.dict = dict
+      } catch (error) {
+        this.$message.error(error)
+      }
+    },
+    async getOtherDict () {
+      const lists = [
+        { key: 'jobLevel', fn: getJobLevel },
+        { key: 'positionCategory', fn: getPositionCategory },
+        { key: 'personnelCategory', fn: getPersonnelCategory },
+        { key: 'positionSequence', fn: getPositionSequence },
+        { key: 'jobName', fn: getJobName }
+      ]
+      try {
+        const result = await Promise.all(lists.map(item => item.fn()))
+        const dict = { ...this.dict }
+        Object.assign(dict, lists.reduce((res, item, index) => {
+          res[item.key] = result[index].data.map(e => ({ label: e, value: e }))
+          return res
+        }, {}))
+        this.dict = dict
       } catch (error) {
         this.$message.error(error)
       }

+ 3 - 3
src/views/humanResources/roster/rosterVersion.vue

@@ -64,8 +64,8 @@ export default {
           prop: 'versionDate',
           options: {
             placeholder: '请选择时间',
-            type: 'datetime',
-            valueFormat: 'yyyy-MM-dd HH:mm:ss'
+            type: 'month',
+            valueFormat: 'yyyy-MM'
           }
         },
         {
@@ -101,7 +101,7 @@ export default {
     async open (headers) {
       this.headers = headers
       this.show = true
-      const time = dateFormat('YYYY-mm-dd HH:MM:SS', new Date())
+      const time = dateFormat('YYYY-mm', new Date())
       this.searchValues.versionDate = time
       this.exportTime = time
       await this.init()