import moment from 'moment';
import { list } from '/@/api/authorize/authorize';
import { FormSchema } from '/@/components/Form';
import { structureList } from '/@/api/sys/menu';

var defTime = moment().format('YYYY-MM-DD HH:mm:ss');
var appList = await list()
appList.map(i => { i.label = i.NAME, i.value = i.KEY })


export const formSchema: FormSchema[] = [
  {
    field: 'sqzys',
    label: '申请资源数',
    component: 'Input',
    required: true,
    componentProps: {
      maxLength: 255,
      disabled: true
    },
  },
  {
    field: 'systemkey',
    label: '应用名称',
    required: true,
    component: 'Select',
    componentProps: {
      options: appList,
    },
  },
  {
    field: 'systemip',
    label: '应用IP地址',
    component: 'Input',
    required: true,
    componentProps: {
      maxLength: 255,
    },
  },
  {
    field: 'sqr',
    label: '申请人',
    component: 'Input',
    required: true,
    componentProps: {
      maxLength: 255,
      disabled: true
    },
  },
  {
    field: 'sqdw',
    component: 'ApiTreeSelect',
    label: '申请单位',
    componentProps: {
      placeholder: '请选择申请单位',
      api: async () => {
        return await structureList();
      },
      onChange(value) {
        sqdw.value = value;
      },
    },
  },
  {
    field: 'time',
    label: '申请时间',
    component: 'Input',
    defaultValue: defTime,
    componentProps: {
      maxLength: 255,
      disabled: true
    },
  },
  {
    field: 'sqyt',
    label: '申请用途',
    component: 'InputTextArea',
    colProps: { span: 48 },
    componentProps: {
      rows: 3,
      maxLength: 255,
    },
  },
];
