<script setup lang="tsx">
import { Form, FormSchema } from '@/components/Form'
import { useForm } from '@/hooks/web/useForm'
import { PropType, reactive, watch } from 'vue'
import { useValidator } from '@/hooks/web/useValidator'

const { required } = useValidator()

const props = defineProps({
  currentRow: {
    type: Object as PropType<any>,
    default: () => null
  },
  actionType: {
    type: String,
    default: 'add'
  }
})

const { formRegister, formMethods } = useForm()
const { setValues, getFormData, getElFormExpose } = formMethods

const formSchema = reactive<FormSchema[]>([
  {
    field: 'pkid',
    label: '序列字段',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custCode',
    label: '名单编号',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custName',
    label: '客户名称',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custType',
    label: '客户公私类型',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custStatus',
    label: '客户状态',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custOrgancode',
    label: '开户机构',
    component: 'Select',
    componentProps: {
      
    },
  },
  {
    field: 'lockStatus',
    label: '黑名单状态',
    component: 'Select',
    componentProps: {
      
    },
  },
  {
    field: 'custPptype',
    label: '客户类型',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custCardtype',
    label: '证件类型',
    component: 'Select',
    componentProps: {
      
    },
  },
  {
    field: 'isnewcust',
    label: '是否新增客户',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custCardno',
    label: '证件号码',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custTel',
    label: '移动电话',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custPhone',
    label: '固定电话',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custAddress',
    label: '地址',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custContactway',
    label: '其他联系方式',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custCountry',
    label: '客户国籍',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custBusinesstype',
    label: '客户行业',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custRegcap',
    label: '注册资金',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'corporationName',
    label: '法人名称',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'corporationCardtye',
    label: '法人证件类型',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'corporationCardno',
    label: '法人证件号码',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'attribute1',
    label: '名单类型',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'attribute2',
    label: '道琼斯黑名单记录ID',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'attribute3',
    label: '黑名单子类',
    component: 'InputNumber',
    componentProps: {
      
    },
  },
  {
    field: 'attribute4',
    label: '黑名单来源',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'attribute5',
    label: '账号',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'attribute6',
    label: '外部发布机构',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'attribute7',
    label: '审核人',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'attribute8',
    label: '审核时间',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'attribute9',
    label: '审核意见',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'attribute10',
    label: 'ETL_DATE',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'cause',
    label: '原因代码',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'controlmeasures',
    label: '控制措施',
    component: 'Select',
    componentProps: {
      
    },
  },
  {
    field: 'spStatus',
    label: '审批状态',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'pubStatus',
    label: '共享状态',
    component: 'Select',
    componentProps: {
      
    },
  },
  {
    field: 'mdMess',
    label: '名单说明',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'updateDate',
    label: '更新日期',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'createDate',
    label: '发布日期',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'birthday',
    label: '出生日期',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'six',
    label: '性别',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'fbjgmc',
    label: '发布机构名称',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'blackType',
    label: '黑名单类型',
    component: 'Select',
    componentProps: {
      
    },
  }
])

const rules = reactive({
  
})

const submit = async () => {
  const elForm = await getElFormExpose()
  const valid = await elForm?.validate().catch((err) => {
    console.log(err)
  })
  if (valid) {
    const formData = await getFormData()
    return formData
  }
}

watch(
  () => props.currentRow,
  (currentRow) => {
    if (!currentRow) return
    setValues(currentRow)
  },
  {
    deep: true,
    immediate: true
  }
)

defineExpose({
  submit
})
</script>

<template>
  <Form :rules="rules" @register="formRegister" :schema="formSchema" />
</template>

