customerManagementAdd.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  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 type="number" @mousewheel.native.prevent 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 type="number" @mousewheel.native.prevent 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 type="number" @mousewheel.native.prevent 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. if (response.recPersonAddr ) {
  289. this.$set( this.customerList,'compAddress',response.recPersonAddr)
  290. }
  291. })
  292. },
  293. upLoadSuccess2(e) {
  294. this.identityLow = 'low'
  295. this.identity[1] = e.url
  296. this.imageUrl2 = e.url
  297. getIdentity({
  298. personImg: e.url
  299. })
  300. .toPromise()
  301. .then((response) => {
  302. if (response.recPerson ) {
  303. this.$set( this.customerList,'customerName',response.recPerson)
  304. this.$set( this.customerList,'payeeName',response.recPerson)
  305. }
  306. if (response.recPersonNo ) {
  307. this.$set( this.customerList,'customerNumberCard',response.recPersonNo)
  308. this.$set( this.customerList,'payeeNumberCard',response.recPersonNo)
  309. }
  310. if (response.recPersonAddr ) {
  311. this.$set( this.customerList,'compAddress',response.recPersonAddr)
  312. }
  313. })
  314. },
  315. bankSuccess1(e) {
  316. this.bankUps = 'bankUp'
  317. this.bank[0] = e.url
  318. this.imageUrl3 = e.url
  319. getBank({
  320. bankImg: e.url
  321. })
  322. .toPromise()
  323. .then((response) => {
  324. if (response.bankNameZhihang.length > 0) {
  325. this.bankList = response.bankNameZhihang
  326. }
  327. if (response.bankNo) {
  328. this.$set(this.customerList,'bankCard',response.bankNo)
  329. }
  330. if (response.bankName) {
  331. this.$set(this.customerList,'bankDeposit',response.bankName)
  332. }
  333. })
  334. },
  335. bankSuccess2(e) {
  336. this.bankLows = 'bankLow'
  337. this.bank[1] = e.url
  338. this.imageUrl4 = e.url
  339. getBank({
  340. bankImg: e.url
  341. })
  342. .toPromise()
  343. .then((response) => {
  344. if (response.bankNameZhihang) {
  345. this.bankList = response.bankNameZhihang
  346. }
  347. if (response.bankNo) {
  348. this.$set(this.customerList,'bankCard',response.bankNo)
  349. }
  350. if (response.bankName) {
  351. this.$set(this.customerList,'bankDeposit',response.bankName)
  352. }
  353. })
  354. },
  355. commit() {
  356. if (!this.imageUrl1) {
  357. this.$message({
  358. message: '请上传身份证正面',
  359. type: 'warning',
  360. })
  361. return
  362. }
  363. if (!this.imageUrl3) {
  364. this.$message({
  365. message: '请上传银行卡正面',
  366. type: 'warning',
  367. })
  368. return
  369. }
  370. if (!this.customerList.customerName) {
  371. this.$message({
  372. message: '请输入姓名',
  373. type: 'warning',
  374. })
  375. return
  376. }
  377. if (!this.customerList.bankCard) {
  378. this.$message({
  379. message: '请输入输入银行卡号',
  380. type: 'warning',
  381. })
  382. return
  383. }
  384. if (!this.customerList.bankDeposit) {
  385. this.$message({
  386. message: '请输入开户行',
  387. type: 'warning',
  388. })
  389. return
  390. }
  391. if (!this.customerList.bankDepositBranch) {
  392. this.$message({
  393. message: '请输入开户支行',
  394. type: 'warning',
  395. })
  396. return
  397. }
  398. if (this.customerList.payeeNumberCard.length != 18) {
  399. this.$message({
  400. message: '收款人身份证号输入有误,请重新输入',
  401. type: 'warning',
  402. })
  403. return
  404. }
  405. if (!this.customerList.customerPhone) {
  406. this.$message({
  407. message: '请输入手机号',
  408. type: 'warning',
  409. })
  410. return
  411. }
  412. if (this.customerList.customerPhone.length != 11) {
  413. this.$message({
  414. message: '输入的手机号有误,请重新输入',
  415. type: 'warning',
  416. })
  417. return
  418. }
  419. // 验证码校验
  420. GetCustomerCodeJY({
  421. phone: this.customerList.customerPhone,
  422. verifyCode: this.verifyCode
  423. })
  424. .toPromise()
  425. .then((response) => {
  426. this.customerList.compId = sessionStorage.getItem('ws-pf_compId')
  427. this.customerList.cardAddressUrl = this.identity.toString()
  428. this.customerList.payeeAddressUrl = this.bank.toString()
  429. this.customerList.customerTypeFlag = 1
  430. this.customerList.customerType = '个人'
  431. if (this.switchType == 1) {
  432. this.$confirm('确定提交客户信息?', '提示', {
  433. confirmButtonText: '确定',
  434. cancelButtonText: '取消',
  435. type: 'warning',
  436. })
  437. .then(() => {
  438. customerAdd(this.customerList)
  439. .toPromise()
  440. .then((response) => {
  441. this.$message.success('添加成功')
  442. this.customerList = {}
  443. this.verifyCode = ''
  444. this.$router.go(-1)
  445. })
  446. })
  447. .catch(() => {
  448. return false
  449. })
  450. } else if (this.switchType == 3) {
  451. this.$confirm('确定修改客户信息?', '提示', {
  452. confirmButtonText: '确定',
  453. cancelButtonText: '取消',
  454. type: 'warning',
  455. })
  456. .then(() => {
  457. CustomerEdit(this.customerList)
  458. .toPromise()
  459. .then((response) => {
  460. this.$message.success('修改成功')
  461. this.customerList = {}
  462. this.verifyCode = ''
  463. this.$router.push({
  464. path: 'customerManagement'
  465. })
  466. })
  467. })
  468. .catch(() => {
  469. return false
  470. })
  471. }
  472. })
  473. },
  474. getList(ids) {
  475. getCustomerLook({
  476. id: ids,
  477. authenticationStatusKey: 7
  478. })
  479. .toPromise()
  480. .then((response) => {
  481. this.customerList = response
  482. this.identity = this.customerList.cardAddressUrl.split(',')
  483. this.bank = this.customerList.payeeAddressUrl.split(',')
  484. this.imageUrl1 = this.identity[0]
  485. this.imageUrl2 = this.identity[1]
  486. this.imageUrl3 = this.bank[0]
  487. this.imageUrl4 = this.bank[1]
  488. })
  489. },
  490. },
  491. }
  492. </script>
  493. <style lang="scss" scoped>
  494. .avatar-uploader1 {
  495. background: url('../../../public/img/identityup.png');
  496. }
  497. .avatar-uploader2 {
  498. background: url('../../../public/img/identitylow.png');
  499. }
  500. .avatar-uploader3 {
  501. background: url('../../../public/img/bankup.png');
  502. }
  503. .avatar-uploader4 {
  504. background: url('../../../public/img/banklow.png');
  505. }
  506. /deep/.el-upload {
  507. height: 200px;
  508. }
  509. .avatar-uploader {
  510. background-size: 100% 100%;
  511. }
  512. .avatar-uploader .el-upload {
  513. border: 1px dashed #d9d9d9;
  514. border-radius: 6px;
  515. cursor: pointer;
  516. position: relative;
  517. overflow: hidden;
  518. }
  519. .avatar-uploader .el-upload:hover {
  520. border-color: #409EFF;
  521. }
  522. .avatar-uploader-icon {
  523. font-size: 28px;
  524. color: #8c939d;
  525. width: 178px;
  526. height: 178px;
  527. line-height: 178px;
  528. text-align: center;
  529. }
  530. .avatar {
  531. width: 330px;
  532. height: 103%;
  533. display: block;
  534. }
  535. .center {
  536. background: #f6f7fc;
  537. }
  538. .seach {
  539. display: flex;
  540. align-items: center;
  541. .find {
  542. width: 32px;
  543. }
  544. .search-left {
  545. display: flex;
  546. }
  547. }
  548. .ws-info-table {
  549. border: none;
  550. width: 80%;
  551. margin: 0 auto;
  552. }
  553. .ws-info-table .el-form-item {
  554. width: 50%;
  555. border: none;
  556. }
  557. /deep/.ws-info-table .el-form-item .el-form-item__label {
  558. width: 30%;
  559. text-align: center;
  560. background: #ffffff;
  561. font-size: 14px;
  562. color: #8890b1;
  563. }
  564. /deep/.ws-info-table .el-form-item .el-form-item__content {
  565. border: none;
  566. }
  567. .bg-left {
  568. padding-left: 30px;
  569. }
  570. .bg-right {
  571. padding-right: 10px;
  572. text-align: right;
  573. }
  574. .bg-bottom {
  575. margin: 15px 0px;
  576. }
  577. .titleup {
  578. position: relative;
  579. }
  580. .titleup::before {
  581. content: '';
  582. display: inline-block;
  583. width: 5px;
  584. height: 30px;
  585. background: #5473e8;
  586. position: absolute;
  587. left: 0;
  588. }
  589. .unload {
  590. background: #ffffff;
  591. padding-top: 20px;
  592. }
  593. .but {
  594. text-align: center;
  595. margin: 20px auto;
  596. }
  597. /deep/.up .el-upload--picture-card {
  598. display: none;
  599. }
  600. /deep/.low .el-upload--picture-card {
  601. display: none;
  602. }
  603. /deep/.bankUp .el-upload--picture-card {
  604. display: none;
  605. }
  606. /deep/.bankLow .el-upload--picture-card {
  607. display: none;
  608. }
  609. .unload-img {
  610. margin: 20px 0;
  611. }
  612. .veriCode {
  613. margin: 0 9px;
  614. }
  615. .jiaoYan{
  616. display: flex;
  617. width: 50%;
  618. padding: 0 9px;
  619. }
  620. /deep/.jiaoYan .el-input__inner{
  621. width: 100%;
  622. }
  623. </style>