import { genWarehouseAuthSearchModal, genCargoownerAuthSearchModal } from '@/views/kzyWMS/SearchModal'
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,
          labelCol: { span: 6 },
          span: 24,
          on: {
            change(value, label, options, form) {
              // form.setFieldsValue({ 'field-select': value })
            }
          },
          ...remote('strategy')
        },
        ...genCargoownerAuthSearchModal(1, true, false, null, null, {
          span: 24,
          labelCol: { span: 6 }
          // wrapperCol: { span: 14 }
        }),
        ...genWarehouseAuthSearchModal(1, true, false, null, null, {
          span: 24,
          labelCol: { span: 6 }
          // wrapperCol: { span: 14 }
        }),
        {
          type: 'input',
          name: 'id',
          label: 'id',
          labelCol: { span: 6 },
          span: 24,
          value: '',
          hidden: true
        },

        {
          type: 'input',
          name: 'name',
          label: '策略名称',
          labelCol: { span: 6 },
          span: 24,
          value: ''
        }
      ]
    }
  }
}

export default model
