form.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. <!-- -->
  2. <template>
  3. <div class="m-container">
  4. <h2>
  5. <el-page-header
  6. @back="onCancel"
  7. :content="payType == 'create' ? '创建账号' : '修改账号'"
  8. ></el-page-header>
  9. </h2>
  10. <!-- m-core -->
  11. <div class="w1200" style="overflow: hidden">
  12. <el-form
  13. :model="form"
  14. :rules="rules"
  15. ref="accountForm"
  16. label-position="right"
  17. label-width="180px"
  18. >
  19. <el-card class="box-card">
  20. <el-alert
  21. title="企业信息"
  22. :closable="false"
  23. type="info"
  24. style="margin: 20px 0"
  25. >
  26. </el-alert>
  27. <el-col :span="12" :lg="14" :md="20" :sm="20" :xs="24">
  28. <el-form-item label="商户号" prop="memberId">
  29. <el-input
  30. v-model="form.memberId"
  31. :disabled="payType == 'update' ? true : false"
  32. placeholder="请输入商户号"
  33. ></el-input>
  34. </el-form-item>
  35. <el-form-item label="公司名称" prop="name">
  36. <el-input
  37. v-model="form.name"
  38. placeholder="请输入公司名称"
  39. ></el-input>
  40. </el-form-item>
  41. <el-form-item label="统一社会信用码" prop="socialCreditCode">
  42. <el-input
  43. v-model="form.socialCreditCode"
  44. placeholder="请输入统一社会信用码"
  45. ></el-input>
  46. </el-form-item>
  47. <el-form-item
  48. label="统一社会信用码有效期"
  49. prop="socialCreditCodeExpires"
  50. >
  51. <el-date-picker
  52. v-model="form.socialCreditCodeExpires"
  53. :picker-options="{ firstDayOfWeek: 1 }"
  54. value-format="yyyyMMdd"
  55. type="date"
  56. placeholder="请选择统一社会信用码有效期"
  57. >
  58. </el-date-picker>
  59. </el-form-item>
  60. <el-form-item label="公司法人" prop="legalPerson">
  61. <el-input
  62. v-model="form.legalPerson"
  63. placeholder="请输入公司法人"
  64. ></el-input>
  65. </el-form-item>
  66. <el-form-item label="公司法人手机号" prop="legalMp">
  67. <el-input
  68. v-model="form.legalMp"
  69. maxlength="11"
  70. placeholder="请输入公司法人手机号"
  71. ></el-input>
  72. </el-form-item>
  73. <el-form-item label="法人身份证号" prop="legalCertId">
  74. <el-input
  75. v-model="form.legalCertId"
  76. placeholder="请输入法人身份证号"
  77. ></el-input>
  78. </el-form-item>
  79. <el-form-item label="身份证有效期" prop="legalCertIdExpires">
  80. <el-date-picker
  81. v-model="form.legalCertIdExpires"
  82. :picker-options="{ firstDayOfWeek: 1 }"
  83. value-format="yyyyMMdd"
  84. type="date"
  85. placeholder="请选择身份证有效期"
  86. >
  87. </el-date-picker>
  88. </el-form-item>
  89. <el-form-item label="经营范围" prop="businessScope">
  90. <!-- <el-input v-model="form.businessScope" placeholder="请输入经营范围"></el-input> -->
  91. <el-input
  92. type="textarea"
  93. :rows="3"
  94. v-model="form.businessScope"
  95. placeholder="请输入经营范围"
  96. ></el-input>
  97. </el-form-item>
  98. <el-form-item label="公司地址" prop="address">
  99. <el-input
  100. v-model="form.address"
  101. placeholder="请输入公司地址"
  102. ></el-input>
  103. </el-form-item>
  104. <el-form-item label="证照文件" prop="multipartFile">
  105. <template slot="label">
  106. 证照文件
  107. <el-tooltip placement="top" popper-class="mTooltip">
  108. <div slot="content">
  109. 内容须包含三证合一证件照、法人身份证正面照、法人身份证反面照、开户银行许可证照。
  110. 压缩 zip包后上传。最大限制为 9 M。
  111. <!-- 最大限制为 9 M。 -->
  112. </div>
  113. <i
  114. class="el-icon-question micon el-tooltip"
  115. style="
  116. font-size: 18px;
  117. color: #f56c6c;
  118. top: 2px;
  119. position: relative;
  120. "
  121. ></i>
  122. </el-tooltip>
  123. </template>
  124. <!-- <el-input type="file" class="uploadFile" v-model="form.multipartFile"></el-input> -->
  125. <el-upload
  126. class="avatar-upload"
  127. ref="upload"
  128. action="/api-web/uploadFile"
  129. :headers="headers"
  130. :on-preview="handlePreview"
  131. :on-remove="handleRemove"
  132. :on-change="handleChange"
  133. :file-list="fileList"
  134. accept=".zip"
  135. :multiple="false"
  136. :limit="1"
  137. :auto-upload="false"
  138. >
  139. <el-button slot="trigger" type="primary">选取文件</el-button>
  140. <!-- ,且不超过500kb -->
  141. <div
  142. slot="tip"
  143. style="display: inline; padding-left: 20px"
  144. class="el-upload__tip"
  145. >
  146. 只能上传一个文件
  147. </div>
  148. </el-upload>
  149. <!-- <el-upload class="avatar-uploader"
  150. action="/api-web/uploadFile"
  151. :headers="headers"
  152. :show-file-list="false"
  153. :on-success="handleAvatarSuccess"
  154. :before-upload="beforeAvatarUpload">
  155. <img v-if="form.multipartFile"
  156. :src="form.coverImg"
  157. class="avatar" />
  158. <i v-else
  159. class="el-icon-plus avatar-uploader-icon"></i>
  160. </el-upload> -->
  161. </el-form-item>
  162. <el-form-item label="邮编" prop="zipCode">
  163. <el-input
  164. v-model="form.zipCode"
  165. placeholder="请输入邮编"
  166. ></el-input>
  167. </el-form-item>
  168. </el-col>
  169. </el-card>
  170. <el-card class="box-card">
  171. <el-alert
  172. title="账户设置"
  173. :closable="false"
  174. type="info"
  175. style="margin: 20px 0"
  176. >
  177. </el-alert>
  178. <el-col :span="12" :lg="14" :md="20" :sm="20" :xs="24">
  179. <el-form-item label="银行卡号" prop="cardNo">
  180. <el-input
  181. v-model="form.cardNo"
  182. placeholder="请输入银行卡号"
  183. ></el-input>
  184. </el-form-item>
  185. <el-form-item label="所属银行" prop="bankCode">
  186. <el-select v-model="form.bankCode" placeholder="请选择所属银行">
  187. <el-option
  188. v-for="(item, index) in backList"
  189. :key="index"
  190. :label="item.title"
  191. :value="item.value"
  192. ></el-option>
  193. </el-select>
  194. </el-form-item>
  195. <el-form-item label="银行账户类型" prop="bankAcctType">
  196. <el-select
  197. v-model="form.bankAcctType"
  198. placeholder="请选择银行账户类型"
  199. >
  200. <el-option label="对公" value="1"></el-option>
  201. <el-option label="对私" value="2"></el-option>
  202. </el-select>
  203. </el-form-item>
  204. <el-form-item label="银行卡对应的户名" prop="cardName">
  205. <el-input
  206. v-model="form.cardName"
  207. placeholder="请输入银行卡对应的户名"
  208. ></el-input>
  209. </el-form-item>
  210. <el-form-item label="省市" required>
  211. <el-row>
  212. <el-col :span="12">
  213. <el-form-item prop="provCode" style="margin-bottom: 0">
  214. <el-select
  215. v-model="form.provCode"
  216. style="width: 98% !important"
  217. @change="onProvChange"
  218. placeholder="请选择省份"
  219. >
  220. <el-option
  221. v-for="(item, index) in cityList"
  222. :key="index"
  223. :label="item.title"
  224. :value="item.value"
  225. ></el-option>
  226. </el-select>
  227. </el-form-item>
  228. </el-col>
  229. <el-col :span="12">
  230. <el-form-item prop="areaCode" style="margin-bottom: 0">
  231. <el-select
  232. v-model="form.areaCode"
  233. style="width: 100% !important"
  234. placeholder="请选择城市"
  235. >
  236. <el-option
  237. v-for="(item, index) in selectListCity"
  238. :key="index"
  239. :label="item.title"
  240. :value="item.value"
  241. ></el-option>
  242. </el-select>
  243. </el-form-item>
  244. </el-col>
  245. </el-row>
  246. </el-form-item>
  247. <el-form-item>
  248. <el-button type="primary" @click="onSubmit('accountForm')"
  249. >确 定</el-button
  250. >
  251. <el-button @click="onCancel">取 消</el-button>
  252. </el-form-item>
  253. </el-col>
  254. </el-card>
  255. </el-form>
  256. </div>
  257. </div>
  258. </template>
  259. <script>
  260. import { cityJson } from "../../utils/cityJson";
  261. import { bankJson } from "../../utils/bankJson";
  262. import { getToken } from "@/utils/auth";
  263. import load from "@/utils/loading";
  264. import { createMember, updateMember } from "./api.js";
  265. import { isvalidPhone } from "@/utils/validate";
  266. let validPhone = (rule, value, callback) => {
  267. if (!value) {
  268. callback(new Error("请输入公司法人手机号"));
  269. } else if (!isvalidPhone(value)) {
  270. callback(new Error("请输入正确的11位手机号码"));
  271. } else {
  272. callback();
  273. }
  274. };
  275. export default {
  276. name: "ADaPayAccount",
  277. data() {
  278. const query = this.$route.query;
  279. return {
  280. payType: query.type,
  281. row: query.row ? JSON.parse(query.row) : {},
  282. backList: bankJson,
  283. cityList: cityJson,
  284. selectListCity: [],
  285. headers: {
  286. Authorization: getToken(),
  287. },
  288. fileList: [],
  289. files: null, // 上传对象
  290. id: null, // 编号
  291. form: {
  292. memberId: null,
  293. name: null,
  294. legalPerson: null,
  295. legalMp: null,
  296. legalCertId: null,
  297. legalCertIdExpires: null,
  298. cardNo: null,
  299. bankCode: null,
  300. provCode: null,
  301. areaCode: null,
  302. socialCreditCode: null,
  303. socialCreditCodeExpires: null,
  304. businessScope: null,
  305. address: null,
  306. multipartFile: null,
  307. zipCode: null,
  308. bankAcctType: null,
  309. cardName: null,
  310. },
  311. rules: {
  312. memberId: [
  313. { required: true, message: "请输入商户号", trigger: "blur" },
  314. ],
  315. name: [{ required: true, message: "请输入公司名称", trigger: "blur" }],
  316. legalPerson: [
  317. { required: true, message: "请输入公司法人", trigger: "blur" },
  318. ],
  319. legalMp: [
  320. {
  321. type: "number",
  322. required: true,
  323. validator: validPhone,
  324. trigger: "blur",
  325. },
  326. ],
  327. legalCertId: [
  328. { required: true, message: "请输入法人身份证号", trigger: "blur" },
  329. ],
  330. legalCertIdExpires: [
  331. { required: true, message: "请选择身份证有效期", trigger: "change" },
  332. ],
  333. cardNo: [
  334. { required: true, message: "请输入银行卡号", trigger: "blur" },
  335. ],
  336. bankCode: [
  337. { required: true, message: "请选择所属银行", trigger: "change" },
  338. ],
  339. provCode: [
  340. { required: true, message: "请选择省份", trigger: "change" },
  341. ],
  342. areaCode: [
  343. { required: true, message: "请选择城市", trigger: "change" },
  344. ],
  345. socialCreditCode: [
  346. { required: true, message: "请输入统一社会信用码", trigger: "blur" },
  347. ],
  348. socialCreditCodeExpires: [
  349. {
  350. required: true,
  351. message: "请选择统一社会信用码有效期",
  352. trigger: "change",
  353. },
  354. ],
  355. businessScope: [
  356. { required: true, message: "请输入经营范围", trigger: "blur" },
  357. ],
  358. address: [
  359. { required: true, message: "请输入公司地址", trigger: "blur" },
  360. ],
  361. multipartFile: [
  362. { required: true, message: "请上传证照文件", trigger: "change" },
  363. ],
  364. zipCode: [{ required: true, message: "请输入邮编", trigger: "blur" }],
  365. cardName: [
  366. {
  367. required: true,
  368. message: "请输入银行卡对应的户名",
  369. trigger: "blur",
  370. },
  371. ],
  372. bankAcctType: [
  373. {
  374. required: true,
  375. message: "银行账户类型",
  376. trigger: "blur",
  377. },
  378. ],
  379. },
  380. };
  381. },
  382. mounted() {
  383. this.__init();
  384. },
  385. methods: {
  386. __init() {
  387. const query = this.$route.query;
  388. this.payType = query.type;
  389. this.row = query.row ? JSON.parse(query.row) : {};
  390. this.files = null;
  391. this.fileList = [];
  392. this.form.multipartFile = null;
  393. if (this.payType == "update") {
  394. const row = this.row;
  395. this.id = row.id;
  396. this.form = {
  397. memberId: row.memberId,
  398. name: row.name,
  399. legalPerson: row.legalPerson,
  400. legalMp: row.legalMp,
  401. legalCertId: row.legalCertId,
  402. legalCertIdExpires: row.legalCertIdExpires,
  403. cardNo: row.cardNo,
  404. bankCode: row.bankCode,
  405. provCode: row.provCode,
  406. areaCode: row.areaCode,
  407. socialCreditCode: row.socialCreditCode,
  408. socialCreditCodeExpires: row.socialCreditCodeExpires,
  409. businessScope: row.businessScope,
  410. address: row.address,
  411. multipartFile: row.multipartFile,
  412. zipCode: row.zipCode,
  413. bankAcctType: row.bankAcctType,
  414. cardName: row.cardName,
  415. };
  416. this.cityList.forEach((item) => {
  417. if (item.value == row.provCode) {
  418. this.selectListCity = item.cities;
  419. }
  420. });
  421. } else if (this.payType == "create") {
  422. // this.form = {
  423. // memberId: null,
  424. // name: null,
  425. // legalPerson: null,
  426. // legalMp: null,
  427. // legalCertId: null,
  428. // legalCertIdExpires: null,
  429. // cardNo: null,
  430. // bankCode: null,
  431. // provCode: null,
  432. // areaCode: null,
  433. // socialCreditCode: null,
  434. // socialCreditCodeExpires: null,
  435. // businessScope: null,
  436. // address: null,
  437. // multipartFile: null,
  438. // zipCode: null
  439. // }
  440. this.$refs["accountForm"].resetFields();
  441. }
  442. },
  443. async onSubmit(formName) {
  444. this.$refs[formName].validate((valid) => {
  445. if (valid) {
  446. const form = this.form;
  447. let formData = new FormData();
  448. formData.append("memberId", form.memberId);
  449. formData.append("name", form.name);
  450. formData.append("legalPerson", form.legalPerson);
  451. formData.append("legalMp", form.legalMp);
  452. formData.append("legalCertId", form.legalCertId);
  453. formData.append("legalCertIdExpires", form.legalCertIdExpires);
  454. formData.append("cardNo", form.cardNo);
  455. formData.append("bankCode", form.bankCode);
  456. formData.append("provCode", form.provCode);
  457. formData.append("areaCode", form.areaCode);
  458. formData.append("socialCreditCode", form.socialCreditCode);
  459. formData.append(
  460. "socialCreditCodeExpires",
  461. form.socialCreditCodeExpires
  462. );
  463. formData.append("businessScope", form.businessScope);
  464. formData.append("address", form.address);
  465. formData.append("multipartFile", form.multipartFile);
  466. formData.append("zipCode", form.zipCode);
  467. formData.append("bankAcctType", form.bankAcctType);
  468. formData.append("cardName", form.cardName);
  469. if (this.payType == "create") {
  470. createMember(formData).then((res) => {
  471. if (res.code == 200) {
  472. this.$message.success("保存成功");
  473. this.onCancel();
  474. } else {
  475. this.$message.error(res.msg);
  476. }
  477. });
  478. } else if (this.payType == "update") {
  479. formData.append("id", this.id);
  480. updateMember(formData).then((res) => {
  481. if (res.code == 200) {
  482. this.$message.success("保存成功");
  483. this.onCancel();
  484. } else {
  485. this.$message.error(res.msg);
  486. }
  487. });
  488. }
  489. } else {
  490. this.$nextTick(() => {
  491. let isError = document.getElementsByClassName("is-error");
  492. isError[0].scrollIntoView({
  493. block: "center",
  494. behavior: "smooth",
  495. });
  496. });
  497. return false;
  498. }
  499. });
  500. },
  501. handleChange(file) {
  502. console.log(file);
  503. const isLt2M = file.size / 1024 / 1024 < 9;
  504. if (!isLt2M) {
  505. this.$message.error(`上传文件大小不能超过 ${9}MB!`);
  506. this.fileList = [];
  507. return;
  508. }
  509. this.files = file;
  510. this.form.multipartFile = file.raw;
  511. this.$refs["accountForm"].validateField("multipartFile");
  512. },
  513. handleRemove(file, fileList) {
  514. this.files = null;
  515. this.form.multipartFile = null;
  516. },
  517. handlePreview(file) {
  518. // (file);
  519. },
  520. onProvChange(value) {
  521. this.form.areaCode = null;
  522. this.cityList.forEach((item) => {
  523. if (item.value == value) {
  524. this.selectListCity = item.cities;
  525. }
  526. });
  527. },
  528. onCancel() {
  529. this.files = null;
  530. this.fileList = [];
  531. this.form.multipartFile = null;
  532. this.$store.dispatch("delVisitedViews", this.$route);
  533. this.$router.push({
  534. path: "/sysBasics/adapayManager",
  535. });
  536. },
  537. },
  538. };
  539. </script>
  540. <style lang='scss' scoped>
  541. .box-card {
  542. margin-bottom: 20px;
  543. padding-bottom: 20px;
  544. }
  545. .el-input,
  546. .el-textarea,
  547. .el-select {
  548. width: 100% !important;
  549. }
  550. .el-button--primary {
  551. color: #fff;
  552. &:hover,
  553. &:active,
  554. &:focus {
  555. color: #fff;
  556. }
  557. }
  558. /deep/.avatar-uploader {
  559. .el-upload {
  560. border: 1px dashed #d9d9d9;
  561. border-radius: 6px;
  562. cursor: pointer;
  563. position: relative;
  564. overflow: hidden;
  565. &:hover {
  566. border-color: #409eff;
  567. }
  568. }
  569. }
  570. .uploadFile {
  571. /deep/.el-input__inner {
  572. padding: 0;
  573. height: 40px;
  574. line-height: 32px;
  575. }
  576. }
  577. .avatar-uploader-icon {
  578. font-size: 28px;
  579. color: #8c939d;
  580. width: 178px;
  581. height: 178px;
  582. line-height: 178px;
  583. text-align: center;
  584. }
  585. .avatar {
  586. width: 178px;
  587. height: 178px;
  588. display: block;
  589. }
  590. .w1200 {
  591. width: 1000px;
  592. margin: 0 auto;
  593. }
  594. </style>