export const defaultProps = {
  children: 'children',
  label: 'aircaftTypeName'
}

export const columns = (_this) => [
  {
    prop: 'aircaftModelName',
    label: '机型名称',
    align: 'left'
  },
  {
    prop: 'aircaftModelCode',
    label: '机型编号'
  },
  {
    prop: 'aircaftTypeName',
    label: '机种名称'
  },
  {
    prop: 'status',
    label: '状态',
    render: (h, params) => {
      if (params.row.status == 1) {
        return h('span', { class: 'success-state' }, '启用')
      } else {
        return h('span', { class: 'warning-state' }, '禁用')
      }
    }
  },
  {
    button: true,
    label: '操作',
    width: '240px',
    group: [
      {
        name: '编辑',
        type: 'text',
        round: false,
        plain: false,
        onClick: (row, index, scope) => {
          _this.handUpdate(row)
        }
      },
      {
        name: '启用',
        type: 'text',
        statusKey: 'status',
        unDisableKey: 0,
        round: false,
        plain: false,
        onClick: (row, index, scope) => {
          _this.toggle('启用', row)
        }
      },
      {
        name: '禁用',
        type: 'text',
        statusKey: 'status',
        unDisableKey: 1,
        round: false,
        plain: false,
        onClick: (row, index, scope) => {
          _this.toggle('禁用', row)
        }
      },
      {
        name: '删除',
        type: 'text',
        round: false,
        plain: false,
        onClick: (row, index, scope) => {
          _this.remove([row.aircaftModelId])
        }
      }
    ]
  }
]

export const options = {
  stripe: true, // 斑马纹
  mutiSelect: true, // 多选框
  index: false, // 显示序号， 多选则 mutiSelect
  loading: false, // 表格动画
  initTable: true, // 是否一挂载就加载数据
  border: true,
  height: 'calc(100vh - 300px)'
}

export const modalConfig = (_this) => ({
  formItems: [
    { key: 'aircaftTypeName', type: 'input', label: '所属机种', disabled: true, colLayout: { span: 24 } },
    { key: 'aircaftModelName', type: 'input', label: '机型名称', placeHolder: '请输入机型名称', colLayout: { span: 24 } },
    { key: 'aircaftModelCode', type: 'input', label: '机型编号', placeHolder: '请输入机型编号', colLayout: { span: 24 } }
  ],
  labelWidth: '80px',
  width: '500px',
  itemStyle: { padding: '10px' },
  rules: {
    aircaftModelName: [{ required: true, message: '请输入机型名称', trigger: 'blur' }],
    aircaftModelCode: [{ required: true, message: '请输入机型编号', trigger: 'blur' }],
    status: [{ required: true, message: '请选择状态', trigger: 'blur' }]
  }
})
