index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <!-- 新增客户资料 -->
  3. <a-modal class="add-custom"
  4. title="新增客户资料"
  5. v-model:visible="visible"
  6. @cancel="cancel"
  7. centered
  8. :maskClosable="false"
  9. width="890px">
  10. <template #footer>
  11. <a-button key="submit"
  12. type="primary"
  13. :loading="loading"
  14. @click="submit">完成</a-button>
  15. </template>
  16. <a-form class="inlineForm"
  17. ref="formRef"
  18. :model="formState"
  19. :rules="rules">
  20. <a-row :gutter="24">
  21. <a-col :span="12">
  22. <a-form-item label="客户类型"
  23. name="userinfotype">
  24. <a-select class="typeSelect"
  25. style="width: 200px"
  26. v-model:value="formState.userinfotype"
  27. placeholder="请选择客户类型">
  28. <a-select-option value="1">
  29. 个人
  30. </a-select-option>
  31. <a-select-option value="2">
  32. 企业
  33. </a-select-option>
  34. </a-select>
  35. </a-form-item>
  36. </a-col>
  37. <template v-if="!isPersonal()">
  38. <a-col :span="12">
  39. <a-form-item label="企业名称"
  40. name="customername">
  41. <a-input class="dialogInput"
  42. v-model:value="formState.customername"
  43. style="width: 200px"
  44. placeholder="请输入企业名称" />
  45. </a-form-item>
  46. </a-col>
  47. <a-col :span="12">
  48. <a-form-item label="企业简称"
  49. name="nickname">
  50. <a-input class="dialogInput"
  51. style="width: 200px"
  52. v-model:value="formState.nickname"
  53. placeholder="请输入企业简称" />
  54. </a-form-item>
  55. </a-col>
  56. <a-col :span="12">
  57. <a-form-item label="证件类型"
  58. name="cardtype">
  59. <a-select class="inlineFormSelect"
  60. v-model:value="formState.cardtype"
  61. style="width: 200px"
  62. placeholder="请选择证件类型">
  63. <a-select-option :value="item.enumitemname"
  64. v-for="item in cardTypeList"
  65. :key="item.autoid">
  66. {{item.enumdicname}}
  67. </a-select-option>
  68. </a-select>
  69. </a-form-item>
  70. </a-col>
  71. <a-col :span="12">
  72. <a-form-item label="法定代表人"
  73. name="legalpersonname">
  74. <a-input class="dialogInput"
  75. style="width: 200px"
  76. v-model:value="formState.legalpersonname"
  77. placeholder="请输入法定代表人" />
  78. </a-form-item>
  79. </a-col>
  80. <a-col :span="12">
  81. <a-form-item label="证件号码"
  82. name="cardnum">
  83. <a-input class="dialogInput"
  84. style="width: 200px"
  85. v-model:value="formState.cardnum"
  86. placeholder="请输入证件号码" />
  87. </a-form-item>
  88. </a-col>
  89. <a-col :span="12">
  90. <a-form-item label="纳税人识别号"
  91. name="taxpayernum">
  92. <a-input class="dialogInput"
  93. style="width: 200px"
  94. v-model:value="formState.taxpayernum"
  95. placeholder="请输入纳税人识别号" />
  96. </a-form-item>
  97. </a-col>
  98. <a-col :span="12">
  99. <a-form-item label="营业执照">
  100. <div class="upload">
  101. <a-upload action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
  102. :transform-file="transformFile">
  103. <a-button class="uploadBtn">上传</a-button>
  104. </a-upload>
  105. <div class="look">查看附件</div>
  106. </div>
  107. </a-form-item>
  108. </a-col>
  109. <a-col :span="12">
  110. <a-form-item label="联系人"
  111. name="contactname">
  112. <a-input class="dialogInput"
  113. style="width: 200px"
  114. v-model:value="formState.contactname"
  115. placeholder="请输入联系人" />
  116. </a-form-item>
  117. </a-col>
  118. <a-col :span="12">
  119. <a-form-item label="联系人手机号"
  120. name="mobilephone">
  121. <a-input class="dialogInput"
  122. style="width: 200px"
  123. v-model:value="formState.mobilephone"
  124. placeholder="请输入联系人手机号" />
  125. </a-form-item>
  126. </a-col>
  127. <a-col :span="12">
  128. <a-form-item label="联系电话"
  129. name="telphone">
  130. <a-input class="dialogInput"
  131. style="width: 200px"
  132. v-model:value="formState.telphone"
  133. placeholder="请输入联系电话" />
  134. </a-form-item>
  135. </a-col>
  136. </template>
  137. <template v-else>
  138. <a-col :span="12">
  139. <a-form-item label="姓名"
  140. name="username">
  141. <a-input class="dialogInput"
  142. style="width: 200px"
  143. v-model:value="formState.username"
  144. placeholder="请输入姓名" />
  145. </a-form-item>
  146. </a-col>
  147. <a-col :span="12">
  148. <a-form-item label="身份证号码"
  149. name="cardnum">
  150. <a-input class="dialogInput"
  151. style="width: 200px"
  152. v-model:value="formState.cardnum"
  153. placeholder="请输入身份证号码" />
  154. </a-form-item>
  155. </a-col>
  156. <a-col :span="12">
  157. <a-form-item label="手机号码"
  158. name="mobilephone">
  159. <a-input class="dialogInput"
  160. style="width: 200px"
  161. v-model:value="formState.mobilephone"
  162. placeholder="请输入手机号码" />
  163. </a-form-item>
  164. </a-col>
  165. <a-col :span="12">
  166. <a-form-item label="身份证正面照"
  167. name="cardbackphotourl">
  168. <div class="upload">
  169. <a-upload action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
  170. :transform-file="transformFile">
  171. <a-button class="uploadBtn">上传</a-button>
  172. </a-upload>
  173. <div class="look">查看附件</div>
  174. </div>
  175. </a-form-item>
  176. </a-col>
  177. <a-col :span="12">
  178. <a-form-item label="邮箱"
  179. name="email">
  180. <a-input class="dialogInput"
  181. style="width: 200px"
  182. v-model:value="formState.email"
  183. placeholder="请输入邮箱" />
  184. </a-form-item>
  185. </a-col>
  186. <a-col :span="24">
  187. <a-form-item label="身份证反面照"
  188. name="cardfrontphotourl">
  189. <div class="upload">
  190. <a-upload action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
  191. :transform-file="transformFile">
  192. <a-button class="uploadBtn">上传</a-button>
  193. </a-upload>
  194. <div class="look">查看附件</div>
  195. </div>
  196. </a-form-item>
  197. </a-col>
  198. <a-col :span="12">
  199. <a-form-item label="联系电话"
  200. name="telphone">
  201. <a-input class="dialogInput"
  202. style="width: 200px"
  203. v-model:value="formState.telphone"
  204. placeholder="请输入联系电话" />
  205. </a-form-item>
  206. </a-col>
  207. <a-col :span="12">
  208. <a-form-item>
  209. &nbsp;
  210. </a-form-item>
  211. </a-col>
  212. </template>
  213. <a-col :span="24">
  214. <a-form-item label="通讯地址">
  215. <a-select class="inlineFormSelect"
  216. style="width: 205px"
  217. placeholder="请选择省">
  218. <a-select-option value="1">
  219. 客户一
  220. </a-select-option>
  221. <a-select-option value="2">
  222. 客户二
  223. </a-select-option>
  224. </a-select>
  225. <a-select class="inlineFormSelect ml10"
  226. style="width: 205px"
  227. placeholder="请选择市">
  228. <a-select-option value="1">
  229. 客户一
  230. </a-select-option>
  231. <a-select-option value="2">
  232. 客户二
  233. </a-select-option>
  234. </a-select>
  235. <a-select class="inlineFormSelect ml10"
  236. style="width: 205px"
  237. placeholder="请选择县(区)">
  238. <a-select-option value="1">
  239. 客户一
  240. </a-select-option>
  241. <a-select-option value="2">
  242. 客户二
  243. </a-select-option>
  244. </a-select>
  245. </a-form-item>
  246. </a-col>
  247. <a-col :span="24">
  248. <a-form-item label="&nbsp;"
  249. name="cardaddress">
  250. <a-input class="dialogInput"
  251. style="width: 635px"
  252. v-model:value="formState.cardaddress"
  253. placeholder="请输入详细地址" />
  254. </a-form-item>
  255. </a-col>
  256. <a-col :span="24">
  257. <a-form-item label="备注"
  258. name="remark">
  259. <a-input class="dialogInput"
  260. style="width: 635px"
  261. v-model:value="formState.remark"
  262. placeholder="请输入备注" />
  263. </a-form-item>
  264. </a-col>
  265. </a-row>
  266. </a-form>
  267. </a-modal>
  268. </template>
  269. <script lang="ts">
  270. import { closeModal } from '@/common/setup/modal/index';
  271. import { initData } from '@/common/methods/index';
  272. import { defineComponent, ref, reactive, toRaw, UnwrapRef } from 'vue';
  273. import { getCardType, initFormState, handleApply } from './setup';
  274. import { AllEnums } from '@/services/go/commonService/interface';
  275. import { FormState } from './interface';
  276. import { RuleObject, ValidateErrorEntity } from 'ant-design-vue/es/form/interface';
  277. export default defineComponent({
  278. name: 'add-custom',
  279. components: {},
  280. setup() {
  281. // 控制关闭弹窗
  282. const { visible, cancel } = closeModal('custom_info_btn_add');
  283. // 证件类型
  284. const cardTypeList = ref<AllEnums[]>(getCardType());
  285. // 表单
  286. const formRef = ref();
  287. const formState: UnwrapRef<FormState> = reactive(initFormState());
  288. const rules = {
  289. userinfotype: [{ required: true, message: '请选择客户类型', trigger: 'change' }],
  290. customername: [{ required: true, message: '请输入企业名称', trigger: 'blur' }],
  291. nickname: [{ required: true, message: '请输入企业简称', trigger: 'blur' }],
  292. cardtype: [{ required: true, message: '请选择证件类型', trigger: 'change' }],
  293. };
  294. // 下单方法
  295. const { loading, applyAction } = handleApply();
  296. function isPersonal(): boolean {
  297. return formState.userinfotype === '1';
  298. }
  299. function submit() {
  300. formRef.value
  301. .validate()
  302. .then(() => {
  303. const param = toRaw(formState);
  304. applyAction(param);
  305. console.log('values', formState);
  306. })
  307. .catch((error: ValidateErrorEntity<FormState>) => {
  308. console.log('error', error);
  309. });
  310. }
  311. initData(() => {});
  312. return {
  313. formState,
  314. rules,
  315. formRef,
  316. cardTypeList,
  317. isPersonal,
  318. visible,
  319. cancel,
  320. submit,
  321. loading,
  322. };
  323. },
  324. });
  325. </script>
  326. <style lang="less">
  327. .add-custom {
  328. }
  329. </style
  330. >;