|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div class="history-table">
|
|
|
+ <div class="history-table" v-if="loading">
|
|
|
<BasicTable ref="historyTable" @register="registerTable" >
|
|
|
<template #bodyCell="{ column, record }">
|
|
|
<slot name="filterCell" v-bind="{ column, record }"></slot>
|
|
@@ -18,12 +18,13 @@
|
|
|
import { defHttp } from '/@/utils/http/axios';
|
|
|
import dayjs from 'dayjs';
|
|
|
import { getAutoScrollContainer } from '/@/utils/common/compUtils';
|
|
|
+import { onMounted } from 'vue';
|
|
|
|
|
|
const globalConfig = inject('globalConfig');
|
|
|
|
|
|
const historyTable = ref();
|
|
|
const dataSource = ref([])
|
|
|
-
|
|
|
+ const loading = ref(false)
|
|
|
const list = (params) => {
|
|
|
if(globalConfig.History_Type == 'vent') {
|
|
|
return defHttp.get({ url: '/safety/ventanalyMonitorData/list', params })
|
|
@@ -63,8 +64,11 @@
|
|
|
default: () => []
|
|
|
}
|
|
|
});
|
|
|
+ const historyType = ref('')
|
|
|
const columns = ref([])
|
|
|
const tableScroll = props.scroll.y ? ref({ y: props.scroll.y - 100 }) : ref({})
|
|
|
+ let deviceOptions = <any[]>[]
|
|
|
+ let deviceList = <any[]>[]
|
|
|
|
|
|
watch(
|
|
|
() => {
|
|
@@ -88,6 +92,20 @@
|
|
|
}
|
|
|
);
|
|
|
|
|
|
+ watch(historyType, (type) => {
|
|
|
+ debugger
|
|
|
+ if (!type) return
|
|
|
+ // if (historyTable.value) getForm().resetFields()
|
|
|
+ const column = getTableHeaderColumns(type.includes('_history') ? type : type + '_history')
|
|
|
+ if (column && column.length < 1) {
|
|
|
+ const arr = type.split('_')
|
|
|
+ columns.value = getTableHeaderColumns(arr[0] + '_history');
|
|
|
+ } else {
|
|
|
+ columns.value = column
|
|
|
+ }
|
|
|
+ setColumns(columns.value)
|
|
|
+ })
|
|
|
+
|
|
|
watch(() => props.scroll.y, (newVal) => {
|
|
|
if(newVal){
|
|
|
tableScroll.value = {y: newVal - 100 }
|
|
@@ -96,7 +114,25 @@
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-
|
|
|
+ async function getDeviceList() {
|
|
|
+ let result;
|
|
|
+ if(globalConfig.History_Type == 'vent'){
|
|
|
+ result = await defHttp.get({ url: '/safety/ventanalyManageSystem/linkdevicelist', params: { sysId: props.sysId, deviceType: props.deviceType } })
|
|
|
+ }else {
|
|
|
+ result = await defHttp.get({ url: '/safety/ventanalyManageSystem/linkdevicelist', params: { sysId: props.sysId, deviceType: props.deviceType.startsWith('vehicle') ? 'location_normal' : props.deviceType } })
|
|
|
+ }
|
|
|
+ if(result){
|
|
|
+ deviceOptions = []
|
|
|
+ deviceOptions = result.map((item) => {
|
|
|
+ return {label: item['strname'], value: item['id'], strtype: item['strtype'], devicekind: item['devicekind'] }
|
|
|
+ // return { label: item['strname'], value: item['id']}
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ await getDeviceList()
|
|
|
+ loading.value = true
|
|
|
// 列表页面公共参数、方法
|
|
|
const { tableContext } = useListPage(
|
|
|
globalConfig.History_Type == 'vent' ? {
|
|
@@ -150,14 +186,31 @@
|
|
|
{
|
|
|
label: '查询设备',
|
|
|
field: 'gdeviceid',
|
|
|
- component: 'ApiSelect',
|
|
|
+ component: 'Select',
|
|
|
+ defaultValue: deviceOptions[0] ? deviceOptions[0]['value'] : '',
|
|
|
required: true,
|
|
|
+ // componentProps: ({ formModel }) => {
|
|
|
+ // return {
|
|
|
+ // options: deviceOptions.value,
|
|
|
+ // // api: () => defHttp.get({ url: '/safety/ventanalyManageSystem/linkdevicelist', params: { sysId: props.sysId, deviceType: props.deviceType } }),
|
|
|
+ // // resultField: 'result',
|
|
|
+ // // labelField: 'strinstallpos',
|
|
|
+ // // valueField: 'id',
|
|
|
+ // // onChange: (e, option) => {
|
|
|
+ // // if (option && (option['strtype'] || option['devicekind'])) historyType.value = option['strtype'] || option['devicekind']
|
|
|
+ // // },
|
|
|
+ // }
|
|
|
+ // },
|
|
|
componentProps: {
|
|
|
- api: () => defHttp.get({ url: '/safety/ventanalyManageSystem/linkdevicelist', params: { sysId: props.sysId, deviceType: props.deviceType } }),
|
|
|
- // resultField: 'result',
|
|
|
- labelField: 'strinstallpos',
|
|
|
- valueField: 'id',
|
|
|
- // numberToString: true,
|
|
|
+ options: deviceOptions,
|
|
|
+ // api: () => defHttp.get({ url: '/safety/ventanalyManageSystem/linkdevicelist', params: { sysId: props.sysId, deviceType: props.deviceType } }),
|
|
|
+ // // resultField: 'result',
|
|
|
+ // labelField: 'strinstallpos',
|
|
|
+ // valueField: 'id',
|
|
|
+ onChange: (e, option) => {
|
|
|
+ debugger
|
|
|
+ if (option && (option['strtype'] || option['devicekind'])) historyType.value = option['strtype'] || option['devicekind']
|
|
|
+ },
|
|
|
},
|
|
|
colProps: {
|
|
|
span: 4,
|
|
@@ -274,15 +327,32 @@
|
|
|
{
|
|
|
label: '查询设备',
|
|
|
field: 'deviceId',
|
|
|
- component: 'ApiSelect',
|
|
|
+ component: 'Select',
|
|
|
+ defaultValue: deviceOptions[0] ? deviceOptions[0]['value'] : '',
|
|
|
required: true,
|
|
|
componentProps: {
|
|
|
- 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',
|
|
|
+ options: deviceOptions,
|
|
|
+ // 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',
|
|
|
// numberToString: true,
|
|
|
+ onChange: (e, option) => {
|
|
|
+ if(option && (option['strtype'] || option['devicekind'])) historyType.value = option['strtype'] || option['devicekind']
|
|
|
+ },
|
|
|
},
|
|
|
+ // 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: '间隔时间',
|
|
@@ -366,7 +436,7 @@
|
|
|
);
|
|
|
|
|
|
//注册table数据
|
|
|
- const [registerTable, { getDataSource, reload, setLoading, getForm }] = tableContext;
|
|
|
+ const [registerTable, { getDataSource, reload, setLoading, getForm, setColumns }] = tableContext;
|
|
|
|
|
|
watchEffect(() => {
|
|
|
if (historyTable.value && getDataSource) {
|
|
@@ -375,6 +445,11 @@
|
|
|
console.log('[ data ] >', data);
|
|
|
}
|
|
|
});
|
|
|
+ onMounted(() => {
|
|
|
+ if (!props.columnsType) {
|
|
|
+ historyType.value = deviceOptions[0]['strtype'] || deviceOptions[0]['devicekind']
|
|
|
+ }
|
|
|
+ })
|
|
|
defineExpose({ setLoading })
|
|
|
</script>
|
|
|
|