| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- import { getCardTypeEnumList } from '@/common/constants/enumsList';
- import { validateCommon } from '@/common/setup/validate';
- import { QueryAddUserInfoApply } from '@/services/go/ermcp/customInfo';
- import { AddUserInfoApplyReq } from '@/services/go/ermcp/customInfo/interface';
- import { message } from 'ant-design-vue';
- import { RuleObject } from 'ant-design-vue/lib/form/interface';
- import { reactive, ref, UnwrapRef } from 'vue';
- import { FormState } from './interface';
- /**
- * 获取证件类型
- * @returns
- */
- export function getCardType() {
- const arr = [2, 4, 18, 21];
- return getCardTypeEnumList().filter(e => arr.includes(e.enumitemname))
- }
- export function handleForm() {
- const formRef = ref();
- const formState: UnwrapRef<FormState> = reactive(initFormState());
- // 验证仓库类型
- async function v_cardtype(rule: RuleObject, value: number) {
- return validateCommon(value, '请选择证件类型')
- }
- const rules = {
- userinfotype: [{ required: true, message: '请选择客户类型', trigger: 'change' }],
- customername: [{ required: true, message: '请输入企业名称', trigger: 'blur' }],
- nickname: [{ required: true, message: '请输入企业简称', trigger: 'blur' }],
- cardtype: [{ required: true, validator: v_cardtype, trigger: 'change' }],
- };
- return { formRef, formState, rules }
- }
- /**
- * 初始化表单数据
- * @returns
- */
- export function initFormState(): FormState {
- return {
- userinfotype: '2',
- customername: '',
- nickname: '',
- cardtype: undefined,
- cardnum: '',
- legalpersonname: '',
- taxpayernum: '',
- attachment1: '',
- attachment2: '',
- attachment3: '',
- attachment4: '',
- attachment5: '',
- contactname: '',
- mobilephone: '',
- telphone: '',
- provinceid: undefined,
- cityid: undefined,
- districtid: undefined,
- cardaddress: '',
- remark: '',
- username: '',
- cardbackphotourl: '',
- cardfrontphotourl: '',
- email: '',
- }
- }
- export function handleApply() {
- const loading = ref<boolean>(false);
- function applyAction(param: AddUserInfoApplyReq) {
- loading.value = true;
- QueryAddUserInfoApply(param).then(res => {
- console.log('res', res);
- }).catch(err => {
- message.error(err)
- }).finally(() => loading.value = false)
- }
- return { loading, applyAction }
- }
|