index.vue 25 KB

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