Просмотр исходного кода

人员管理看板通用接口调整,数据处理逻辑重构

cfort 10 месяцев назад
Родитель
Сommit
515cd1866f

+ 1 - 1
src/store/modules/ibps/modules/user.js

@@ -207,7 +207,7 @@ export default {
         getDeptList ({ state, dispatch }, { first, second }) {
             const params = second ? ` and (pe.path_ like '%${second}%' or pe.id_ = '${first}')` : first ? ` and pe.path_ like '%${first}%'` : ''
             // const sql = `select id_ as positionId, name_ as positionName, path_ as path, depth_ as depth, sn_ as sn from ibps_party_entity where party_type_ = 'position'${params} order by depth_ asc, sn_ asc`
-            // const sql = `select pe.id_ as positionId, pe.name_ as positionName, pe.path_ as path, pe.depth_ as depth, pe.party_alias_ as alias, pe.sn_ as sn, ifnull(r.name_, '') as manager, ifnull(r.id_, '') as managerId from ibps_party_entity as pe left join (select em.id_, em.positions_, em.name_ from ibps_party_employee as em left join ibps_party_user_role as ur on em.id_ = ur.user_id_ left join ibps_party_role as pr on pr.id_ = ur.role_id_ where role_alias_ in ('zhsfzr', 'syszr', 'zhglzzc')) as r on find_in_set(pe.id_, r.positions_) > 0 where pe.party_type_ = 'position' and pe.path_ like CONCAT('%', ${first}, '%') group by pe.id_ order by pe.depth_ asc, pe.sn_ asc,pe.id_ asc`
+            // const sql = `select pe.id_ as positionId, pe.name_ as positionName, pe.path_ as path, pe.depth_ as depth, pe.party_alias_ as alias, pe.sn_ as sn, pe.parent_id_ as parentId, ifnull(r.name_, '') as manager, ifnull(r.id_, '') as managerId from ibps_party_entity as pe left join (select em.id_, em.positions_, em.name_ from ibps_party_employee as em left join ibps_party_user_role as ur on em.id_ = ur.user_id_ left join ibps_party_role as pr on pr.id_ = ur.role_id_ where role_alias_ in ('zhsfzr', 'syszr', 'zhglzzc')) as r on find_in_set(pe.id_, r.positions_) > 0 where pe.party_type_ = 'position' and pe.path_ like CONCAT('%', ${first}, '%') group by pe.id_ order by pe.depth_ asc, pe.sn_ asc,pe.id_ asc`
             common.request('query', {
                 key: 'getDeptList',
                 params: [first]

+ 38 - 145
src/views/component/selectPositions.vue

@@ -1,7 +1,7 @@
 <template>
     <el-cascader
         ref="cascader"
-        v-model="selectDatas"
+        v-model="selection"
         :options="options"
         :props="props"
         collapse-tags
@@ -21,163 +21,56 @@ export default {
         }
     },
     data () {
-        const { level, userId, userInfo } = this.$store.getters
+        const { level } = this.$store.getters
         return {
             level,
-            userId,
-            userInfo,
             props: {
                 children: 'children',
-                label: 'NAME_',
-                value: 'ID_',
+                label: 'positionName',
+                value: 'positionId',
                 multiple: false,
                 expandTrigger: 'hover',
-                checkStrictly: true
+                checkStrictly: true,
+                emitPath: false
             },
-            sqlDatas: [],
             options: [],
-            selectDatas: [],
-            iniselectDatas: []
+            selection: '',
+            selectionDept: {},
+            filterDept: []
         }
     },
     watch: {
-        selectDatas (v) {
-            if (v.length == 0) {
-                this.selectDatas = this.iniselectDatas
-                this.$emit('handleFunc', this.iniselectDatas)
-            } else {
-                this.$emit('handleFunc', { v, i: this.sqlDatas })
+        selection (val) {
+            if (!val) {
+                return
             }
+            this.$emit('handleSelectionChange', { selection: this.selection, selectionDept: this.selectionDept, filterDept: this.filterDept })
         }
     },
     mounted () {
         this.getPositionList()
     },
     methods: {
-    // 获取本账户所在的部门
+        // 获取本账户所在的部门
         getPositionList () {
-            let positonsSql = ''
-            // 金通账号id
-            //   if (this.userId == "702117247933480960") {
-            //     positonsSql = `select * FROM ibps_party_entity WHERE party_type_ = 'position'
-            //             AND (
-            //             DEPTH_ IN (1,2) OR (
-            //             (DEPTH_=3 AND NAME_ = '检验科') OR  parent_id_ IN (SELECT id_ FROM ibps_party_entity WHERE DEPTH_=3 AND NAME_ = '检验科'  )  )
-            //             )`;
-            //   } else {
-            //     // 所属医院的系统管理员
-            //     let isAdmin = this.userInfo.role.some((so) => {
-            //       return so.name == "系统管理角色";
-            //     });
-            //     if (isAdmin) {
-            //       positonsSql = `select * from ibps_party_entity where party_type_ = 'position' and PATH_ like '%${this.level.first}%'
-            //       AND (
-            //             DEPTH_ IN (1,2) OR (
-            //             (DEPTH_=3 AND NAME_ = '检验科') OR  parent_id_ IN (SELECT id_ FROM ibps_party_entity WHERE DEPTH_=3 AND NAME_ = '检验科'  )  )
-            //             )`;
-            //     } else {
-            //       let allPositions = [];
-            //       for (var i of this.userInfo.positions) {
-            //         for (var item of i.path.split(".")) {
-            //           if (item !== "") {
-            //             allPositions.push(`id_ like '%${item}%'`);
-            //           }
-            //         }
-            //       }
-            //       allPositions = [...new Set(allPositions)];
-            //       // 如果是单纯的是普通账户登录,就只显示所属部门的信息
-            //       positonsSql = `select * from ibps_party_entity where ${allPositions.join(
-            //         " or "
-            //       )}`;
-            //     }
-            //   }
-            // 所属医院的系统管理员
-            const isAdmin = this.userInfo.role.some((so) => {
-                return so.name == '系统管理角色'
-            })
-            //   if (isAdmin) {
-            //     positonsSql = `select * from ibps_party_entity where party_type_ = 'position' and PATH_ like '%${this.level.first}%'
-            //       AND (
-            //             DEPTH_ not  IN (1,2) OR (
-            //             (DEPTH_=3 AND NAME_ = '检验科') OR  parent_id_ IN (SELECT id_ FROM ibps_party_entity WHERE DEPTH_=3 AND NAME_ = '检验科'  )  )
-            //             )`;
-            //   } else {
-            //     let allPositions = [];
-            //     for (var i of this.userInfo.positions) {
-            //       for (var item of i.path.split(".")) {
-            //         if (item !== "") {
-            //           allPositions.push(`id_ like '%${item}%'`);
-            //         }
-            //       }
-            //     }
-            //     allPositions = [...new Set(allPositions)];
-            //     // 如果是单纯的是普通账户登录,就只显示所属部门的信息
-            //     positonsSql = `select * from ibps_party_entity where (${allPositions.join(
-            //       " or "
-            //     )}) and DEPTH_ not  IN (1,2)`;
-            //   }
-            // positonsSql = `select * from ibps_party_entity where party_type_ = 'position' and PATH_ like concat('%', '${this.level.first}', '%') AND (DEPTH_ not IN (1,2) OR ((DEPTH_ = 3 AND NAME_ = '检验科') OR parent_id_ IN (SELECT id_ FROM ibps_party_entity WHERE DEPTH_=3 AND NAME_ = '检验科')))`
-            this.$common.request('query', {
-                key: 'getDeptInEmpBoard',
-                params: [this.level.first]
-            }).then((res) => {
-                if (res.state === 200) {
-                    let datas = res.variables.data
-                    this.sqlDatas = datas
-                    const positionsValue = []
-                    if (datas.length > 0) {
-                        if (this.filterGroup) {
-                            datas = datas.filter(fil => {
-                                console.log(datas)
-                                return fil.ID_ !== '1166373874003083264' && fil.NAME_.indexOf('综合') == -1
-                            })
-                        }
-
-                        this.options = this.toTree(datas)
-                        // for (var i of this.options) {
-                        //   //   if (i.children !== undefined) {
-                        //   //   }
-                        //   const getTail = (item) =>
-                        //     item.children && item.children.length > 0
-                        //       ? item.children.map((m) => getTail(m))
-                        //       : [item];
-                        //   let result = _.flattenDeep(i.children.map((m) => getTail(m)));
-                        //   console.log('result', result)
-
-                        //   for (var item of result) {
-                        //     let itemArr = item.PATH_.split(".");
-                        //     // console.log('itemArr', itemArr)
-
-                        //     itemArr.splice(itemArr.length - 1, 1);
-                        //     positionsValue.push(itemArr);
-                        //   }
-                        // }
-                        for (var i of datas) {
-                            console.log(i, datas)
-
-                            const itemArr = i.PATH_.split('.')
-                            // 先删除前面部门的数据,比如:"xxx医院/院本部/检验科.....",只保留"检验科....."
-                            itemArr.splice(0, 2)
-                            itemArr.splice(itemArr.length - 1, 1)
-                            if (this.filterGroup && (i.ID_ === '1166373874003083264' || i.NAME_.indexOf('综合') != -1)) {
-
-                            } else {
-                                positionsValue.push(itemArr)
-                            }
-                        }
-                        // this.selectDatas = positionsValue;
-                        this.selectDatas = positionsValue.slice(0, 2).map(item => item[item.length - 1])
-                        if (this.iniselectDatas.length == 0) {
-                            this.iniselectDatas = positionsValue
-                        }
-                    }
-                }
-            })
+            // 直接获取store部门数据,无需调用接口
+            // this.$common.request('query', {
+            //     key: 'empManageBoard0',
+            //     params: [this.level.first]
+            // }).then(({ state, variables: { data } }) => {
+            const { deptList = [], mainPosition, position } = this.$store.getters || {}
+            const mainPos = mainPosition ? mainPosition.id : position.split(',')[0]
+            this.selection = mainPos
+            this.selectionDept = deptList.find(i => i.positionId === mainPos)
+            const deptEntity = deptList.filter(i => i.depth >= 3)
+            const filterLetter = ['综合', '质量', '科研', '教学', '医疗', '样品', '助理', '急诊']
+            this.filterDept = this.filterGroup ? deptEntity.filter(d => !filterLetter.some(i => d.positionName.includes(i))) : deptEntity
+            this.options = this.toTree(this.filterDept)
         },
         toTree (data) {
             return TreeUtils.transformToTreeFormat(data, {
-                idKey: 'ID_',
-                pIdKey: 'PARENT_ID_',
+                idKey: 'positionId',
+                pIdKey: 'parentId',
                 childrenKey: 'children'
             })
         }
@@ -185,13 +78,13 @@ export default {
 }
 </script>
 <style lang="less" scoped>
-/deep/ .el-tag--info {
-  color: #fcfcfc;
-  background-color: #00083e;
-}
-/deep/.el-input__inner {
-  background-color: #00083e;
-  border: 1px solid #4ea5d6;
-  color: #fff;
-}
+    /deep/ .el-tag--info {
+    color: #fcfcfc;
+    background-color: #00083e;
+    }
+    /deep/.el-input__inner {
+    background-color: #00083e;
+    border: 1px solid #4ea5d6;
+    color: #fff;
+    }
 </style>

+ 153 - 365
src/views/peopleManages/taskStatistics/index.vue

@@ -55,7 +55,7 @@
                         "
                     >
                         <!-- 部门选择 -->
-                        <SelectPositions :filterGroup="true" @handleFunc="handleFunc" />
+                        <select-positions :filter-group="true" @handleSelectionChange="initData" />
                         <div
                             style="
                                 width: 30%;
@@ -170,28 +170,27 @@ export default {
         ExamStatistics: () => import('../personComcont/ExamStatistics')
     },
     data () {
-        const { level } = this.$store.getters
+        const { level, userList = [] } = this.$store.getters
+        userList.filter(i => i.userName === 'admin').map(i => i.id)
         const colorGroup1 = ['#d20962', '#f47721', '#00bce4', '#7552cc']
         const colorGroup2 = ['#00a78e', '#7d3f98', '#f85a40']
         return {
             level: level.second || level.first,
+            userList,
             monthValues: [],
             startDate: '',
             endDate: '',
             employeeNum: 0,
-            //   employeeInfo: [],
-            otherPositions: [], // 用于其他图sql条件查询
-            positions: [], // 用于部门统计信息sql条件查询
-            // 查询出来的部门选择数据
-            sqlPositionsDatasIni: [],
-            // 轮询部门信息用
-            positionIni: [],
+            // 部门Data
+            selectionDept: {},
+            // 部门ID
+            selection: '',
+            // 过滤后的所有部门
+            filterDept: [],
             // 判断是否初步加载,1:已初步加载
             initOnLoad: 0,
             // 人员id
             personIds: '',
-            // 部门数组
-            positionsIdArr: [],
             // 日期选择配置
             pickerOptions: {
                 shortcuts: [{
@@ -820,35 +819,10 @@ export default {
         }
     },
     created () {
-        const initendDate = new Date()
-        // this.endDate =
-        //     initendDate.getFullYear() +
-        //     '-' +
-        //     (initendDate.getMonth() + 1 > 9
-        //         ? initendDate.getMonth() + 1
-        //         : '0' + (initendDate.getMonth() + 1)) +
-        //     '-' +
-        //     (initendDate.getDate() > 9
-        //         ? initendDate.getDate()
-        //         : '0' + initendDate.getDate()) +
-        //     ' 23:59:59'
-        // this.startDate = this.preDate(this.endDate, 60) + ' 00:00:00'
-
-        // this.monthValues = [
-        //     new Date(this.startDate),
-        //     new Date(
-        //         initendDate.getFullYear() +
-        //             '-' +
-        //             (initendDate.getMonth() + 1) +
-        //             '-' +
-        //             initendDate.getDate()
-        //     )
-        // ]
         if (screenfull.isEnabled && !screenfull.isFullscreen) {
             this.allView()
         }
     },
-    mounted () {},
     beforeDestroy () {
         if (this.interval) {
             clearInterval(this.interval)
@@ -859,69 +833,21 @@ export default {
     },
     methods: {
         changeDate (value) {
-            // const year = value[1].getFullYear()
-            // const month = value[1].getMonth() + 1
-            // // 这里传入的是整数时间,返回的是下个月的第一天,因为月份是0-11
-            // const nextMonthFirthDay = new Date(year, month, 1) // 下个月的第一天
-            // const oneDay = 1000 * 60 * 60 * 24 // 一天的时间毫秒数
-            // const endDay = new Date(nextMonthFirthDay - oneDay)
-            // const day = endDay.getDate() // 本月最后一天
-            // this.endDate =
-            //     value[1].getFullYear() +
-            //     '-' +
-            //     (value[1].getMonth() + 1 > 9
-            //         ? value[1].getMonth() + 1
-            //         : '0' + (value[1].getMonth() + 1)) +
-            //     '-' +
-            //     (day > 9 ? day : '0' + day) +
-            //     ' 23:59:59'
-            // this.startDate =
-            //     value[0].getFullYear() +
-            //     '-' +
-            //     (value[0].getMonth() + 1 > 9
-            //         ? value[0].getMonth() + 1
-            //         : '0' + (value[0].getMonth() + 1)) +
-            //     '-' +
-            //     (value[0].getDate() > 9
-            //         ? value[0].getDate()
-            //         : '0' + value[0].getDate()) +
-            //     ' 00:00:00'
-            // this.getTtaskMattersData()
-            if (value && value.length) {
-                this.startDate = value[0]
-                this.endDate = value[1]
-            } else {
-                this.startDate = ''
-                this.endDate = ''
-            }
+            this.startDate = value?.[0] || ''
+            this.endDate = value?.[1] || ''
             // console.log(this.startDate, this.endDate)
             this.getTrainingStatisticsData()
             this.getExamStatisticsData()
         },
         // 人员基本信息 轮播表数据
         async employeeInfoData () {
-            let data = []
-            this.optionPerson.yAxis.data = []
-            const positionsWhere =
-                this.otherPositions.length !== 0
-                    ? `(${this.otherPositions.join(' or ')} )`
-                    : `ee.positions_ = '没有选择部门'`
-            const sql = `select a.id_,a.parent_id_,ee.name_,a.zui_gao_xue_li_x_,a.zhi_cheng_deng_ji,ee.jian_ding_zi_ge_z,a.ren_zhi_shi_jian_,
-      a.ru_zhi_shi_jian_ from  t_ryjbqk as a join  ibps_party_employee as ee on a.parent_id_= ee.id_ where a.id_ !='861622496187645952' and ${positionsWhere}`
-            await curdPost('sql', sql).then((res) => {
-                data = res.variables.data
-            })
-            if (this.initOnLoad === 0) {
-                this.employeeNum = data.length
-                this.initOnLoad = 1
-            }
-            const personIdsArr = []
-            for (const it of data) {
-                personIdsArr.push(it.parent_id_)
-                this.optionPerson.yAxis.data.push(it.name_)
-            }
-            this.personIds = personIdsArr.join(',')
-            this.getTtaskMattersData()
+            // const sql = `select a.id_, a.parent_id_, a.zui_gao_xue_li_x_, a.zhi_cheng_deng_ji, a.ren_zhi_shi_jian_, a.ru_zhi_shi_jian_, ee.name_, ee.jian_ding_zi_ge_z from t_ryjbqk as a join ibps_party_employee as ee on a.parent_id_= ee.id_`
+            // const { variables: { data = [] }} = await this.$common.request('query', { key: 'empManageBoard1', params: [null] }) || {}
+            const deptUserList = this.userList.filter(item => item.positionId.includes(this.selection))
+            this.employeeNum = this.userList.length
+            this.personIds = deptUserList.map(i => i.userId).join(',')
+            this.optionPerson.yAxis.data = deptUserList.map(i => i.userName)
+            // this.getTtaskMattersData()
         },
         // 饼图 环形图数据
         async degreeGradeInfoData () {
@@ -932,265 +858,160 @@ export default {
             this.ranksPieData.data[0].value = 0
             this.ranksPieData.data[1].value = 0
             this.ranksPieData.data[2].value = 0
-            let data = []
-            const positionsWhere =
-                this.otherPositions.length !== 0
-                    ? `(${this.otherPositions.join(' or ')} )`
-                    : `ee.positions_ = '没有选择部门'`
-            const sql = `select
-                sum(a.zui_gao_xue_li_x_ like '%博士%') as boShi,
-                sum(a.zui_gao_xue_li_x_ like '%硕士%') as shuoShi,
-                sum(a.zui_gao_xue_li_x_ = '本科') as benKe,
-                sum(a.zui_gao_xue_li_x_ = '大专') as daZhuan,
-                sum(a.zhi_cheng_deng_ji = '初级') as chuJi,
-                sum(a.zhi_cheng_deng_ji = '中级') as zhongJi,
-                sum(a.zhi_cheng_deng_ji = '高级') as gaoJi,
-                sum(a.zhi_cheng_deng_ji = '' || a.zhi_cheng_deng_ji is null) as other
-                from t_ryjbqk as a join  ibps_party_employee as ee on a.parent_id_= ee.id_ where  ${positionsWhere}`
-            await curdPost('sql', sql).then((res) => {
-                data = res.variables.data
+            // const sql = `select sum(a.zui_gao_xue_li_x_ like '%博士%') as boShi, sum(a.zui_gao_xue_li_x_ like '%硕士%') as shuoShi, sum(a.zui_gao_xue_li_x_ = '本科') as benKe, sum(a.zui_gao_xue_li_x_ = '大专') as daZhuan, sum(a.zhi_cheng_deng_ji = '初级') as chuJi, sum(a.zhi_cheng_deng_ji = '中级') as zhongJi, sum(a.zhi_cheng_deng_ji = '高级') as gaoJi, sum(a.zhi_cheng_deng_ji = '' || a.zhi_cheng_deng_ji is null) as other from t_ryjbqk as a join ibps_party_employee as ee on a.parent_id_= ee.id_`
+            const { variables: { data = [] }} = await this.$common.request('query', {
+                key: 'empManageBoard3',
+                params: [null]
             })
-            if (data.length === 0 || data[0] == null) {
+            if (!data.length) {
                 return
             }
-            this.degreePieData.data[0].value = data[0].daZhuan
-                ? data[0].daZhuan
-                : 0
-            this.degreePieData.data[1].value = data[0].benKe
-                ? data[0].benKe
-                : 0
-            this.degreePieData.data[2].value = data[0].shuoShi
-                ? data[0].shuoShi
-                : 0
-            this.degreePieData.data[3].value = data[0].boShi
-                ? data[0].boShi
-                : 0
+            this.degreePieData.data[0].value = data[0]?.daZhuan || 0
+            this.degreePieData.data[1].value = data[0]?.benKe || 0
+            this.degreePieData.data[2].value = data[0]?.shuoShi || 0
+            this.degreePieData.data[3].value = data[0]?.boShi || 0
 
-            this.ranksPieData.data[0].value = data[0].chuJi ? data[0].chuJi : 0
-            this.ranksPieData.data[1].value = data[0].zhongJi
-                ? data[0].zhongJi
-                : 0
-            this.ranksPieData.data[2].value = data[0].gaoJi ? data[0].gaoJi : 0
+            this.ranksPieData.data[0].value = data[0]?.chuJi || 0
+            this.ranksPieData.data[1].value = data[0]?.zhongJi || 0
+            this.ranksPieData.data[2].value = data[0]?.gaoJi || 0
         },
         // 部门信息统计
         positionsInfoData () {
-            const positionsWhere =
-                this.positions.length !== 0
-                    ? `(${this.positions.join(' or ')} )`
-                    : `en.path_ = '没有选择部门'`
-            const sql = `select jh.*from (select  en.id_ ,en.name_ AS enName,  
-            sum(gy.zui_gao_xue_li_x_ like '%博士%') as boShi,
-            sum(gy.zui_gao_xue_li_x_ like '%硕士%') as shuoShi,
-            sum(gy.zui_gao_xue_li_x_ = '本科') as benKe,
-            sum(gy.zui_gao_xue_li_x_ = '大专') as daZhuan,
-            sum(gy.zhi_cheng_deng_ji = '初级') AS chuJi,
-            sum(gy.zhi_cheng_deng_ji = '中级') AS zhongJi,
-            sum(gy.zhi_cheng_deng_ji = '高级') AS gaoJi FROM (SELECT
-            ee.id_ AS eeID,ee.name_ AS eeName,ee.positions_,ry.zui_gao_xue_li_x_,ry.zhi_cheng_deng_ji
-            FROM t_ryjbqk AS ry JOIN  ibps_party_employee AS ee ON ry.parent_id_= ee.id_ 
-            )gy LEFT JOIN   ibps_party_entity en ON FIND_IN_SET(en.id_,gy.positions_)  where ${positionsWhere} and en.id_!='1166373874003083264' and en.name_ not like '%综合%' GROUP BY enName) jh`
-            curdPost('sql', sql).then((res) => {
-                const data = res.variables.data
+            // const sql = `select jh.* from (select en.id_, en.name_ AS enName, sum(gy.zui_gao_xue_li_x_ like '%博士%') as boShi, sum(gy.zui_gao_xue_li_x_ like '%硕士%') as shuoShi, sum(gy.zui_gao_xue_li_x_ = '本科') as benKe, sum(gy.zui_gao_xue_li_x_ = '大专') as daZhuan, sum(gy.zhi_cheng_deng_ji = '初级') AS chuJi, sum(gy.zhi_cheng_deng_ji = '中级') AS zhongJi, sum(gy.zhi_cheng_deng_ji = '高级') AS gaoJi FROM (SELECT ee.id_ AS eeID, ee.name_ AS eeName, ee.positions_, ry.zui_gao_xue_li_x_, ry.zhi_cheng_deng_ji FROM t_ryjbqk AS ry JOIN ibps_party_employee AS ee ON ry.parent_id_= ee.id_) gy LEFT JOIN ibps_party_entity en ON FIND_IN_SET(en.id_, gy.positions_) GROUP BY enName) jh where enName is not null`
+            const filterDeptIds = this.filterDept.map(i => i.positionId).join(',')
+            this.$common.request('query', {
+                key: 'empManageBoard2',
+                params: [filterDeptIds]
+            }).then(res => {
+                const { data = [] } = res.variables || {}
                 // 组装数据集,以学历职称为列,以部门为行:{" 大专":['1','2','3']}
-                const degreeSeriesDatas = this.PositionsDegreeOption.series
-                const ranksSeriesDatas = this.PositionsRanksOption.series
-                this.PositionsDegreeOption.xAxis[0].data = []
-                this.PositionsRanksOption.xAxis[0].data = []
-                this.PositionsDegreeOption.series[0].data = []
-                this.PositionsDegreeOption.series[1].data = []
-                this.PositionsDegreeOption.series[2].data = []
-                this.PositionsDegreeOption.series[3].data = []
-                this.PositionsRanksOption.series[0].data = []
-                this.PositionsRanksOption.series[1].data = []
-                this.PositionsRanksOption.series[2].data = []
-                if (data.length !== 0) {
-                    // 跟《部门信息统计配置表》排列顺序一致
-                    const shuZuList = [
-                        'daZhuan',
-                        'benKe',
-                        'shuoShi',
-                        'boShi',
-                        'chuJi',
-                        'zhongJi',
-                        'gaoJi'
-                    ]
-                    console.log(data)
-                    for (let t = 0; t < data.length; t++) {
-                        this.PositionsDegreeOption.xAxis[0].data.push(
-                            data[t].enName
-                        )
-                        this.PositionsRanksOption.xAxis[0].data.push(
-                            data[t].enName
-                        )
-                        for (let i = 0; i < degreeSeriesDatas.length; i++) {
-                            degreeSeriesDatas[i].data[t] =
-                                data[t][shuZuList[i]]
-                        }
-                        for (let i = 0; i < ranksSeriesDatas.length; i++) {
-                            ranksSeriesDatas[i].data[t] =
-                                data[t][shuZuList[i + 4]]
-                        }
-                    }
-                    this.PositionsDegreeOption.series = degreeSeriesDatas
-                    this.PositionsRanksOption.series = ranksSeriesDatas
-                }
-            })
-        },
-        // 个人任务统计
-        async getTtaskMattersData () {
-            const this_ = this
-            this_.optionPerson.series[0].data = []
-            this_.optionPerson.series[1].data = []
-            let data = [] // 待办数据
-            let yibanData = []
-            if (!this.personIds) {
-                return
-            }
-            // 待办数据
-            const sql = `select  executor_,count(executor_) as num ,ee.name_ FROM  IBPS_BPM_TASKS as a join IBPS_BPM_TASK_ASSIGN as b  
-                on a.task_id_ = b.task_id_ join ibps_party_employee as ee on b.executor_ = ee.id_ and
-                ee.STATUS_= 'actived' and ee.ID_ != '1' and ee.ID_ != '-1'  and b.executor_ in(${this.personIds}) 
-                and  a.CREATE_TIME_  between '${this.startDate}' and '${this.endDate}'
-                  GROUP BY  executor_ order by FIELD(b.executor_,${this.personIds}) `
-            await curdPost('sql', sql).then((res) => {
-                data = res.variables.data
-            })
-            const yibansql = `select task.AUDITOR_,ee.name_,COUNT(ee.name_) AS num FROM 
-                            (SELECT DISTINCT inst.* FROM
-                                ( SELECT ap.AUDITOR_,rinst.* FROM
-                                ibps_bpm_inst rinst
-                                RIGHT JOIN ibps_bpm_approval ap ON ap.PROC_INST_ID_ = rinst.ID_
-                                WHERE
-                                ap.AUDITOR_ in(${this.personIds}) and 
-                                ap.CREATE_TIME_  between '${this.startDate}' and '${this.endDate}'
-                                UNION ALL
-                                SELECT aphis.AUDITOR_,insthis.* FROM
-                                ibps_bpm_inst_his insthis
-                                RIGHT JOIN ibps_bpm_approval_his aphis ON aphis.PROC_INST_ID_ = insthis.ID_
-                                WHERE 
-                                aphis.AUDITOR_ in(${this.personIds})  AND insthis.id_ IS NOT NULL
-                                ) inst ) AS  task 
-                                LEFT JOIN ibps_party_employee ee ON task.AUDITOR_ = ee.id_ 
-                                where  task.CREATE_TIME_  between '${this.startDate}' and '${this.endDate}'
-                                GROUP BY  task.AUDITOR_ order by FIELD(task.AUDITOR_,${this.personIds})`
-            await curdPost('sql', yibansql).then((res) => {
-                yibanData = res.variables.data
-            })
-            for (const i of this.personIds.split(',')) {
-                // 判断已读中是否存在该人员的待办
-                const daiBan = data.filter((fil) => {
-                    return fil.executor_ === i
+                const { PositionsDegreeOption, PositionsRanksOption } = this
+                const degreeSeries = PositionsDegreeOption.series
+                const ranksSeries = PositionsRanksOption.series;
+                [PositionsDegreeOption, PositionsRanksOption].forEach(option => {
+                    option.xAxis[0].data = []
+                    option.series.forEach(s => { s.data = [] })
                 })
-                if (daiBan.length === 0) {
-                    this_.optionPerson.series[0].data.push(0)
-                } else {
-                    this_.optionPerson.series[0].data.push(daiBan[0].num)
+                if (!data.length) {
+                    return
                 }
-                // 判断已读中是否存在该人员的已办
-                const yiBan = yibanData.filter((fil) => {
-                    return fil.AUDITOR_ === i
+                // 跟《部门信息统计配置表》排列顺序一致
+                const shuZuList = ['daZhuan', 'benKe', 'shuoShi', 'boShi', 'chuJi', 'zhongJi', 'gaoJi']
+                data.forEach(item => {
+                    PositionsDegreeOption.xAxis[0].data.push(item.enName)
+                    PositionsRanksOption.xAxis[0].data.push(item.enName)
+
+                    // 设置学历系列数据
+                    degreeSeries.forEach((series, i) => {
+                        series.data.push(item[shuZuList[i]])
+                    })
+
+                    // 设置职级系列数据
+                    ranksSeries.forEach((series, i) => {
+                        series.data.push(item[shuZuList[i + 4]])
+                    })
                 })
-                if (yiBan.length === 0) {
-                    this_.optionPerson.series[1].data.push(0)
-                } else {
-                    this_.optionPerson.series[1].data.push(yiBan[0].num)
-                }
-            }
-        },
-        preDate (dateParameter, num) {
-            // 往前推算日期
-            var translateDate = ''
-            var dateString = ''
-            var monthString = ''
-            var dayString = ''
-            translateDate = dateParameter.replace('-', '/').replace('-', '/')
-            var newDate = new Date(translateDate)
-            newDate = newDate.valueOf()
-            newDate = newDate - num * 24 * 60 * 60 * 1000 // 备注 如果是往前计算日期则为减号 否则为加号
-            newDate = new Date(newDate) // 如果月份长度少于2,则前加 0 补位
-            if ((newDate.getMonth() + 1).toString().length === 1) {
-                monthString = 0 + '' + (newDate.getMonth() + 1).toString()
-            } else {
-                monthString = (newDate.getMonth() + 1).toString()
-            }
-            if (newDate.getDate().toString().length === 1) {
-                // 如果天数长度少于2,则前加 0 补位
-                dayString = 0 + '' + newDate.getDate().toString()
-                0
-            } else {
-                dayString = newDate.getDate().toString()
-            }
-            dateString =
-                newDate.getFullYear() + '-' + monthString + '-' + dayString
-            return dateString
-        },
-        // 简化部门信息
-        simplifyPosition (v) {
-            this.positions = [] // 用于sql条件查询
-            this.otherPositions = []
-            for (let i = 0; i < v.length; i++) {
-                this.positions.push(
-                    `en.path_ like '%${v[i][v[i].length - 1]}%'`
-                )
-                this.otherPositions.push(
-                    `ee.positions_ like '%${v[i][v[i].length - 1]}%'`
-                )
-            }
+                console.log(PositionsDegreeOption)
+                PositionsDegreeOption.series = degreeSeries
+                PositionsRanksOption.series = ranksSeries
+            })
         },
+        // 个人任务统计
+        // async getTtaskMattersData () {
+        //     this.optionPerson.series[0].data = []
+        //     this.optionPerson.series[1].data = []
+        //     let data = [] // 待办数据
+        //     let yibanData = []
+        //     if (!this.personIds) {
+        //         return
+        //     }
+        //     // 待办数据
+        //     const sql = `select  executor_,count(executor_) as num ,ee.name_ FROM  IBPS_BPM_TASKS as a join IBPS_BPM_TASK_ASSIGN as b on a.task_id_ = b.task_id_ join ibps_party_employee as ee on b.executor_ = ee.id_ and ee.STATUS_= 'actived' and ee.ID_ != '1' and ee.ID_ != '-1'  and b.executor_ in(${this.personIds}) and  a.CREATE_TIME_  between '${this.startDate}' and '${this.endDate}' GROUP BY  executor_ order by FIELD(b.executor_,${this.personIds}) `
+        //     await curdPost('sql', sql).then((res) => {
+        //         data = res.variables.data
+        //     })
+        //     const yibansql = `select task.AUDITOR_,ee.name_,COUNT(ee.name_) AS num FROM (SELECT DISTINCT inst.* FROM ( SELECT ap.AUDITOR_,rinst.* FROM ibps_bpm_inst rinst
+        //     RIGHT JOIN ibps_bpm_approval ap ON ap.PROC_INST_ID_ = rinst.ID_ WHERE ap.AUDITOR_ in(${this.personIds}) and  ap.CREATE_TIME_  between '${this.startDate}' and '${this.endDate}'
+        //     UNION ALL SELECT aphis.AUDITOR_,insthis.* FROM ibps_bpm_inst_his insthis RIGHT JOIN ibps_bpm_approval_his aphis ON aphis.PROC_INST_ID_ = insthis.ID_ WHERE aphis.AUDITOR_ in(${this.personIds})  AND insthis.id_ IS NOT NULL) inst ) AS  task
+        //     LEFT JOIN ibps_party_employee ee ON task.AUDITOR_ = ee.id_ where  task.CREATE_TIME_  between '${this.startDate}' and '${this.endDate}' GROUP BY  task.AUDITOR_ order by FIELD(task.AUDITOR_,${this.personIds})`
+        //     await curdPost('sql', yibansql).then((res) => {
+        //         yibanData = res.variables.data
+        //     })
+        //     for (const i of this.personIds.split(',')) {
+        //         // 判断已读中是否存在该人员的待办
+        //         const daiBan = data.filter((fil) => {
+        //             return fil.executor_ === i
+        //         })
+        //         if (daiBan.length === 0) {
+        //             this.optionPerson.series[0].data.push(0)
+        //         } else {
+        //             this.optionPerson.series[0].data.push(daiBan[0].num)
+        //         }
+        //         // 判断已读中是否存在该人员的已办
+        //         const yiBan = yibanData.filter((fil) => {
+        //             return fil.AUDITOR_ === i
+        //         })
+        //         if (yiBan.length === 0) {
+        //             this.optionPerson.series[1].data.push(0)
+        //         } else {
+        //             this.optionPerson.series[1].data.push(yiBan[0].num)
+        //         }
+        //     }
+        // },
         handleAllGetFunc () {
             this.employeeInfoData()
             if (this.initOnLoad === 0) {
                 this.positionsInfoData()
                 this.degreeGradeInfoData()
+                this.initOnLoad = 1
             }
         },
         // 通过部门 id 获取部门人员
         getPositionPeopleIds (positionId) {
-            const { userList } = this.$store.getters
-            return userList.filter(user => user.positionId.indexOf(positionId) > -1)
+            return this.userList.filter(user => user.positionId.includes(positionId))
         },
         // 根据部门和时间获取考试统计数据
         async getExamStatisticsData () {
-            if (this.positionsIdArr.length) {
-                const users = this.getPositionPeopleIds(this.positionsIdArr[0])
-                const userIds = users.map(user => user.userId)
-                const renyuan =userIds.map(i => `'${i}'`).join(',')!=='' ? `and kao_shi_ren_ in (${userIds.map(i => `'${i}'`).join(',')})`:''
-                const sql = `select * from t_examination where zhuang_tai_ = '已完成' ${renyuan} `
-                let { variables: { data }} = await this.$common.request('sql', sql)
-                if (this.startDate && this.endDate) {
-                    data = data.filter(item => {
-                        return new Date(item.jie_shu_shi_jian_).getTime() >= new Date(this.startDate).getTime() && new Date(item.jie_shu_shi_jian_).getTime() <= new Date(this.endDate).getTime()
-                    })
-                }
-                // console.log('考试1', data)
-                const resultData = users.map(user => {
-                    let count = 0
-                    let passCount = 0
-                    data.forEach(item => {
-                        if (item.kao_shi_ren_ === user.userId) {
-                            count++
-                            if (+item.de_fen_ * 100 >= +item.ti_ku_zong_fen_ * +item.da_biao_zhan_bi_) {
-                                passCount++
-                            }
-                        }
-                    })
-                    return {
-                        ...user,
-                        count,
-                        passCount,
-                        passRate: (count === 0 ? 0 : (passCount / count * 100).toFixed(2)) + '%'
-                    }
-                })
-                resultData.sort((a, b) => {
-                    return a.userId - b.userId
+            if (!this.selection) {
+                return
+            }
+            const deptUserList = this.getPositionPeopleIds(this.selection)
+            const deptUserIdList = deptUserList.map(user => user.userId)
+            // const sql = `select * from t_examination where zhuang_tai_ = '已完成' and find_in_set(kao_shi_ren_, '${deptUserIdList.join(',')}')`
+            let { variables: { data }} = await this.$common.request('query', {
+                key: 'empManageBoard0',
+                params: [deptUserIdList.join(',')]
+            })
+            if (this.startDate && this.endDate) {
+                data = data.filter(item => {
+                    // return new Date(item.jie_shu_shi_jian_).getTime() >= new Date(this.startDate).getTime() && new Date(item.jie_shu_shi_jian_).getTime() <= new Date(this.endDate).getTime()
+                    const itemTime = new Date(item.jie_shu_shi_jian_).getTime()
+                    return itemTime >= +new Date(this.startDate) && itemTime <= +new Date(this.endDate)
                 })
-                // console.log('考试', resultData)
-                // 格式化统计图需要的数据
-                this.optionExamStatisticsConfig.xAxis.data = resultData.map(item => item.userName)
-                this.optionExamStatisticsConfig.series[0].data = resultData.map(item => item.count)
-                this.optionExamStatisticsConfig.series[1].data = resultData.map(item => item.passCount)
-                this.optionExamStatisticsConfig.series[2].data = resultData.map(item => item.passRate)
             }
+            const resultData = deptUserList.map(user => {
+                const userExams = data.filter(item => item.kao_shi_ren_ === user.userId)
+                const count = userExams.length
+                const passCount = userExams.filter(item =>
+                    +item.de_fen_ * 100 >= +item.ti_ku_zong_fen_ * +item.da_biao_zhan_bi_
+                ).length
+
+                return {
+                    ...user,
+                    count,
+                    passCount,
+                    passRate: count ? `${(passCount / count * 100).toFixed(2)}%` : '0%'
+                }
+            })
+            resultData.sort((a, b) => {
+                return a.userId - b.userId
+            })
+            // console.log('考试', resultData)
+            // 格式化统计图需要的数据
+            this.optionExamStatisticsConfig.xAxis.data = resultData.map(item => item.userName)
+            this.optionExamStatisticsConfig.series[0].data = resultData.map(item => item.count)
+            this.optionExamStatisticsConfig.series[1].data = resultData.map(item => item.passCount)
+            this.optionExamStatisticsConfig.series[2].data = resultData.map(item => item.passRate)
         },
         // 根据部门和时间获取培训统计数据
         async getTrainingStatisticsData () {
@@ -1199,8 +1020,8 @@ export default {
                 params.startTime = this.startDate
                 params.endTime = this.endDate
             }
-            if (this.positionsIdArr.length) {
-                params.deptId = this.positionsIdArr[0]
+            if (this.selection) {
+                params.deptId = this.selection
             }
             const { data } = await getUserStatisticList(params)
             data.sort((a, b) => {
@@ -1213,48 +1034,15 @@ export default {
             this.optionTrainingStatisticsConfig.series[1].data = data.map(item => item.truejoin)
             this.optionTrainingStatisticsConfig.series[2].data = data.map(item => item.participationRate)
         },
-        handleFunc (e) {
-            this.sqlPositionsDatasIni = e.i
-            this.positionIni = e.v
-            this.simplifyPosition(e.v)
+        initData ({ selection, selectionDept, filterDept }) {
+            this.selection = selection
+            this.selectionDept = selectionDept
+            this.filterDept = filterDept
             this.handleAllGetFunc()
             // clearInterval(this.interval)
-            // this.intervalHandle()
-            if (e.v.length >= 2) {
-                this.positionsIdArr = [e.v[1]]
-            }
             this.getTrainingStatisticsData()
             this.getExamStatisticsData()
         },
-        handleInt (e) {
-            // 找到对应id的部门信息
-            const obj = this.sqlPositionsDatasIni.find(
-                (item) => item.ID_ === e[0][e[0].length - 1]
-            )
-            if (obj === undefined) {
-                this.optionPersonConfig.title = `部门(/)员工任务统计`
-            } else {
-                this.optionPersonConfig.title = `部门(${obj.NAME_})员工任务统计`
-            }
-            this.simplifyPosition(e)
-            this.employeeInfoData()
-        },
-        // 定时任务调用接口,一分钟一次
-        intervalHandle () {
-            let cishu = 0 // 记录所选择的部门个数,即需要轮询多少次
-            this.interval = setInterval(() => {
-                if (this.positionIni.length === 0) {
-                    return
-                }
-                if (cishu > this.positionIni.length - 1) {
-                    cishu = 0
-                    this.handleInt([this.positionIni[0]])
-                } else {
-                    this.handleInt([this.positionIni[cishu]])
-                    cishu++
-                }
-            }, 10000)
-        },
         allView () {
             // 默认显示全屏
             screenfull.request()

+ 2 - 2
src/views/system/jbdScan/goods/deviceTag.vue

@@ -176,11 +176,11 @@ export default {
             // const sql = `select she_bei_ming_cheng_, she_bei_shi_bie_h, gui_ge_xing_hao_, she_bei_zhuang_ta, bi_xu_de_huan_jin, bi_xu_she_shi_, cai_gou_he_tong_, zi_chan_bian_hao_ FROM t_sbdj WHERE find_in_set(id_, ${id})`
             // const personSql = `select * from ibps_party_employee`
             Promise.all([
-                this.$common.requset('query', {
+                this.$common.request('query', {
                     key: 'getDeviceInfoByIds',
                     params: [id]
                 }),
-                this.$common.requset('query', {
+                this.$common.request('query', {
                     key: 'getAllUser',
                     params: [null]
                 })