zhengnaiwen_citu il y a 7 mois
Parent
commit
ec6fea86d0

+ 10 - 0
src/api/salary.js

@@ -61,3 +61,13 @@ export function getWelfareCategoryPage (param) {
 export function getWelfareCategoryDetails (param) {
   return http.post('/subsidy/personnel/category/detail', param)
 }
+
+// 福利待遇 - 福利类型 保存
+export function saveWelfareCategory (param) {
+  return http.post('/subsidy/personnel/category/save', param)
+}
+
+// 福利待遇 - 福利类型 删除
+export function deleteWelfareCategory (param) {
+  return http.post('/subsidy/personnel/category/del', param)
+}

+ 1 - 1
src/api/system.js

@@ -150,6 +150,6 @@ export function downloadRosterTemplate (params) {
 }
 
 // 花名册钻取员工
-export function drillEmployee (params) {
+export function organizationDrill (params) {
   return http.post('/digitizationData/employee/organization/tree/subordinates', params)
 }

+ 2 - 4
src/components/AutoComponents/MDialog/index.vue

@@ -1,6 +1,7 @@
 <template>
   <el-dialog
     :visible.sync="show"
+    :title="title"
     width="800px"
     lock-scroll
     :close-on-click-modal="false"
@@ -21,10 +22,7 @@
 export default {
   name: 'm-dialog',
   props: {
-    // draggable: {
-    //   type: Boolean,
-    //   default: true
-    // }
+    title: String
   },
   data () {
     return {

+ 1 - 1
src/components/AutoComponents/MTable/index.vue

@@ -19,7 +19,7 @@
         </template>
       </m-table-column>
     </el-table>
-    <div class="pt-3 text-right">
+    <div class="pt-3 text-right" v-if="total">
       <el-pagination
         @current-change="handleCurrentChange"
         :current-page="pageCurrent"

+ 2 - 2
src/views/humanResources/organizationStructure/index.vue

@@ -18,7 +18,7 @@
 <script>
 import {
   getOrganizationTree,
-  drillEmployee
+  organizationDrill
 } from '@/api/system'
 export default {
   name: 'organization-structure',
@@ -51,7 +51,7 @@ export default {
     },
     async load (tree, treeNode, resolve) {
       try {
-        const { data } = await drillEmployee({ deptName: tree.organizationName })
+        const { data } = await organizationDrill({ deptName: tree.organizationName })
         resolve(data)
       } catch (error) {
         this.$message.error(error)

+ 22 - 14
src/views/humanResources/welfare/index.vue

@@ -1,32 +1,40 @@
 <template>
   <div class="white pa-3">
-    <el-tabs v-model="activeName">
-      <el-tab-pane label="福利待遇列表" name="welfareList">
-        <welfare-list></welfare-list>
-      </el-tab-pane>
-      <el-tab-pane label="福利类型" name="welfareType">
-        <welfare-type></welfare-type>
+    <el-tabs v-model="activeName" @tab-click="onClick">
+      <el-tab-pane v-for="item in items" :key="item.name" :label="item.label" :name="item.name">
+        <component :is="item.component"></component>
       </el-tab-pane>
     </el-tabs>
   </div>
 </template>
 
 <script>
-import welfareList from './welfareList.vue'
-import welfareType from './welfareType.vue'
 export default {
   name: 'human-resources-welfare',
-  components: {
-    welfareList,
-    welfareType
-  },
   data () {
     return {
-      activeName: 'welfareList'
+      activeName: null,
+      items: []
     }
   },
   created () {
-    console.log(this.$route)
+    this.items = this.$route.meta.roles.map(e => {
+      return {
+        name: e.name,
+        label: e.label,
+        component: () => import(`@/views/${e.component}.vue`)
+      }
+    })
+    if (!this.$route.query.active) {
+      this.activeName = this.items[0].name
+    } else {
+      this.activeName = this.$route.query.active
+    }
+  },
+  methods: {
+    onClick (tab) {
+      this.$router.push({ query: { active: tab.name } })
+    }
   }
 }
 </script>

+ 2 - 2
src/views/humanResources/welfare/welfareList.vue

@@ -85,7 +85,7 @@ export default {
           prop: 'subsidyName',
           type: 'input',
           option: {
-            placeholder: '请输入补助名称'
+            placeholder: '请输入福利名称'
           }
         },
         {
@@ -93,7 +93,7 @@ export default {
           prop: 'subsidyPersonnelCategoryId',
           type: 'select',
           option: {
-            placeholder: '请输入补助分类',
+            placeholder: '请输入福利类别',
             filterable: true,
             remote: true,
             remoteMethod: this.remoteMethod,

+ 2 - 0
src/views/humanResources/welfare/welfareListEdit.vue

@@ -41,6 +41,8 @@ export default {
             placeholder: '请选择福利类型',
             filterable: true,
             remote: true,
+            labelText: 'title',
+            labelValue: 'subsidyPersonnelCategoryId',
             remoteMethod: this.remoteMethod,
             valueKey: 'subsidyPersonnelCategoryId',
             defaultFirstOption: true,

+ 82 - 12
src/views/humanResources/welfare/welfareType.vue

@@ -13,22 +13,45 @@
       :page-current="pageInfo.current"
       v-loading="loading"
       @page-change="onPageChange"
-    ></m-table>
+    >
+      <template #actions="{ row }">
+        <m-button type="primary" text size="small" @click="onEdit(row)">编辑</m-button>
+        <m-button type="danger" text size="small" @click="onDelete(row)">删除</m-button>
+      </template>
+    </m-table>
+    <welfareTypeEdit ref="editRefs" @refresh="onInit"></welfareTypeEdit>
   </div>
 </template>
 
 <script>
+import welfareTypeEdit from './welfareTypeEdit.vue'
+import {
+  getWelfareCategoryPage,
+  getWelfareCategoryDetails,
+  deleteWelfareCategory
+} from '@/api/salary'
 export default {
   name: 'welfare-type',
+  components: {
+    welfareTypeEdit
+  },
   data () {
     return {
       searchItems: [
         {
-          label: '类型/描述',
+          label: '类型',
+          type: 'input',
+          prop: 'title',
+          option: {
+            placeholder: '请输入福利类型'
+          }
+        },
+        {
+          label: '描述',
           type: 'input',
-          prop: 'welfareType',
+          prop: 'tag',
           option: {
-            placeholder: '请输入福利类型 / 描述'
+            placeholder: '请输入福利描述'
           }
         }
       ],
@@ -38,16 +61,19 @@ export default {
       headers: [
         {
           label: '福利类型',
-          prop: 'welfareType'
+          prop: 'title'
         },
         {
           label: '描述',
-          prop: 'description'
+          prop: 'tag'
+        },
+        {
+          label: '创建时间',
+          prop: 'createDate'
         },
         {
           label: '操作',
-          prop: 'action',
-          width: 200
+          prop: 'actions'
         }
       ],
       items: [],
@@ -63,10 +89,54 @@ export default {
     this.onInit()
   },
   methods: {
-    onInit () {},
-    onAdd () {},
-    onSearch () {},
-    onPageChange () {}
+    async onInit () {
+      this.loading = true
+      try {
+        const { data } = await getWelfareCategoryPage({
+          page: this.pageInfo,
+          entity: this.searchValues
+        })
+        this.items = data.records
+      } catch (error) {
+        this.$message.error(error)
+      } finally {
+        this.loading = false
+      }
+    },
+    onAdd () {
+      this.$refs.editRefs.open()
+    },
+    async onEdit (item) {
+      try {
+        const { data } = await getWelfareCategoryDetails({ subsidyPersonnelCategoryId: item.subsidyPersonnelCategoryId })
+        this.$refs.editRefs.open(data)
+      } catch (error) {
+        this.$message.error(error)
+      }
+    },
+    onDelete (item) {
+      this.$confirm('确定删除该条数据?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(async () => {
+        try {
+          await deleteWelfareCategory({ subsidyPersonnelCategoryId: item.subsidyPersonnelCategoryId })
+          this.$message.success('删除成功')
+          this.onInit()
+        } catch (error) {
+          this.$message.error(error)
+        }
+      })
+    },
+    onSearch () {
+      this.pageInfo.current = 1
+      this.onInit()
+    },
+    onPageChange (index) {
+      this.pageInfo.current = index
+      this.onInit()
+    }
   }
 }
 </script>

+ 208 - 0
src/views/humanResources/welfare/welfareTypeEdit.vue

@@ -0,0 +1,208 @@
+<template>
+  <m-dialog ref="dialog" :title="title" v-bind="$attrs" v-on="$listeners" @sure="onSure">
+    <m-form ref="form" :items="formItems" label-width="180px" v-model="values" v-loading="loading">
+      <template #organizationName>
+        <el-dropdown trigger="click">
+          <el-input v-model="values.organizationName" readonly placeholder="请选择职务所属机构"></el-input>
+          <el-dropdown-menu slot="dropdown">
+            <div class="treeBox">
+              <el-tree
+                :data="treeItems"
+                node-key="uuid"
+                show-checkbox
+                :highlight-current="true"
+                :expand-on-click-node="false"
+                :default-expanded-keys="expandRowKeys"
+                :default-checked-keys="defaultCheckedKeys"
+                :props="{ label: 'organizationName', children: 'child' }"
+                @check="onCheck"
+              ></el-tree>
+            </div>
+          </el-dropdown-menu>
+        </el-dropdown>
+      </template>
+    </m-form>
+  </m-dialog>
+</template>
+
+<script>
+import { organizationDrill, getOrganizationTree } from '@/api/system'
+import {
+  saveWelfareCategory
+} from '@/api/salary'
+export default {
+  name: 'welfare-type-edit',
+  data () {
+    return {
+      loading: false,
+      headers: [
+        { label: '职务名称', prop: 'organizationName' },
+        { label: '应用部门', prop: 'tag' }
+      ],
+      title: '',
+      values: {},
+      choose: [],
+      defaultCheckedKeys: [],
+      items: [],
+      treeItems: [],
+      expandRowKeys: []
+    }
+  },
+  computed: {
+    formItems () {
+      return [
+        {
+          label: '福利类型名称',
+          prop: 'title',
+          type: 'input',
+          options: {
+            placeholder: '请输入福利类型名称'
+          },
+          rules: [
+            { required: true, message: '请输入福利类型名称', trigger: 'blur' }
+          ]
+        },
+        {
+          label: '职务名称',
+          prop: 'postName',
+          type: 'select',
+          options: {
+            items: this.items,
+            labelText: 'organizationName',
+            labelValue: 'organizationName'
+          },
+          rules: [
+            { required: true, message: '请选择职务', trigger: 'change' }
+          ]
+        },
+        {
+          label: '机构',
+          prop: 'organizationName',
+          rules: [
+            { required: true, message: '请选择机构', trigger: 'change' }
+          ]
+        },
+        {
+          label: '描述',
+          prop: 'tag',
+          type: 'input',
+          options: {
+            type: 'textarea',
+            placeholder: '请输入描述'
+          }
+        }
+      ]
+    }
+  },
+  methods: {
+    async open (item) {
+      this.loading = true
+      this.$refs.dialog.open()
+      await this.getData()
+      await this.getOrganizationTree()
+      this.loading = false
+      if (!item) {
+        this.title = '新增福利类型'
+        this.values = {
+          title: null,
+          tag: null,
+          postName: null,
+          organizationName: null
+        }
+        this.defaultCheckedKeys = []
+      } else {
+        this.title = '编辑福利类型'
+        this.values = {
+          subsidyPersonnelCategoryId: item.subsidyPersonnelCategoryId,
+          title: item.title,
+          tag: item.tag,
+          postName: item.subsidyPersonnelCategoryItems[0]?.postName ?? null,
+          organizationName: this.onShow(item.subsidyPersonnelCategoryItems.length)
+        }
+        this.choose = item.subsidyPersonnelCategoryItems
+        this.defaultCheckedKeys = this.onGetUUID(item.subsidyPersonnelCategoryItems, this.treeItems)
+      }
+    },
+    onSure () {
+      this.$refs.form.validate(async valid => {
+        if (!valid) {
+          return
+        }
+        try {
+          await saveWelfareCategory({
+            subsidyPersonnelCategory: {
+              subsidyPersonnelCategoryId: this.values.subsidyPersonnelCategoryId,
+              title: this.values.title,
+              tag: this.values.tag
+            },
+            subsidyPersonnelCategoryItems: this.choose.map(e => {
+              return {
+                postName: this.values.postName,
+                organizationName: e.organizationName,
+                level: e.level
+              }
+            })
+          })
+          this.$message.success('保存成功')
+          this.$refs.dialog.close()
+          this.$emit('refresh')
+        } catch (error) {
+          this.$message.error(error)
+        }
+      })
+    },
+    async getOrganizationTree () {
+      try {
+        const { data } = await getOrganizationTree()
+        this.expandRowKeys = [data.uuid]
+        this.treeItems = [data]
+      } catch (error) {
+        this.$message.error(error)
+      }
+    },
+    async getData () {
+      try {
+        const { data } = await organizationDrill({ resDataType: 1 })
+        this.items = data.map(e => {
+          return {
+            ...e,
+            value: null
+          }
+        })
+      } catch (error) {
+        this.$message.error(error)
+      }
+    },
+    onGetUUID (arr, items, content = []) {
+      items.forEach(e => {
+        if (e.child && e.child.length) {
+          content.push(...this.onGetUUID(arr, e.child, content))
+        }
+        const item = arr.find(_e => _e.level === e.level && _e.organizationName === e.organizationName)
+        if (item) {
+          content.push(e.uuid)
+        }
+      })
+      return content
+    },
+    onShow (val) {
+      if (!val) {
+        return null
+      }
+      return `已选 ${val} 个机构`
+    },
+    onCheck (data, event) {
+      this.choose = event.checkedNodes
+      this.values.organizationName = this.onShow(this.choose.length)
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.treeBox {
+  width: 250px;
+  max-height: 400px;
+  overflow: auto;
+}
+</style>