소스 검색

task-6633 内部培训统计增加导出功能

tianxinyu 5 일 전
부모
커밋
fd2bb6ec93
1개의 변경된 파일78개의 추가작업 그리고 4개의 파일을 삭제
  1. 78 4
      src/views/component/trainingManage/index.vue

+ 78 - 4
src/views/component/trainingManage/index.vue

@@ -85,6 +85,8 @@ import ibpsUserSelector from '@/business/platform/org/selector'
 
 import { getUserStatisticList } from '@/api/platform/org/employee'
 import TrainingStatic from './trainingStatic.vue'
+import dayjs from 'dayjs'
+import IbpsExport from '@/plugins/export'
 
 export default {
   components: {
@@ -93,10 +95,13 @@ export default {
   },
   mixins: [FixHeight],
   data() {
-    const { level, userList } = this.$store.getters
+    const { level, userList, deptList, setting } = this.$store.getters
+    console.log('1111111', setting)
     return {
+      exportBtn: setting?.intTrainStats?.exportBtn || false,
       level: level.second || level.first,
       userList: userList,
+      deptList: deptList,
       dialogVisible: false,
       params: {},
       loading: false,
@@ -154,7 +159,7 @@ export default {
       //   listTreeData: [],
       listConfig: {
         // 工具栏
-        toolbars: [{ key: 'search' }],
+        toolbars: [{ key: 'search' },],
         // 查询条件
         searchForm: {
           forms: [
@@ -200,8 +205,18 @@ export default {
       pos: ''
     }
   },
+  created() {
+    if(this.exportBtn){
+      this.listConfig.toolbars[1] = {
+        key: 'customExport',
+        label: '导出',
+        icon: 'ibps-icon-sign-in',
+        type: 'primary'
+      }
+    }
+  },
   mounted() {
-    this.getDatas()
+    this.getDatas()  
   },
 
   methods: {
@@ -237,7 +252,6 @@ export default {
       console.log('params', params)
       try {
         const { data: tempList } = await getUserStatisticList(params)
-        console.log('接口数据', tempList)
         tempList.forEach((item) => {
           item.jian_ding_zi_ge_z = item.jian_ding_zi_ge_z
             ? item.jian_ding_zi_ge_z
@@ -294,10 +308,70 @@ export default {
         case 'search': // 查询
           this.refreshData()
           break
+        case 'customExport':
+          this.handleCustomExport(selection, data)
+          break
         default:
           break
       }
     },
+    handleCustomExport() {
+      const userMap = new Map(this.userList.map(item => [item.userId, item.userName]));
+      const positionMap = new Map(this.deptList.map(item => [item.positionId, item.positionName]));
+      
+      this.selectListData.forEach(item => { 
+        item.id_ = userMap.get(item.id_)
+        item.positions_ = item.positions_
+            .split(',')
+            .map(pos => positionMap.get(pos.trim()))
+            .filter(val => val !== undefined)
+            .join(',');//positionMap.get(item.positions_)
+      })
+
+      const exportColumns = [
+        {
+          field_name: 'id_',
+          label: '姓名',
+          name: 'id_'
+        },
+        {
+          field_name: 'positions_',
+          label: '部门',
+          name: 'positions_'
+        },
+        {
+          field_name: 'jian_ding_zi_ge_z',
+          label: '工号',
+          name: 'jian_ding_zi_ge_z'
+        },
+        {
+          field_name: 'planedjoin',
+          label: '应参训次数',
+          name: 'planedjoin'
+        },
+        {
+          field_name: 'truejoin',
+          label: '实参训次数',
+          name: 'truejoin'
+        },
+        {
+          field_name: 'participationRate',
+          label: '参训率',
+          name: 'participationRate'
+        }
+      ]
+      IbpsExport.excel({
+        columns: exportColumns,
+        data: this.selectListData,
+        nameKey: 'name',
+        title: '内部培训统计' + this.getTimeStamp()
+      }).then(() => {
+        ActionUtils.success('导出成功')
+      })
+    },
+    getTimeStamp() {
+      return dayjs().format('YYYYMMDDHHmmss')
+    },
     /**
      * 处理排序
      */