Parcourir la source

花名册适配全景

zhengnaiwen_citu il y a 8 mois
Parent
commit
8a9d6f32b5
1 fichiers modifiés avec 33 ajouts et 18 suppressions
  1. 33 18
      src/views/humanResources/roster/index.vue

+ 33 - 18
src/views/humanResources/roster/index.vue

@@ -1,6 +1,6 @@
 <template>
-  <div class="white" :class="{ 'pa-3': !panorama.organizationNo }">
-    <m-search v-if="!panorama.organizationNo" :items="searchItems" v-model="searchValues" class="mb-3" @search="onSearch">
+  <div class="white" :class="{ 'pa-3': !$attrs.panorama }">
+    <m-search v-if="!$attrs.panorama" :items="searchItems" v-model="searchValues" class="mb-3" @search="onSearch">
       <template #button>
         <m-button type="primary" icon="el-icon-plus" plain @click="onAdd">新增</m-button>
         <el-upload class="el-button pa-0" action="#" :show-file-list="false" :http-request="onImport">
@@ -41,6 +41,7 @@ import {
   exportRoster,
   downloadRosterTemplate
 } from '@/api/system'
+import { mapGetters } from 'vuex'
 export default {
   name: 'sys-roster',
   components: { rosterEdit },
@@ -82,6 +83,7 @@ export default {
     }
   },
   computed: {
+    ...mapGetters(['organizationTree']),
     searchItems () {
       return [
         {
@@ -95,10 +97,19 @@ export default {
         {
           label: '部门名称',
           options: {
-            placeholder: '请输入机构名称'
+            clearable: true,
+            placeholder: '请选择部门',
+            options: this.organizationTree,
+            showAllLevels: false,
+            props: {
+              emitPath: false,
+              value: 'organizationNo',
+              label: 'organizationName',
+              children: 'child'
+            }
           },
-          prop: 'organizationName',
-          type: 'input'
+          prop: 'organizationNo',
+          type: 'cascader'
         }
       ]
     }
@@ -118,32 +129,36 @@ export default {
         this.searchValues = {
           personnelCode: employeeNo
         }
-        return
-      }
-      this.searchValues = {
-        organizationNo: organizationNo
+      } else {
+        this.searchValues = {
+          organizationNo: organizationNo
+        }
       }
       this.init()
     },
     async init () {
       this.loading = true
       const query = {}
-      if (this.searchValues.personnelCode) {
-        query.entity = {
-          personnelCode: this.searchValues.personnelCode
+      if (Object.keys(this.panorama).length > 0) {
+        if (this.searchValues.personnelCode) {
+          query.entity = {
+            personnelCode: this.searchValues.personnelCode
+          }
         }
-      }
-      if (this.searchValues.organizationNo) {
+        if (this.searchValues.organizationNo) {
+          Object.assign(query, {
+            organizationNo: this.searchValues.organizationNo
+          })
+        }
+      } else {
         Object.assign(query, {
-          organizationNo: this.searchValues.organizationNo
+          entity: this.searchValues
         })
       }
       try {
         const { data } = await getRosterList({
           page: { ...this.pageInfo, orders: this.orders },
-          entity: {
-            ...this.searchValues
-          }
+          ...query
         })
         this.items = data.records.map(e => {
           const date = new Date(e.tradeUnionsTime)