优化代码

This commit is contained in:
曹磊 2025-10-31 17:05:54 +08:00
parent cfb9f0ab6c
commit a6e3db4d8b
11 changed files with 202 additions and 178 deletions

View File

@ -276,7 +276,7 @@ function createAxios(opt?: Partial<CreateAxiosOptions>) {
// authenticationScheme: 'Bearer',
authenticationScheme: '',
//接口超时设置
timeout: 10 * 1000,
timeout: 60 * 1000,
// 基础接口地址
// baseURL: globSetting.apiUrl,
headers: { 'Content-Type': ContentTypeEnum.JSON },

View File

@ -33,13 +33,13 @@
<a-row :gutter="20" class="third-row">
<a-col :xs="24" :md="12">
<a-card bordered class="mini-card">
<div class="mini-title">乡镇瞬时热量实时</div>
<div class="mini-title">乡镇累积热量GJ</div>
<div ref="countyPowerChartRef" class="chart-medium"></div>
</a-card>
</a-col>
<a-col :xs="24" :md="12">
<a-card bordered class="mini-card" style="margin-left: 8px;">
<div class="mini-title">乡镇瞬时流量实时</div>
<div class="mini-title">乡镇累积流量</div>
<div ref="countyFlowChartRef" class="chart-medium"></div>
</a-card>
</a-col>
@ -95,7 +95,7 @@ function sortByTime(arr: any[]) {
}
function splitByRegion(data: any[]) {
const city = data.filter(d => String(d.regionType).includes('城区'));
const county = data.filter(d => String(d.regionType).includes('乡镇'));
let county = data.filter(d => String(d.regionType).includes('乡镇'));
return { city: sortByTime(city), county: sortByTime(county) };
}
function buildXAxis(records: any[], key = 'view028') {
@ -142,25 +142,25 @@ function prepareOptions(records: any[]) {
color: ['#D64545', '#12A0A6']
};
const powerY = county.map((r: any) => safeNum(r.view041));
const powerY = county.map((r: any) => safeNum(r.view044));
countyPowerOption = {
title: { text: '', left: 'center', top: 8 },
tooltip: { trigger: 'axis' },
grid: { left: '6%', right: '6%', bottom: 60, top: 50, containLabel: true },
xAxis: { type: 'category', data: countyX, axisLabel: { rotate: 20 } },
yAxis: { type: 'value', name: '瞬时热量' },
series: [{ name: '瞬时热量', type: 'line', data: powerY, smooth: false, areaStyle: {}, showSymbol: false, lineStyle: { type: 'solid' } }],
yAxis: { type: 'value', name: '累积热量' },
series: [{ name: '累积热量', type: 'line', data: powerY, smooth: false, areaStyle: {}, showSymbol: false, lineStyle: { type: 'solid' } }],
color: ['#E89B3B']
};
const flowY = county.map((r: any) => safeNum(r.view037));
const flowY = county.map((r: any) => safeNum(r.view040));
countyFlowOption = {
title: { text: '', left: 'center', top: 8 },
tooltip: { trigger: 'axis' },
grid: { left: '6%', right: '6%', bottom: 60, top: 50, containLabel: true },
xAxis: { type: 'category', data: countyX, axisLabel: { rotate: 20 } },
yAxis: { type: 'value', name: '瞬时流量' },
series: [{ name: '瞬时流量', type: 'line', data: flowY, smooth: false, showSymbol: false, lineStyle: { type: 'solid' } }],
yAxis: { type: 'value', name: '累积流量' },
series: [{ name: '累积流量', type: 'line', data: flowY, smooth: false, showSymbol: false, lineStyle: { type: 'solid' } }],
color: ['#7C55FF']
};
}

View File

@ -127,13 +127,13 @@ export const jxcolumns: BasicColumn[] = [
title: '供水温度',
align: "center",
width: 90,
dataIndex: 'view005',
dataIndex: 'view035',
},
{
title: '回水温度',
align: "center",
width: 90,
dataIndex: 'view006'
dataIndex: 'view036'
},
{
title: '供水压力',

View File

@ -46,13 +46,13 @@
</a-col>
<a-col :lg="5">
<a-form-item label="开始时间">
<a-date-picker placeholder="请选择开始时间" v-model:value="queryParam.SDate" :disabledDate="startDisabledDate"
<a-date-picker placeholder="请选择开始时间" v-model:value="queryParam.SDateStr" value-format="YYYY-MM-DD HH:mm:ss" :disabledDate="startDisabledDate"
@change="handleStartChange" show-time style="width: 100%" allow-clear />
</a-form-item>
</a-col>
<a-col :lg="5">
<a-form-item label="结束时间">
<a-date-picker placeholder="请选择结束时间" v-model:value="queryParam.EDate" :disabledDate="endDisabledDate"
<a-date-picker placeholder="请选择结束时间" v-model:value="queryParam.EDateStr" value-format="YYYY-MM-DD HH:mm:ss" :disabledDate="endDisabledDate"
@change="handleEndChange" show-time style="width: 100%" allow-clear />
</a-form-item>
</a-col>
@ -77,6 +77,7 @@ import {
heatsourcestationlist,
page
} from './HeatanalysisHistory.api';
import dayjs from "dayjs";
const queryParam = ref<any>({});
const toggleSearchStatus = ref<boolean>(false);
@ -92,6 +93,7 @@ const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
clickToRowSelect: false,
showActionColumn: false,
showIndexColumn: false,
immediate: false,
tableSetting: {
//
redo: false,
@ -136,23 +138,26 @@ function searchQuery() {
/**
* 重置
*/
function searchReset() {
async function searchReset() {
queryParam.value = {};
selectedRowKeys.value = [];
getHeatsource();
getHeatsourcestation();
await getHeatsource();
await getHeatsourcestation();
let list = thermalcompany.value;
queryParam.value.view001 = list[0].id;
queryParam.value.SDateStr = dayjs().format('YYYY-MM-DD HH:mm:ss');
//
reload();
}
const thermalcompany = ref();
async function getThermalcompany() {
thermalcompany.value = await companylist();
thermalcompany.value = await companylist({regionType: '城区'});
}
const heatsource = ref();
async function getHeatsource() {
heatsource.value = await heatsourcelist();
heatsource.value = await heatsourcelist({regionType: '城区'});
}
const heatsourcestation = ref();
@ -175,57 +180,59 @@ function handleChange3(record) {
//
function startDisabledDate(current) {
//
if (!queryParam.value.EDate) return false;
return !current.isSame(queryParam.value.EDate, 'month') ||
current.isAfter(queryParam.value.EDate, 'day');
if (!queryParam.value.EDateStr) return false;
return !current.isSame(queryParam.value.EDateStr, 'month') ||
current.isAfter(queryParam.value.EDateStr, 'day');
}
//
function endDisabledDate(current) {
//
if (!queryParam.value.SDate) return true;
return !current.isSame(queryParam.value.SDate, 'month') ||
current.isBefore(queryParam.value.SDate, 'day');
if (!queryParam.value.SDateStr) return true;
return !current.isSame(queryParam.value.SDateStr, 'month') ||
current.isBefore(queryParam.value.SDateStr, 'day');
}
//
function handleStartChange(momentObj) {
if (momentObj && queryParam.value.EDate &&
!momentObj.isSame(queryParam.value.EDate, 'month')) {
queryParam.value.EDate = null;
if (momentObj && queryParam.value.EDateStr &&
!momentObj.isSame(queryParam.value.EDateStr, 'month')) {
queryParam.value.EDateStr = null;
}
}
//
function handleEndChange(momentObj) {
if (momentObj && queryParam.value.SDate &&
!momentObj.isSame(queryParam.value.SDate, 'month')) {
queryParam.value.SDate = null;
if (momentObj && queryParam.value.SDateStr &&
!momentObj.isSame(queryParam.value.SDateStr, 'month')) {
queryParam.value.SDateStr = null;
}
}
onMounted(() => {
getThermalcompany();
getHeatsource();
getHeatsourcestation();
onMounted(async() => {
await getThermalcompany();
await getHeatsource();
await getHeatsourcestation();
let list = thermalcompany.value;
queryParam.value.view001 = list[0].id;
queryParam.value.SDateStr = dayjs().format('YYYY-MM-DD HH:mm:ss');
watch(
() => queryParam.value.SDate,
() => queryParam.value.SDateStr,
async (newVal) => {
if (newVal && queryParam.value.EDate &&
(!newVal.isSame(queryParam.value.EDate, 'month') || newVal > queryParam.value.EDate)) {
queryParam.value.EDate = null;
if (newVal && queryParam.value.EDateStr &&
(!newVal.isSame(queryParam.value.EDateStr, 'month') || newVal > queryParam.value.EDateStr)) {
queryParam.value.EDateStr = null;
}
},
{ deep: true, immediate: true }
);
//
watch(
() => queryParam.value.EDate,
() => queryParam.value.EDateStr,
async (newVal) => {
if (newVal && queryParam.value.SDate &&
(!newVal.isSame(queryParam.value.SDate, 'month') || newVal < queryParam.value.SDate)) {
queryParam.value.SDate = null;
if (newVal && queryParam.value.SDateStr &&
(!newVal.isSame(queryParam.value.SDateStr, 'month') || newVal < queryParam.value.SDateStr)) {
queryParam.value.SDateStr = null;
}
},
{ deep: true, immediate: true }

View File

@ -46,13 +46,13 @@
</a-col>
<a-col :lg="5">
<a-form-item label="开始时间">
<a-date-picker placeholder="请选择开始时间" v-model:value="queryParam.SDate" :disabledDate="startDisabledDate"
<a-date-picker placeholder="请选择开始时间" v-model:value="queryParam.SDateStr" value-format="YYYY-MM-DD HH:mm:ss" :disabledDate="startDisabledDate"
@change="handleStartChange" show-time style="width: 100%" allow-clear />
</a-form-item>
</a-col>
<a-col :lg="5">
<a-form-item label="结束时间">
<a-date-picker placeholder="请选择结束时间" v-model:value="queryParam.EDate" :disabledDate="endDisabledDate"
<a-date-picker placeholder="请选择结束时间" v-model:value="queryParam.EDateStr" value-format="YYYY-MM-DD HH:mm:ss" :disabledDate="endDisabledDate"
@change="handleEndChange" show-time style="width: 100%" allow-clear />
</a-form-item>
</a-col>
@ -76,6 +76,7 @@ import {
heatsourcestationlist,
jxpage
} from './HeatanalysisHistory.api';
import dayjs from 'dayjs';
const queryParam = ref<any>({});
const toggleSearchStatus = ref<boolean>(false);
@ -91,6 +92,7 @@ const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
clickToRowSelect: false,
showActionColumn: false,
showIndexColumn: false,
immediate: false,
tableSetting: {
//
redo: false,
@ -135,23 +137,26 @@ function searchQuery() {
/**
* 重置
*/
function searchReset() {
async function searchReset() {
queryParam.value = {};
selectedRowKeys.value = [];
getHeatsource();
getHeatsourcestation();
await getHeatsource();
await getHeatsourcestation();
let list = thermalcompany.value;
queryParam.value.view001 = list[0].id;
queryParam.value.SDateStr = dayjs().format('YYYY-MM-DD HH:mm:ss');
//
reload();
}
const thermalcompany = ref();
async function getThermalcompany() {
thermalcompany.value = await companylist();
thermalcompany.value = await companylist({regionType: '乡镇'});
}
const heatsource = ref();
async function getHeatsource() {
heatsource.value = await heatsourcelist();
heatsource.value = await heatsourcelist({regionType: '乡镇'});
}
const heatsourcestation = ref();
@ -174,57 +179,59 @@ function handleChange3(record) {
//
function startDisabledDate(current) {
//
if (!queryParam.value.EDate) return false;
return !current.isSame(queryParam.value.EDate, 'month') ||
current.isAfter(queryParam.value.EDate, 'day');
if (!queryParam.value.EDateStr) return false;
return !current.isSame(queryParam.value.EDateStr, 'month') ||
current.isAfter(queryParam.value.EDateStr, 'day');
}
//
function endDisabledDate(current) {
//
if (!queryParam.value.SDate) return true;
return !current.isSame(queryParam.value.SDate, 'month') ||
current.isBefore(queryParam.value.SDate, 'day');
if (!queryParam.value.SDateStr) return true;
return !current.isSame(queryParam.value.SDateStr, 'month') ||
current.isBefore(queryParam.value.SDateStr, 'day');
}
//
function handleStartChange(momentObj) {
if (momentObj && queryParam.value.EDate &&
!momentObj.isSame(queryParam.value.EDate, 'month')) {
queryParam.value.EDate = null;
if (momentObj && queryParam.value.EDateStr &&
!momentObj.isSame(queryParam.value.EDateStr, 'month')) {
queryParam.value.EDateStr = null;
}
}
//
function handleEndChange(momentObj) {
if (momentObj && queryParam.value.SDate &&
!momentObj.isSame(queryParam.value.SDate, 'month')) {
queryParam.value.SDate = null;
if (momentObj && queryParam.value.SDateStr &&
!momentObj.isSame(queryParam.value.SDateStr, 'month')) {
queryParam.value.SDateStr = null;
}
}
onMounted(() => {
getThermalcompany();
getHeatsource();
getHeatsourcestation();
onMounted(async() => {
await getThermalcompany();
await getHeatsource();
await getHeatsourcestation();
let list = thermalcompany.value;
queryParam.value.view001 = list[0].id;
queryParam.value.SDateStr = dayjs().format('YYYY-MM-DD HH:mm:ss');
watch(
() => queryParam.value.SDate,
() => queryParam.value.SDateStr,
async (newVal) => {
if (newVal && queryParam.value.EDate &&
(!newVal.isSame(queryParam.value.EDate, 'month') || newVal > queryParam.value.EDate)) {
queryParam.value.EDate = null;
if (newVal && queryParam.value.EDateStr &&
(!newVal.isSame(queryParam.value.EDateStr, 'month') || newVal > queryParam.value.EDateStr)) {
queryParam.value.EDateStr = null;
}
},
{ deep: true, immediate: true }
);
//
watch(
() => queryParam.value.EDate,
() => queryParam.value.EDateStr,
async (newVal) => {
if (newVal && queryParam.value.SDate &&
(!newVal.isSame(queryParam.value.SDate, 'month') || newVal < queryParam.value.SDate)) {
queryParam.value.SDate = null;
if (newVal && queryParam.value.SDateStr &&
(!newVal.isSame(queryParam.value.SDateStr, 'month') || newVal < queryParam.value.SDateStr)) {
queryParam.value.SDateStr = null;
}
},
{ deep: true, immediate: true }

View File

@ -9,8 +9,13 @@ enum Api {
companylist = '/heating/thermalcompany/list',
heatsourcelist = '/heating/heatsource/list',
heatsourcestationlist = '/heating/heatsourcestation/list',
exportXls = '/heating/heatanalysis/exportYunweiXls',
}
/**
* api
* @param params
*/
export const getExportUrl = Api.exportXls;
/**
*
* @param params

View File

@ -122,13 +122,13 @@ export const columns: BasicColumn[] = [
title: '热量',
align:"center",
width:120,
dataIndex: 'view041',
dataIndex: 'view044',
},
{
title: '水流量',
align:"center",
width:120,
dataIndex: 'view037'
dataIndex: 'view040'
},
];

View File

@ -58,6 +58,7 @@
<a-col :lg="6">
<a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
<a-button preIcon="ant-design:sync-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
<a-button danger preIcon="ant-design:export-outlined" @click="onExportXls" style="margin-left: 8px">导出</a-button>
</a-col>
</span>
</a-col>
@ -102,7 +103,7 @@ import { ref, reactive, onMounted } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { columns } from './Heatanalysis.data';
import { list, companylist, heatsourcelist, heatsourcestationlist } from './Heatanalysis.api';
import { list, companylist, heatsourcelist, heatsourcestationlist, getExportUrl } from './Heatanalysis.api';
import HeatanalysisReamrksListModal from './components/HeatanalysisReamrksListModal.vue'
import ChangeLevelModal from './components/ChangeLevelModal.vue'
@ -139,6 +140,10 @@ const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
return Object.assign(params, queryParam.value);
},
},
exportConfig: {
name: '运维数据列表',
url: getExportUrl,
},
});
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
const labelCol = reactive({
@ -244,7 +249,6 @@ onMounted(() => {
getHeatsourcestation();
});
</script>
<style lang="less" scoped>

View File

@ -1102,7 +1102,7 @@ function updateChartArea82() {
},
yAxis: {
type: 'value',
name: '焦耳',
name: 'GJ',
nameLocation: 'end',
nameTextStyle: {
color: '#ffffff',
@ -1386,8 +1386,10 @@ async function loadData() {
});
cityList.value = cities;
countyList.value = filterSongshanData(countys);
countyAddList.value = sumSongshanData(countys);
// countyList.value = filterSongshanData(countys);
countyList.value = countys;
// countyAddList.value = sumSongshanData(countys);
countyAddList.value = countys;
//
const arr2 = (z_ && z_.data) ? z_.data : [];
const cities2: { name: string; value: number; raw: any }[] = [];

View File

@ -70,10 +70,9 @@ function buildXAxis(records: any[], key = 'view028') {
/* ---- build options折线改为直线 smooth: false ---- */
function prepareOptions(records: any[]) {
const { city } = splitByRegion(records);
const cityX = buildXAxis(city, 'datatime');
const citySW = city.map((r: any) => safeNum(r.view005));
const cityHW = city.map((r: any) => safeNum(r.view006));
const citySW = city.map((r: any) => safeNum(r.view035));
const cityHW = city.map((r: any) => safeNum(r.view036));
cityOption = {
title: { text: '乡镇锅炉房历史供/回水温度', left: 'center', top: 10 },
tooltip: { trigger: 'axis' },

View File

@ -72,16 +72,16 @@ function prepareOptions(records: any[]) {
const { city } = splitByRegion(records);
const cityX = buildXAxis(city, 'datatime');
const citySW = city.map((r: any) => safeNum(r.view037));
const citySW = city.map((r: any) => safeNum(r.view041));
cityOption = {
title: { text: '乡镇锅炉房历史热量', left: 'center', top: 10 },
title: { text: '乡镇锅炉房历史热量', left: 'center', top: 10 },
tooltip: { trigger: 'axis' },
legend: { top: 36, left: 'center' },
grid: { left: '6%', right: '4%', bottom: 70, top: 70, containLabel: true },
xAxis: { type: 'category', data: cityX, axisLabel: { rotate: 0,formatter: (val: string) => val.replace(' ', '\n') } },
yAxis: { type: 'value', name: 'kw' },
series: [
{ name: '热量', type: 'line', data: citySW, smooth: false, showSymbol: false, lineStyle: { type: 'solid' } },
{ name: '热量', type: 'line', data: citySW, smooth: false, showSymbol: false, lineStyle: { type: 'solid' } },
],
color: ['#176AB3', '#2F9E8A'] // 线
};