export const getFormItems = self => {
  return [
    { name: 'id', label: 'ID', type: 'input', required: true, hidden: self.mx_modal_state > 0 },
    { name: 'dsName', label: '数据源名称', type: 'input', required: true },
    { name: 'dsUserName', label: '账号', type: 'input', required: true },
    { name: 'dsPassword', label: '密码', type: 'password', required: true },
    { name: 'dsUrl', label: 'URL', type: 'textarea', limit: false, required: true },
    { name: 'dsDriver', label: '驱动类', type: 'select', options: self.drivesList, required: true },
    { name: 'dsInitialSize', label: '初始化大小', type: 'number', required: true, value: 1 },
    { name: 'dsMaxActive', label: '最大连接数', type: 'number', required: true, value: 10 },
    { name: 'dsMinIdle', label: '最小空闲连接数', type: 'number', required: true, value: 1 },
    { name: 'dsMaxWait', label: '超时时间(毫秒)', type: 'number', required: true, value: 60000 },
    { name: 'dsDescription', label: '描述', type: 'input' },
    { name: 'dsValidationQuery', label: '验证SQL', type: 'textarea', limit: false },

    // {
    //   label: '测试数据源',
    //   name: 'btn',
    //   label: '测试数据源',
    //   type: 'row',
    //   list: [
    //     {
    //       span: 0,
    //       type: 'button',
    //       value: '开始测试',
    //       btnType: 'primary',
    //       on: {
    //         clickSync(event, form) {
    //           let values = form.getFieldsValue()
    //           let btn = self.mx_modal_formItems.find(item => item.name == 'btn').list[0]
    //           self.$set(btn, 'value', '测试中...')
    //           self.$set(btn, 'icon', 'loading')
    //           self.mx_testDateSource(values).then(() => {
    //             self.$set(btn, 'value', '开始测试')
    //             self.$set(btn, 'icon', '')
    //           })
    //         }
    //       }
    //     },
    //     {
    //       span: 0,
    //       type: (...args) => {
    //        return self._c('a-alert', {
    //           attrs: {
    //             message: 'Success Tips',
    //             showIcon: true,
    //             type: 'success'
    //           }
    //         })
    //       }
    //     }
    //   ]
    // }

    {
      name: 'btn',
      label: '测试数据源',
      type: 'button',
      value: '开始测试',
      btnType: 'primary',
      on: {
        clickSync(event, form) {
          let values = form.getFieldsValue()
          let btn = self.mx_modal_formItems.find(item => item.name == 'btn')
          self.$set(btn, 'value', '测试中...')
          self.$set(btn, 'icon', 'loading')
          self.mx_testDateSource(values).then(() => {
            self.$set(btn, 'value', '开始测试')
            self.$set(btn, 'icon', '')
          })
        }
      }
    }
  ]
}
