123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- <template>
- <div class="history-table">
- <BasicTable v-if="globalConfig.History_Type == 'vent'" ref="historyTable" @register="registerTable" >
- <template #bodyCell="{ column, record }">
- <slot name="filterCell" v-bind="{ column, record }"></slot>
- </template>
- </BasicTable>
- <BasicTable v-else ref="historyTable" @register="registerTable" >
- <template #bodyCell="{ column, record }">
- <slot name="filterCell" v-bind="{ column, record }"></slot>
- </template>
- </BasicTable>
- </div>
- </template>
- <script lang="ts" name="system-user" setup>
- //ts语法
- import { watchEffect, ref, watch, defineExpose, inject } from 'vue';
- import { FormSchema } from '/@/components/Form/index';
- import { BasicTable } from '/@/components/Table';
- import { useListPage } from '/@/hooks/system/useListPage';
- import { getTableHeaderColumns } from '/@/hooks/web/useWebColumns';
- import { defHttp } from '/@/utils/http/axios';
- import dayjs from 'dayjs';
- const globalConfig = inject('globalConfig');
- const historyTable = ref();
- const dataSource = ref([])
- const list = (params) => {
- if(globalConfig.History_Type == 'vent') {
- return defHttp.get({ url: '/safety/ventanalyMonitorData/list', params })
- } else {
- return defHttp.post({ url: '/ventanaly-device/history/getHistoryData', params })
- }
- };
- const emit = defineEmits(['change']);
- const props = defineProps({
- columnsType: {
- type: String,
- },
- columns: {
- type: Array,
- // required: true,
- default: () => [],
- },
- deviceType: {
- type: String,
- required: true,
- },
- deviceListApi: {
- type: Function,
- required: true,
- },
- designScope: {
- type: String,
- },
- sysId: {
- type: String,
- },
- scroll: {
- type: Object,
- default: { y: 0 }
- },
- formSchemas: {
- type: Array<FormSchema>,
- default: () => []
- }
- });
- const columns = ref([])
- const tableScroll = props.scroll.y ? ref({ y: props.scroll.y - 100 }) : ref({})
- watch(
- () => {
- return props.columnsType;
- },
- (newVal) => {
- if (!newVal) return
- if(historyTable.value) getForm().resetFields()
- const column = getTableHeaderColumns(newVal + '_history')
- if (column && column.length < 1) {
- const arr = newVal.split('_')
- const columnKey = arr.reduce((prev, cur, index) => {
- if (index !== arr.length - 2) {
- return prev + '_' + cur
- } else {
- return prev
- }
- })
- columns.value = getTableHeaderColumns(arr[0] + '_history');
- } else {
- columns.value = column
- }
- if(historyTable.value) reload()
- },
- {
- immediate: true
- }
- );
- watch(() => props.scroll.y, (newVal) => {
- if(newVal){
- tableScroll.value = {y: newVal - 100 }
- }else{
- tableScroll.value = {}
- }
- })
- // 列表页面公共参数、方法
- const { tableContext } = useListPage(
- globalConfig.History_Type == 'vent' ? {
- tableProps: {
- api: list,
- columns: props.columnsType ? columns : (props.columns as any[]),
- canResize: true,
- showTableSetting: false,
- showActionColumn: false,
- bordered: false,
- size: 'small',
- scroll: tableScroll,
- 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 : [
- {
- label: '查询日期',
- field: 'tData',
- component: 'DatePicker',
- defaultValue: dayjs(),
- componentProps: {
- valueFormat: 'YYYY-MM-DD',
- },
- },
- {
- label: '时间区间',
- field: 'tickectDate',
- component: 'TimeRangePicker',
- componentProps: {
- placeholder: ['开始时间', '结束时间'],
- valueFormat: 'HH:mm:ss',
- },
- },
- {
- label: '查询设备',
- field: 'gdeviceid',
- component: 'ApiSelect',
- required: true,
- componentProps: {
- api: () => defHttp.get({ url: '/safety/ventanalyManageSystem/linkdevicelist', params: { sysId: props.sysId, deviceType: props.deviceType } }),
- // resultField: 'result',
- labelField: 'strinstallpos',
- valueField: 'id',
- // numberToString: true,
- },
- },
- {
- label: '间隔时间',
- field: 'skip',
- component: 'Select',
- componentProps: {
- options: [
- {
- label: '5秒',
- value: '1',
- },
- {
- label: '10秒',
- value: '2',
- },
- {
- label: '1分钟',
- value: '3',
- },
- {
- label: '5分钟',
- value: '4',
- },
- {
- label: '10分钟',
- value: '5',
- },
- ],
- },
- },
- ],
- fieldMapToTime: [['tickectDate', ['ttime_begin', 'ttime_end'], '']],
- },
- fetchSetting: {
- listField: globalConfig.History_Type == 'iot'? 'records': globalConfig.History_Type == 'records'? '': 'datalist.records',
- totalField: globalConfig.History_Type == 'iot' ? 'total' : globalConfig.History_Type == 'total' ? 'total' : 'datalist.total',
- },
- beforeFetch(params) {
- params.strtype = props.deviceType + '*';
- if(props.sysId){
- params.sysId = props.sysId;
- }
- },
- afterFetch(resultItems) {
- resultItems.map((item) => {
- Object.assign(item, item['readData']);
- });
- return resultItems;
- },
- },
- }: {
- tableProps: {
- api: list,
- columns: props.columnsType ? columns : (props.columns as any[]),
- canResize: true,
- showTableSetting: false,
- showActionColumn: false,
- bordered: false,
- size: 'small',
- scroll: tableScroll,
- 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 : [
- {
- label: '查询日期',
- field: 'tData',
- component: 'DatePicker',
- defaultValue: dayjs(),
- componentProps: {
- valueFormat: 'YYYY-MM-DD hh:mm:ss',
- },
- },
- {
- label: '查询设备',
- field: 'deviceId',
- component: 'ApiSelect',
- required: true,
- componentProps: {
- api: () => defHttp.get({ url: '/safety/ventanalyManageSystem/linkdevicelist', params: { sysId: props.sysId, deviceType: props.deviceType } }),
- // resultField: 'result',
- labelField: 'strinstallpos',
- valueField: 'id',
- // numberToString: true,
- },
- },
- {
- label: '间隔时间',
- field: 'interval',
- component: 'Select',
- defaultValue: 1,
- componentProps: {
- options: [
- {
- label: '5秒',
- value: '1',
- },
- {
- label: '10秒',
- value: '2',
- },
- {
- label: '1分钟',
- value: '3',
- },
- {
- label: '10分钟',
- value: '4',
- },
- {
- label: '20分钟',
- value: '5',
- },
- ],
- },
- },
- ],
- fieldMapToTime: [['tData', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']],
- },
- beforeFetch(params) {
- params.strtype = props.deviceType + '*';
- if (props.sysId) {
- params.sysId = props.sysId;
- }
- if(params.interval){
- params.interval = params.interval+'m'
- }else{
- params.interval = '1m'
- }
- },
- afterFetch(result) {
- let dataSource = []
- if(result['records'] && result['records'].length >0){
- dataSource = result['records'].map((item) => {
- Object.assign(item, result['deviceId'], result['deviceName'], result['devicePos'] );
- })
- }
- return dataSource;
- },
- },
- }
- );
- //注册table数据
- const [registerTable, { getDataSource, reload, setLoading, getForm }] = tableContext;
- watchEffect(() => {
- if (historyTable.value && getDataSource) {
- const data = getDataSource() || [];
- emit('change', data);
- console.log('[ data ] >', data);
- }
- });
-
- defineExpose({ setLoading })
- </script>
- <style scoped lang="less">
- @import '/@/design/vent/color.less';
-
- :deep(.@{ventSpace}-table-body) {
- height: auto !important;
- }
- :deep(.zxm-picker){
- height: 30px !important;
- }
- .history-table {
- width: 100%;
- :deep(.jeecg-basic-table-form-container) {
- .@{ventSpace}-form {
- padding: 0 !important;
- border: none !important;
- margin-bottom: 0 !important;
- .@{ventSpace}-picker,
- .@{ventSpace}-select-selector {
- width: 100% !important;
- height: 100%;
- background: #00000017;
- border: 1px solid #b7b7b7;
- input,
- .@{ventSpace}-select-selection-item,
- .@{ventSpace}-picker-suffix {
- color: #fff;
- }
- .@{ventSpace}-select-selection-placeholder {
- color: #ffffffaa;
- }
- }
- }
- .@{ventSpace}-table-title {
- min-height: 0 !important;
- }
- }
- }
- </style>
|