<!-- 标准装置分析 --数据看板 --> <script name="standardDevice" lang="ts" setup> import dayjs from 'dayjs' import draggable from 'vuedraggable' import { colors } from '../environment/colors' import { getRangeAllMonth } from '@/utils/date' // import img1 from '@/assets/images/data/swiper/1.jpg' // import img2 from '@/assets/images/data/swiper/2.jpg' import { getBaseInfo, getNearYearTrend, getStandardStatusAnalysis, getOneYearAnalysis, getCurrentYearRank } from '@/api/dataManagement/data/standardDevice' import { standardDevice } from './img' const props = defineProps({ lab: { type: String, default: '', }, }) // 查询条件 const searchQueryResult = ref({ // groupCode: '', labCode: '' }) watch(() => props.lab, (newVal) => { if (newVal) { searchQueryResult.value.labCode = props.lab fetchData() } }) // 基础信息展示数据 const baseInfo = ref([ { name: '标准装置总数', value: 'standardAmount', data: '', icon: standardDevice['标准装置总数'], color: '#00A1E6' }, { name: '当年复查标准装置总数', value: 'thisYearAmount', data: '', icon: standardDevice['当年复查标准装置总数'], color: '#F59A23' }, { name: '核查记录总数', value: 'recordAmount', data: '', icon: standardDevice['核查记录总数'], color: '#00A1E6' }, { name: '核查记录总数(本季度)', value: 'quarterRecordAmount', data: '', icon: standardDevice['核查记录总数(本季度)'], color: '#00A1E6' }, { name: '核查记录总数(本年度)', value: 'yearRecordAmount', data: '', icon: standardDevice['核查记录总数(本年度)'], color: '#00A1E6' }, ]) const showChart = ref<any[]>([ { name: '近五年标准装置复查趋势', type: 'line', source: 'system', smooth: false, }, { name: '标准装置状态分析', type: 'bar-horizontal', source: 'system', }, { name: '近一年部门核查分析', type: 'bar-vertical', source: 'system', colors: [ ['#2d8cf0', '#fff'], ['#2352d6', '#fff'], ['#fed700', '#fff'], ['#feb501', '#fff'], ['#2352d6', '#fff'], ['#fed700', '#fff'], ['#feb501', '#fff'], ['#2352d6', '#fff'], ['#fed700', '#fff'], ['#feb501', '#fff'], ] }, { name: '当年标准装置核查排行榜', type: 'rank-table', source: 'system', columns: [ { text: '标准装置名称', value: 'standardName', align: 'center', }, { text: '本年度核查次数', value: 'checkNum', align: 'center', }, { text: '最近核查时间', value: 'recentCheckDate', align: 'center', }, ], data: [], }, ]) watch(() => showChart.value.length, () => { setTimeout(() => { const resize = new Event('resize') window.dispatchEvent(resize) }) }) // 模拟数据 const loading = ref(false) function fetchData() { // 获取基础数据 getBaseInfo(searchQueryResult.value).then(res => { baseInfo.value.forEach(item => { item.data = res.data[item.value] }) }) // 近五年标准装置复查趋势 getNearYearTrend({ ...searchQueryResult.value, timeStart: dayjs().subtract(5, 'year').format('YYYY-MM-DD'), timeEnd: dayjs().format('YYYY-MM-DD') }).then(res => { console.log(res.data, '近五年标准装置复查趋势') const current = showChart.value.filter((item: any) => item.name === '近五年标准装置复查趋势')[0] current.xAxisData = res.data.map((item: any) => item.dimension) const data = [ { name: '无线电脉冲组', value: 'wmAmount', data: '' }, { name: '热工压力组', value: 'rlAmount', data: '' }, { name: '电学电源组', value: 'ddAmount', data: '' }, ] current.data = data.map((item: any) => ({ name: item.name, symbol: 'circle', data: res.data.map((citem: any) => String(citem[data.filter((ccitem: any) => ccitem.name === item.name)[0].value])) })) }) // 标准装置状态分析 getStandardStatusAnalysis({ ...searchQueryResult.value, timeStart: `${new Date().getFullYear()}-01-01`, timeEnd: dayjs().format('YYYY-MM-DD') }).then(res => { console.log(res.data, '标准装置状态分析') const current = showChart.value.filter((item: any) => item.name === '标准装置状态分析')[0] current.xAxisData = res.data.map((item: any) => item.approvalTypeName) const data = [ { name: '无线电脉冲组', value: 'wmAmount', data: '' }, { name: '热工压力组', value: 'rlAmount', data: '' }, { name: '电学电源组', value: 'ddAmount', data: '' }, ] current.data = data.map((item: any) => ({ name: item.name, // symbol: 'circle', data: res.data.map((citem: any) => String(citem[data.filter((ccitem: any) => ccitem.name === item.name)[0].value])) })) }) // 近一年部门核查分析 getOneYearAnalysis({ ...searchQueryResult.value, timeStart: `${new Date().getFullYear()}-01-01`, timeEnd: dayjs().format('YYYY-MM-DD') }).then(res => { console.log(res.data, '近一年部门核查分析') const current = showChart.value.filter((item: any) => item.name === '近一年部门核查分析')[0] current.xAxisData = res.data.map((item: any) => item.dimension) const data = [ { name: '无线电脉冲组', value: 'wmAmount', data: '' }, { name: '热工压力组', value: 'rlAmount', data: '' }, { name: '电学电源组', value: 'ddAmount', data: '' }, ] current.data = data.map((item: any) => ({ name: item.name, // symbol: 'circle', data: res.data.map((citem: any) => String(citem[data.filter((ccitem: any) => ccitem.name === item.name)[0].value])) })) }) // 当年标准装置核查排行榜 getCurrentYearRank({ ...searchQueryResult.value, timeStart: `${new Date().getFullYear()}-01-01`, timeEnd: dayjs().format('YYYY-MM-DD') }).then(res => { console.log(res.data, '当年标准装置核查排行榜') const current = showChart.value.filter((item: any) => item.name === '当年标准装置核查排行榜')[0] current.data = res.data.rows }) // loading.value = true // // 近五年标准装置复查趋势 // const name1 = ['电学电源组', '热工压力组', '无线脉冲组'] // const name2 = [] as any[] // for (let i = Number(dayjs().format('YYYY')); i > Number(dayjs().format('YYYY')) - 5; i--) { // name2.push(i) // } // showChart.value.filter((item: any) => item.name === '近五年标准装置复查趋势')[0].xAxisData = name2.map(item => String(item)).reverse() // showChart.value.filter((item: any) => item.name === '近五年标准装置复查趋势')[0].data = name1.map(item => ({ // name: item, // data: name2.map(item => Math.floor(Math.random() * 100) + 1), // symbol: 'emptyCircle', // })) // // 标准装置状态分析 // const name3 = ['撤销', '更换', '建标'] // showChart.value.filter((item: any) => item.name === '标准装置状态分析')[0].data = name1.map(item => ({ // name: item, // data: name3.map(item => Math.floor(Math.random() * 100) + 1), // })) // showChart.value.filter((item: any) => item.name === '标准装置状态分析')[0].xAxisData = name3 // // 近一年部门核查分析 // const name4 = getRangeAllMonth(dayjs().subtract(6, 'month').format('YYYY-MM'), dayjs().format('YYYY-MM')) // showChart.value.filter((item: any) => item.name === '近一年部门核查分析')[0].data = name1.map(item => ({ // name: item, // data: name4.map(item => Math.floor(Math.random() * 100) + 1), // })) // showChart.value.filter((item: any) => item.name === '近一年部门核查分析')[0].xAxisData = name4 // // 当年标准装置核查排行榜 // const name5 = ['直流稳压电源', '多功能校准源', '多功能电气安全', '安全阀', '微波衰减', '信号发生器', '频谱分析仪', '频率短期稳定度', '失真度', '低频信号源', '0.02级活塞式压力计', 'E2等砝码'] // showChart.value.filter((item: any) => item.name === '当年标准装置核查排行榜')[0].data = name5.map(item => ({ // name: item, // count: Math.floor(Math.random() * 10) + 1, // time: dayjs().subtract(Math.floor(Math.random() * 30) + 1, 'day').format('YYYY-MM-DD'), // })) // setTimeout(() => { // loading.value = false // }, 3000) } // setTimeout(() => { // fetchData() // }, 100) onMounted(() => { if (props.lab) { searchQueryResult.value.labCode = props.lab fetchData() } }) defineExpose({ showChart, }) // 拖拽结束 const onEnd = () => { console.log('拖拽结束') const resize = new Event('resize') window.dispatchEvent(resize) } // const imgList = ref([img1, img2]) </script> <template> <div class="container"> <!-- 展示内容 --> <div class="content-count"> <!-- 统计数据 --> <div class="count"> <div class="count-item" v-for="item in baseInfo" :key="item.value"> <div class="header-icon"> <img :src="item.icon" /> </div> <div class="header-content"> <div class="content-title"> {{ item.name }} </div> <div class="content-count" :style="{ color: item.color }"> {{ item.data }} </div> </div> </div> </div> <!-- 图表区域 --> <!-- <div class="chart"> --> <draggable v-model="showChart" item-key="name" class="chart" animation="300" drag-class="dragClass" ghost-class="ghostClass" chosen-class="chosenClass" @end="onEnd"> <template #item="{ element, index }"> <div :style="{ width: `${showChart.length === 4 ? '48%' : index === 0 || index === 1 ? '48%' : '31.5%' }` }" class="chart-item"> <div class="chart-name"> <!-- {{ element.name }} --> </div> <div v-loading="loading" class="chart-page"> <div style="width: 100%; height: 100%"> <div class="chart-name" style="width: 100%; height: 10%; display: flex"> {{ element.name }} <div v-if="element.name === '人员持证到期趋势'" style="width: 350px; margin-left: 40px"> <el-date-picker v-model="datetimerange" type="daterange" value-format="YYYY-MM-DD" format="YYYY-MM-DD" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" /> </div> </div> <div style="width: 100%; height: 90%"> <pie-chart v-if="element.type === 'pie'" :title="element.title" :show-total="element.showTotal" :data="element.data" :colors="colors" :center="element.center" label-formatter="{style1|{c}}" :label-position="element.labelPosition" :radius="element.radius" :grid="{ top: 50, left: 15, right: 15, bottom: 10, containLabel: true }" :legend="{ itemWidth: 8, itemHeight: 8, type: 'scroll', orient: 'horizontal', icon: 'roundRect', left: '0', top: '10' }" /> <line-chart v-if="element.type === 'line'" :colors="colors" :gradient="element.gradient" :x-axis-data="element.xAxisData" :data="element.data" :smooth="element.smooth" :grid="{ top: 47, left: 5, right: 5, bottom: 10, containLabel: true }" :legend="{ itemWidth: 8, itemHeight: 2, type: 'scroll', orient: 'horizontal', icon: 'roundRect', left: '0', top: '5' }" /> <bar-chart-double v-if="element.type === 'bar-double'" :legend-data="element.legendData" :data1="element.data1" :data2="element.data2" :x-axis-data="element.xAxisData" :legend="{ itemWidth: 8, itemHeight: 8, type: 'scroll', orient: 'horizontal', icon: 'roundRect', left: '0', top: '10' }" /> <bar-chart-vertical v-if="element.type === 'bar-vertical'" :bar-coner="0" :data="element.data" :x-axis-data="element.xAxisData" :legend="{ itemWidth: 8, itemHeight: 8, type: 'scroll', orient: 'horizontal', icon: 'roundRect', left: '0', top: '10' }" :colors="element.colors" :gradient="false" /> <bar-chart-horizontal v-if="element.type === 'bar-horizontal'" bar-width="10" :bar-coner="0" :data="element.data" :x-axis-data="element.xAxisData" :legend="{ itemWidth: 8, itemHeight: 8, type: 'scroll', orient: 'horizontal', icon: 'roundRect', left: '0', top: '10' }" /> <scroll-table v-if="element.type === 'rank-table'" style="width: 100%" :height="330" :data="element.data" :columns="element.columns" /> </div> </div> </div> </div> </template> </draggable> <!-- </div> --> </div> </div> </template> <style lang="scss" scoped> .dragClass { /* background-color: blueviolet !important; */ opacity: 1 !important; box-shadow: none !important; outline: none !important; background-image: none !important; color: #6ff !important; } .ghostClass { /* background-color: blue !important; */ } .chosenClass { color: #6ff !important; /* background-color: #ccc !important; */ /* opacity: 1 !important; */ /* width: 32.5% !important; */ } .content { display: flex; .chart { width: 100%; } .swiper { width: 30%; padding-top: 55px; box-sizing: content-box; } } .icon-button-icon { width: 50px; height: 50px; } .container { position: relative; // height: 500px; .btns { width: 100%; position: absolute; top: -36px; right: 60%; // left: 50%; display: flex; justify-content: space-between; padding: 0 60px; } .count { display: flex; width: 66%; margin: 0 auto; position: absolute; top: -40px; left: 50%; transform: translateX(-50%); .count-item { // margin-left: 20px; width: 40%; height: 75px; display: flex; padding: 0 10px; justify-content: space-around; .header-icon { width: 20%; display: flex; flex-direction: column; justify-content: center; } .header-content { // width: 60%; padding: 10px; display: flex; flex-direction: column; justify-content: space-around; .content-title { font-weight: 700; } .content-count { font-weight: 700; font-size: 24px; color: #1aaf8b; text-align: center; } } } } .chart { display: flex; flex-wrap: wrap; justify-content: space-around; // margin-top: 15px; padding-top: 20px; .chart-item { width: 33%; height: 348px; // border: 1px solid red; margin-top: 10px; .chart-name { color: #3d6fb6; font-size: 18px; font-weight: 700; } .chart-page { height: 330px; } } } } </style>