<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: 'autoCode',
    label: '自动运算编号',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'cctDate',
    label: '计算日期',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'ruleCode',
    label: '规则表',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'idxCode',
    label: '对应AML_RULE_IDX表IDX_CODE个字段',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'ruleType',
    label: '交易类型',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'cctType',
    label: '1.系统2人工',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custCode',
    label: '客户号',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custName',
    label: '客户名称',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'ssnNo',
    label: '身份证号',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'ssnNotype',
    label: '客户证件类型',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custCountry',
    label: '客户国籍',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custTel',
    label: '客户联系电话',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custAddress',
    label: '客户住址',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custContactway',
    label: '客户其他联系方式',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'custPptype',
    label: '客户标识',
    component: 'Select',
    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: 'custOrgancode',
    label: '开户机构号',
    component: 'Select',
    componentProps: {
      
    },
  },
  {
    field: 'custClipro',
    label: '客户性质',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'tranOrgan',
    label: '金融机构代码',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'tranOrgantype',
    label: '金融机构代码类型',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'tranOrganname',
    label: '金融机构名称',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'tranAddress',
    label: '交易发生地',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'tranAddresscode',
    label: '金融机构所在地区行政区划代码',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'tranAcct',
    label: '账户',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'tranAcctname',
    label: '账号名称',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'tranAccttype',
    label: '账户类型',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'tranAccthdflg',
    label: '活定期标志',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'tranAccthr',
    label: '账户性质  ',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'tranAcctprdid',
    label: '产品号',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'tranType',
    label: '交易方式',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'tranBh',
    label: '金融机构和大额的关系,银行卡所发生的大额交易:A 金融机构:B 机构:C 客户通过:D 账户:E 00:D在境内开立的E或者A,B为开立E的C或发卡银行 01:D境外A,B为收单行；02:客户不通过E或者A,B为办理业务的C',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'serialNo',
    label: '业务流水号',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'tranDate',
    label: '交易日期',
    component: 'DatePicker',
    componentProps: {
      type: 'daterange'
    },
  },
  {
    field: 'tranTime',
    label: '交易时间',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'tsct',
    label: '涉外收支交易分类与代码',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'currencyCode',
    label: '币种',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'amount',
    label: '交易金额',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'sendcode',
    label: '资金收付标志',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'fundUse',
    label: '资金用途',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'bterPaperstype',
    label: '代办人证件类型',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'bterName',
    label: '代办人姓名',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'bterNationality',
    label: '代办人国籍',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'bterPaersno',
    label: '代办人证件号码',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'oppOrgan',
    label: '对方金融机构代码',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'oppOrgancodetype',
    label: '对方金融机构代码类型',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'oppOrganname',
    label: '对方金融机构名称',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'oppAddress',
    label: '交易去向地',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'opporgAddresscode',
    label: '对手金融机构网点行政区划代码',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'oppName',
    label: '对手姓名',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'oppPaperstype',
    label: '对手证件类型',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'oppPapersno',
    label: '交易对手证件号码',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'oppAccttype',
    label: '对手账户类型',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'oppAcctt',
    label: '交易对手账号',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'telid',
    label: '柜员号',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'txtm',
    label: '交易来源',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'doctyp',
    label: '交易凭证类型',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'stvn',
    label: '交易凭证号',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'crdno',
    label: '卡号',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'ctac',
    label: '人行上报的账户或者卡号',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'status',
    label: '交易状态',
    component: 'Select',
    componentProps: {
      
    },
  },
  {
    field: 'issend',
    label: '0:未下发，1：下发',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'ismanualrecord',
    label: '是否补录',
    component: 'Select',
    componentProps: {
      
    },
  },
  {
    field: 'retErrors',
    label: '回执错误信息内容',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'retxpathRepcontent',
    label: '回执错误对应的XPATH解析出报文中的错误内容',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'retCode',
    label: '回执结果编号',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'warnRemark',
    label: '预警排除备注信息',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'opendate',
    label: '开户时间',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'closedate',
    label: '销户时间',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'manualrecord',
    label: '补录id',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'clipro2',
    label: '对方客户性质',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'hdflg2',
    label: '对方活定标志',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'accchr2',
    label: '账户性质',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'prdid2',
    label: '对方产品号',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'ctflg',
    label: '现转标志,1--现金，2--转账',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'txcm',
    label: '交易来源',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'openorg',
    label: '开户机构号',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'orgcode',
    label: '大额的交易机构号',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'orgbody',
    label: '机构的报告主体',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'oppCustPptype',
    label: '交易对手客户类型  01对公 02 对私 03个体 04 其他',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'attribute1',
    label: '0:未校验，1:校验未通过，2:校验通过',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'attribute2',
    label: 'RULE_CODE的list',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'attribute3',
    label: '每个自主交易规则的分数',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'attribute4',
    label: '是否给出过评审意见，默认没有0，评审过是1',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'cuspbkname',
    label: '客户身份证件/证明文件名称',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'jrdpbna',
    label: '对公客户法定代表人身份证件名称',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'conshName',
    label: '控股股东或实际控制人名称',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'conshCardtype',
    label: '控股股东或实际控制人名称身份证件类型',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'conshCardname',
    label: '控股股东或实际控制人名称身份证件名称',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'conshCardno',
    label: '控股股东或实际控制人名称身份证件号码',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'cardType',
    label: '银行卡类型',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'cardName',
    label: '银行卡类型名称',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'cardno',
    label: ' 银行卡号码',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'agtidn',
    label: '代办人身份证件/证明文件名称',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'cuspbkname1',
    label: '交易对手身份证件/证明文件名称',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'amtCny',
    label: '交易金额(折人民币)',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'amtUsd',
    label: '交易金额(折美元)',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'matchtype',
    label: '收付款方匹配号类型',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'matchno',
    label: '收付款方匹配号',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'countcode',
    label: '非柜台交易方式',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'ocountcode',
    label: '其他非柜台交易方式',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'countno',
    label: '非柜台交易方式的设备代码',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'acctype2',
    label: '交易对手账户类型',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'betrel',
    label: '金融机构与客户的关系',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'betrancode',
    label: '银行与支付机构之间的业务交易编码',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'tranremark',
    label: '交易信息备注',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'oplasttime',
    label: '操作人',
    component: 'Input',
    componentProps: {
      
    },
   remove: props.actionType === 'edit'
  },
  {
    field: 'opuser',
    label: '操作时间',
    component: 'Input',
    componentProps: {
      
    },
   remove: props.actionType === 'edit'
  },
  {
    field: 'fortrancode',
    label: '涉外收支交易分类与代码',
    component: 'Input',
    componentProps: {
      
    },
  },
  {
    field: 'txflg',
    label: '标志： 2、3 为一次性金融服务',
    component: 'Input',
    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>

