import { upcloud_base_strategy,  } from "@/config/serviceSettings";
const remote = function(value) {
  return {
    autoLoad: true,
    remoteUrl: {
      url: upcloud_base_strategy + '/enum/v1',
      params: { typeNname: value },
      headers: {
        'Content-Type': 'application/JSON'
      },
      method: 'get'
    },
    doneBefore(data) {
      if (data && data.success) {
        var da = data.data
        var arr = da.map(x => {
          return {
            label: x.key,
            value: x.value
          }
        })
        data.data = arr
      }
      return data
    }
  }
}
const model = function(that) {
  return {
    //策略
    strategy: {
      items: [
        {
          type: 'select',
          name: 'category',
          label: '分类',
          disabled: true,
          value: that.strategyType,
          //   value: '',
          labelCol: { span: 6 },
          span: 24,
          on: {
            change(value, label, options, form) {
              // form.setFieldsValue({ 'field-select': value }
            }
          },
          ...remote('strategy')
        },
        {
          type: 'input',
          name: 'fieldName',
          label: '字段名',
          required: true,
          value: '',
          labelCol: { span: 6 },
          span: 24
        },
        {
          type: 'input',
          name: 'name',
          label: '因子名称',
          required: true,
          value: '',
          labelCol: { span: 6 },
          span: 24
        },
        {
          type: 'select',
          name: 'type',
          label: ' 因子类型',
          required: true,
          value: '',
          labelCol: { span: 6 },
          span: 24,
          on: {
            change(value, label, options, form) {
              // form.setFieldsValue({ 'field-select': value })
            }
          },
          ...remote('factor')
        },

        {
          type: 'select',
          name: 'valueType',
          label: ' 值类型',
          required: true,
          value: '',
          labelCol: { span: 6 },
          span: 24,
          on: {
            change(value, label, options, form) {
              form.setFieldsValue({ 'field-select': value })
            }
          },
          ...remote('value')
        },
        //   {
        //     //   匹配类型 matchType
        //     //   匹配类型 Equal-等于  Incloudeone-包含于
        //     type: 'select',
        //     name: 'matchType',
        //     label: ' 匹配类型',
        //     required: true,
        //     value: '',
        //     labelCol: { span: 6 },
        //     span: 24,
        //     on: {
        //       change(value, label, options, form) {
        //         form.setFieldsValue({ 'field-select': value })
        //       }
        //     },
        //     ...remote('match')
        //   },
        //   datasource
        {
          type: 'input',
          name: 'datasource',
          label: '数据源',
          value: '',
          labelCol: { span: 6 },
          span: 24
        },
        {
          type: 'input',
          name: 'id',
          label: 'ID',
          value: '',
          labelCol: { span: 6 },
          span: 24,
          hidden: true
        },
        {
          // 数据源类型 datasourceType
          //   数据源类型 Interface - 接口 Enum-枚举 Input-输入
          type: 'select',
          name: 'datasourceType',
          label: ' 数据源类型',
          required: true,
          value: '',
          labelCol: { span: 6 },
          span: 24,
          on: {
            change(value, label, options, form) {
              form.setFieldsValue({ 'field-select': value })
            }
          },
          ...remote('datasource')
        }
      ]
    }
  }
}

export default model
