index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <!-- 修改客户资料 -->
  3. <a-modal class="commonModal modify-custom"
  4. title="修改客户资料"
  5. v-if="visible"
  6. v-model:visible="visible"
  7. centered
  8. :maskClosable="false"
  9. @cancel="cancel"
  10. width="890px">
  11. <template #footer>
  12. <a-button key="submit"
  13. class="cancelBtn"
  14. @click="submit(1)">保存草稿
  15. </a-button>
  16. <a-button key="submit"
  17. type="primary"
  18. :loading="loading"
  19. @click="submit(2)">提交修改</a-button>
  20. </template>
  21. <a-form class="inlineForm"
  22. ref="formRef"
  23. :model="formState"
  24. :rules="rules">
  25. <a-row :gutter="24">
  26. <a-col :span="12">
  27. <a-form-item label="客户类型"
  28. name="userinfotype">
  29. <a-select class="typeSelect"
  30. style="width: 200px"
  31. v-model:value="formState.userinfotype"
  32. placeholder="请选择客户类型">
  33. <a-select-option value = "1">
  34. 个人
  35. </a-select-option>
  36. <a-select-option value = "2">
  37. 企业
  38. </a-select-option>
  39. </a-select>
  40. </a-form-item>
  41. </a-col>
  42. <template v-if="!isPersonal()">
  43. <a-col :span="12">
  44. <a-form-item label="企业名称"
  45. name="customername">
  46. <a-input class="dialogInput"
  47. v-model:value="formState.customername"
  48. style="width: 200px"
  49. placeholder="请输入企业名称" />
  50. </a-form-item>
  51. </a-col>
  52. <a-col :span="12">
  53. <a-form-item label="企业简称"
  54. name="nickname">
  55. <a-input class="dialogInput"
  56. style="width: 200px"
  57. v-model:value="formState.nickname"
  58. placeholder="请输入企业简称" />
  59. </a-form-item>
  60. </a-col>
  61. <a-col :span="12">
  62. <a-form-item label="证件类型"
  63. name="cardtype">
  64. <a-select class="inlineFormSelect"
  65. v-model:value="formState.cardtype"
  66. style="width: 200px"
  67. placeholder="请选择证件类型">
  68. <a-select-option :value="item.enumitemname"
  69. v-for="item in cardTypeList"
  70. :key="item.autoid">
  71. {{ item.enumdicname }}
  72. </a-select-option>
  73. </a-select>
  74. </a-form-item>
  75. </a-col>
  76. <a-col :span="12">
  77. <a-form-item label="法定代表人"
  78. name="legalpersonname">
  79. <a-input class="dialogInput"
  80. style="width: 200px"
  81. v-model:value="formState.legalpersonname"
  82. placeholder="请输入法定代表人" />
  83. </a-form-item>
  84. </a-col>
  85. <a-col :span="12">
  86. <a-form-item label="证件号码"
  87. name="cardnum">
  88. <a-input class="dialogInput"
  89. style="width: 200px"
  90. v-model:value="formState.cardnum"
  91. placeholder="请输入证件号码" />
  92. </a-form-item>
  93. </a-col>
  94. <a-col :span="12">
  95. <a-form-item label="纳税人识别号"
  96. name="taxpayernum">
  97. <a-input class="dialogInput"
  98. style="width: 200px"
  99. v-model:value="formState.taxpayernum"
  100. placeholder="请输入纳税人识别号" />
  101. </a-form-item>
  102. </a-col>
  103. <a-col :span="12">
  104. <a-form-item label="营业执照">
  105. <UploadImg :visible="visible"
  106. :imgList="attachmentImgList"
  107. @upload="attachmentUpload" />
  108. </a-form-item>
  109. </a-col>
  110. <a-col :span="12">
  111. <a-form-item label="联系人"
  112. name="contactname">
  113. <a-input class="dialogInput"
  114. style="width: 200px"
  115. v-model:value="formState.contactname"
  116. placeholder="请输入联系人" />
  117. </a-form-item>
  118. </a-col>
  119. <a-col :span="12">
  120. <a-form-item label="联系人手机号"
  121. name="mobilephone">
  122. <a-input class="dialogInput"
  123. style="width: 200px"
  124. v-model:value="formState.mobilephone"
  125. placeholder="请输入联系人手机号" />
  126. </a-form-item>
  127. </a-col>
  128. <a-col :span="12">
  129. <a-form-item label="联系电话"
  130. name="telphone">
  131. <a-input class="dialogInput"
  132. style="width: 200px"
  133. v-model:value="formState.telphone"
  134. placeholder="请输入联系电话" />
  135. </a-form-item>
  136. </a-col>
  137. </template>
  138. <template v-else>
  139. <a-col :span="12">
  140. <a-form-item label="姓名"
  141. name="username">
  142. <a-input class="dialogInput"
  143. style="width: 200px"
  144. v-model:value="formState.username"
  145. placeholder="请输入姓名" />
  146. </a-form-item>
  147. </a-col>
  148. <a-col :span="12">
  149. <a-form-item label="身份证号码"
  150. name="cardnum">
  151. <a-input class="dialogInput"
  152. style="width: 200px"
  153. v-model:value="formState.cardnum"
  154. placeholder="请输入身份证号码" />
  155. </a-form-item>
  156. </a-col>
  157. <a-col :span="12">
  158. <a-form-item label="手机号码"
  159. name="mobilephone">
  160. <a-input class="dialogInput"
  161. style="width: 200px"
  162. v-model:value="formState.mobilephone"
  163. placeholder="请输入手机号码" />
  164. </a-form-item>
  165. </a-col>
  166. <a-col :span="12">
  167. <a-form-item label="身份证正面照"
  168. name="cardbackphotourl">
  169. <UploadImg :visible="visible"
  170. :imgList="cardfrontImgList"
  171. @upload="cardfrontUpload" />
  172. </a-form-item>
  173. </a-col>
  174. <a-col :span="12">
  175. <a-form-item label="邮箱"
  176. name="email">
  177. <a-input class="dialogInput"
  178. style="width: 200px"
  179. v-model:value="formState.email"
  180. placeholder="请输入邮箱" />
  181. </a-form-item>
  182. </a-col>
  183. <a-col :span="24">
  184. <a-form-item label="身份证反面照"
  185. name="cardfrontphotourl">
  186. <UploadImg :visible="visible"
  187. :imgList="cardbackImgList"
  188. @upload="cardbackUpload" />
  189. </a-form-item>
  190. </a-col>
  191. <a-col :span="12">
  192. <a-form-item label="联系电话"
  193. name="telphone">
  194. <a-input class="dialogInput"
  195. style="width: 200px"
  196. v-model:value="formState.telphone"
  197. placeholder="请输入联系电话" />
  198. </a-form-item>
  199. </a-col>
  200. <a-col :span="12">
  201. <a-form-item>
  202. &nbsp;
  203. </a-form-item>
  204. </a-col>
  205. </template>
  206. <a-col :span="24">
  207. <a-form-item label="通讯地址">
  208. <a-select class="inlineFormSelect"
  209. style="width: 205px"
  210. v-model:value="formState.provinceid"
  211. @change="getCityList"
  212. placeholder="请选择省">
  213. <a-select-option v-for="item in provinceList"
  214. :key="item.autoid"
  215. :value="item.autoid">
  216. {{ item.divisionname }}
  217. </a-select-option>
  218. </a-select>
  219. <a-select class="inlineFormSelect ml9"
  220. style="width: 205px"
  221. v-model:value="formState.cityid"
  222. @change="getDistrictList"
  223. placeholder="请选择市">
  224. <a-select-option v-for="item in cityList"
  225. :key="item.autoid"
  226. :value="item.autoid">
  227. {{ item.divisionname }}
  228. </a-select-option>
  229. </a-select>
  230. <a-select class="inlineFormSelect ml9"
  231. v-model:value="formState.districtid"
  232. style="width: 205px"
  233. placeholder="请选择县(区)">
  234. <a-select-option v-for="item in districtList"
  235. :key="item.autoid"
  236. :value="item.autoid">
  237. {{ item.divisionname }}
  238. </a-select-option>
  239. </a-select>
  240. </a-form-item>
  241. </a-col>
  242. <a-col :span="24">
  243. <a-form-item label="&nbsp;"
  244. name="cardaddress">
  245. <a-input class="dialogInput"
  246. style="width: 635px"
  247. v-model:value="formState.cardaddress"
  248. placeholder="请输入详细地址" />
  249. </a-form-item>
  250. </a-col>
  251. <a-col :span="24">
  252. <a-form-item label="备注"
  253. name="remark">
  254. <a-input class="dialogInput"
  255. style="width: 635px"
  256. v-model:value="formState.remark"
  257. placeholder="请输入备注" />
  258. </a-form-item>
  259. </a-col>
  260. </a-row>
  261. </a-form>
  262. </a-modal>
  263. </template>
  264. <script lang="ts">
  265. import { closeModal } from '@/common/setup/modal/index';
  266. import { defineComponent, PropType, ref, watchEffect } from 'vue';
  267. import { getCardType, handleForm, initFormState } from '../add/setup';
  268. import { AllEnums } from '@/services/go/commonService/interface';
  269. import { FormState } from '../add/interface';
  270. import { getAddress } from '@/services/go/adress';
  271. import { ModifyUserInfoApplyReq, QueryCustomInfoType } from '@/services/go/ermcp/customInfo/interface';
  272. import { getUserId } from '@/services/bus/account';
  273. import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
  274. import { QueryModifyUserInfoApply } from '@/services/go/ermcp/customInfo';
  275. import { mergeTwoObj } from '@/utils/objHandle';
  276. import { validateAction } from '@/common/setup/form';
  277. import { delAddress } from '@/services/socket/address';
  278. import UploadImg from '@/common/components/uploadImg/index.vue';
  279. import { getUploadImg } from '@/common/setup/upload';
  280. import {addCustomerInfoOperate} from "@/services/proto/accountinfo";
  281. import {CustomerInfoOperateReq} from "@/services/proto/accountinfo/interface";
  282. export default defineComponent({
  283. name: 'modify-custom',
  284. components: { UploadImg },
  285. props: {
  286. selectedRow: {
  287. default: initFormState,
  288. type: Object as PropType<QueryCustomInfoType>,
  289. },
  290. },
  291. setup(props, context) {
  292. const { visible, cancel } = closeModal('custom_info_btn_modify');
  293. const loading = ref<boolean>(false);
  294. // 证件类型
  295. const cardTypeList = ref<AllEnums[]>(getCardType());
  296. // 表单
  297. const { formRef, formState, rules } = handleForm();
  298. // 地址
  299. const { cityList, districtList, provinceList, getCityList, getDistrictList } = getAddress();
  300. // 营业执照
  301. const { uploadImgAction: attachmentUpload, uploadImgList: attachmentImgList, handleImg: attachmentHandle } = getUploadImg();
  302. // 背面证件照地址
  303. const { uploadImgAction: cardbackUpload, uploadImgList: cardbackImgList, handleImg: cardbackHandle } = getUploadImg();
  304. // 正面证件照地址
  305. const { uploadImgAction: cardfrontUpload, uploadImgList: cardfrontImgList, handleImg: cardfrontHandle } = getUploadImg();
  306. function isPersonal(): boolean {
  307. return formState.userinfotype === '1';
  308. }
  309. const userid = ref<number>(0);
  310. const countryid = ref<number>(0);
  311. watchEffect(() => {
  312. if (visible.value) {
  313. userid.value = props.selectedRow.userid;
  314. countryid.value = props.selectedRow.countryid;
  315. mergeTwoObj(formState, props.selectedRow);
  316. formState.userinfotype = formState.userinfotype.toString()
  317. if (isPersonal()) {
  318. formState.username = props.selectedRow.customername;
  319. }else{
  320. formState.username = props.selectedRow.username;
  321. }
  322. const { provinceid, cityid, address, mobile, attachment1, cardfrontphotourl, cardbackphotourl } = props.selectedRow;
  323. formState.cardaddress = address;
  324. formState.mobilephone = mobile;
  325. provinceid ? getCityList(provinceid) : (formState.provinceid = undefined);
  326. cityid ? getDistrictList(cityid) : ((formState.cityid = undefined), (formState.districtid = undefined));
  327. if (attachment1) {
  328. // 营业执照
  329. attachmentImgList.value = attachmentHandle(attachment1);
  330. }
  331. if (cardbackphotourl) {
  332. // 背面证件照地址
  333. cardbackImgList.value = cardbackHandle(cardbackphotourl);
  334. }
  335. if (cardbackphotourl) {
  336. // 正面证件照地址
  337. cardfrontImgList.value = cardfrontHandle(cardbackphotourl);
  338. }
  339. }
  340. });
  341. function submit(OperateType: 1 | 2) {
  342. validateAction<FormState>(formRef, formState).then((param) => {
  343. const reqParam: CustomerInfoOperateReq = {
  344. operatetype: 2, // 1: 新增 2:修改
  345. username: param.userinfotype === '1' ? param.username : param.customername,
  346. userid: userid.value,
  347. areaid: getUserId(),
  348. userinfotype: Number(param.userinfotype),
  349. userstate: OperateType, // 1: 保存草稿 2: 新增
  350. cardtype: (param.cardtype as number) !== undefined ? (param.cardtype as number) : 0, // 证件类型
  351. cardnum: param.cardnum, // 证件号码
  352. nickname: param.nickname, // 昵称
  353. remark: param.remark, // 备注
  354. mobilephone: param.mobilephone, // 手机号码
  355. telphone: param.telphone, // 电话
  356. cardfrontphotourl: param.cardfrontphotourl, // 正面照片
  357. ipaddress: param.cardaddress, // 证件地址
  358. cityid: (param.cityid as number) !== undefined ? (param.cityid as number) : 0, //城市
  359. districtid: (param.districtid as number) !== undefined ? (param.districtid as number) : 0, // 地区
  360. // countryid: param.,9
  361. provinceid: (param.provinceid as number) !== undefined ? (param.provinceid as number) : 0, //省
  362. // countryid: countryid.value,
  363. contactname: param.contactname, // 联系人
  364. legalpersonname: param.legalpersonname, // 法人姓名(企业)
  365. taxpayernum: param.taxpayernum, // 纳税人识别号
  366. email: param.email, // email
  367. proxystatementurl: '',
  368. };
  369. requestResultLoadingAndInfo(addCustomerInfoOperate, reqParam, loading, OperateType === 1 ? ['保存草稿成功', '保存草稿失败:'] : ['新增客户资料成功', '新增客户资料失败:']).then(() => {
  370. cancel();
  371. context.emit('refresh');
  372. });
  373. });
  374. }
  375. return {
  376. formState,
  377. rules,
  378. formRef,
  379. cardTypeList,
  380. isPersonal,
  381. visible,
  382. cancel,
  383. submit,
  384. loading,
  385. cityList,
  386. districtList,
  387. provinceList,
  388. getCityList,
  389. getDistrictList,
  390. attachmentUpload,
  391. attachmentImgList,
  392. cardbackUpload,
  393. cardbackImgList,
  394. cardfrontUpload,
  395. cardfrontImgList,
  396. };
  397. },
  398. });
  399. </script>
  400. <style lang="less">
  401. .modify-custom {
  402. .upload {
  403. display: inline-flex;
  404. .ant-btn.uploadBtn {
  405. width: 60px;
  406. height: 30px;
  407. background: @m-blue0;
  408. border: 0;
  409. padding: 0;
  410. text-align: center;
  411. font-size: 14px;
  412. color: @m-white0;
  413. .rounded-corners(3px);
  414. &:hover {
  415. background: rgba(@m-blue0, 0);
  416. color: rgba(@m-white0, 0.8);
  417. }
  418. }
  419. .look {
  420. color: @m-blue0;
  421. font-size: 14px;
  422. margin-left: 10px;
  423. cursor: pointer;
  424. }
  425. }
  426. }
  427. </style
  428. >;