| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <template>
- <div>
- <el-button type="primary" @click="showWorkshopData()">车间统计数据</el-button>
- <el-button type="primary" @click="showCameraData()">相机统计数据</el-button>
- <QueryTable
- v-if="tableData !== undefined"
- :department-list="departmentList"
- :workshop-list="flattenedWorkshops"
- :table-data="tableData"
- table-label="访问次数"
- @table-params-changed="
- (v) => {
- tableQueryParams = _.cloneDeep(v);
- }
- "
- />
- <el-dialog
- v-model="dialogVisible"
- width="1000px"
- :title="dialogTitle"
- :close-on-click-modal="true"
- :destroy-on-close="true"
- center
- >
- <DialogNavBar
- :workshop-list="dialogTitle === '相机统计数据' ? flattenedWorkshops : undefined"
- @chart-params-changed="
- async (v) => {
- await getChartData(v);
- }
- "
- />
- <BarChart :chart-data="chartData.val" :chart-lable="chartData.label" />
- </el-dialog>
- </div>
- </template>
- <script setup lang="ts">
- import QueryTable from '../common/QueryTable.vue';
- import DialogNavBar from '../common/DialogNavBar.vue';
- import BarChart from '../../charts/BarChart.vue';
- import { ref, onMounted, watch } from 'vue';
- import { useSceneInfos } from '@/hooks/useSceneInfos';
- import {
- type UserAccessRecordQueryParams,
- type UserAccessRecordList,
- type ChartQuery,
- getUserAccessRecords,
- getCameraVisitedTimes,
- getWorkshopVisitedTimes,
- } from '@/api/datamanagement/dataplatform';
- import { formatWorkshopChart, formatCameraChart } from '@/utils/platformUtils';
- import { getAllDepartments } from '@/api/auth/dept';
- import _ from 'lodash-es';
- import { PaginationRequest } from '@/types/common/type';
- const departmentList = ref<any[]>([]);
- // 下拉菜单车间列表数据
- const sceneInfos = useSceneInfos();
- const { flattenedWorkshops, getScenesTree, calculateTreeData } = sceneInfos;
- onMounted(() => {
- getScenesTree({ level: 1, valueKey: 'code', labelKey: 'name', disabled: true });
- getAllDepartments().then((res) => {
- departmentList.value = calculateTreeData(res, { level: 3, valueKey: 'id', labelKey: 'deptName' }, 1);
- });
- });
- // dialog显示
- const dialogVisible = ref(false);
- const dialogTitle = ref('');
- const showWorkshopData = () => {
- dialogVisible.value = true;
- dialogTitle.value = '车间统计数据';
- };
- const showCameraData = () => {
- dialogVisible.value = true;
- dialogTitle.value = '相机统计数据';
- };
- // 请求画图数据
- const getChartData = async (cp: ChartQuery) => {
- if (dialogTitle.value.includes('车间')) {
- const data = await getWorkshopVisitedTimes(cp);
- chartData.value = formatWorkshopChart(data);
- } else {
- const data = await getCameraVisitedTimes(cp);
- chartData.value = formatCameraChart(data);
- }
- };
- const chartData = ref<{
- label: string[];
- val: number[];
- }>({
- label: [],
- val: [],
- });
- // 请求表格数据
- const tableQueryParams = ref<PaginationRequest & { queryParam: UserAccessRecordQueryParams }>({
- pageNumber: 1,
- pageSize: 10,
- queryParam: {},
- // nickname: '',
- // username: '',
- // sortKey: 'statisticAll',
- // sortType: 'asc',
- });
- const tableData = ref<UserAccessRecordList>();
- watch(
- () => tableQueryParams.value,
- async () => {
- const data = await getUserAccessRecords(tableQueryParams.value);
- tableData.value = {
- list: data.records,
- pageNumber: data.pageNumber,
- pageSize: data.pageSize,
- total: data.totalRow,
- };
- },
- {
- immediate: true,
- deep: true,
- },
- );
- </script>
- <style scoped lang="scss">
- :deep(.el-dialog__header) {
- text-align: left;
- border-bottom: 1px solid rgba(232, 232, 232, 1);
- padding-bottom: 16px;
- margin-bottom: 16px;
- }
- :deep(.el-dialog__title) {
- font-weight: 600;
- font-size: 16px;
- color: rgba(0, 0, 0, 0.88);
- line-height: 24px;
- }
- </style>
|