|
@@ -14,7 +14,7 @@
|
|
|
|
|
|
<script lang="ts" name="system-user" setup>
|
|
|
//ts语法
|
|
|
- import { watchEffect, ref, watch, defineExpose, inject } from 'vue';
|
|
|
+ import { watchEffect, ref, watch, defineExpose, inject, nextTick } from 'vue';
|
|
|
import { FormSchema } from '/@/components/Form/index';
|
|
|
import { BasicTable } from '/@/components/Table';
|
|
|
import { useListPage } from '/@/hooks/system/useListPage';
|
|
@@ -66,6 +66,16 @@
|
|
|
const loading = ref(false);
|
|
|
const stationType = ref('plc');
|
|
|
const dataSource = ref([]);
|
|
|
+ const intervalMap = new Map([
|
|
|
+ ['1', '1s'],
|
|
|
+ ['2', '5s'],
|
|
|
+ ['3', '10s'],
|
|
|
+ ['4', '30s'],
|
|
|
+ ['5', '1m'],
|
|
|
+ ['6', '10m'],
|
|
|
+ ['7', '30m'],
|
|
|
+ ['8', '1h'],
|
|
|
+ ]);
|
|
|
|
|
|
const getExportXlsUrl = () => {
|
|
|
if (stationType.value !== 'redis') {
|
|
@@ -132,319 +142,11 @@
|
|
|
|
|
|
watch(stationType, (type) => {
|
|
|
if (type) {
|
|
|
- getDataSource();
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- function getTableProps(stationTypeStr) {
|
|
|
- if (stationTypeStr !== 'redis') {
|
|
|
- debugger;
|
|
|
- setProps({
|
|
|
- api: (params) => defHttp.get({ url: '/safety/ventanalyMonitorData/listdays', params }),
|
|
|
- formConfig: {
|
|
|
- labelAlign: 'left',
|
|
|
- showAdvancedButton: false,
|
|
|
- baseColProps: {
|
|
|
- xs: 24,
|
|
|
- sm: 24,
|
|
|
- md: 24,
|
|
|
- lg: 9,
|
|
|
- xl: 7,
|
|
|
- xxl: 4,
|
|
|
- },
|
|
|
- schemas:
|
|
|
- props.formSchemas.length > 0
|
|
|
- ? props.formSchemas
|
|
|
- : [
|
|
|
- {
|
|
|
- field: 'ttime_begin',
|
|
|
- label: '开始时间',
|
|
|
- component: 'DatePicker',
|
|
|
- defaultValue: dayjs().startOf('date'),
|
|
|
- required: true,
|
|
|
- componentProps: {
|
|
|
- showTime: true,
|
|
|
- valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
|
|
- getPopupContainer: getAutoScrollContainer,
|
|
|
- },
|
|
|
- colProps: {
|
|
|
- span: 4,
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- field: 'ttime_end',
|
|
|
- label: '结束时间',
|
|
|
- component: 'DatePicker',
|
|
|
- defaultValue: dayjs(),
|
|
|
- required: true,
|
|
|
- componentProps: {
|
|
|
- showTime: true,
|
|
|
- valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
|
|
- getPopupContainer: getAutoScrollContainer,
|
|
|
- },
|
|
|
- colProps: {
|
|
|
- span: 4,
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- label: '查询设备',
|
|
|
- field: 'gdeviceid',
|
|
|
- component: 'Select',
|
|
|
- defaultValue: deviceOptions.value[0] ? deviceOptions.value[0]['value'] : '',
|
|
|
- required: true,
|
|
|
- componentProps: {
|
|
|
- options: deviceOptions,
|
|
|
- onChange: (e, option) => {
|
|
|
- if (option && (option['strinstallpos'] || option['strtype'] || option['devicekind']))
|
|
|
- historyType.value = option['strtype'] || option['devicekind'];
|
|
|
- if (option['strtype']) deviceTypeStr.value = option['strtype'];
|
|
|
- stationType.value = option['stationtype'];
|
|
|
- },
|
|
|
- },
|
|
|
- colProps: {
|
|
|
- span: 4,
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- label: '间隔时间',
|
|
|
- field: 'skip',
|
|
|
- component: 'Select',
|
|
|
- defaultValue: 5,
|
|
|
- componentProps: {
|
|
|
- options: [
|
|
|
- {
|
|
|
- label: '5秒',
|
|
|
- value: '1',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '10秒',
|
|
|
- value: '2',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '30秒',
|
|
|
- value: '3',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '1分钟',
|
|
|
- value: '4',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '5分钟',
|
|
|
- value: '5',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '10分钟',
|
|
|
- value: '6',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '30分钟',
|
|
|
- value: '7',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '1小时',
|
|
|
- value: '8',
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- colProps: {
|
|
|
- span: 4,
|
|
|
- },
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- // fetchSetting: {
|
|
|
- // listField: 'datalist',
|
|
|
- // totalField: 'datalist.total',
|
|
|
- // },
|
|
|
- pagination: {
|
|
|
- current: 1,
|
|
|
- pageSize: 10,
|
|
|
- pageSizeOptions: ['10', '30', '50', '100'],
|
|
|
- showQuickJumper: false,
|
|
|
- },
|
|
|
- // beforeFetch(params) {
|
|
|
- // params.strtype = deviceTypeStr.value
|
|
|
- // ? deviceTypeStr.value
|
|
|
- // : deviceOptions.value[0]['strtype']
|
|
|
- // ? deviceOptions.value[0]['strtype']
|
|
|
- // : props.deviceType + '*';
|
|
|
- // if (props.sysId) {
|
|
|
- // params.sysId = props.sysId;
|
|
|
- // }
|
|
|
- // return params;
|
|
|
- // },
|
|
|
- // afterFetch(result) {
|
|
|
- // const resultItems = result['records'];
|
|
|
- // resultItems.map((item) => {
|
|
|
- // Object.assign(item, item['readData']);
|
|
|
- // });
|
|
|
- // console.log('result---------------->', result);
|
|
|
- // return resultItems;
|
|
|
- // },
|
|
|
- });
|
|
|
- } else {
|
|
|
- setProps({
|
|
|
- api: (params) => defHttp.post({ url: '/ventanaly-device/history/getHistoryData', params }),
|
|
|
- formConfig: {
|
|
|
- labelAlign: 'left',
|
|
|
- showAdvancedButton: false,
|
|
|
- // autoAdvancedCol: 2,
|
|
|
-
|
|
|
- baseColProps: {
|
|
|
- // offset: 0.5,
|
|
|
- xs: 24,
|
|
|
- sm: 24,
|
|
|
- md: 24,
|
|
|
- lg: 9,
|
|
|
- xl: 7,
|
|
|
- xxl: 4,
|
|
|
- },
|
|
|
- schemas:
|
|
|
- props.formSchemas.length > 0
|
|
|
- ? props.formSchemas
|
|
|
- : [
|
|
|
- {
|
|
|
- field: 'startTime',
|
|
|
- label: '开始时间',
|
|
|
- component: 'DatePicker',
|
|
|
- defaultValue: dayjs().startOf('date'),
|
|
|
- required: true,
|
|
|
- componentProps: {
|
|
|
- showTime: true,
|
|
|
- valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
|
|
- getPopupContainer: getAutoScrollContainer,
|
|
|
- },
|
|
|
- colProps: {
|
|
|
- span: 4,
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- field: 'endTime',
|
|
|
- label: '结束时间',
|
|
|
- component: 'DatePicker',
|
|
|
- defaultValue: dayjs(),
|
|
|
- required: true,
|
|
|
- componentProps: {
|
|
|
- showTime: true,
|
|
|
- valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
|
|
- getPopupContainer: getAutoScrollContainer,
|
|
|
- },
|
|
|
- colProps: {
|
|
|
- span: 4,
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- label: '查询设备',
|
|
|
- field: 'deviceId',
|
|
|
- component: 'Select',
|
|
|
- defaultValue: deviceOptions.value[0] ? deviceOptions.value[0]['value'] : '',
|
|
|
- required: true,
|
|
|
- componentProps: {
|
|
|
- options: deviceOptions,
|
|
|
- onChange: (e, option) => {
|
|
|
- if (option && (option['strinstallpos'] || option['strtype'] || option['devicekind']))
|
|
|
- historyType.value = option['strtype'] || option['devicekind'];
|
|
|
- stationType.value = option['stationtype'];
|
|
|
- },
|
|
|
- },
|
|
|
- colProps: {
|
|
|
- span: 4,
|
|
|
- },
|
|
|
- // componentProps: ({ formModel }) => {
|
|
|
- // return {
|
|
|
- // options: deviceOptions.value,
|
|
|
- // // api: () => defHttp.get({ url: '/safety/ventanalyManageSystem/linkdevicelist', params: { sysId: props.sysId, deviceType: props.deviceType.startsWith('vehicle') ? 'location_normal' : props.deviceType } }),
|
|
|
- // // resultField: 'result',
|
|
|
- // // labelField: 'strinstallpos',
|
|
|
- // // valueField: 'id',
|
|
|
- // // onChange: (e, option) => {
|
|
|
- // // if(option && (option['strtype'] || option['devicekind'])) historyType.value = option['strtype'] || option['devicekind']
|
|
|
- // // },
|
|
|
- // }
|
|
|
- // },
|
|
|
- },
|
|
|
- {
|
|
|
- label: '间隔时间',
|
|
|
- field: 'interval',
|
|
|
- component: 'Select',
|
|
|
- defaultValue: '30s',
|
|
|
- componentProps: {
|
|
|
- options: [
|
|
|
- {
|
|
|
- label: '1秒',
|
|
|
- value: '1s',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '5秒',
|
|
|
- value: '5s',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '10秒',
|
|
|
- value: '10s',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '30秒',
|
|
|
- value: '30s',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '1分钟',
|
|
|
- value: '1m',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '10分钟',
|
|
|
- value: '10m',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '30分钟',
|
|
|
- value: '30m',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '1小时',
|
|
|
- value: '1h',
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- colProps: {
|
|
|
- span: 4,
|
|
|
- },
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- pagination: {
|
|
|
- current: 1,
|
|
|
- pageSize: 10,
|
|
|
- pageSizeOptions: ['10', '30', '50', '100'],
|
|
|
- showQuickJumper: false,
|
|
|
- },
|
|
|
- fetchSetting: {
|
|
|
- totalField: 'total',
|
|
|
- // 每页显示多少条
|
|
|
- sizeField: 'pageSize',
|
|
|
- // 请求结果列表字段 支持 a.b.c
|
|
|
- pageField: 'pageNo',
|
|
|
- },
|
|
|
- beforeFetch(params) {
|
|
|
- params.strtype = props.deviceType + '*';
|
|
|
- if (props.sysId) {
|
|
|
- params.sysId = props.sysId;
|
|
|
- }
|
|
|
- if (params.interval) {
|
|
|
- params.interval = params.interval;
|
|
|
- } else {
|
|
|
- params.interval = '1m';
|
|
|
- }
|
|
|
- if (props.deviceType.startsWith('vehicle')) {
|
|
|
- params['isEmployee'] = false;
|
|
|
- } else if (props.deviceType.startsWith('location')) {
|
|
|
- params['isEmployee'] = true;
|
|
|
- }
|
|
|
- },
|
|
|
- afterFetch(result) {
|
|
|
- return result;
|
|
|
- },
|
|
|
+ nextTick(() => {
|
|
|
+ getDataSource();
|
|
|
});
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
|
|
|
async function getDeviceList() {
|
|
|
if (props.deviceType.split('_')[1] && props.deviceType.split('_')[1] === 'history') return;
|
|
@@ -474,15 +176,11 @@
|
|
|
strtype: item['strtype'],
|
|
|
strinstallpos: item['strinstallpos'],
|
|
|
devicekind: item['devicekind'],
|
|
|
- stationtype: index > 2 ? 'redis' : 'plc',
|
|
|
+ stationtype: item['stationtype'],
|
|
|
};
|
|
|
- // return { label: item['strname'], value: item['id']}
|
|
|
});
|
|
|
}
|
|
|
- console.log('deviceOptions---------------->', deviceOptions.value);
|
|
|
- globalConfig.History_Type == 'vent' && deviceOptions.value[0]
|
|
|
- ? getForm().setFieldsValue({ gdeviceid: deviceOptions.value[0] ? deviceOptions.value[0]['value'] : '' })
|
|
|
- : getForm().setFieldsValue({ deviceId: deviceOptions.value[0] ? deviceOptions.value[0]['value'] : '' });
|
|
|
+ getForm().setFieldsValue({ gdeviceid: deviceOptions.value[0] ? deviceOptions.value[0]['value'] : '' });
|
|
|
}
|
|
|
|
|
|
async function getDataSource() {
|
|
@@ -503,6 +201,7 @@
|
|
|
formData['sysId'] = props.sysId;
|
|
|
}
|
|
|
const result = await defHttp.get({ url: '/safety/ventanalyMonitorData/listdays', params: formData });
|
|
|
+ setPagination({ total: Math.abs(result['datalist']['total']) || 0 });
|
|
|
if (result['datalist']['records'].length > 0) {
|
|
|
dataSource.value = result['datalist']['records'].map((item: any) => {
|
|
|
return Object.assign(item, item['readData']);
|
|
@@ -517,10 +216,11 @@
|
|
|
deviceId: formData['gdeviceid'],
|
|
|
strtype: props.deviceType + '*',
|
|
|
sysId: props.sysId,
|
|
|
- interval: formData['skip'] ? formData['skip'] : '1m',
|
|
|
+ interval: intervalMap.get(formData['skip']) ? intervalMap.get(formData['skip']) : '1h',
|
|
|
isEmployee: props.deviceType.startsWith('vehicle') ? false : true,
|
|
|
};
|
|
|
const result = await defHttp.post({ url: '/ventanaly-device/history/getHistoryData', params: params });
|
|
|
+ setPagination({ total: Math.abs(result['total']) || 0 });
|
|
|
dataSource.value = result['records'] || [];
|
|
|
}
|
|
|
setLoading(false);
|
|
@@ -608,7 +308,7 @@
|
|
|
label: '间隔时间',
|
|
|
field: 'skip',
|
|
|
component: 'Select',
|
|
|
- defaultValue: 5,
|
|
|
+ defaultValue: '8',
|
|
|
componentProps: {
|
|
|
options: [
|
|
|
{
|
|
@@ -689,13 +389,12 @@
|
|
|
});
|
|
|
|
|
|
//注册table数据
|
|
|
- const [registerTable, { reload, setLoading, getForm, setColumns, getPaginationRef }] = tableContext;
|
|
|
+ const [registerTable, { reload, setLoading, getForm, setColumns, getPaginationRef, setPagination }] = tableContext;
|
|
|
|
|
|
watchEffect(() => {
|
|
|
if (historyTable.value && dataSource) {
|
|
|
const data = dataSource.value || [];
|
|
|
emit('change', data);
|
|
|
- console.log('[ data ] >', data);
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -704,7 +403,9 @@
|
|
|
if (deviceOptions.value[0]) {
|
|
|
stationType.value = deviceOptions.value[0]['stationtype'];
|
|
|
historyType.value = deviceOptions.value[0]['strtype'] || deviceOptions.value[0]['devicekind'];
|
|
|
- getDataSource();
|
|
|
+ nextTick(() => {
|
|
|
+ getDataSource();
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
defineExpose({ setLoading });
|