index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. <template>
  2. <!-- 平安客户资料 -->
  3. <a-modal
  4. class="add-custom"
  5. :title="isAdd() ? '新增客户资料' : '修改客户资料'"
  6. v-model:visible="visible"
  7. @cancel="cancel"
  8. centered
  9. :maskClosable="false"
  10. v-if="isPingAnOem()"
  11. width="890px"
  12. >
  13. <template #footer>
  14. <a-button
  15. key="submit"
  16. class="cancelBtn"
  17. :loading="loading"
  18. :disabled="loading"
  19. @click="submit(1)"
  20. >完成</a-button>
  21. </template>
  22. <a-form class="inlineForm" ref="formRef" :model="formState" :rules="rules">
  23. <a-row :gutter="24">
  24. <a-col :span="12">
  25. <a-form-item label="客户类型" name="userinfotype">
  26. <a-select
  27. class="typeSelect"
  28. style="width: 200px"
  29. v-model:value="formState.userinfotype"
  30. placeholder="请选择客户类型"
  31. >
  32. <a-select-option value="1">个人</a-select-option>
  33. <a-select-option value="2">企业</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="企业名称" name="customername">
  40. <a-input
  41. class="dialogInput"
  42. v-model:value="formState.customername"
  43. style="width: 200px"
  44. placeholder="请输入企业名称"
  45. />
  46. </a-form-item>
  47. </a-col>
  48. </template>
  49. <template v-else>
  50. <a-col :span="12">
  51. <a-form-item label="姓名" name="username">
  52. <a-input
  53. class="dialogInput"
  54. style="width: 200px"
  55. v-model:value="formState.username"
  56. placeholder="请输入姓名"
  57. />
  58. </a-form-item>
  59. </a-col>
  60. </template>
  61. <a-col :span="12">
  62. <a-form-item label="点价联系人" name="contactname">
  63. <a-input
  64. class="dialogInput"
  65. style="width: 200px"
  66. v-model:value="formState.contactname"
  67. placeholder="请输入联系人"
  68. />
  69. </a-form-item>
  70. </a-col>
  71. <a-col :span="12">
  72. <a-form-item label="联系人手机号" name="mobilephone">
  73. <a-input
  74. class="dialogInput"
  75. style="width: 200px"
  76. v-model:value="formState.mobilephone"
  77. placeholder="请输入联系人手机号"
  78. />
  79. </a-form-item>
  80. </a-col>
  81. </a-row>
  82. </a-form>
  83. </a-modal>
  84. <!-- 其他项目客户资料 -->
  85. <a-modal
  86. class="add-custom"
  87. v-else
  88. :title="isAdd() ? '新增客户资料' : '修改客户资料'"
  89. v-model:visible="visible"
  90. @cancel="cancel"
  91. centered
  92. :maskClosable="false"
  93. width="890px"
  94. >
  95. <template #footer>
  96. <a-button
  97. key="submit"
  98. class="cancelBtn"
  99. :loading="loading"
  100. :disabled="loading"
  101. @click="submit(1)"
  102. >保存草稿</a-button>
  103. <a-button
  104. key="submit"
  105. type="primary"
  106. :loading="loading"
  107. :disabled="loading"
  108. @click="submit(2)"
  109. >提交审核</a-button>
  110. </template>
  111. <a-form class="inlineForm" ref="formRef" :model="formState" :rules="rules">
  112. <a-row :gutter="24">
  113. <template v-if="isQianHaiJin()">
  114. <a-col :span="12">
  115. <a-form-item label="所属机构" name="areaid">
  116. <a-select
  117. class="typeSelect"
  118. style="width: 200px"
  119. v-model:value="formState.areaid"
  120. placeholder="请选择所属机构"
  121. >
  122. <a-select-option v-for="item in areaList" :key="item.userid">{{ item.accountname }}</a-select-option>
  123. </a-select>
  124. </a-form-item>
  125. </a-col>
  126. <a-col :span="12">
  127. <a-form-item label="所属客户经理" name="teammanageruserid">
  128. <a-select
  129. class="typeSelect"
  130. style="width: 200px"
  131. v-model:value="formState.teammanageruserid"
  132. placeholder="请选择所属客户经理"
  133. >
  134. <a-select-option
  135. v-for="item in brokerList"
  136. :key="item.userid"
  137. >{{ item.customername }}</a-select-option>
  138. </a-select>
  139. </a-form-item>
  140. </a-col>
  141. <a-col :span="12" v-if="isAdd()">
  142. <a-form-item label="登录账号" name="logincode">
  143. <a-input
  144. class="dialogInput"
  145. v-model:value="formState.logincode"
  146. style="width: 200px"
  147. placeholder="请输入登录账号"
  148. />
  149. </a-form-item>
  150. </a-col>
  151. <a-col :span="12" v-if="isAdd()">
  152. <a-form-item label="登录密码" name="loginpwd">
  153. <a-input
  154. class="dialogInput"
  155. v-model:value="formState.loginpwd"
  156. style="width: 200px"
  157. placeholder="请输入登录密码"
  158. />
  159. </a-form-item>
  160. </a-col>
  161. </template>
  162. <a-col :span="12">
  163. <a-form-item label="客户类型" name="userinfotype">
  164. <a-select
  165. class="typeSelect"
  166. style="width: 200px"
  167. v-model:value="formState.userinfotype"
  168. placeholder="请选择客户类型"
  169. >
  170. <a-select-option value="1">个人</a-select-option>
  171. <a-select-option value="2">企业</a-select-option>
  172. </a-select>
  173. </a-form-item>
  174. </a-col>
  175. <template v-if="!isPersonal()">
  176. <a-col :span="12">
  177. <a-form-item label="企业名称" name="customername">
  178. <a-input
  179. class="dialogInput"
  180. v-model:value="formState.customername"
  181. style="width: 200px"
  182. placeholder="请输入企业名称"
  183. />
  184. </a-form-item>
  185. </a-col>
  186. <a-col :span="12">
  187. <a-form-item label="企业简称" name="nickname">
  188. <a-input
  189. class="dialogInput"
  190. style="width: 200px"
  191. v-model:value="formState.nickname"
  192. placeholder="请输入企业简称"
  193. />
  194. </a-form-item>
  195. </a-col>
  196. <a-col :span="12">
  197. <a-form-item label="证件类型" name="cardtype">
  198. <a-select
  199. class="inlineFormSelect"
  200. v-model:value="formState.cardtype"
  201. style="width: 200px"
  202. placeholder="请选择证件类型"
  203. >
  204. <a-select-option
  205. :value="item.enumitemname"
  206. v-for="item in cardTypeList"
  207. :key="item.autoid"
  208. >{{ item.enumdicname }}</a-select-option>
  209. </a-select>
  210. </a-form-item>
  211. </a-col>
  212. <a-col :span="12">
  213. <a-form-item label="法定代表人" name="legalpersonname">
  214. <a-input
  215. class="dialogInput"
  216. style="width: 200px"
  217. v-model:value="formState.legalpersonname"
  218. placeholder="请输入法定代表人"
  219. />
  220. </a-form-item>
  221. </a-col>
  222. <a-col :span="12">
  223. <a-form-item label="证件号码" name="cardnum">
  224. <a-input
  225. class="dialogInput"
  226. style="width: 200px"
  227. v-model:value="formState.cardnum"
  228. placeholder="请输入证件号码"
  229. />
  230. </a-form-item>
  231. </a-col>
  232. <a-col :span="12">
  233. <a-form-item label="纳税人识别号" name="taxpayernum">
  234. <a-input
  235. class="dialogInput"
  236. style="width: 200px"
  237. v-model:value="formState.taxpayernum"
  238. placeholder="请输入纳税人识别号"
  239. />
  240. </a-form-item>
  241. </a-col>
  242. <a-col :span="12">
  243. <a-form-item label="营业执照">
  244. <UploadImg
  245. :visible="visible"
  246. :imgList="attachmentImgList"
  247. @upload="attachmentUpLoad"
  248. />
  249. </a-form-item>
  250. </a-col>
  251. <a-col :span="12">
  252. <a-form-item label="联系人" name="contactname">
  253. <a-input
  254. class="dialogInput"
  255. style="width: 200px"
  256. v-model:value="formState.contactname"
  257. placeholder="请输入联系人"
  258. />
  259. </a-form-item>
  260. </a-col>
  261. <a-col :span="12">
  262. <a-form-item label="联系人手机号" name="mobilephone">
  263. <a-input
  264. class="dialogInput"
  265. style="width: 200px"
  266. v-model:value="formState.mobilephone"
  267. placeholder="请输入联系人手机号"
  268. />
  269. </a-form-item>
  270. </a-col>
  271. <a-col :span="12">
  272. <a-form-item label="联系电话" name="telphone">
  273. <a-input
  274. class="dialogInput"
  275. style="width: 200px"
  276. v-model:value="formState.telphone"
  277. placeholder="请输入联系电话"
  278. />
  279. </a-form-item>
  280. </a-col>
  281. </template>
  282. <template v-else>
  283. <a-col :span="12">
  284. <a-form-item label="姓名" name="username">
  285. <a-input
  286. class="dialogInput"
  287. style="width: 200px"
  288. v-model:value="formState.username"
  289. placeholder="请输入姓名"
  290. />
  291. </a-form-item>
  292. </a-col>
  293. <a-col :span="12">
  294. <a-form-item label="身份证号码" name="cardnum">
  295. <a-input
  296. class="dialogInput"
  297. style="width: 200px"
  298. v-model:value="formState.cardnum"
  299. placeholder="请输入身份证号码"
  300. />
  301. </a-form-item>
  302. </a-col>
  303. <a-col :span="12">
  304. <a-form-item label="手机号码" name="mobilephone">
  305. <a-input
  306. class="dialogInput"
  307. style="width: 200px"
  308. v-model:value="formState.mobilephone"
  309. placeholder="请输入手机号码"
  310. />
  311. </a-form-item>
  312. </a-col>
  313. <a-col :span="12">
  314. <a-form-item label="身份证正面照" name="cardbackphotourl">
  315. <UploadImg
  316. :visible="visible"
  317. :imgList="cardfrontImgList"
  318. @upload="cardfrontphotourlUpLoad"
  319. />
  320. </a-form-item>
  321. </a-col>
  322. <a-col :span="12">
  323. <a-form-item label="邮箱" name="email">
  324. <a-input
  325. class="dialogInput"
  326. style="width: 200px"
  327. v-model:value="formState.email"
  328. placeholder="请输入邮箱"
  329. />
  330. </a-form-item>
  331. </a-col>
  332. <a-col :span="12">
  333. <a-form-item label="身份证反面照" name="cardfrontphotourl">
  334. <UploadImg
  335. :visible="visible"
  336. :imgList="cardbackImgList"
  337. @upload="cardbackphotourlUpLoad"
  338. />
  339. </a-form-item>
  340. </a-col>
  341. <a-col :span="12">
  342. <a-form-item label="联系电话" name="telphone">
  343. <a-input
  344. class="dialogInput"
  345. style="width: 200px"
  346. v-model:value="formState.telphone"
  347. placeholder="请输入联系电话"
  348. />
  349. </a-form-item>
  350. </a-col>
  351. <a-col :span="12" v-if="isQianHaiJin()">
  352. <a-form-item label="性别" name="sex">
  353. <a-select
  354. class="inlineFormSelect"
  355. v-model:value="formState.sex"
  356. style="width: 200px"
  357. placeholder="请选择性别"
  358. >
  359. <a-select-option
  360. :value="item.id"
  361. v-for="item in sexList"
  362. :key="item.id"
  363. >{{ item.value }}</a-select-option>
  364. </a-select>
  365. <!-- <a-input class="dialogInput"
  366. style="width: 200px"
  367. v-model:value="formState.sex"
  368. placeholder="请选择性别" />-->
  369. </a-form-item>
  370. </a-col>
  371. <a-col :span="12" v-if="isQianHaiJin()">
  372. <a-form-item label="生日" name="birthday">
  373. <a-date-picker
  374. v-model:value="formState.birthday"
  375. :allowClear="false"
  376. style="width: 200px"
  377. placeholder="请选择生日"
  378. class="commonDatePicker"
  379. />
  380. <!-- <a-input class="dialogInput"
  381. style="width: 200px"
  382. v-model:value="formState.birthday"
  383. placeholder="请选择性别" />-->
  384. </a-form-item>
  385. </a-col>
  386. <a-col :span="12">
  387. <a-form-item>&nbsp;</a-form-item>
  388. </a-col>
  389. </template>
  390. <a-col :span="24">
  391. <a-form-item label="通讯地址">
  392. <a-select
  393. class="inlineFormSelect"
  394. style="width: 205px"
  395. v-model:value="formState.provinceid"
  396. @change="getCityList"
  397. placeholder="请选择省"
  398. >
  399. <a-select-option
  400. v-for="item in provinceList"
  401. :key="item.autoid"
  402. :value="item.autoid"
  403. >{{ item.divisionname }}</a-select-option>
  404. </a-select>
  405. <a-select
  406. class="inlineFormSelect ml9"
  407. style="width: 205px"
  408. v-model:value="formState.cityid"
  409. @change="getDistrictList"
  410. placeholder="请选择市"
  411. >
  412. <a-select-option
  413. v-for="item in cityList"
  414. :key="item.autoid"
  415. :value="item.autoid"
  416. >{{ item.divisionname }}</a-select-option>
  417. </a-select>
  418. <a-select
  419. class="inlineFormSelect ml9"
  420. v-model:value="formState.districtid"
  421. style="width: 205px"
  422. placeholder="请选择县(区)"
  423. >
  424. <a-select-option
  425. v-for="item in districtList"
  426. :key="item.autoid"
  427. :value="item.autoid"
  428. >{{ item.divisionname }}</a-select-option>
  429. </a-select>
  430. </a-form-item>
  431. </a-col>
  432. <a-col :span="24">
  433. <a-form-item label="&nbsp;" name="cardaddress">
  434. <a-input
  435. class="dialogInput"
  436. style="width: 635px"
  437. v-model:value="formState.cardaddress"
  438. placeholder="请输入详细地址"
  439. />
  440. </a-form-item>
  441. </a-col>
  442. <a-col :span="24">
  443. <a-form-item label="备注" name="remark">
  444. <a-input
  445. class="dialogInput"
  446. style="width: 635px"
  447. v-model:value="formState.remark"
  448. placeholder="请输入备注"
  449. />
  450. </a-form-item>
  451. </a-col>
  452. </a-row>
  453. </a-form>
  454. </a-modal>
  455. </template>
  456. <script lang="ts">
  457. import UploadImg from '@/common/components/uploadImg/index.vue';
  458. import { isPingAnOem, isQianHaiJin } from '@/common/config/projectName';
  459. import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
  460. import { validateAction } from '@/common/setup/form';
  461. import { _closeModal } from '@/common/setup/modal/modal';
  462. import { getUploadImg } from '@/common/setup/upload';
  463. import { getUserId } from '@/services/bus/user';
  464. import { getAddress } from '@/services/go/adress';
  465. import { AllEnums } from '@/services/go/commonService/interface';
  466. import { QhjCustomer } from '@/services/go/ermcp/qhj/interface';
  467. import { addCustomerInfoOperate } from '@/services/proto/accountinfo';
  468. import { CustomerInfoOperateReq } from '@/services/proto/accountinfo/interface';
  469. import { mergeTwoObj } from '@/utils/objHandle';
  470. import { toBase64String } from '@/utils/storage/base64';
  471. import moment from 'moment';
  472. import { defineComponent, PropType, ref } from 'vue';
  473. import { FormState } from './interface';
  474. import { getCardType, handleAreaList, handleBrokerApplyt, handleForm } from './setup';
  475. export default defineComponent({
  476. name: 'add-custom',
  477. emits: ['cancel', 'update'],
  478. components: { UploadImg },
  479. props: {
  480. selectedRow: {
  481. default: {},
  482. type: Object as PropType<QhjCustomer>,
  483. },
  484. },
  485. setup(props, context) {
  486. // 控制关闭弹窗
  487. const { visible, cancel } = _closeModal(context);
  488. const loading = ref<boolean>(false);
  489. // 证件类型
  490. const cardTypeList = ref<AllEnums[]>(getCardType());
  491. // 表单
  492. const { formRef, formState, rules } = handleForm();
  493. // 地址
  494. const { cityList, districtList, provinceList, getCityList, getDistrictList } = getAddress();
  495. // 营业执照
  496. const { getFirstImg: getAttachmentImg, uploadImgAction: attachmentUpLoad, uploadImgList: attachmentImgList, handleImg: attachmentHandle } = getUploadImg();
  497. // 背面证件照地址
  498. const { getFirstImg: getBackImg, uploadImgAction: cardbackphotourlUpLoad, uploadImgList: cardbackImgList, handleImg: cardbackHandle } = getUploadImg();
  499. // 正面证件照地址
  500. const { getFirstImg: getFrontImg, uploadImgAction: cardfrontphotourlUpLoad, uploadImgList: cardfrontImgList, handleImg: cardfrontHandle } = getUploadImg();
  501. //查询所属机构列表
  502. const { areaList, getAreaList } = handleAreaList();
  503. // 查询客户经理
  504. const { brokerList, getBrokerApply } = handleBrokerApplyt();
  505. if (isQianHaiJin()) {
  506. Promise.all([getAreaList(loading), getBrokerApply(loading)]);
  507. }
  508. // 性别
  509. const sexList = [
  510. { id: 0, value: '女' },
  511. { id: 1, value: '男' },
  512. ];
  513. function isPersonal(): boolean {
  514. return formState.userinfotype === '1';
  515. }
  516. const isAdd = () => !props.selectedRow.userinfotype;
  517. const isN = (value: string) => value === '--';
  518. // 修改 客户资料的逻辑
  519. if (!isAdd()) {
  520. console.log('修改::::::::::::::::::::::::::');
  521. mergeTwoObj(formState, props.selectedRow);
  522. formState.userinfotype = formState.userinfotype.toString();
  523. if (isPersonal()) {
  524. formState.username = props.selectedRow.customername;
  525. } else {
  526. formState.username = props.selectedRow.username;
  527. }
  528. const { provinceid, cityid, address, mobile, memberuserid, brokerid, cardfrontphotourl, cardbackphotourl } = props.selectedRow;
  529. formState.cardaddress = isN(address) ? '' : address;
  530. formState.mobilephone = mobile;
  531. formState.areaid = memberuserid;
  532. formState.teammanageruserid = brokerid ? brokerid : undefined;
  533. provinceid ? getCityList(provinceid) : (formState.provinceid = undefined);
  534. cityid ? getDistrictList(cityid) : ((formState.cityid = undefined), (formState.districtid = undefined));
  535. if (cardfrontphotourl && !isN(cardfrontphotourl)) {
  536. // 营业执照
  537. attachmentImgList.value = attachmentHandle(cardfrontphotourl);
  538. }
  539. if (cardbackphotourl && !isN(cardbackphotourl)) {
  540. // 背面证件照地址
  541. cardbackImgList.value = cardbackHandle(cardbackphotourl);
  542. }
  543. if (cardbackphotourl && !isN(cardbackphotourl)) {
  544. // 正面证件照地址
  545. cardfrontImgList.value = cardfrontHandle(cardbackphotourl);
  546. }
  547. }
  548. function submit(OperateType: 1 | 2) {
  549. validateAction<FormState>(formRef, formState).then((param) => {
  550. console.log(props.selectedRow);
  551. const reqParam: CustomerInfoOperateReq = {
  552. operatetype: isAdd() ? 1 : 2, // 1: 新增 2:修改
  553. userid: getUserId(), // 必填
  554. areaid: getUserId(),
  555. userinfotype: Number(param.userinfotype),
  556. username: Number(param.userinfotype) === 1 ? param.username : param.customername,
  557. userstate: OperateType, // 1: 保存草稿 2: 新增
  558. // 以上必填
  559. cardtype: (param.cardtype as number) !== undefined ? (param.cardtype as number) : 0, // 证件类型
  560. cardnum: param.cardnum, // 证件号码
  561. nickname: param.nickname, // 昵称
  562. remark: param.remark, // 备注
  563. mobilephone: param.mobilephone, // 手机号码
  564. telphone: param.telphone, // 电话
  565. cardfrontphotourl: isPersonal() ? getFrontImg() : getAttachmentImg(), // 正面照片
  566. cardbackphotourl: isPersonal() ? getBackImg() : '', // 背面证件照地址
  567. ipaddress: param.cardaddress, // 证件地址
  568. cityid: (param.cityid as number) !== undefined ? (param.cityid as number) : 0, //城市
  569. districtid: (param.districtid as number) !== undefined ? (param.districtid as number) : 0, // 地区
  570. // countryid: param.,9
  571. provinceid: (param.provinceid as number) !== undefined ? (param.provinceid as number) : 0, //省
  572. contactname: param.contactname, // 联系人
  573. legalpersonname: param.legalpersonname, // 法人姓名(企业)
  574. taxpayernum: param.taxpayernum, // 纳税人识别号
  575. email: param.email, // email
  576. proxystatementurl: '',
  577. };
  578. if (isQianHaiJin()) {
  579. // 千海金
  580. reqParam.areaid = param.areaid as number;
  581. reqParam.logincode = param.logincode;
  582. reqParam.teammanageruserid = param.teammanageruserid ? param.teammanageruserid : 0;
  583. if (isPersonal()) {
  584. reqParam.sex = param.sex;
  585. if (param.birthday) {
  586. reqParam.birthday = moment(param.birthday).format('YYYY-MM-DD');
  587. }
  588. }
  589. reqParam.loginpwd = toBase64String(toBase64String(param.loginpwd));
  590. reqParam.userstate = 2;
  591. }
  592. debugger;
  593. requestResultLoadingAndInfo(addCustomerInfoOperate, reqParam, loading, OperateType === 1 ? ['保存草稿成功', '保存草稿失败:'] : ['新增客户资料成功', '新增客户资料失败:']).then(() => {
  594. cancel(true);
  595. });
  596. });
  597. }
  598. return {
  599. formState,
  600. rules,
  601. formRef,
  602. cardTypeList,
  603. isPersonal,
  604. visible,
  605. cancel,
  606. submit,
  607. loading,
  608. cityList,
  609. districtList,
  610. provinceList,
  611. areaList,
  612. brokerList,
  613. attachmentImgList,
  614. cardbackImgList,
  615. cardfrontImgList,
  616. sexList,
  617. getCityList,
  618. getDistrictList,
  619. attachmentUpLoad,
  620. cardbackphotourlUpLoad,
  621. cardfrontphotourlUpLoad,
  622. isPingAnOem,
  623. isQianHaiJin,
  624. isAdd,
  625. };
  626. },
  627. });
  628. </script>