123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- import dayjs from 'dayjs';
- import { BasicTableProps, PaginationProps, FormProps, FormSchema } from '/@/components/Table';
- import { getAutoScrollContainer } from '/@/utils/common/compUtils';
- import { get } from 'lodash-es';
- /**
- * 默认的查询表单项props
- *
- * @param dictOptions 用于初始化子设备下拉框
- * @param deviceOptions 用于初始化设备下拉框
- * @returns
- */
- export const getDefaultSchemas: (dictOptions: any[], deviceOptions: any[]) => FormSchema[] = (dictOptions: any[], deviceOptions: any[]) => {
- const device = get(deviceOptions, '[0].value', '');
- const dictcode = get(dictOptions, '[0].value', '');
- const isRedis = get(deviceOptions, '[0].stationtype', 'redis') === 'redis';
- 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: 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: 'gdeviceids',
- component: 'Select',
- required: true,
- defaultValue: isRedis ? device : [device],
- componentProps: {
- options: deviceOptions,
- // onChange: (e, option) => {
- mode: isRedis ? undefined : 'multiple',
- maxTagCount: 'responsive',
- // nextTick(async () => {
- // await getDataSource();
- // });
- // },
- },
- colProps: {
- span: 4,
- },
- },
- {
- 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) => {
- // nextTick(async () => {
- // await getDataSource();
- // });
- // },
- },
- colProps: {
- span: 4,
- },
- },
- // {
- // label: '子设备',
- // field: 'deviceNum',
- // // component: 'JDictSelectTag',
- // // show: Boolean(dictCode),
- // componentProps: {
- // dictCode,
- // showChooseOption: false,
- // placeholder: '请选择',
- // },
- // colProps: {
- // span: 4,
- // },
- // },
- {
- label: '间隔时间',
- field: 'skip',
- component: 'Select',
- defaultValue: '8',
- componentProps: {
- options: [
- {
- label: '1秒',
- value: '1',
- },
- {
- label: '5秒',
- value: '2',
- },
- {
- label: '10秒',
- value: '3',
- },
- {
- label: '30秒',
- value: '4',
- },
- {
- label: '1分钟',
- value: '5',
- },
- {
- label: '10分钟',
- value: '6',
- },
- {
- label: '30分钟',
- value: '7',
- },
- {
- label: '1小时',
- value: '8',
- },
- ],
- },
- colProps: {
- span: 4,
- },
- },
- ];
- };
- /** 默认的表格props,参考 BasicTable 组件 */
- export const defaultTableProps: BasicTableProps = {
- columns: [
- {
- align: 'center',
- dataIndex: 'strinstallpos',
- defaultHidden: false,
- title: '安装位置',
- width: 80,
- },
- ],
- bordered: false,
- size: 'small',
- showIndexColumn: true,
- showActionColumn: false,
- };
- /** 默认的查询表单props,参考 BasicForm 组件 */
- export const defaultFormProps: FormProps = {
- labelAlign: 'left',
- labelCol: { span: 8 },
- showAdvancedButton: false,
- showSubmitButton: false,
- showResetButton: false,
- };
- /** 默认的表格分页props,参考 BasicTable 组件 */
- export const defaultPaginationProps: PaginationProps = {
- current: 1,
- pageSize: 10,
- pageSizeOptions: ['10', '30', '50', '100'],
- showQuickJumper: false,
- };
|