setup.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. import { getCardTypeEnumList } from '@/common/constants/enumsList';
  2. import { queryResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
  3. import { validateCommon } from '@/common/setup/validate';
  4. import { getUserId } from '@/services/bus/user';
  5. import { QueryAddUserInfoApply } from '@/services/go/ermcp/customInfo';
  6. import { AddUserInfoApplyReq } from '@/services/go/ermcp/customInfo/interface';
  7. import { QueryBrokerApply, queryParentAreaList } from '@/services/go/ermcp/qhj';
  8. import { QhjParentAreaList, QueryBrokerApplyRsp } from '@/services/go/ermcp/qhj/interface';
  9. import { message } from 'ant-design-vue';
  10. import { RuleObject } from 'ant-design-vue/lib/form/interface';
  11. import { reactive, Ref, ref, UnwrapRef } from 'vue';
  12. import { FormState } from './interface';
  13. /**
  14. * 获取证件类型
  15. * @returns
  16. */
  17. export function getCardType() {
  18. const arr = [2, 4, 18, 21];
  19. return getCardTypeEnumList().filter(e => arr.includes(e.enumitemname))
  20. }
  21. export function handleForm() {
  22. const formRef = ref();
  23. const formState: UnwrapRef<FormState> = reactive(initFormState());
  24. // 验证仓库类型
  25. async function v_cardtype(rule: RuleObject, value: number) {
  26. return validateCommon(value, '请选择证件类型')
  27. }
  28. const rules = {
  29. userinfotype: [{ required: true, message: '请选择客户类型', trigger: 'change' }],
  30. areaid: [{ required: true, message: '请选择所属机构' }],
  31. sex: [{ required: true, message: '请选择性别' }],
  32. customername: [{ required: true, message: '请输入企业名称', trigger: 'blur' }],
  33. mobilephone: [
  34. { required: true, message: '请输入联系人手机号', trigger: 'blur' },
  35. { message: '请输入正确的手机号', pattern: /^[1][3,4,5,7,8,9][0-9]{9}$/ }
  36. ],
  37. username: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
  38. nickname: [{ required: true, message: '请输入企业简称', trigger: 'blur' }],
  39. // cardtype: [{ required: true, validator: v_cardtype, trigger: 'change' }],
  40. };
  41. return { formRef, formState, rules }
  42. }
  43. /**
  44. * 初始化表单数据
  45. * @returns
  46. */
  47. export function initFormState(): FormState {
  48. return {
  49. areaid: undefined,
  50. logincode: '',
  51. loginpwd: '',
  52. userinfotype: '2',
  53. customername: '',
  54. nickname: '',
  55. cardtype: undefined,
  56. cardnum: '',
  57. legalpersonname: '',
  58. taxpayernum: '',
  59. attachment1: '',
  60. attachment2: '',
  61. attachment3: '',
  62. attachment4: '',
  63. attachment5: '',
  64. contactname: '',
  65. mobilephone: '',
  66. telphone: '',
  67. provinceid: undefined,
  68. cityid: undefined,
  69. districtid: undefined,
  70. cardaddress: '',
  71. remark: '',
  72. username: '',
  73. cardbackphotourl: '',
  74. cardfrontphotourl: '',
  75. email: '',
  76. birthday: '',
  77. teammanageruserid: undefined,
  78. sex: undefined,
  79. }
  80. }
  81. export function handleApply() {
  82. const loading = ref<boolean>(false);
  83. function applyAction(param: AddUserInfoApplyReq) {
  84. loading.value = true;
  85. QueryAddUserInfoApply(param).then(res => {
  86. }).catch(err => {
  87. message.error(err)
  88. }).finally(() => loading.value = false)
  89. }
  90. return { loading, applyAction }
  91. }
  92. // 查询所属机构列表
  93. export function handleAreaList() {
  94. const areaList = ref<QhjParentAreaList[]>([])
  95. function getAreaList(loading: Ref<boolean>) {
  96. queryResultLoadingAndInfo(queryParentAreaList, loading).then(res => {
  97. areaList.value = res
  98. })
  99. }
  100. return { areaList, getAreaList }
  101. }
  102. // 查询客户经理
  103. export function handleBrokerApplyt() {
  104. const brokerList = ref<QueryBrokerApplyRsp[]>([])
  105. function getBrokerApply(loading: Ref<boolean>) {
  106. const param = {
  107. userid: getUserId(),
  108. filterstatus: 2,
  109. includesub: 1,
  110. }
  111. queryResultLoadingAndInfo(QueryBrokerApply, loading, param).then(res => {
  112. brokerList.value = res
  113. })
  114. }
  115. return { brokerList, getBrokerApply }
  116. }