|
@@ -0,0 +1,322 @@
|
|
|
+<template>
|
|
|
+ <div class="statistics-order-hotspot-are-container layout-padding">
|
|
|
+ <div class="layout-padding-auto layout-padding-view pd20">
|
|
|
+ <el-tabs v-model="state.queryParams.HotspotLevel" @tab-change="handleQuery">
|
|
|
+ <el-tab-pane name="1" label="第一级别"></el-tab-pane>
|
|
|
+ <el-tab-pane name="2" label="第二级别"></el-tab-pane>
|
|
|
+ <el-tab-pane name="3" label="第三级别"></el-tab-pane>
|
|
|
+ <el-tab-pane name="4" label="第四级别"></el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
+ <el-form :model="state.queryParams" ref="ruleFormRef" @submit.native.prevent inline class="search-form">
|
|
|
+ <el-form-item label="时间段" prop="crTime">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="state.queryParams.crTime"
|
|
|
+ type="daterange"
|
|
|
+ unlink-panels
|
|
|
+ range-separator="至"
|
|
|
+ start-placeholder="开始时间"
|
|
|
+ end-placeholder="结束时间"
|
|
|
+ :shortcuts="shortcuts"
|
|
|
+ @change="handleQuery"
|
|
|
+ value-format="YYYY-MM-DD"
|
|
|
+ :clearable="false"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label-width="0">
|
|
|
+ <el-button type="primary" @click="handleQuery" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
|
|
|
+ <el-button @click="resetQuery(ruleFormRef)" class="default-button" :loading="state.loading">
|
|
|
+ <SvgIcon name="ele-Refresh" class="mr5" />重置
|
|
|
+ </el-button>
|
|
|
+ </el-form-item>
|
|
|
+ <div class="tool-buttons">
|
|
|
+ <el-button circle @click="queryList" title="刷新表格" :disabled="state.loading">
|
|
|
+ <SvgIcon name="ele-Refresh" />
|
|
|
+ </el-button>
|
|
|
+ <el-button circle @click="exportAll" title="导出全部" :disabled="exportLoading">
|
|
|
+ <SvgIcon name="iconfont icon-export" />
|
|
|
+ </el-button>
|
|
|
+ <el-button v-if="exportLoading" :loading="exportLoading">导出中,请稍后。。。</el-button>
|
|
|
+ </div>
|
|
|
+ </el-form>
|
|
|
+ <!-- 表格 -->
|
|
|
+ <el-auto-resizer class="table" v-loading="state.loading">
|
|
|
+ <template #default="{ height, width }">
|
|
|
+ <el-table-v2
|
|
|
+ :columns="columns"
|
|
|
+ :data="state.tableData"
|
|
|
+ fixed
|
|
|
+ :width="width"
|
|
|
+ :height="height - 5"
|
|
|
+ ref="virtuallyTableRef"
|
|
|
+ :scrollbar-always-on="true"
|
|
|
+ >
|
|
|
+ </el-table-v2>
|
|
|
+ </template>
|
|
|
+ </el-auto-resizer>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script setup lang="tsx" name="statisticsOrderHotspotArea">
|
|
|
+import { onMounted, reactive, ref, defineAsyncComponent } from 'vue';
|
|
|
+import { ElMessageBox, FormInstance } from 'element-plus';
|
|
|
+import { defaultDate, shortcuts } from '@/utils/constants';
|
|
|
+import Other from '@/utils/other';
|
|
|
+import { statisticsOrderHot, statisticsOrderHotExport } from '@/api/statistics/order';
|
|
|
+import { useRouter } from 'vue-router';
|
|
|
+import { downloadFileByStream } from '@/utils/tools';
|
|
|
+
|
|
|
+const TextTooltip = defineAsyncComponent(() => import('@/components/TextTooltip/index.vue'));
|
|
|
+
|
|
|
+// 表格配置项
|
|
|
+const columns = ref<any[]>([]);
|
|
|
+// 定义变量内容
|
|
|
+const ruleFormRef = ref<RefType>(); // 表单ref
|
|
|
+const state = reactive<any>({
|
|
|
+ queryParams: {
|
|
|
+ // 查询条件
|
|
|
+ HotspotLevel: '1',
|
|
|
+ IdentityType: null, // 关键词
|
|
|
+ Gateway: null,
|
|
|
+ crTime: defaultDate, //
|
|
|
+ StartTime: null,
|
|
|
+ EndTime: null,
|
|
|
+ },
|
|
|
+ tableData: [], //表单
|
|
|
+ loading: false, // 加载
|
|
|
+ total: 0, // 总数
|
|
|
+ callForwardingSource: [],
|
|
|
+});
|
|
|
+/** 搜索按钮操作 */
|
|
|
+const handleQuery = () => {
|
|
|
+ // state.queryParams.PageIndex = 1;
|
|
|
+ queryList();
|
|
|
+};
|
|
|
+/** 获取列表 */
|
|
|
+const requestParams = ref({});
|
|
|
+const queryList = async () => {
|
|
|
+ state.loading = true;
|
|
|
+ try {
|
|
|
+ requestParams.value = Other.deepClone(state.queryParams);
|
|
|
+ requestParams.value.StartTime = state.queryParams.crTime === null ? null : state.queryParams.crTime[0];
|
|
|
+ requestParams.value.EndTime = state.queryParams.crTime === null ? null : state.queryParams.crTime[1];
|
|
|
+ Reflect.deleteProperty(requestParams.value, 'crTime');
|
|
|
+ const { result } = await statisticsOrderHot(requestParams.value);
|
|
|
+ columns.value = result.areaList.map((item: any) => {
|
|
|
+ return {
|
|
|
+ key: item.id,
|
|
|
+ dataKey: item.id,
|
|
|
+ title: item.areaName,
|
|
|
+ width: 95,
|
|
|
+ align: 'center',
|
|
|
+ cellRenderer: (data: any) => {
|
|
|
+ return (
|
|
|
+ <el-button type="primary" link onClick={() => linkDetail(data)}>
|
|
|
+ {data.rowData[item.id]}
|
|
|
+ </el-button>
|
|
|
+ );
|
|
|
+ },
|
|
|
+ };
|
|
|
+ });
|
|
|
+ state.tableData = result.data;
|
|
|
+ state.tableData = state.tableData.map((item: any) => {
|
|
|
+ // 取第一级名称
|
|
|
+ item.HotspotName1 = item.HotspotName.split('-')[0];
|
|
|
+ // 取第二级名称
|
|
|
+ item.HotspotName2 = item.HotspotName.split('-')[1];
|
|
|
+ // 取第三级名称
|
|
|
+ item.HotspotName3 = item.HotspotName.split('-')[2];
|
|
|
+ // 取第四级名称
|
|
|
+ item.HotspotName4 = item.HotspotName.split('-')[3];
|
|
|
+ return { ...item };
|
|
|
+ });
|
|
|
+ switch (state.queryParams.HotspotLevel) {
|
|
|
+ case '1':
|
|
|
+ // 分类级别
|
|
|
+ columns.value.unshift({
|
|
|
+ key: 'HotspotId',
|
|
|
+ dataKey: 'HotspotName',
|
|
|
+ title: `一级分类`,
|
|
|
+ width: 150,
|
|
|
+ align: 'center',
|
|
|
+ cellRenderer: (data: any) => {
|
|
|
+ return <TextTooltip content={data.rowData.HotspotName} effect="dark" placement="top"></TextTooltip>;
|
|
|
+ },
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case '2':
|
|
|
+ columns.value.unshift({
|
|
|
+ key: 'HotspotId',
|
|
|
+ dataKey: 'HotspotName',
|
|
|
+ title: `一级分类`,
|
|
|
+ width: 150,
|
|
|
+ align: 'center',
|
|
|
+ cellRenderer: (data: any) => {
|
|
|
+ return <TextTooltip content={data.rowData.HotspotName} effect="dark" placement="top"></TextTooltip>;
|
|
|
+ },
|
|
|
+ },{
|
|
|
+ key: 'HotspotId',
|
|
|
+ dataKey: 'HotspotName',
|
|
|
+ title: `二级分类`,
|
|
|
+ width: 150,
|
|
|
+ align: 'center',
|
|
|
+ cellRenderer: (data: any) => {
|
|
|
+ return <TextTooltip content={data.rowData.HotspotName} effect="dark" placement="top"></TextTooltip>;
|
|
|
+ },
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case '3':
|
|
|
+ columns.value.unshift({
|
|
|
+ key: 'HotspotId',
|
|
|
+ dataKey: 'HotspotName',
|
|
|
+ title: `一级分类`,
|
|
|
+ width: 150,
|
|
|
+ align: 'center',
|
|
|
+ cellRenderer: (data: any) => {
|
|
|
+ return <TextTooltip content={data.rowData.HotspotName} effect="dark" placement="top"></TextTooltip>;
|
|
|
+ },
|
|
|
+ },{
|
|
|
+ key: 'HotspotId',
|
|
|
+ dataKey: 'HotspotName',
|
|
|
+ title: `二级分类`,
|
|
|
+ width: 150,
|
|
|
+ align: 'center',
|
|
|
+ cellRenderer: (data: any) => {
|
|
|
+ return <TextTooltip content={data.rowData.HotspotName} effect="dark" placement="top"></TextTooltip>;
|
|
|
+ },
|
|
|
+ },{
|
|
|
+ key: 'HotspotId',
|
|
|
+ dataKey: 'HotspotName',
|
|
|
+ title: `三级分类`,
|
|
|
+ width: 150,
|
|
|
+ align: 'center',
|
|
|
+ cellRenderer: (data: any) => {
|
|
|
+ return <TextTooltip content={data.rowData.HotspotName} effect="dark" placement="top"></TextTooltip>;
|
|
|
+ },
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case '4':
|
|
|
+ columns.value.unshift({
|
|
|
+ key: 'HotspotId',
|
|
|
+ dataKey: 'HotspotName',
|
|
|
+ title: `一级分类`,
|
|
|
+ width: 150,
|
|
|
+ align: 'center',
|
|
|
+ cellRenderer: (data: any) => {
|
|
|
+ return <TextTooltip content={data.rowData.HotspotName} effect="dark" placement="top"></TextTooltip>;
|
|
|
+ },
|
|
|
+ },{
|
|
|
+ key: 'HotspotId',
|
|
|
+ dataKey: 'HotspotName',
|
|
|
+ title: `二级分类`,
|
|
|
+ width: 150,
|
|
|
+ align: 'center',
|
|
|
+ cellRenderer: (data: any) => {
|
|
|
+ return <TextTooltip content={data.rowData.HotspotName} effect="dark" placement="top"></TextTooltip>;
|
|
|
+ },
|
|
|
+ },{
|
|
|
+ key: 'HotspotId',
|
|
|
+ dataKey: 'HotspotName',
|
|
|
+ title: `三级分类`,
|
|
|
+ width: 150,
|
|
|
+ align: 'center',
|
|
|
+ cellRenderer: (data: any) => {
|
|
|
+ return <TextTooltip content={data.rowData.HotspotName} effect="dark" placement="top"></TextTooltip>;
|
|
|
+ },
|
|
|
+ },{
|
|
|
+ key: 'HotspotId',
|
|
|
+ dataKey: 'HotspotName',
|
|
|
+ title: `四级分类`,
|
|
|
+ width: 150,
|
|
|
+ align: 'center',
|
|
|
+ cellRenderer: (data: any) => {
|
|
|
+ return <TextTooltip content={data.rowData.HotspotName} effect="dark" placement="top"></TextTooltip>;
|
|
|
+ },
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算横轴小计
|
|
|
+ state.tableData = result.data.map((item: any) => {
|
|
|
+ let subtotal = 0;
|
|
|
+ for (let i of result.areaList) {
|
|
|
+ const itemI = item[i.id] ?? 0;
|
|
|
+ subtotal += itemI;
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ subtotal,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ columns.value.push({
|
|
|
+ align: 'center',
|
|
|
+ key: 'subtotal',
|
|
|
+ dataKey: 'subtotal',
|
|
|
+ title: '小计',
|
|
|
+ width: 100,
|
|
|
+ });
|
|
|
+
|
|
|
+ state.loading = false;
|
|
|
+ } catch (e) {
|
|
|
+ state.loading = false;
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+};
|
|
|
+/** 重置按钮操作 */
|
|
|
+const resetQuery = (formEl: FormInstance | undefined) => {
|
|
|
+ if (!formEl) return;
|
|
|
+ formEl.resetFields();
|
|
|
+ queryList();
|
|
|
+};
|
|
|
+// 查看列表明细
|
|
|
+const router = useRouter();
|
|
|
+const linkDetail = (data) => {
|
|
|
+ console.log(data, '111');
|
|
|
+ /*router.push({
|
|
|
+ name: 'statisticsOrderDetailAcceptTime',
|
|
|
+ });*/
|
|
|
+};
|
|
|
+const exportLoading = ref(false);
|
|
|
+// 导出
|
|
|
+const exportAll = () => {
|
|
|
+ ElMessageBox.confirm(`您确定要导出全部数据,是否继续?`, '提示', {
|
|
|
+ confirmButtonText: '确认',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ draggable: true,
|
|
|
+ cancelButtonClass: 'default-button',
|
|
|
+ autofocus: false,
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ exportLoading.value = true;
|
|
|
+ const specialRequest = {
|
|
|
+ ...requestParams.value,
|
|
|
+ AddColumnName: columns.value.map((item: any) => item.title),
|
|
|
+ };
|
|
|
+ statisticsOrderHotExport(specialRequest)
|
|
|
+ .then((res: any) => {
|
|
|
+ downloadFileByStream(res);
|
|
|
+ exportLoading.value = false;
|
|
|
+ })
|
|
|
+ .catch((e) => {
|
|
|
+ console.log(`导出失败:${e}`);
|
|
|
+ exportLoading.value = false;
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
+};
|
|
|
+onMounted(() => {
|
|
|
+ queryList();
|
|
|
+});
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.search-form {
|
|
|
+ position: relative;
|
|
|
+ .tool-buttons {
|
|
|
+ position: absolute;
|
|
|
+ right: 0;
|
|
|
+ top: 5px;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|