<!-- 检定管理 --> <script lang="ts" setup name="MeasureManage"> import { ElMessage } from 'element-plus' import { position } from 'html2canvas/dist/types/css/property-descriptors/position' import type { DateModelType } from 'element-plus' import { getDictByCode } from '@/api/system/dict' import type { deptType, dictType } from '@/global' import useUserStore from '@/store/modules/user' import { getCertAmount, getMeasureConclusion, getMeasureDevice } from '@/api/workBench/measureManage' const user = useUserStore() // 用户信息 const loading = ref(false) const showEmpty = ref(false) const labCode = ref('') // 实验室 const groupCode = ref('') as any // 部门 const isAdministrator = ref('0') // 是不是超级管理员 const emptyDisc = ref('') // 描述文字 const certCountYear = ref('-') // 检定/校准/校验/测试证书总数(本年度) const certCountQuarter = ref('-') // 检定/校准/校验/测试证书总数(本季度) const certCountMonth = ref('-') // 检定/校准/校验/测试证书总数(本月度) // 检校设备分析 const equipmentAnalysis = ref([]) as any // 检校结果分析 const resultAnalysis = ref([]) as any const dateRange = ref<[DateModelType, DateModelType]>(['', ''])// 筛选时间段数据 // ------------------------------------------字典---------------------------------------------- const groupCodeList = ref([]) as any // 部门 const labCodeList = ref<dictType[]>([]) // 实验室 function getDict() { // 部门 getDictByCode('bizGroupCode').then((response) => { const tempMenu = ['电学电源组', '热工力学组', '无线电脉冲组'] tempMenu.forEach((item) => { const tempFindData = response.data.find((e: { name: string; value: string }) => e.name === item) if (tempFindData) { groupCodeList.value.push({ name: tempFindData.name, id: `${tempFindData.id}`, value: `${tempFindData.value}`, }) } }) groupCodeList.value.unshift({ id: 'A', name: '全部', value: 'A', }) }) // 实验室 getDictByCode('bizLabCode').then((response) => { labCodeList.value = response.data }) } getDict() // --------------------------------------------获取数据---------------------------------------------- // 检校设备分析 const fetchMeasureDevice = (startDate = '', endDate = '') => { // 设备类型分析 getMeasureDevice({ endDate, // 结束日期(检校设备分析/检校结果分析查询条件) groupCode: groupCode.value === 'A' ? null : groupCode.value, // 部门编号(当是管理组人员时,为下拉选择的部门) labCode: labCode.value === 'A' ? null : labCode.value, // 实验室编号 startDate, // 起始日期(检校设备分析/检校结果分析查询条件) }).then((res) => { if (res.data && res.data.length) { equipmentAnalysis.value = res.data.map((item: any) => { return { ...item, name: item.dimension, value: item.amount, } }) } else { equipmentAnalysis.value = [] } loading.value = false }) } // 检校结果分析 const fetchMeasureConclusion = (startDate = '', endDate = '') => { getMeasureConclusion({ endDate, // 结束日期(检校设备分析/检校结果分析查询条件) groupCode: groupCode.value === 'A' ? null : groupCode.value, // 部门编号(当是管理组人员时,为下拉选择的部门) labCode: labCode.value === 'A' ? null : labCode.value, // 实验室编号 startDate, // 起始日期(检校设备分析/检校结果分析查询条件) }).then((res) => { if (res.data && res.data.length) { resultAnalysis.value = res.data.map((item: any) => { return { ...item, name: item.dimension, value: item.amount, } }) } else { resultAnalysis.value = [] } loading.value = false }) } const fetchertAmount = () => { getCertAmount({ endDate: '', // 结束日期(检校设备分析/检校结果分析查询条件) groupCode: groupCode.value === 'A' ? null : groupCode.value, // 部门编号(当是管理组人员时,为下拉选择的部门) labCode: labCode.value === 'A' ? null : labCode.value, // 实验室编号 startDate: '', // 起始日期(检校设备分析/检校结果分析查询条件) }).then((res) => { if (res.data && res.data.length) { const indexYear = res.data.findIndex((item: { dimension: string }) => item.dimension === '检定/校准/校验/测试证书总数(本年度)') // 检定/校准/校验/测试证书总数(本年度) if (indexYear !== -1) { certCountYear.value = res.data[indexYear].amount } const indexQuarter = res.data.findIndex((item: { dimension: string }) => item.dimension === '检定/校准/校验/测试证书总数(本季度)') // 检定/校准/校验/测试证书总数(本季度) if (indexQuarter !== -1) { certCountQuarter.value = res.data[indexQuarter].amount } const indexMonth = res.data.findIndex((item: { dimension: string }) => item.dimension === '检定/校准/校验/测试证书总数(本月度)') // 检定/校准/校验/测试证书总数(本月度) if (indexMonth !== -1) { certCountMonth.value = res.data[indexMonth].amount } loading.value = false } }) } const fetchData = () => { loading.value = true fetchMeasureDevice() fetchMeasureConclusion() fetchertAmount() } // --------------------------------------------钩子------------------------------------------------- watch(dateRange, (val) => { if (val) { loading.value = true fetchMeasureDevice(`${val[0]}`, `${val[1]}`) fetchMeasureConclusion(`${val[0]}`, `${val[1]}`) } else { loading.value = true fetchMeasureDevice() fetchMeasureConclusion() } }) // 改变实验室\部门 const changeSelect = () => { if (!showEmpty.value && (isAdministrator.value === '1' || (user.bizLabCode && user.groupNo))) { fetchData() } } onMounted(() => { isAdministrator.value = user.roleTips.includes('administrator') ? '1' : '0' // 是否是超级管理员 console.log('是否是超级管理员', user.roleTips, isAdministrator.value) if (isAdministrator.value === '1') { // 超级管理员 labCode.value = user.bizLabCode || 'A' // 有实验室就默认本人实验室,没有实验室就默认海口 groupCode.value = 'A' // 超级管理员默认查看全部 fetchData() } else { // 不是超级管理员 if (!user.bizLabCode) { // 没有实验室 emptyDisc.value = '此用户非超级管理员且无实验室,无权限查看' showEmpty.value = true } else if (!user.groupNo) { // 有实验室但没有组 emptyDisc.value = '此用户非超级管理员且无部门,无权限查看' showEmpty.value = true } else { // 有实验室且有组 showEmpty.value = false if (user.groupNo === 'GL') { // 综合管理组 labCode.value = user.bizLabCode // 实验室 // 综合管理组默认查实验室下面的所有数据,不筛选部门 groupCode.value = 'A' // 综合管理组可以查看待分发 } else { // 其他组 labCode.value = user.bizLabCode // 实验室 // 其他组默认筛选自己组 groupCode.value = user.groupNo } fetchData() } } }) </script> <template> <el-empty v-show="showEmpty" style="height: 100%;" :description="emptyDisc" /> <div v-show="!showEmpty" class="workBench-measure-manage"> <!-- 超级管理员才可以筛选实验室 --> <el-select v-model="labCode" :disabled="isAdministrator === '0'" style="width: 130px;position: absolute; top: 5px;right: 150px;" class="short-input" placeholder="实验室" @change="changeSelect"> <el-option v-for="item in labCodeList" :key="item.id" :label="item.name" :value="item.value" /> </el-select> <!-- 综合管理组才可以筛选部门 --> <el-select v-model="groupCode" :disabled="isAdministrator === '0' && user.groupNo !== 'GL'" style="width: 130px;position: absolute; top: 5px;right: 10px;" class="short-input" placeholder="部门" @change="changeSelect"> <el-option v-for="item in groupCodeList" :key="item.id" :label="item.name" :value="item.value" /> </el-select> <div v-loading="loading" style="display: flex;flex-direction: column;width: 100%;height: 100%;"> <!-- 证书统计 --> <div style="display: flex;margin: 16px 0 0;justify-content: space-around;"> <div style="display: flex;margin-right: 20px;"> <el-icon :size="30" color="#3d7eff"> <svg-icon name="icon-certi" /> </el-icon> <div> <div style="font-size: 14px;"> 检定/校准/校验/测试证书总数(本年度) </div> <div style="margin-left: 10px;color: #000;font-weight: 600;"> {{ certCountYear }} </div> </div> </div> <div style="display: flex;"> <el-icon :size="30" color="#f88070"> <svg-icon name="icon-certi" /> </el-icon> <div> <div style="font-size: 14px;"> 检定/校准/校验/测试证书总数(本季度) </div> <div style="margin-left: 10px;color: #000;font-weight: 600;"> {{ certCountQuarter }} </div> </div> </div> <div style="display: flex;"> <el-icon :size="30" color="#10d069"> <svg-icon name="icon-certi" /> </el-icon> <div> <div style="font-size: 14px;"> 检定/校准/校验/测试证书总数(本月度) </div> <div style="margin-left: 10px;color: #000;font-weight: 600;"> {{ certCountMonth }} </div> </div> </div> </div> <div style="width: 100%;margin: 10px 0;"> <el-date-picker v-model="dateRange" class="short-input" type="daterange" range-separator="至" format="YYYY-MM-DD" value-format="YYYY-MM-DD" start-placeholder="开始日期" end-placeholder="结束日期" size="small" style="width: 220px;float: right;" /> </div> <!-- 图 --> <div style="display: flex;width: 100%;flex: 1;"> <!-- 左边图 检校设备分析 --> <div style="width: 50%;"> <div style="font-weight: 600;font-size: 14px;color: #343434;margin: 0;padding: 0;"> 检校设备分析 </div> <pie-chart v-if="equipmentAnalysis.length" value-type="percentage" :data="equipmentAnalysis" :radius="['70%', '50%']" :label-show="false" :emphasis="{ show: false }" :show-total="true" title=" " style="width: 100%;height: 300px;" /> <el-empty v-if="!equipmentAnalysis.length" style="width: 100%;height: 100%;" description="暂无数据" /> </div> <!-- 右边图 --> <div style="width: 50%;"> <div style="font-weight: 600;font-size: 14px;color: #343434;margin: 0;padding: 0;"> 检校结果分析 </div> <pie-chart v-if="resultAnalysis.length" :data="resultAnalysis" :radius="['70%']" :label-show="false" :emphasis="{ show: false }" style="width: 100%;height: 300px;" /> <el-empty v-if="!resultAnalysis.length" style="width: 100%;height: 100%;" description="暂无数据" /> </div> </div> </div> </div> </template> <style lang="scss" scoped> .workBench-measure-manage { width: 100%; height: 100%; } </style>