| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- import dayjs from 'dayjs';
- import { FormSchema } from '/@/components/Table';
- import { getAutoScrollContainer } from '/@/utils/common/compUtils';
- import { get } from 'lodash-es';
- /**
- * 默认的查询表单项props
- *
- * @param dictOptions 用于初始化子设备下拉框
- * @param deviceOptions 用于初始化设备下拉框
- * @param onDeviceChange 设备下拉框选择内容后的回调函数
- * @returns
- */
- export const getDefaultSchemas: (dictOptions: any[], deviceOptions: any[], onDeviceChange?: Function) => FormSchema[] = (
- dictOptions: any[],
- deviceOptions: any[],
- onDeviceChange?: Function
- ) => {
- const device = get(deviceOptions, '[0].value', '');
- const isRedis = get(deviceOptions, '[0].stationtype', 'redis') === 'redis';
- const dictcode = get(dictOptions, '[0].value', '');
- return [
- {
- 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: 5,
- },
- },
- {
- field: 'ttime_end',
- label: '结束时间',
- component: 'DatePicker',
- defaultValue: dayjs(),
- required: true,
- componentProps: {
- showTime: true,
- valueFormat: 'YYYY-MM-DD HH:mm:ss',
- getPopupContainer: getAutoScrollContainer,
- },
- colProps: {
- span: 5,
- },
- },
- {
- label: '查询设备',
- field: 'deviceId',
- component: 'Select',
- required: true,
- defaultValue: VENT_PARAM.historyIsMultiple ? [device] : device,
- componentProps: {
- options: deviceOptions,
- mode: VENT_PARAM.historyIsMultiple ? 'multiple' : undefined,
- maxTagCount: 'responsive',
- onChange: onDeviceChange,
- },
- colProps: {
- span: 5,
- },
- },
- {
- label: '子设备',
- field: 'deviceNum',
- component: 'Select',
- required: isRedis ? false : Boolean(dictOptions.length),
- show: isRedis ? false : Boolean(dictOptions.length),
- defaultValue: isRedis ? '' : dictcode,
- componentProps: {
- options: dictOptions,
- // onChange: (e, option) => {
- // },
- },
- colProps: {
- span: 4,
- },
- },
- ];
- };
|