| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 |
- <template>
- <div class="chartsContainer">
- <div class="chartsContainer-title">查获明细</div>
- <div class="chartsContainer-list">
- <div class="chartsContainer-content">
- <div class="chartsContainer-content-top">
- <div class="chartsContainer-content-name">违禁品类别</div>
- </div>
- <div class="chartsContainer-content-content" ref="pieCategory" />
- </div>
- <div class="chartsContainer-content">
- <div class="chartsContainer-content-top">
- <div class="chartsContainer-content-name">查获部位</div>
- </div>
- <div class="chartsContainer-content-content" ref="pieAppPosition" />
- </div>
- <div class="chartsContainer-content">
- <div class="chartsContainer-content-top">
- <div class="chartsContainer-content-name">安检岗位</div>
- </div>
- <div class="chartsContainer-content-content" ref="pieLargeScreenPost" />
- </div>
-
- <div class="chartsContainer-content">
- <div class="chartsContainer-content-top">
- <div class="chartsContainer-content-name">查获时间分布</div>
- </div>
- <div class="chartsContainer-content-content" ref="lineChart" />
- </div>
- </div>
- </div>
- </template>
- <script setup>
- import { category, appPosition, largeScreenPost, appTimeSpan } from '@/api/item/items'
- import { useTimeOut } from './useTimeOut';
- import { useECharts } from '@/hooks/useEcharts.js';
- import { ref, computed, inject } from 'vue'
- const provideParams = inject('provideParams')
- const pieCategory = ref(null)
- const pieCategoryData = ref([])
- const setChartsOptions = computed(() => {
- return {
- tooltip: {
- trigger: 'item',
- formatter: '{a} <br/>{b}: {c} ({d}%)'
- },
- legend: {
- show: false
- },
- series: [
- {
- name: '违禁品类别',
- type: 'pie',
- radius: [ '0%', '50%' ], // 环形图设置
- center: [ '50%', '50%' ],
- data: pieCategoryData.value.map(item => {
- return {
- name: item.name,
- value: item.total
- }
- }),
- label: {
- show: true,
- formatter: function (params) {
- return params.name + '\n' + params.percent + '%'
- },
- color: '#fff',
- fontSize: 14,
- },
- labelLine: {
- length: 15
- },
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.5)'
- }
- }
- }
- ]
- }
- })
- useECharts(pieCategory, setChartsOptions);
- const pieAppPosition = ref(null)
- const pieAppPositionData = ref([])
- const setpieAppPositionOptions = computed(() => {
- return {
- tooltip: {
- trigger: 'item',
- formatter: '{a} <br/>{b}: {c} ({d}%)'
- },
- legend: {
- show: false
- },
- series: [
- {
- name: '查获部位',
- type: 'pie',
- radius: [ '0%', '50%' ], // 环形图设置
- center: [ '50%', '50%' ],
- data: pieAppPositionData.value.map(item => {
- return {
- name: item.name,
- value: item.total
- }
- }),
- label: {
- show: true,
- formatter: function (params) {
- return params.name + '\n' + params.percent + '%'
- },
- color: '#fff',
- fontSize: 14,
- },
- labelLine: {
- length: 15
- },
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.5)'
- }
- }
- }
- ]
- }
- })
- useECharts(pieAppPosition, setpieAppPositionOptions);
- const pieLargeScreenPost = ref(null)
- const pieLargeScreenPostData = ref([])
- const setpieLargeScreenPostOptions = computed(() => {
- return {
- tooltip: {
- trigger: 'item',
- formatter: '{a} <br/>{b}: {c} ({d}%)'
- },
- legend: {
- show: false
- },
- series: [
- {
- name: '安检岗位',
- type: 'pie',
- radius: [ '0%', '50%' ], // 环形图设置
- center: [ '50%', '50%' ],
- data: pieLargeScreenPostData.value.map(item => {
- return {
- name: item.name,
- value: item.total
- }
- }),
- label: {
- show: true,
- formatter: function (params) {
- return params.name + '\n' + params.percent + '%'
- },
- color: '#fff',
- fontSize: 14,
- },
- labelLine: {
- length: 15
- },
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.5)'
- }
- }
- }
- ]
- }
- })
- useECharts(pieLargeScreenPost, setpieLargeScreenPostOptions);
- const lineChart = ref(null)
- const lineChartData = ref([])
- const setlineChartOptions = computed(() => {
- return {
- tooltip: {
- trigger: 'axis'
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- data: lineChartData.value.map(item => item.hourOfDay),
- axisLabel: {
- color: '#fff',
- rotate: 25,
- fontSize: 12,
- }
- },
- yAxis: {
- type: 'value',
- minInterval: 1,
- max: Math.max(...lineChartData.value.map(item => item.total)) * 2,
- axisLabel: {
- color: '#fff',
- }
- },
- series: {
- data: lineChartData.value.map(item => item.total),
- type: 'line',
- smooth: true,
- },
- grid: {
- left: '5%',
- right: '0%',
- bottom: '10%',
- top: '5%',
- containLabel: true
- }
- };
- })
- useECharts(lineChart, setlineChartOptions);
- useTimeOut(() => {
- provideParams.value.inspectDepartmentId && category({
- startDate: provideParams.value.startDate,
- endDate: provideParams.value.endDate,
- inspectDepartmentId: provideParams.value.inspectDepartmentId === 'ALL' ? '' : provideParams.value.inspectDepartmentId
- }).then(res => {
- pieCategoryData.value = (res.data || [])
- })
- provideParams.value.inspectDepartmentId && appPosition({
- startDate: provideParams.value.startDate,
- endDate: provideParams.value.endDate,
- inspectDepartmentId: provideParams.value.inspectDepartmentId === 'ALL' ? '' : provideParams.value.inspectDepartmentId
- }).then(res => {
- pieAppPositionData.value = (res.data || [])
- })
- provideParams.value.inspectDepartmentId && largeScreenPost({
- startDate: provideParams.value.startDate,
- endDate: provideParams.value.endDate,
- inspectDepartmentId: provideParams.value.inspectDepartmentId === 'ALL' ? '' : provideParams.value.inspectDepartmentId
- }).then(res => {
- pieLargeScreenPostData.value = (res.data || [])
- })
- provideParams.value.inspectDepartmentId && appTimeSpan({
- startDate: provideParams.value.startDate,
- endDate: provideParams.value.endDate,
- inspectDepartmentId: provideParams.value.inspectDepartmentId === 'ALL' ? '' : provideParams.value.inspectDepartmentId
- }).then(res => {
- lineChartData.value = Array.isArray(res.data) ? Array.from({length: 24}, (_, index) => {
- const item = res.data.find(item => Number(item.hourOfDay) === index)
- if (item) {
- return {
- total: item.total,
- hourOfDay: `${index}:00`
- }
- } else {
- return {
- total: 0,
- hourOfDay: `${index}:00`
- }
- }
- }) : []
-
- })
- }, [provideParams])
- </script>
- <style lang="scss" scoped>
- .chartsContainer {
- width: 100%;
- height: 100%;
- position: relative;
- background: linear-gradient(to bottom, rgba(8, 97, 117, 0) 0%, #13a2d6 200%);
- border-radius: 4px;
- overflow: hidden;
- display: flex;
- flex-direction: column;
- .chartsContainer-title {
- height: 42px;
- width: 100%;
- background: linear-gradient(to right, #004387 0%, #090B18 100%);
- border-left: 1px solid #1892CE;
- line-height: 42px;
- color: #fff;
- font-weight: 900;
- font-size: 20px;
- text-indent: 1em;
- }
- .chartsContainer-list {
- padding: 20px 15px 10px;
- box-sizing: border-box;
- display: flex;
- column-gap: 20px;
- row-gap: 20px;
- flex: 1;
- overflow: hidden;
- flex-wrap: wrap;
- }
- .chartsContainer-content {
- display: flex;
- flex-direction: column;
- row-gap: 10px;
- width: calc(50% - 10px);
- height: calc(50% - 10px);
- overflow: hidden;
- .chartsContainer-content-top {
- display: flex;
- align-items: center;
- color: #78DEF5;
- .chartsContainer-content-name {
- color: #fff;
- font-weight: bold;
- font-size: 16px;
- display: flex;
- align-items: center;
- &::before {
- content: '';
- display: inline-block;
- border-left: 9px solid #1CB6FF;
- border-top: 8px solid transparent;
- border-right: 9px solid transparent;
- border-bottom: 8px solid transparent;
- }
- }
- }
- .chartsContainer-content-describe {
- color: #78DEF5;
- font-size: 12px;
- font-weight: bold;
- display: flex;
- align-items: center;
- }
- .chartsContainer-content-content {
- flex: 1;
- width: 100%;
- overflow: hidden;
- }
- }
- }
- </style>
|