index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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="maskClosableFlag"
  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. <div class="upload">
  106. <a-upload action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
  107. :transform-file="transformFile">
  108. <a-button class="uploadBtn">上传</a-button>
  109. </a-upload>
  110. <div class="look">查看附件</div>
  111. </div>
  112. </a-form-item>
  113. </a-col>
  114. <a-col :span="12">
  115. <a-form-item label="联系人"
  116. name="contactname">
  117. <a-input class="dialogInput"
  118. style="width: 200px"
  119. v-model:value="formState.contactname"
  120. placeholder="请输入联系人" />
  121. </a-form-item>
  122. </a-col>
  123. <a-col :span="12">
  124. <a-form-item label="联系人手机号"
  125. name="mobilephone">
  126. <a-input class="dialogInput"
  127. style="width: 200px"
  128. v-model:value="formState.mobilephone"
  129. placeholder="请输入联系人手机号" />
  130. </a-form-item>
  131. </a-col>
  132. <a-col :span="12">
  133. <a-form-item label="联系电话"
  134. name="telphone">
  135. <a-input class="dialogInput"
  136. style="width: 200px"
  137. v-model:value="formState.telphone"
  138. placeholder="请输入联系电话" />
  139. </a-form-item>
  140. </a-col>
  141. </template>
  142. <template v-else>
  143. <a-col :span="12">
  144. <a-form-item label="姓名"
  145. name="username">
  146. <a-input class="dialogInput"
  147. style="width: 200px"
  148. v-model:value="formState.username"
  149. placeholder="请输入姓名" />
  150. </a-form-item>
  151. </a-col>
  152. <a-col :span="12">
  153. <a-form-item label="身份证号码"
  154. name="cardnum">
  155. <a-input class="dialogInput"
  156. style="width: 200px"
  157. v-model:value="formState.cardnum"
  158. placeholder="请输入身份证号码" />
  159. </a-form-item>
  160. </a-col>
  161. <a-col :span="12">
  162. <a-form-item label="手机号码"
  163. name="mobilephone">
  164. <a-input class="dialogInput"
  165. style="width: 200px"
  166. v-model:value="formState.mobilephone"
  167. placeholder="请输入手机号码" />
  168. </a-form-item>
  169. </a-col>
  170. <a-col :span="12">
  171. <a-form-item label="身份证正面照"
  172. name="cardbackphotourl">
  173. <div class="upload">
  174. <a-upload action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
  175. :transform-file="transformFile">
  176. <a-button class="uploadBtn">上传</a-button>
  177. </a-upload>
  178. <div class="look">查看附件</div>
  179. </div>
  180. </a-form-item>
  181. </a-col>
  182. <a-col :span="12">
  183. <a-form-item label="邮箱"
  184. name="email">
  185. <a-input class="dialogInput"
  186. style="width: 200px"
  187. v-model:value="formState.email"
  188. placeholder="请输入邮箱" />
  189. </a-form-item>
  190. </a-col>
  191. <a-col :span="24">
  192. <a-form-item label="身份证反面照"
  193. name="cardfrontphotourl">
  194. <div class="upload">
  195. <a-upload action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
  196. :transform-file="transformFile">
  197. <a-button class="uploadBtn">上传</a-button>
  198. </a-upload>
  199. <div class="look">查看附件</div>
  200. </div>
  201. </a-form-item>
  202. </a-col>
  203. <a-col :span="12">
  204. <a-form-item label="联系电话"
  205. name="telphone">
  206. <a-input class="dialogInput"
  207. style="width: 200px"
  208. v-model:value="formState.telphone"
  209. placeholder="请输入联系电话" />
  210. </a-form-item>
  211. </a-col>
  212. <a-col :span="12">
  213. <a-form-item>
  214. &nbsp;
  215. </a-form-item>
  216. </a-col>
  217. </template>
  218. <a-col :span="24">
  219. <a-form-item label="通讯地址">
  220. <a-select class="inlineFormSelect"
  221. style="width: 205px"
  222. v-model:value="formState.provinceid"
  223. @change="getCityList"
  224. placeholder="请选择省">
  225. <a-select-option v-for="item in provinceList"
  226. :key="item.autoid"
  227. :value="item.autoid">
  228. {{ item.divisionname }}
  229. </a-select-option>
  230. </a-select>
  231. <a-select class="inlineFormSelect ml9"
  232. style="width: 205px"
  233. v-model:value="formState.cityid"
  234. @change="getDistrictList"
  235. placeholder="请选择市">
  236. <a-select-option v-for="item in cityList"
  237. :key="item.autoid"
  238. :value="item.autoid">
  239. {{ item.divisionname }}
  240. </a-select-option>
  241. </a-select>
  242. <a-select class="inlineFormSelect ml9"
  243. v-model:value="formState.districtid"
  244. style="width: 205px"
  245. placeholder="请选择县(区)">
  246. <a-select-option v-for="item in districtList"
  247. :key="item.autoid"
  248. :value="item.autoid">
  249. {{ item.divisionname }}
  250. </a-select-option>
  251. </a-select>
  252. </a-form-item>
  253. </a-col>
  254. <a-col :span="24">
  255. <a-form-item label="&nbsp;"
  256. name="cardaddress">
  257. <a-input class="dialogInput"
  258. style="width: 635px"
  259. v-model:value="formState.cardaddress"
  260. placeholder="请输入详细地址" />
  261. </a-form-item>
  262. </a-col>
  263. <a-col :span="24">
  264. <a-form-item label="备注"
  265. name="remark">
  266. <a-input class="dialogInput"
  267. style="width: 635px"
  268. v-model:value="formState.remark"
  269. placeholder="请输入备注" />
  270. </a-form-item>
  271. </a-col>
  272. </a-row>
  273. </a-form>
  274. </a-modal>
  275. </template>
  276. <script lang="ts">
  277. import { closeModal } from '@/common/setup/modal/index';
  278. import { defineComponent, PropType, ref, watchEffect } from 'vue';
  279. import { getCardType, handleForm, initFormState } from '../add/setup';
  280. import { AllEnums } from '@/services/go/commonService/interface';
  281. import { FormState } from '../add/interface';
  282. import { getAddress } from '@/services/go/adress';
  283. import { ModifyUserInfoApplyReq, QueryCustomInfoType } from '@/services/go/ermcp/customInfo/interface';
  284. import { getUserId } from '@/services/bus/account';
  285. import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
  286. import { QueryModifyUserInfoApply } from '@/services/go/ermcp/customInfo';
  287. import { mergeTwoObj } from '@/utils/objHandle';
  288. import { validateAction } from '@/common/setup/form';
  289. export default defineComponent({
  290. name: 'modify-custom',
  291. components: {},
  292. props: {
  293. selectedRow: {
  294. default: initFormState,
  295. type: Object as PropType<QueryCustomInfoType>,
  296. },
  297. },
  298. setup(props, context) {
  299. const { visible, cancel } = closeModal('custom_info_btn_modify');
  300. const loading = ref<boolean>(false);
  301. // 证件类型
  302. const cardTypeList = ref<AllEnums[]>(getCardType());
  303. // 表单
  304. const { formRef, formState, rules } = handleForm();
  305. // 地址
  306. const { cityList, districtList, provinceList, getCityList, getDistrictList } = getAddress();
  307. function isPersonal(): boolean {
  308. return formState.userinfotype === '1';
  309. }
  310. const userid = ref<number>(0);
  311. const countryid = ref<number>(0);
  312. watchEffect(() => {
  313. if (visible.value) {
  314. userid.value = props.selectedRow.userid;
  315. countryid.value = props.selectedRow.countryid;
  316. mergeTwoObj(formState, props.selectedRow);
  317. const { provinceid, cityid } = props.selectedRow;
  318. provinceid ? getCityList(provinceid) : (formState.provinceid = undefined);
  319. cityid ? getDistrictList(cityid) : ((formState.cityid = undefined), (formState.districtid = undefined));
  320. }
  321. });
  322. function submit(OperateType: 1 | 2) {
  323. validateAction<FormState>(formRef, formState).then((param) => {
  324. const reqParam: ModifyUserInfoApplyReq = {
  325. customername: param.customername, // 必填
  326. userid: userid.value,
  327. memberareaid: getUserId(),
  328. userinfotype: Number(param.userinfotype),
  329. username: param.customername,
  330. userstate: OperateType, // 1: 保存草稿 2: 新增
  331. cardtype: param.cardtype, // 证件类型
  332. cardnum: param.cardnum, // 证件号码
  333. nickname: param.nickname, // 昵称
  334. remark: param.remark, // 备注
  335. mobilephone: param.mobilephone, // 手机号码
  336. telphone: param.telphone, // 电话
  337. cardfrontphotourl: param.cardfrontphotourl, // 正面照片
  338. cardaddress: param.cardaddress, // 证件地址
  339. cityid: param.cityid, //
  340. districtid: param.districtid, // 地区
  341. countryid: countryid.value,
  342. provinceid: param.provinceid, //省
  343. contactname: param.contactname, // 联系人
  344. legalpersonname: param.legalpersonname, // 法人姓名(企业)
  345. taxpayernum: param.taxpayernum, // 纳税人识别号
  346. email: param.email, // email
  347. };
  348. requestResultLoadingAndInfo(QueryModifyUserInfoApply, reqParam, loading, OperateType === 1 ? ['保存草稿成功', '保存草稿失败:'] : ['新增客户资料成功', '新增客户资料失败:']).then(() => {
  349. cancel();
  350. context.emit('refresh');
  351. });
  352. });
  353. }
  354. return {
  355. formState,
  356. rules,
  357. formRef,
  358. cardTypeList,
  359. isPersonal,
  360. visible,
  361. cancel,
  362. submit,
  363. loading,
  364. cityList,
  365. districtList,
  366. provinceList,
  367. getCityList,
  368. getDistrictList,
  369. };
  370. },
  371. });
  372. </script>
  373. <style lang="less">
  374. .modify-custom {
  375. .upload {
  376. display: inline-flex;
  377. .ant-btn.uploadBtn {
  378. width: 60px;
  379. height: 30px;
  380. background: @m-blue0;
  381. border: 0;
  382. padding: 0;
  383. text-align: center;
  384. font-size: 14px;
  385. color: @m-white0;
  386. .rounded-corners(3px);
  387. &:hover {
  388. background: rgba(@m-blue0, 0);
  389. color: rgba(@m-white0, 0.8);
  390. }
  391. }
  392. .look {
  393. color: @m-blue0;
  394. font-size: 14px;
  395. margin-left: 10px;
  396. cursor: pointer;
  397. }
  398. }
  399. }
  400. </style
  401. >;