plateNumber.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. <template>
  2. <div class="plate-keyboard">
  3. <!-- 选择车牌号 首个汉字键盘 弹出层 -->
  4. <van-popup v-model="chinese_popup" position="bottom" class="uni-popup plate_number" :close-on-click-overlay="false" :maskClick="false">
  5. <div class="plate_number_wrap">
  6. <!-- 提示区域 -->
  7. <div class="event-box">
  8. <div class="close" @click.stop="close_keyboard">取消</div>
  9. <div>车牌键盘</div>
  10. <div class="sure" @click.stop="close_keyboard">确认</div>
  11. </div>
  12. <div class="plate_chinese_box">
  13. <button size="small" :class="[item.id === 99 && 'del']" v-for="(item, index) in ChineseList" :key="item.id" :disabled="disabledKeyboard(index)" @click="checkChinese(index)">
  14. <span v-if="item.id !== 99">{{ item.name }}</span>
  15. <img v-else :src="require(`../../static/images/close.png`)" alt="" />
  16. </button>
  17. </div>
  18. </div>
  19. </van-popup>
  20. <!-- 英文 数字 键盘 -->
  21. <van-popup v-model="allBoard_popup" position="bottom" class="uni-popup allBoard" :maskClick="false" :close-on-click-overlay="false">
  22. <div class="allBoard_wrap">
  23. <!-- 提示区域 -->
  24. <div class="event-box">
  25. <div class="close" @click.stop="close_keyboard">取消</div>
  26. <div>全拼键盘</div>
  27. <div class="sure" @click.stop="close_keyboard">确认</div>
  28. </div>
  29. <div class="close-box">
  30. <div class="plate_number_box">
  31. <!-- :disabled="item.id === 45 || item.id === 46 ? true : false" -->
  32. <button :disabled="item.id === 45 || item.id === 46 ? true : false" size="small" v-for="(item, index) in English_Number" :key="item.id" :class="[item.id === 99 && 'del', item.id === 66 && 'mini']" @click="checkEnglish_num(index)">
  33. <span v-if="item.id !== 99">{{ item.name }}</span>
  34. <img v-else :src="require(`../../static/images/back.png`)" alt="" />
  35. </button>
  36. </div>
  37. </div>
  38. </div>
  39. </van-popup>
  40. </div>
  41. </template>
  42. <script>
  43. import uniPop from '../uni-popup/uni-popup.vue';
  44. export default {
  45. components: {
  46. uniPop,
  47. },
  48. props: {
  49. carType: {
  50. type: Number,
  51. default: 0,
  52. },
  53. ind: {
  54. type: Number,
  55. default: 0,
  56. },
  57. active: {
  58. type: Number,
  59. default: -1,
  60. },
  61. numArr: {
  62. type: Array,
  63. default() {
  64. return ['', '', '', '', '', '', ''];
  65. },
  66. },
  67. disBtn:{
  68. type: Array,
  69. default() {
  70. return [];
  71. },
  72. },
  73. noDisBtn:{
  74. type: Array,
  75. default() {
  76. return [];
  77. },
  78. }
  79. },
  80. data() {
  81. return {
  82. chinese_popup: false,
  83. allBoard_popup: false,
  84. ChineseList: [
  85. {
  86. name: '京',
  87. id: 1,
  88. },
  89. {
  90. name: '沪',
  91. id: 2,
  92. },
  93. {
  94. name: '粤',
  95. id: 3,
  96. },
  97. {
  98. name: '津',
  99. id: 4,
  100. },
  101. {
  102. name: '冀',
  103. id: 5,
  104. },
  105. {
  106. name: '晋',
  107. id: 6,
  108. },
  109. {
  110. name: '蒙',
  111. id: 7,
  112. },
  113. {
  114. name: '辽',
  115. id: 8,
  116. },
  117. {
  118. name: '吉',
  119. id: 9,
  120. },
  121. {
  122. name: '黑',
  123. id: 10,
  124. },
  125. {
  126. name: '苏',
  127. id: 11,
  128. },
  129. {
  130. name: '浙',
  131. id: 12,
  132. },
  133. {
  134. name: '皖',
  135. id: 13,
  136. },
  137. {
  138. name: '闽',
  139. id: 14,
  140. },
  141. {
  142. name: '赣',
  143. id: 15,
  144. },
  145. {
  146. name: '鲁',
  147. id: 16,
  148. },
  149. {
  150. name: '豫',
  151. id: 17,
  152. },
  153. {
  154. name: '鄂',
  155. id: 18,
  156. },
  157. {
  158. name: '湘',
  159. id: 19,
  160. },
  161. {
  162. name: '桂',
  163. id: 20,
  164. },
  165. {
  166. name: '琼',
  167. id: 21,
  168. },
  169. {
  170. name: '渝',
  171. id: 22,
  172. },
  173. {
  174. name: '川',
  175. id: 23,
  176. },
  177. {
  178. name: '贵',
  179. id: 24,
  180. },
  181. {
  182. name: '云',
  183. id: 25,
  184. },
  185. {
  186. name: '藏',
  187. id: 26,
  188. },
  189. {
  190. name: '陕',
  191. id: 27,
  192. },
  193. {
  194. name: '甘',
  195. id: 28,
  196. },
  197. {
  198. name: '青',
  199. id: 29,
  200. },
  201. {
  202. name: '宁',
  203. id: 30,
  204. },
  205. /* {
  206. name: 'ABC',
  207. id: 66,
  208. }, */
  209. {
  210. name: '新',
  211. id: 31,
  212. },
  213. {
  214. name: '使',
  215. id: 32,
  216. },
  217. {
  218. name: '领',
  219. id: 33,
  220. },
  221. {
  222. name: '警',
  223. id: 34,
  224. },
  225. {
  226. name: '学',
  227. id: 35,
  228. },
  229. {
  230. name: '港',
  231. id: 36,
  232. },
  233. {
  234. name: '澳',
  235. id: 37,
  236. },
  237. {
  238. name: '台',
  239. id: 38,
  240. },
  241. {
  242. name: '临',
  243. id: 39,
  244. },
  245. {
  246. name: '←',
  247. id: 99,
  248. },
  249. ],
  250. English_Number: [
  251. {
  252. name: '1',
  253. id: 28,
  254. },
  255. {
  256. name: '2',
  257. id: 29,
  258. },
  259. {
  260. name: '3',
  261. id: 30,
  262. },
  263. {
  264. name: '4',
  265. id: 31,
  266. },
  267. {
  268. name: '5',
  269. id: 32,
  270. },
  271. {
  272. name: '6',
  273. id: 33,
  274. },
  275. {
  276. name: '7',
  277. id: 34,
  278. },
  279. {
  280. name: '8',
  281. id: 35,
  282. },
  283. {
  284. name: '9',
  285. id: 36,
  286. },
  287. {
  288. name: '0',
  289. id: 37,
  290. },
  291. {
  292. name: 'Q',
  293. id: 38,
  294. },
  295. {
  296. name: 'W',
  297. id: 39,
  298. },
  299. {
  300. name: 'E',
  301. id: 40,
  302. },
  303. {
  304. name: 'R',
  305. id: 41,
  306. },
  307. {
  308. name: 'T',
  309. id: 42,
  310. },
  311. {
  312. name: 'Y',
  313. id: 43,
  314. },
  315. {
  316. name: 'U',
  317. id: 44,
  318. },
  319. {
  320. name: 'I',
  321. id: 45,
  322. },
  323. {
  324. name: 'O',
  325. id: 46,
  326. },
  327. {
  328. name: 'P',
  329. id: 47,
  330. },
  331. {
  332. name: 'A',
  333. id: 48,
  334. },
  335. {
  336. name: 'S',
  337. id: 49,
  338. },
  339. {
  340. name: 'D',
  341. id: 50,
  342. },
  343. {
  344. name: 'F',
  345. id: 51,
  346. },
  347. {
  348. name: 'G',
  349. id: 52,
  350. },
  351. {
  352. name: 'H',
  353. id: 53,
  354. },
  355. {
  356. name: 'J',
  357. id: 54,
  358. },
  359. {
  360. name: 'K',
  361. id: 55,
  362. },
  363. {
  364. name: 'L',
  365. id: 56,
  366. },
  367. {
  368. name: '地区',
  369. id: 66,
  370. },
  371. {
  372. name: 'Z',
  373. id: 57,
  374. },
  375. {
  376. name: 'X',
  377. id: 58,
  378. },
  379. {
  380. name: 'C',
  381. id: 59,
  382. },
  383. {
  384. name: 'V',
  385. id: 60,
  386. },
  387. {
  388. name: 'B',
  389. id: 61,
  390. },
  391. {
  392. name: 'N',
  393. id: 62,
  394. },
  395. {
  396. name: 'M',
  397. id: 63,
  398. },
  399. {
  400. name: '←',
  401. id: 99,
  402. },
  403. ],
  404. carnoIndex: 0,
  405. activeIndex: -1,
  406. carnoArr: ['', '', '', '', '', '', ''],
  407. };
  408. },
  409. computed: {
  410. init() {
  411. console.log(406, this.ind, this.active, this.numArr);
  412. console.log(406, this.carnoIndex, this.activeIndex, this.carnoArr);
  413. return 99900;
  414. },
  415. // ChineseList() {
  416. // if (this.carType === 2) {
  417. // return this.chinese.filter(item => item.id >= 32 && item.id <= 99);
  418. // }
  419. // return this.chinese.filter(item => item.id <= 32 || item.id === 66 || item.id === 99);
  420. // }
  421. },
  422. watch: {
  423. ind(val) {
  424. this.carnoIndex = val;
  425. },
  426. active(val) {
  427. this.activeIndex = val;
  428. },
  429. numArr(val) {
  430. console.log(432, val);
  431. this.carnoArr = val;
  432. },
  433. },
  434. methods: {
  435. disabledKeyboard(index) {
  436. let dis = this.x !== 2 && index >= 32 && index <= 37;
  437. if(this?.disBtn?.length && this.disBtn.indexOf(index) > -1) {
  438. dis = true;
  439. }
  440. //
  441. if(this?.noDisBtn?.length && this.noDisBtn.indexOf(index) > -1) {
  442. dis = false;
  443. }
  444. return dis;
  445. },
  446. // 选择车牌号前面的汉字
  447. checkChinese(index) {
  448. // 点击删除键
  449. if (this.ChineseList[index].id == 99) {
  450. this.carnoArr[this.carnoIndex] = '';
  451. if (this.carnoIndex === 7 && this.carnoArr[this.carnoIndex] === '') {
  452. this.carnoArr.pop();
  453. }
  454. this.carnoIndex--;
  455. this.activeIndex = this.carnoIndex;
  456. if (this.carnoIndex === -1) {
  457. return this.close_keyboard();
  458. }
  459. } else if (this.ChineseList[index].id == 66) {
  460. //切换英文
  461. this.closeKeyboardCN();
  462. this.openKeyboardEN();
  463. } else {
  464. // 把选中的字赋值
  465. this.$set(this.carnoArr, this.carnoIndex, this.ChineseList[index].name);
  466. if (this.carnoIndex === this.carnoArr.length - 1) {
  467. this.close_keyboard();
  468. } else {
  469. this.carnoIndex++;
  470. this.activeIndex = this.carnoIndex;
  471. this.closeKeyboardCN();
  472. this.openKeyboardEN();
  473. }
  474. }
  475. this.$emit('carnoArr', {
  476. numArr: this.carnoArr,
  477. active: this.activeIndex,
  478. ind: this.carnoIndex,
  479. });
  480. },
  481. // 选择车牌号后面的数字和字母
  482. checkEnglish_num(index) {
  483. // 点击删除键
  484. if (this.English_Number[index].id == 99) {
  485. this.carnoArr[this.carnoIndex] = '';
  486. if (this.search_price == true) {
  487. this.search_price = false;
  488. this.vehicleMgt_content_index = index;
  489. }
  490. if (this.carnoIndex === 7 && this.carnoArr[this.carnoIndex] === '') {
  491. this.carnoArr.pop();
  492. }
  493. this.carnoIndex--;
  494. this.activeIndex = this.carnoIndex;
  495. if (this.carnoIndex === -1) {
  496. this.close_keyboard();
  497. }
  498. } else if (this.English_Number[index].id == 66) {
  499. //切换中文
  500. this.closeKeyboardEN();
  501. this.openKeyboardCN();
  502. } else {
  503. // 把选中的字赋值
  504. this.$set(this.carnoArr, this.carnoIndex, this.English_Number[index].name);
  505. if (this.carnoIndex === this.carnoArr.length - 1) {
  506. this.close_keyboard();
  507. } else {
  508. this.carnoIndex++;
  509. this.activeIndex = this.carnoIndex;
  510. this.closeKeyboardCN();
  511. this.openKeyboardEN();
  512. }
  513. }
  514. this.$emit('carnoArr', {
  515. numArr: this.carnoArr,
  516. active: this.activeIndex,
  517. ind: this.carnoIndex,
  518. });
  519. },
  520. openKeyboardCN() {
  521. this.closeKeyboardEN();
  522. this.chinese_popup = true;
  523. this.allBoard_popup = false;
  524. },
  525. closeKeyboardCN() {
  526. this.chinese_popup = false;
  527. },
  528. openKeyboardEN() {
  529. this.openKeyboardCN();
  530. this.allBoard_popup = true;
  531. this.chinese_popup = false;
  532. },
  533. closeKeyboardEN() {
  534. this.allBoard_popup = false;
  535. },
  536. // 关闭虚拟键盘
  537. close_keyboard() {
  538. this.activeIndex = null;
  539. this.closeKeyboardCN();
  540. this.closeKeyboardEN();
  541. },
  542. },
  543. };
  544. </script>
  545. <style lang="less">
  546. .class-van-button-small {
  547. min-width: 0;
  548. border-radius: 10px;
  549. margin: 6px 3px;
  550. box-shadow: 0px 2px 0px #9da0a3;
  551. }
  552. .van-overlay {
  553. background-color: rgba(0,0,0,0.1);
  554. }
  555. .event-box {
  556. display: flex;
  557. justify-content: space-around;
  558. background: #ffffff;
  559. & > * {
  560. flex: 1;
  561. text-align: center;
  562. padding: 26px 0;
  563. color: #333;
  564. font-size: 34px;
  565. }
  566. .close {
  567. text-align: left;
  568. padding-left: 44px;
  569. }
  570. .sure {
  571. text-align: right;
  572. padding-right: 44px;
  573. }
  574. }
  575. .plate_number {
  576. width: 100%;
  577. display: flex;
  578. flex-direction: column;
  579. .plate_number_wrap {
  580. width: 100%;
  581. display: flex;
  582. flex-direction: column;
  583. background: #D1D5DB;
  584. padding: 0;
  585. box-sizing: border-box;
  586. .close-box {
  587. width: 100%;
  588. font-size: 24px;
  589. color: #3e67ff;
  590. text-align: right;
  591. margin-right: 1.25rem;
  592. div {
  593. padding: 10px;
  594. }
  595. }
  596. .plate_chinese_box {
  597. width: 100%;
  598. display: flex;
  599. flex-wrap: wrap;
  600. justify-content: center;
  601. background-color: #d1d5db;
  602. box-sizing: border-box;
  603. padding-top: 18px;
  604. margin-bottom: calc(13px + 59px);
  605. // padding-bottom: constant(safe-area-inset-bottom); /* 兼容 iOS<11.2 */
  606. // padding-bottom: env(safe-area-inset-bottom); /* 兼容iOS>= 11.2 */
  607. button {
  608. width: 9%;
  609. height: 85px;
  610. line-height: 85px;
  611. text-align: center;
  612. padding: 0;
  613. color: #000;
  614. font-weight: 400;
  615. font-size: 36px;
  616. margin: 6px;
  617. background: #ffffff;
  618. .class-van-button-small;
  619. &.del {
  620. background-color: #adb3bc;
  621. img {
  622. width: 43px;
  623. height: 30px;
  624. }
  625. }
  626. }
  627. button[disabled='disabled'] {
  628. color: #9da0a3;
  629. }
  630. }
  631. }
  632. }
  633. .allBoard {
  634. width: 100%;
  635. display: flex;
  636. flex-direction: column;
  637. // margin-bottom: 19px;
  638. .allBoard_wrap {
  639. width: 100%;
  640. display: flex;
  641. flex-direction: column;
  642. // background: #eaf1f9;
  643. background: #D1D5DB;
  644. // padding: 0 0 10px;
  645. box-sizing: border-box;
  646. // padding-bottom: constant(safe-area-inset-bottom); /* 兼容 iOS<11.2 */
  647. // padding-bottom: env(safe-area-inset-bottom); /* 兼容iOS>= 11.2 */
  648. }
  649. .close-box {
  650. padding-top: 18px;
  651. box-sizing: border-box;
  652. font-size: 24px;
  653. text-align: right;
  654. background: #d1d5db;
  655. padding-bottom: calc(13px + 59px);
  656. // padding-bottom: 24px;
  657. }
  658. .plate_number_box {
  659. width: 100%;
  660. display: flex;
  661. flex-wrap: wrap;
  662. justify-content: center;
  663. button {
  664. width: 9%;
  665. height: 85px;
  666. line-height: 85px;
  667. text-align: center;
  668. padding: 0;
  669. font-size: 36px;
  670. background: #ffffff;
  671. .class-van-button-small;
  672. &.del {
  673. img {
  674. width: 33px;
  675. height: 22px;
  676. }
  677. }
  678. &.mini {
  679. font-size: 28px;
  680. }
  681. }
  682. button[disabled='disabled'] {
  683. color: #9da0a3;
  684. }
  685. }
  686. }
  687. </style>