|
|
@@ -54,13 +54,13 @@
|
|
|
<el-table-column v-if="tableLabel === '访问次数'" label="访问次数统计图" align="center">
|
|
|
<template #default="scope">
|
|
|
<img
|
|
|
- style="display: inline-block; margin-right: 20px"
|
|
|
+ style="display: inline-block; margin-right: 20px; cursor: pointer"
|
|
|
src="@/assets/icons/chart-bar.png"
|
|
|
alt=""
|
|
|
@click="showBargraph(scope.row)"
|
|
|
/>
|
|
|
<img
|
|
|
- style="display: inline-block"
|
|
|
+ style="display: inline-block; cursor: pointer"
|
|
|
src="@/assets/icons/chart-line.png"
|
|
|
alt=""
|
|
|
@click="showLinechart(scope.row)"
|
|
|
@@ -80,25 +80,25 @@
|
|
|
</div>
|
|
|
<el-dialog
|
|
|
v-model="bargraphVisible"
|
|
|
- :title="bargraphTitle"
|
|
|
+ :title="chartTitle"
|
|
|
:close-on-click-modal="true"
|
|
|
:destroy-on-close="true"
|
|
|
width="1000px"
|
|
|
center
|
|
|
>
|
|
|
- <DialogNavBar @params-changed="(v) => console.log(v)" />
|
|
|
- <BarChart :chart-data="barData.val" :chart-lable="barData.label" />
|
|
|
+ <DialogNavBar @chart-params-changed="onDialogParamsChanged" />
|
|
|
+ <BarChart :chart-data="chartData.val" :chart-lable="chartData.label" />
|
|
|
</el-dialog>
|
|
|
<el-dialog
|
|
|
v-model="linechartVisible"
|
|
|
- :title="linechartTitle"
|
|
|
+ :title="chartTitle"
|
|
|
:close-on-click-modal="true"
|
|
|
:destroy-on-close="true"
|
|
|
width="1000px"
|
|
|
center
|
|
|
>
|
|
|
- <DialogNavBar :workshop-list="workshopList" @params-changed="(v) => console.log(v)" />
|
|
|
- <LineChart :chart-data="LineData.val" :chart-lable="LineData.label" />
|
|
|
+ <DialogNavBar :workshop-list="workshopList" @chart-params-changed="onDialogParamsChanged" />
|
|
|
+ <LineChart :chart-data="chartData.val" :chart-lable="chartData.label" />
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
|
|
|
@@ -109,19 +109,22 @@
|
|
|
import BarChart from '../../charts/BarChart.vue';
|
|
|
import LineChart from '../../charts/LineChart.vue';
|
|
|
import {
|
|
|
- UserAccessRecordList,
|
|
|
- UserAccessRecordQueryParams,
|
|
|
+ type ChartQuery,
|
|
|
+ type UserAccessRecordList,
|
|
|
+ type UserAccessRecordQueryParams,
|
|
|
+ getUserVisitTimes,
|
|
|
+ getUserDailyVisitTimes,
|
|
|
} from '@/api/datamanagement/dataplatform';
|
|
|
+ import { formatWorkshopChart, formatTimeChart } from '@/utils/platformUtils';
|
|
|
|
|
|
+ // 获取下拉菜单数据和表格数据
|
|
|
const props = defineProps<{
|
|
|
workshopList: any[];
|
|
|
tableData: UserAccessRecordList;
|
|
|
tableLabel: string;
|
|
|
}>();
|
|
|
|
|
|
- const tableQueryTypeContent = ref<string>();
|
|
|
-
|
|
|
- const tableQueryType = ref<string>('姓名');
|
|
|
+ // 表格查询参数和修改事件
|
|
|
const tableQueryParams = ref<UserAccessRecordQueryParams>({
|
|
|
pageNumber: 1,
|
|
|
pageSize: 10,
|
|
|
@@ -130,22 +133,24 @@
|
|
|
// sortKey: "",
|
|
|
// sortType: "",
|
|
|
});
|
|
|
+ const emits = defineEmits<{
|
|
|
+ (e: 'tableParamsChanged', parmas: UserAccessRecordQueryParams);
|
|
|
+ }>();
|
|
|
|
|
|
- //柱状图logo
|
|
|
- const bargraphVisible = ref(false);
|
|
|
- const bargraphTitle = ref('');
|
|
|
- const showBargraph = (rowData) => {
|
|
|
- bargraphVisible.value = true;
|
|
|
- bargraphTitle.value = rowData.nickname + '访问车间统计柱状图';
|
|
|
+ // 页码导航栏修改事件
|
|
|
+ const handleSizeChange = (v: number) => {
|
|
|
+ tableQueryParams.value.pageSize = v;
|
|
|
+ emits('tableParamsChanged', tableQueryParams.value);
|
|
|
};
|
|
|
- //折线图logo
|
|
|
- const linechartVisible = ref(false);
|
|
|
- const linechartTitle = ref('');
|
|
|
- const showLinechart = (rowData) => {
|
|
|
- linechartVisible.value = true;
|
|
|
- linechartTitle.value = rowData.nickname + '访问车间统计折线图';
|
|
|
+ const handleCurrentPageChange = (v: number) => {
|
|
|
+ tableQueryParams.value.pageNumber = v;
|
|
|
+ emits('tableParamsChanged', tableQueryParams.value);
|
|
|
};
|
|
|
|
|
|
+ // TODO 表格排序事件
|
|
|
+
|
|
|
+ // 复用输入框类型和变化事件
|
|
|
+ const tableQueryType = ref<string>('姓名');
|
|
|
const handleTableQueryTypeChange = (v: string) => {
|
|
|
if (v === '姓名') {
|
|
|
delete tableQueryParams.value.username;
|
|
|
@@ -153,21 +158,8 @@
|
|
|
delete tableQueryParams.value.nickname;
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
- const handleSizeChange = (v: number) => {
|
|
|
- tableQueryParams.value.pageSize = v;
|
|
|
- emits('tableParamsChanged', tableQueryParams.value);
|
|
|
- };
|
|
|
-
|
|
|
- const handleCurrentPageChange = (v: number) => {
|
|
|
- tableQueryParams.value.pageNumber = v;
|
|
|
- emits('tableParamsChanged', tableQueryParams.value);
|
|
|
- };
|
|
|
- const emits = defineEmits<{
|
|
|
- (e: 'tableParamsChanged', parmas: UserAccessRecordQueryParams);
|
|
|
- }>();
|
|
|
-
|
|
|
- // 搜索数据
|
|
|
+ // 复用输入框绑定内容、提交事件、重置事件
|
|
|
+ const tableQueryTypeContent = ref<string>();
|
|
|
function submitTableQuery() {
|
|
|
if (tableQueryType.value === '姓名') {
|
|
|
tableQueryParams.value.nickname = tableQueryTypeContent.value;
|
|
|
@@ -176,30 +168,53 @@
|
|
|
}
|
|
|
emits('tableParamsChanged', tableQueryParams.value);
|
|
|
}
|
|
|
-
|
|
|
- // 重置表单
|
|
|
function resetTable() {
|
|
|
- emits('tableParamsChanged', {
|
|
|
+ tableQueryTypeContent.value = '';
|
|
|
+ tableQueryParams.value = {
|
|
|
pageNumber: 1,
|
|
|
pageSize: 10,
|
|
|
- });
|
|
|
+ };
|
|
|
+ emits('tableParamsChanged', tableQueryParams.value);
|
|
|
}
|
|
|
|
|
|
- const barData = ref<{
|
|
|
- label: string[];
|
|
|
- val: number[];
|
|
|
- }>({
|
|
|
- label: ['车间1', '车间2', '车间3', '车间4', '车间5', '车间6'],
|
|
|
- val: [9, 66, 77, 82, 35, 100],
|
|
|
- });
|
|
|
+ // dialog显示和画图
|
|
|
+ const chartTitle = ref('');
|
|
|
+ const ChartQueryUserId = ref('');
|
|
|
+ const bargraphVisible = ref(false);
|
|
|
+ const showBargraph = (rowData) => {
|
|
|
+ bargraphVisible.value = true;
|
|
|
+ chartTitle.value = rowData.nickname + '访问车间统计柱状图';
|
|
|
+ ChartQueryUserId.value = rowData.userId;
|
|
|
+ };
|
|
|
+ const linechartVisible = ref(false);
|
|
|
+ const showLinechart = (rowData) => {
|
|
|
+ linechartVisible.value = true;
|
|
|
+ chartTitle.value = rowData.nickname + '访问车间统计折线图';
|
|
|
+ ChartQueryUserId.value = rowData.userId;
|
|
|
+ };
|
|
|
|
|
|
- const LineData = ref<{
|
|
|
+ // 请求画图数据
|
|
|
+ const getChartData = async (cp: ChartQuery) => {
|
|
|
+ if (chartTitle.value.includes('柱状')) {
|
|
|
+ const data = await getUserVisitTimes(cp);
|
|
|
+ chartData.value = formatWorkshopChart(data);
|
|
|
+ } else {
|
|
|
+ const data = await getUserDailyVisitTimes(cp);
|
|
|
+ chartData.value = formatTimeChart(data);
|
|
|
+ // TODO 整理数据传入chartData
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const chartData = ref<{
|
|
|
label: string[];
|
|
|
val: number[];
|
|
|
}>({
|
|
|
- label: ['日期1', '日期2', '日期3', '日期4', '日期5', '日期6'],
|
|
|
- val: [9, 56, 77, 802, 0, 100],
|
|
|
+ label: [],
|
|
|
+ val: [],
|
|
|
});
|
|
|
+ const onDialogParamsChanged = async (v: ChartQuery) => {
|
|
|
+ v.userId = ChartQueryUserId.value;
|
|
|
+ await getChartData(v);
|
|
|
+ };
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|