customerManagementAdd.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. <!--客户管理添加-->
  2. <template>
  3. <div class="center">
  4. <el-row>
  5. <el-col :span="12">
  6. <h2 class="bg-left titleup">{{ trader }}粮商</h2>
  7. </el-col>
  8. <el-col :span="12" class="bg-right">
  9. <el-button class="bg-bottom" type="primary" size="small" @click="cancel"><img width="6" height="10"
  10. style="vertical-align: bottom; margin-right: 3px" src="../../../public/img/lujing.png" alt="" />返回
  11. </el-button>
  12. </el-col>
  13. </el-row>
  14. <div class="unload">
  15. <ws-form ref="customerList" :model="customerList" label-width="120px">
  16. <ws-info-table>
  17. <div style="display: flex; width: 100%; text-align: center">
  18. <div style="width: 330px; margin: 0 auto">
  19. <div class="unload-img">上传身份证人像面</div>
  20. <el-upload class="avatar-uploader avatar-uploader1" action="https://www.zthymaoyi.com/upload/admin"
  21. :show-file-list="false" :on-success="upLoadSuccess1" :disabled="disabled">
  22. <img v-if="imageUrl1" :src="imageUrl1" class="avatar">
  23. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  24. </el-upload>
  25. </div>
  26. <div style="width: 330px; margin: 0 auto">
  27. <div class="unload-img">上传身份证国徽面</div>
  28. <el-upload class="avatar-uploader avatar-uploader2" action="https://www.zthymaoyi.com/upload/admin"
  29. :show-file-list="false" :on-success="upLoadSuccess2" :disabled="disabled">
  30. <img v-if="imageUrl2" :src="imageUrl2" class="avatar">
  31. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  32. </el-upload>
  33. </div>
  34. </div>
  35. <div style="display: flex; width: 100%; text-align: center">
  36. <div style="width:330px; margin: 0 auto">
  37. <div class="unload-img">上传银行卡正面</div>
  38. <el-upload class="avatar-uploader avatar-uploader3" action="https://www.zthymaoyi.com/upload/admin"
  39. :show-file-list="false" :on-success="bankSuccess1" :disabled="disabled">
  40. <img v-if="imageUrl3" :src="imageUrl3" class="avatar">
  41. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  42. </el-upload>
  43. </div>
  44. <div style="width:330px; margin: 0 auto">
  45. <div class="unload-img">上传银行卡反面</div>
  46. <el-upload class="avatar-uploader avatar-uploader4" action="https://www.zthymaoyi.com/upload/admin"
  47. :show-file-list="false" :on-success="bankSuccess2" :disabled="disabled">
  48. <img v-if="imageUrl4" :src="imageUrl4" class="avatar">
  49. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  50. </el-upload>
  51. </div>
  52. </div>
  53. <ws-form-item label="姓名" span="1" prop="customerName" label-width="80px">
  54. <ws-input v-model="customerList.customerName" placeholder="请输入姓名" maxlength="15" size="small"
  55. :disabled="disabled" />
  56. </ws-form-item>
  57. <ws-form-item label="身份证号" span="1" prop="customerNumberCard">
  58. <ws-input v-model="customerList.customerNumberCard" placeholder="请输入身份证号" maxlength="18" size="small"
  59. :disabled="disabled" />
  60. </ws-form-item>
  61. <ws-form-item label="银行卡号" span="1" prop="bankCard">
  62. <ws-input v-model="customerList.bankCard" placeholder="请输入银行卡号" maxlength="19" size="small"
  63. :disabled="disabled" />
  64. </ws-form-item>
  65. <ws-form-item label="开户行" span="1" prop="bankDeposit">
  66. <ws-input v-model="customerList.bankDeposit" placeholder="请输入开户行" maxlength="100" size="small"
  67. :disabled="disabled" />
  68. </ws-form-item>
  69. <ws-form-item label="开户支行" span="1" prop="bankDepositBranch">
  70. <ws-input v-if="bankInput" v-model="customerList.bankDepositBranch" placeholder="请输入开户支行" maxlength="100" size="small"
  71. :disabled="disabled" />
  72. <ws-select v-else v-model="customerList.bankDepositBranch" placeholder="请输入开户支行" :disabled="disabled">
  73. <ws-option v-for="item in bankList" :key="item" :label="item" :value="item" />
  74. </ws-select>
  75. <el-button type="primary" @click="bankInputChange" v-if="switchType != 2">{{bankText}}</el-button>
  76. </ws-form-item>
  77. <ws-form-item label="收款人姓名" span="1" prop="payeeName">
  78. <ws-input v-model="customerList.payeeName" placeholder="请输入收款人姓名" maxlength="15" size="small"
  79. :disabled="disabled" />
  80. </ws-form-item>
  81. <ws-form-item label="收款人身份证号" span="1" prop="payeeNumberCard">
  82. <ws-input v-model="customerList.payeeNumberCard" placeholder="请输入收款人身份证号" maxlength="18" size="small"
  83. :disabled="disabled" />
  84. </ws-form-item>
  85. <ws-form-item label="手机号" span="1" prop="customerPhone">
  86. <ws-input v-model="customerList.customerPhone" placeholder="请输入手机号" maxlength="11" size="small"
  87. :disabled="disabled" />
  88. </ws-form-item>
  89. <ws-form-item label="联系地址" span="1" prop="compAddress">
  90. <ws-input v-model="customerList.compAddress" placeholder="请输入联系地址" maxlength="100" size="small"
  91. :disabled="disabled" />
  92. </ws-form-item>
  93. <div v-if="this.switchType == 1 || this.switchType == 3" class = "jiaoYan">
  94. <el-button type="primary" class="veriCode" @click="toSend()" v-if="!sendDisabled">获取验证码</el-button>
  95. <el-button type="warning" class="veriCode" v-if="sendDisabled">{{sendText}}</el-button>
  96. <ws-input v-model="verifyCode" placeholder="请输入验证码" maxlength="100" size="small" :disabled="disabled" />
  97. </div>
  98. </ws-info-table>
  99. <div class="but">
  100. <el-button type="primary" @click="commit" v-if="switchType == 1 || switchType == 3">提交</el-button>
  101. <el-button type="primary" @click="cancel" v-if="switchType == 2">关闭</el-button>
  102. </div>
  103. </ws-form>
  104. </div>
  105. </div>
  106. </template>
  107. <script>
  108. import {
  109. customerAdd,
  110. customerIdentity,
  111. getCustomerLook,
  112. CustomerEdit,
  113. getIdentity,
  114. getBank,
  115. GetCustomerCode,
  116. GetCustomerCodeJY
  117. } from '@/model/houseSelfCollect/index'
  118. export default {
  119. components: {},
  120. watch: {},
  121. data() {
  122. return {
  123. imageUrl1: "",
  124. imageUrl2: "",
  125. imageUrl3: "",
  126. imageUrl4: "",
  127. dialogImageUrl: '',
  128. dialogVisible: false,
  129. customerList: {
  130. customerName: "",
  131. customerNumberCard: "",
  132. bankCard: "",
  133. bankDeposit: "",
  134. },
  135. disabledFlag: true,
  136. disabled: false,
  137. identity: [],
  138. bank: [],
  139. trader: '新增',
  140. switchType: '',
  141. identityImgUp: [{
  142. url: '',
  143. }, ],
  144. identityImgLow: [{
  145. url: '',
  146. }, ],
  147. bankImgUp: [{
  148. url: '',
  149. }, ],
  150. bankImgLow: [{
  151. url: '',
  152. }, ],
  153. identityUp: 'up',
  154. identityLow: 'low',
  155. bankUps: 'bankUp',
  156. bankLows: 'bankLow',
  157. sendText: '60S后重发',
  158. sendDisabled: false,
  159. verifyCode: "",
  160. bankList:[],
  161. bankInput:false,
  162. bankText:"手动填写"
  163. }
  164. },
  165. activated() {
  166. this.switchType = this.$route.query.types
  167. if (this.$route.query.types == null) {
  168. this.switchType = 1
  169. this.imageUrl1 = ""
  170. this.imageUrl2 = ""
  171. this.imageUrl3 = ""
  172. this.imageUrl4 = ""
  173. this.customerList = {}
  174. }
  175. let id = this.$route.query.id
  176. if (this.switchType == 2) {
  177. this.disabled = true
  178. this.trader = '查看'
  179. this.getList(id)
  180. } else if (this.switchType == 3) {
  181. this.disabled = false
  182. this.trader = '编辑'
  183. this.getList(id)
  184. }
  185. },
  186. methods: {
  187. bankInputChange(){
  188. this.bankInput = !this.bankInput
  189. if(this.bankInput){
  190. this.bankText = "自动识别"
  191. }
  192. else{
  193. this.bankText = "手动填写"
  194. }
  195. },
  196. handleRemove(file, index) {
  197. if (index == 1) {
  198. this.identityUp = ''
  199. } else if (index == 2) {
  200. this.identityLow = ''
  201. }
  202. if (this.switchType == 3) {
  203. for (let i = 0; i < this.identity.length; i++) {
  204. if (file.url == this.identity[i]) {
  205. this.identity.splice(i, 1, '')
  206. }
  207. }
  208. } else if (this.switchType == 1) {
  209. for (let i = 0; i < this.identity.length; i++) {
  210. if (file.response.url == this.identity[i]) {
  211. this.identity.splice(i, 1, '')
  212. }
  213. }
  214. }
  215. },
  216. handleRemove1(file, index) {
  217. if (index == 1) {
  218. this.bankUps = ''
  219. } else if (index == 2) {
  220. this.bankLows = ''
  221. }
  222. if (this.switchType == 3) {
  223. for (let i = 0; i < this.bank.length; i++) {
  224. if (file.url == this.bank[i]) {
  225. this.bank.splice(i, 1, '')
  226. }
  227. }
  228. } else if (this.switchType == 1) {
  229. for (let i = 0; i < this.bank.length; i++) {
  230. if (file.response.url == this.bank[i]) {
  231. this.bank.splice(i, 1, '')
  232. }
  233. }
  234. }
  235. },
  236. handlePictureCardPreview(file) {
  237. this.dialogImageUrl = file.url
  238. this.dialogVisible = true
  239. },
  240. // 发送验证码
  241. toSend() {
  242. let that = this;
  243. if (/^0?1[3|4|5|6|7|8][0-9]\d{8}$/.test(this.customerList.customerPhone)) {
  244. GetCustomerCode({
  245. phone: this.customerList.customerPhone
  246. })
  247. .toPromise().then((response) => {
  248. if (response == 'ok') {
  249. that.sendDisabled = true
  250. let sec = 60
  251. let interval = setInterval(() => {
  252. sec--;
  253. that.sendText = sec + 'S后重发'
  254. if (sec <= 0) {
  255. that.sendDisabled = false
  256. that.sendText = "获取验证码"
  257. clearInterval(interval)
  258. }
  259. }, 1000)
  260. } else {}
  261. })
  262. }
  263. },
  264. cancel() {
  265. this.customerList = {}
  266. this.verifyCode = ""
  267. this.$router.push({
  268. path: 'customerManagement'
  269. })
  270. },
  271. upLoadSuccess1(e) {
  272. this.identityUp = 'up'
  273. this.identity[0] = e.url
  274. this.imageUrl1 = e.url
  275. getIdentity({
  276. personImg: e.url
  277. })
  278. .toPromise()
  279. .then((response) => {
  280. if (response.recPerson ) {
  281. this.$set( this.customerList,'customerName',response.recPerson)
  282. this.$set( this.customerList,'payeeName',response.recPerson)
  283. }
  284. if (response.recPersonNo ) {
  285. this.$set( this.customerList,'customerNumberCard',response.recPersonNo)
  286. this.$set( this.customerList,'payeeNumberCard',response.recPersonNo)
  287. }
  288. })
  289. },
  290. upLoadSuccess2(e) {
  291. this.identityLow = 'low'
  292. this.identity[1] = e.url
  293. this.imageUrl2 = e.url
  294. getIdentity({
  295. personImg: e.url
  296. })
  297. .toPromise()
  298. .then((response) => {
  299. if (response.recPerson ) {
  300. this.$set( this.customerList,'customerName',response.recPerson)
  301. this.$set( this.customerList,'payeeName',response.recPerson)
  302. }
  303. if (response.recPersonNo ) {
  304. this.$set( this.customerList,'customerNumberCard',response.recPersonNo)
  305. this.$set( this.customerList,'payeeNumberCard',response.recPersonNo)
  306. }
  307. })
  308. },
  309. bankSuccess1(e) {
  310. this.bankUps = 'bankUp'
  311. this.bank[0] = e.url
  312. this.imageUrl3 = e.url
  313. getBank({
  314. bankImg: e.url
  315. })
  316. .toPromise()
  317. .then((response) => {
  318. if (response.bankNameZhihang.length > 0) {
  319. this.bankList = response.bankNameZhihang
  320. }
  321. if (response.bankNo) {
  322. this.$set(this.customerList,'bankCard',response.bankNo)
  323. }
  324. if (response.bankName) {
  325. this.$set(this.customerList,'bankDeposit',response.bankName)
  326. }
  327. })
  328. },
  329. bankSuccess2(e) {
  330. this.bankLows = 'bankLow'
  331. this.bank[1] = e.url
  332. this.imageUrl4 = e.url
  333. getBank({
  334. bankImg: e.url
  335. })
  336. .toPromise()
  337. .then((response) => {
  338. if (response.bankNameZhihang) {
  339. this.bankList = response.bankNameZhihang
  340. }
  341. if (response.bankNo) {
  342. this.$set(this.customerList,'bankCard',response.bankNo)
  343. }
  344. if (response.bankName) {
  345. this.$set(this.customerList,'bankDeposit',response.bankName)
  346. }
  347. })
  348. },
  349. commit() {
  350. if (!this.imageUrl1) {
  351. this.$message({
  352. message: '请上传身份证正面',
  353. type: 'warning',
  354. })
  355. return
  356. }
  357. if (!this.imageUrl3) {
  358. this.$message({
  359. message: '请上传银行卡正面',
  360. type: 'warning',
  361. })
  362. return
  363. }
  364. if (!this.customerList.customerName) {
  365. this.$message({
  366. message: '请输入姓名',
  367. type: 'warning',
  368. })
  369. return
  370. }
  371. if (!this.customerList.bankCard) {
  372. this.$message({
  373. message: '请输入输入银行卡号',
  374. type: 'warning',
  375. })
  376. return
  377. }
  378. if (!this.customerList.bankDeposit) {
  379. this.$message({
  380. message: '请输入开户行',
  381. type: 'warning',
  382. })
  383. return
  384. }
  385. if (!this.customerList.bankDepositBranch) {
  386. this.$message({
  387. message: '请输入开户支行',
  388. type: 'warning',
  389. })
  390. return
  391. }
  392. if (this.customerList.payeeNumberCard.length != 18) {
  393. this.$message({
  394. message: '收款人身份证号输入有误,请重新输入',
  395. type: 'warning',
  396. })
  397. return
  398. }
  399. if (!this.customerList.customerPhone) {
  400. this.$message({
  401. message: '请输入手机号',
  402. type: 'warning',
  403. })
  404. return
  405. }
  406. if (this.customerList.customerPhone.length != 11) {
  407. this.$message({
  408. message: '输入的手机号有误,请重新输入',
  409. type: 'warning',
  410. })
  411. return
  412. }
  413. // 验证码校验
  414. GetCustomerCodeJY({
  415. phone: this.customerList.customerPhone,
  416. verifyCode: this.verifyCode
  417. })
  418. .toPromise()
  419. .then((response) => {
  420. this.customerList.compId = sessionStorage.getItem('ws-pf_compId')
  421. this.customerList.cardAddressUrl = this.identity.toString()
  422. this.customerList.payeeAddressUrl = this.bank.toString()
  423. this.customerList.customerTypeFlag = 1
  424. this.customerList.customerType = '个人'
  425. if (this.switchType == 1) {
  426. this.$confirm('确定提交客户信息?', '提示', {
  427. confirmButtonText: '确定',
  428. cancelButtonText: '取消',
  429. type: 'warning',
  430. })
  431. .then(() => {
  432. customerAdd(this.customerList)
  433. .toPromise()
  434. .then((response) => {
  435. this.$message.success('添加成功')
  436. this.customerList = {}
  437. this.verifyCode = ""
  438. this.$router.go(-1)
  439. })
  440. })
  441. .catch(() => {
  442. return false
  443. })
  444. } else if (this.switchType == 3) {
  445. this.$confirm('确定修改客户信息?', '提示', {
  446. confirmButtonText: '确定',
  447. cancelButtonText: '取消',
  448. type: 'warning',
  449. })
  450. .then(() => {
  451. CustomerEdit(this.customerList)
  452. .toPromise()
  453. .then((response) => {
  454. this.$message.success('修改成功')
  455. this.customerList = {}
  456. this.verifyCode = ""
  457. this.$router.push({
  458. path: 'customerManagement'
  459. })
  460. })
  461. })
  462. .catch(() => {
  463. return false
  464. })
  465. }
  466. })
  467. },
  468. getList(ids) {
  469. getCustomerLook({
  470. id: ids,
  471. authenticationStatusKey: 7
  472. })
  473. .toPromise()
  474. .then((response) => {
  475. this.customerList = response
  476. this.identity = this.customerList.cardAddressUrl.split(',')
  477. this.bank = this.customerList.payeeAddressUrl.split(',')
  478. this.imageUrl1 = this.identity[0]
  479. this.imageUrl2 = this.identity[1]
  480. this.imageUrl3 = this.bank[0]
  481. this.imageUrl4 = this.bank[1]
  482. })
  483. },
  484. },
  485. }
  486. </script>
  487. <style lang="scss" scoped>
  488. .avatar-uploader1 {
  489. background: url('../../../public/img/identityup.png');
  490. }
  491. .avatar-uploader2 {
  492. background: url('../../../public/img/identitylow.png');
  493. }
  494. .avatar-uploader3 {
  495. background: url('../../../public/img/bankup.png');
  496. }
  497. .avatar-uploader4 {
  498. background: url('../../../public/img/banklow.png');
  499. }
  500. /deep/.el-upload {
  501. height: 200px;
  502. }
  503. .avatar-uploader {
  504. background-size: 100% 100%;
  505. }
  506. .avatar-uploader .el-upload {
  507. border: 1px dashed #d9d9d9;
  508. border-radius: 6px;
  509. cursor: pointer;
  510. position: relative;
  511. overflow: hidden;
  512. }
  513. .avatar-uploader .el-upload:hover {
  514. border-color: #409EFF;
  515. }
  516. .avatar-uploader-icon {
  517. font-size: 28px;
  518. color: #8c939d;
  519. width: 178px;
  520. height: 178px;
  521. line-height: 178px;
  522. text-align: center;
  523. }
  524. .avatar {
  525. width: 330px;
  526. height: 103%;
  527. display: block;
  528. }
  529. .center {
  530. background: #f6f7fc;
  531. }
  532. .seach {
  533. display: flex;
  534. align-items: center;
  535. .find {
  536. width: 32px;
  537. }
  538. .search-left {
  539. display: flex;
  540. }
  541. }
  542. .ws-info-table {
  543. border: none;
  544. width: 80%;
  545. margin: 0 auto;
  546. }
  547. .ws-info-table .el-form-item {
  548. width: 50%;
  549. border: none;
  550. }
  551. /deep/.ws-info-table .el-form-item .el-form-item__label {
  552. width: 30%;
  553. text-align: center;
  554. background: #ffffff;
  555. font-size: 14px;
  556. color: #8890b1;
  557. }
  558. /deep/.ws-info-table .el-form-item .el-form-item__content {
  559. border: none;
  560. }
  561. .bg-left {
  562. padding-left: 30px;
  563. }
  564. .bg-right {
  565. padding-right: 10px;
  566. text-align: right;
  567. }
  568. .bg-bottom {
  569. margin: 15px 0px;
  570. }
  571. .titleup {
  572. position: relative;
  573. }
  574. .titleup::before {
  575. content: '';
  576. display: inline-block;
  577. width: 5px;
  578. height: 30px;
  579. background: #5473e8;
  580. position: absolute;
  581. left: 0;
  582. }
  583. .unload {
  584. background: #ffffff;
  585. padding-top: 20px;
  586. }
  587. .but {
  588. text-align: center;
  589. margin: 20px auto;
  590. }
  591. /deep/.up .el-upload--picture-card {
  592. display: none;
  593. }
  594. /deep/.low .el-upload--picture-card {
  595. display: none;
  596. }
  597. /deep/.bankUp .el-upload--picture-card {
  598. display: none;
  599. }
  600. /deep/.bankLow .el-upload--picture-card {
  601. display: none;
  602. }
  603. .unload-img {
  604. margin: 20px 0;
  605. }
  606. .veriCode {
  607. margin: 0 9px;
  608. }
  609. .jiaoYan{
  610. display: flex;
  611. width: 50%;
  612. padding: 0 9px;
  613. }
  614. /deep/.jiaoYan .el-input__inner{
  615. width: 100%;
  616. }
  617. </style>