|
@@ -1,6 +1,6 @@
|
|
<template>
|
|
<template>
|
|
<div class="history-table" v-if="loading">
|
|
<div class="history-table" v-if="loading">
|
|
- <BasicTable ref="historyTable" @register="registerTable" :data-source="dataSource">
|
|
|
|
|
|
+ <BasicTable ref="historyTable" @register="registerTable" :data-source="dataSource" :scroll="tableScroll">
|
|
<template #bodyCell="{ column, record }">
|
|
<template #bodyCell="{ column, record }">
|
|
<a-tag v-if="column.dataIndex === 'warnFlag'" :color="record.warnFlag == '0' ? 'green' : 'red'">{{
|
|
<a-tag v-if="column.dataIndex === 'warnFlag'" :color="record.warnFlag == '0' ? 'green' : 'red'">{{
|
|
record.warnFlag == '0' ? '正常' : '报警'
|
|
record.warnFlag == '0' ? '正常' : '报警'
|
|
@@ -23,15 +23,21 @@
|
|
</template>
|
|
</template>
|
|
</BasicTable>
|
|
</BasicTable>
|
|
<BarAndLine
|
|
<BarAndLine
|
|
- v-if="showHistoryCurve"
|
|
|
|
|
|
+ v-if="showCurve"
|
|
:charts-columns="chartsColumns"
|
|
:charts-columns="chartsColumns"
|
|
:option="{
|
|
:option="{
|
|
legend: {
|
|
legend: {
|
|
top: '5',
|
|
top: '5',
|
|
},
|
|
},
|
|
|
|
+ grid: {
|
|
|
|
+ top: 50,
|
|
|
|
+ left: 200,
|
|
|
|
+ right: 200,
|
|
|
|
+ bottom: 50,
|
|
|
|
+ },
|
|
}"
|
|
}"
|
|
:data-source="dataSource"
|
|
:data-source="dataSource"
|
|
- height="250px"
|
|
|
|
|
|
+ height="300px"
|
|
x-axis-prop-type="ttime"
|
|
x-axis-prop-type="ttime"
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
@@ -50,6 +56,8 @@
|
|
import { render } from '/@/utils/common/renderUtils';
|
|
import { render } from '/@/utils/common/renderUtils';
|
|
import { useMethods } from '/@/hooks/system/useMethods';
|
|
import { useMethods } from '/@/hooks/system/useMethods';
|
|
import BarAndLine from '/@/components/chart/BarAndLine.vue';
|
|
import BarAndLine from '/@/components/chart/BarAndLine.vue';
|
|
|
|
+ import { getDictItemsByCode } from '/@/utils/dict';
|
|
|
|
+ import { get } from 'lodash-es';
|
|
|
|
|
|
const globalConfig = inject('globalConfig');
|
|
const globalConfig = inject('globalConfig');
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
@@ -129,7 +137,6 @@
|
|
const historyType = ref('');
|
|
const historyType = ref('');
|
|
const deviceKide = ref('');
|
|
const deviceKide = ref('');
|
|
const columns = ref([]);
|
|
const columns = ref([]);
|
|
- const tableScroll = props.scroll.y ? ref({ y: props.scroll.y - 100 }) : ref({});
|
|
|
|
let deviceOptions = ref([]);
|
|
let deviceOptions = ref([]);
|
|
const deviceTypeStr = ref('');
|
|
const deviceTypeStr = ref('');
|
|
const deviceTypeName = ref('');
|
|
const deviceTypeName = ref('');
|
|
@@ -137,6 +144,17 @@
|
|
const chartsColumns = ref([]);
|
|
const chartsColumns = ref([]);
|
|
loading.value = true;
|
|
loading.value = true;
|
|
|
|
|
|
|
|
+ const selectedOption = computed<Record<string, any> | undefined>(() => {
|
|
|
|
+ let idval: string | undefined = getForm()?.getFieldsValue()?.gdeviceids;
|
|
|
|
+ if (VENT_PARAM.historyIsMultiple && idval) {
|
|
|
|
+ const arr = idval.split(',');
|
|
|
|
+ idval = arr[arr.length - 1];
|
|
|
|
+ }
|
|
|
|
+ return deviceOptions.value.find((e: any) => {
|
|
|
|
+ return e.value === idval;
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
watch(
|
|
watch(
|
|
() => {
|
|
() => {
|
|
return props.columnsType;
|
|
return props.columnsType;
|
|
@@ -188,21 +206,45 @@
|
|
}
|
|
}
|
|
if (props.showHistoryCurve) {
|
|
if (props.showHistoryCurve) {
|
|
const arr = type.split('_');
|
|
const arr = type.split('_');
|
|
- chartsColumns.value = getTableHeaderColumns(arr[0] + '_chart');
|
|
|
|
|
|
+ // 没错,又是安全监控。安全监控的单位无法一次定好,所以根据返回的数据协定单位
|
|
|
|
+ if (props.deviceType.startsWith('safetymonitor')) {
|
|
|
|
+ chartsColumns.value = getTableHeaderColumns(arr[0] + '_chart').map((e) => {
|
|
|
|
+ const unit = get(selectedOption.value, 'readData.unit', e.unit);
|
|
|
|
+ return {
|
|
|
|
+ ...e,
|
|
|
|
+ unit: unit,
|
|
|
|
+ seriesName: unit,
|
|
|
|
+ };
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ chartsColumns.value = getTableHeaderColumns(arr[0] + '_chart');
|
|
|
|
+ }
|
|
}
|
|
}
|
|
setColumns(columns.value);
|
|
setColumns(columns.value);
|
|
});
|
|
});
|
|
|
|
|
|
- watch(
|
|
|
|
- () => props.scroll.y,
|
|
|
|
- (newVal) => {
|
|
|
|
- if (newVal) {
|
|
|
|
- tableScroll.value = { y: newVal - 100 };
|
|
|
|
- } else {
|
|
|
|
- tableScroll.value = {};
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
|
|
+ // 是否显示历史曲线,在devices_shows_history_curve字典里可以配置哪些设备类型需要显示曲线
|
|
|
|
+ // 字典内的字段可以是前缀,例如fanlocal之于fanlocal_normal
|
|
|
|
+ // 安全监控设备需要更多的配置,除去配置safetymonitor,还需要配置哪些安全监控设备需要曲线
|
|
|
|
+ // 因此可以配置例如A1001的dataTypeName代码(可以查看真实数据参考)
|
|
|
|
+ const historyCurveDicts = getDictItemsByCode('devices_shows_history_curve');
|
|
|
|
+ const findDict = (str) => historyCurveDicts.some(({ value }) => str.startsWith(value));
|
|
|
|
+ const showCurve = computed(() => {
|
|
|
|
+ if (!props.showHistoryCurve) return false;
|
|
|
|
+ const dt = props.deviceType; // 依赖项
|
|
|
|
+
|
|
|
|
+ if (!findDict(dt)) return false;
|
|
|
|
+ if (!dt.startsWith('safetymonitor')) return true;
|
|
|
|
+
|
|
|
|
+ // 和字典的设备类型匹配后,如果是安全监控设备,需要额外的匹配安全监控类型
|
|
|
|
+ const dtns = get(selectedOption.value, 'readData.dataTypeName', ''); // 依赖项
|
|
|
|
+ return findDict(dtns);
|
|
|
|
+ });
|
|
|
|
+ const tableScroll = computed(() => {
|
|
|
|
+ if (props.scroll.y && showCurve.value) return { y: props.scroll.y - 450 };
|
|
|
|
+ if (props.scroll.y) return { y: props.scroll.y - 100 };
|
|
|
|
+ return {};
|
|
|
|
+ });
|
|
|
|
|
|
// watch(stationType, (type) => {
|
|
// watch(stationType, (type) => {
|
|
// if (type) {
|
|
// if (type) {
|
|
@@ -266,6 +308,7 @@
|
|
strinstallpos: item['strinstallpos'],
|
|
strinstallpos: item['strinstallpos'],
|
|
devicekind: item['devicekind'],
|
|
devicekind: item['devicekind'],
|
|
stationtype: item['stationtype'],
|
|
stationtype: item['stationtype'],
|
|
|
|
+ readData: item['readData'],
|
|
};
|
|
};
|
|
});
|
|
});
|
|
|
|
|
|
@@ -362,7 +405,6 @@
|
|
showActionColumn: false,
|
|
showActionColumn: false,
|
|
bordered: false,
|
|
bordered: false,
|
|
size: 'small',
|
|
size: 'small',
|
|
- scroll: tableScroll,
|
|
|
|
showIndexColumn: true,
|
|
showIndexColumn: true,
|
|
tableLayout: 'auto',
|
|
tableLayout: 'auto',
|
|
formConfig: {
|
|
formConfig: {
|
|
@@ -425,9 +467,12 @@
|
|
},
|
|
},
|
|
options: deviceOptions,
|
|
options: deviceOptions,
|
|
onChange: (e, option) => {
|
|
onChange: (e, option) => {
|
|
- if (option && (option['strinstallpos'] || option['strtype'] || option['devicekind']))
|
|
|
|
|
|
+ if (option && (option['strinstallpos'] || option['strtype'] || option['devicekind'])) {
|
|
historyType.value = option['strtype'] || option['devicekind'];
|
|
historyType.value = option['strtype'] || option['devicekind'];
|
|
- if (option['strtype']) deviceTypeStr.value = option['strtype'];
|
|
|
|
|
|
+ }
|
|
|
|
+ if (option['strtype']) {
|
|
|
|
+ deviceTypeStr.value = option['strtype'];
|
|
|
|
+ }
|
|
stationType.value = option['stationtype'];
|
|
stationType.value = option['stationtype'];
|
|
nextTick(async () => {
|
|
nextTick(async () => {
|
|
await getDataSource();
|
|
await getDataSource();
|