index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. <template>
  2. <div class="qy_yy">
  3. <div class="form bd_bottom">
  4. <div class="form-label">
  5. <span class="form-requird">*</span>
  6. <span>供应商</span>
  7. </div>
  8. <div @click="oepnGysPopup()" style="font-size: 28rpx">
  9. {{ form.gysName ? form.gysName : "请选择" }}
  10. </div>
  11. </div>
  12. <div class="form bd_bottom">
  13. <div class="form-label">
  14. <span class="form-requird">*</span>
  15. <span>选择车辆</span>
  16. </div>
  17. <div class="form-value" style="min-width: 435rpx; width: auto;font-size: 28rpx">
  18. <picker
  19. @change="selectUsedCar"
  20. :value="index"
  21. :range="usedCarList"
  22. range-key="label"
  23. >
  24. <!-- <view class="uni-input">{{ array[index] }}</view> -->
  25. {{ usedCar ? usedCar : "请选择" }}
  26. </picker>
  27. </div>
  28. <van-icon name="arrow" />
  29. <span style="color: #8A0554" @click="jumpPage('/pages/subPackages/carmange/add')">
  30. <van-icon
  31. size="48rpx"
  32. color="#8A0554"
  33. name="add"
  34. />
  35. </span>
  36. </div>
  37. <div class="form bd_bottom pdt32 pdb32" style="display: block">
  38. <div class="form-label">
  39. <span class="form-requird">*</span>
  40. <span>车牌号</span>
  41. </div>
  42. <div>
  43. <car-number :disable="false" ref="carNum" v-model="carNumber"></car-number>
  44. </div>
  45. </div>
  46. <div class="form bd_bottom">
  47. <div class="form-label">
  48. <span class="form-requird">*</span>
  49. <span>车辆类型</span>
  50. </div>
  51. <div class="form-value" style="font-size: 28rpx">
  52. <picker
  53. @change="selectCarType"
  54. :value="index"
  55. :range="dockCarTypeList"
  56. range-key="label"
  57. >
  58. <!-- <view class="uni-input">{{ array[index] }}</view> -->
  59. {{ form.carType ? form.carType : "请选择" }}
  60. </picker>
  61. </div>
  62. <van-icon name="arrow" />
  63. </div>
  64. <div class="form bd_bottom" style="display: block">
  65. <div style="display: flex">
  66. <div class="form-label">
  67. <span class="form-requird">*</span>
  68. <span>司机姓名</span>
  69. </div>
  70. <div class="form-value">
  71. <input
  72. type="text"
  73. readonly
  74. placeholder="请选择"
  75. v-model="form.driverName"
  76. />
  77. </div>
  78. </div>
  79. </div>
  80. <div class="form bd_bottom" style="display: block">
  81. <div style="display: flex">
  82. <div class="form-label">
  83. <span class="form-requird">*</span>
  84. <span>手机号</span>
  85. </div>
  86. <div class="form-value">
  87. <input
  88. type="text"
  89. readonly
  90. placeholder="请选择"
  91. v-model="form.driverUsername"
  92. />
  93. </div>
  94. </div>
  95. </div>
  96. <div class="form bd_bottom mt32">
  97. <div class="form-label">
  98. <span class="form-requird">*</span>
  99. <span>装卸类型:</span>
  100. </div>
  101. <div>
  102. {{ form.loadType }}
  103. </div>
  104. </div>
  105. <div class="form bd_bottom">
  106. <div class="form-label">
  107. <span class="form-requird">*</span>
  108. <span>件数/托盘数:</span>
  109. </div>
  110. <div>
  111. <input type="number" placeholder="请输入" v-model="form.loadNum" />
  112. </div>
  113. </div>
  114. <div class="form bd_bottom" v-if="mtId">
  115. <div class="form-label">
  116. <span class="form-requird">*</span>
  117. <span>预约日期:</span>
  118. </div>
  119. <div class="uni-input">
  120. <picker @change="selectYYDate" :value="index" :range="yydateList">
  121. <!-- <view class="uni-input">{{ array[index] }}</view> -->
  122. {{ form.reservationDate ? form.reservationDate : "请选择" }}
  123. </picker>
  124. <!-- {{form.reservationDate?form.reservationDate:''}} -->
  125. </div>
  126. <van-icon name="arrow" />
  127. </div>
  128. <div class="bottom-form mt32">
  129. <div class="mt-select">
  130. <div
  131. class="select-item"
  132. :style="{
  133. background: item.value == mtId ? '#8A0554' : '#f5f7fa',
  134. color: item.value == mtId ? 'white' : 'black',
  135. }"
  136. v-for="item in mtList"
  137. @click="getMtId(item)"
  138. :key="item.value"
  139. >
  140. {{ item.label }}
  141. </div>
  142. </div>
  143. <div class="sj-select-title">
  144. <div class="sj-label">
  145. <span style="color: red">*</span>
  146. 可选时间
  147. </div>
  148. <div style="display: flex;flex-wrap: wrap;margin-top: 32rpx">
  149. <div class="legend">
  150. <div class="white-legend"></div>
  151. <div>可选</div>
  152. </div>
  153. <div class="legend">
  154. <div class="purple-legend"></div>
  155. <div>占用</div>
  156. </div>
  157. <div class="legend">
  158. <div class="ysd-legend"></div>
  159. <div>锁定</div>
  160. </div>
  161. <div class="legend">
  162. <div class="yxz-legend"></div>
  163. <div>选中</div>
  164. </div>
  165. </div>
  166. </div>
  167. <!-- isSeletStyle-->
  168. <div class="sj-select">
  169. <div
  170. :class="
  171. form.dockSettingDetailId == item.dockSettingDetailId &&
  172. form.dockSettingId == item.dockSettingId &&
  173. form.timeEnd == item.timeEnd &&
  174. form.timeStart == item.timeStart
  175. ?'select-item isSeletStyle'
  176. :item.statusStr == '已预约'
  177. ? 'select-item yyyStatus'
  178. : item.statusStr == '已锁定'
  179. ? 'select-item ysdStatus'
  180. : 'select-item '
  181. "
  182. @click="timeSelect(item)"
  183. v-for="item in kxTimeList"
  184. >
  185. {{ item.timeStart }}~{{ item.timeEnd }}
  186. <!-- <van-icon-->
  187. <!-- name="success"-->
  188. <!-- v-if="-->
  189. <!-- "-->
  190. <!-- />-->
  191. </div>
  192. </div>
  193. <div class="foot-btn">
  194. <van-button
  195. color="rgba(0, 0, 0, 0.05)"
  196. type="default"
  197. class="cancel"
  198. @click="cancelYY"
  199. >
  200. 返回
  201. </van-button>
  202. <van-button
  203. color="rgba(138, 5, 84, 1)"
  204. type="primary"
  205. @click="submitReservationByBiz()"
  206. >
  207. 提交
  208. </van-button>
  209. </div>
  210. </div>
  211. </div>
  212. </template>
  213. <script>
  214. import CarNumber from "@/components/codecook-carnumber/codecook-carnumber.vue";
  215. import {
  216. getDockCarType,
  217. getCarNoByBizAndUser,
  218. getBizByUsername,
  219. getDockSelectList,
  220. getDockLoadType,
  221. getAvailableDateList,
  222. getDockTimeList,
  223. submitReservationByBiz,
  224. getHistoryContactPhoneByUserId,
  225. getCarDataByBiz,
  226. } from "@/js_sdk/chooseCarApi.js";
  227. import { getUserLocalStorageInfo } from "@/js_sdk/localUserInfo.js";
  228. export default {
  229. data() {
  230. return {
  231. formData: {},
  232. carNumber: "",
  233. gysList: [],
  234. dockCarTypeList: [],
  235. form: {},
  236. mtList: [],
  237. mtId: "",
  238. yydateList: [],
  239. usedCarList: [],
  240. kxTimeList: [],
  241. usedCar: "",
  242. };
  243. },
  244. components: {
  245. CarNumber,
  246. },
  247. onLoad(e) {
  248. this.getDockCarType();
  249. this.form.bizId = getUserLocalStorageInfo().biz.id;
  250. this.form.loadType = e.zxtype.replace("预约", "");
  251. console.log(e.zxtype);
  252. this.form.carType = e.carTypeLabel;
  253. this.form.gysName = getUserLocalStorageInfo().user.dispName;
  254. this.getDockSelectList();
  255. this.againRenderData();
  256. this.getCarDataByBiz();
  257. },
  258. onShow(){
  259. this.getCarDataByBiz()
  260. },
  261. methods: {
  262. jumpPage(path) {
  263. console.log(path);
  264. uni.navigateTo({
  265. url: path,
  266. fail: (fail) => {},
  267. });
  268. },
  269. cancelYY() {
  270. uni.navigateBack();
  271. },
  272. async submitReservationByBiz() {
  273. if (!this.form.bizId) {
  274. this.$showToast("请选择供应商");
  275. return;
  276. }
  277. if (!this.carNumber) {
  278. this.$showToast("请输入车牌号");
  279. return;
  280. }
  281. if (!this.form.carType) {
  282. this.$showToast("请选择车辆类型");
  283. return;
  284. }
  285. if (!this.form.driverName) {
  286. this.$showToast("请输入司机姓名");
  287. return;
  288. }
  289. if (!this.form.driverName) {
  290. this.$showToast("请输入司机姓名");
  291. return;
  292. }
  293. if (!this.form.driverUsername) {
  294. this.$showToast("请输入手机号/账号");
  295. return;
  296. }
  297. if (!this.form.timeStart || !this.form.timeEnd) {
  298. this.$showToast("请选择预约时间段");
  299. return;
  300. }
  301. if (!this.form.loadNum) {
  302. this.$showToast("请填写托盘数");
  303. return;
  304. }
  305. // if (!this.form.driverContactPhone) {
  306. // this.$showToast("联系电话");
  307. // return;
  308. // }
  309. let res = await submitReservationByBiz({
  310. ...this.form,
  311. userId: getUserLocalStorageInfo().user.id,
  312. carNo: this.carNumber,
  313. });
  314. if (res.errmsg == "成功") {
  315. this.$showToast("预约成功");
  316. this.jumpPage('/pages/subPackages/yy_history/index')
  317. // uni.navigateBack({ delta: 2 });
  318. }
  319. console.log(res);
  320. },
  321. timeSelect(item) {
  322. console.log(item);
  323. if (item.statusStr == "已锁定") {
  324. this.$showToast("该时段已被锁定,请勿选择");
  325. return;
  326. }
  327. if (item.statusStr == "已预约") {
  328. this.$showToast("该时段已被预约,请勿选择");
  329. return;
  330. }
  331. console.log(item);
  332. this.form.dockSettingDetailId = item.dockSettingDetailId;
  333. this.form.dockSettingId = item.dockSettingId;
  334. this.form.timeEnd = item.timeEnd;
  335. this.form.dockId = item.dockId;
  336. this.form.timeStart = item.timeStart;
  337. let form = { ...this.form };
  338. this.form = {};
  339. this.form = form;
  340. },
  341. selectUsedCar({ detail }) {
  342. console.log(detail.value);
  343. let usedCarList = JSON.parse(
  344. JSON.stringify(this.usedCarList[detail.value])
  345. );
  346. console.log(usedCarList);
  347. this.form.driverName = usedCarList.driver_name;
  348. this.form.driverId = usedCarList.driver_id;
  349. this.form.driverUsername = usedCarList.driver_username;
  350. // this.form.driverUsername = usedCarList.driver_username0
  351. this.usedCar = usedCarList.label;
  352. this.$refs.carNum.setCarNumValue(usedCarList.car_no);
  353. console.log(this.usedCarList[detail.value]);
  354. },
  355. async getCarDataByBiz() {
  356. let { data } = await getCarDataByBiz({
  357. bizId: getUserLocalStorageInfo().biz.id,
  358. });
  359. this.usedCarList = data.map((e) => {
  360. return {
  361. label: `${e.car_no}-${e.driver_name}-${e.driver_username}`,
  362. car_no: e.car_no,
  363. driver_name: e.driver_name,
  364. driver_username: e.driver_username,
  365. driver_id: e.driver_id,
  366. };
  367. });
  368. console.log("getCarDataByBiz", data);
  369. },
  370. async getDockCarType() {
  371. let { data } = await getDockCarType();
  372. this.dockCarTypeList = data;
  373. console.log(data);
  374. },
  375. async selectYYDate({ detail }) {
  376. console.log(this.yydateList[detail.value]);
  377. this.form.reservationDate = this.yydateList[detail.value];
  378. let form = { ...this.form };
  379. this.form = {};
  380. this.form = form;
  381. let { data } = await getDockTimeList({
  382. dateStr: this.form.reservationDate,
  383. dockId: this.mtId,
  384. bizId: this.form.bizId,
  385. });
  386. this.kxTimeList = data;
  387. this.form.dockSettingDetailId = "";
  388. this.form.dockSettingId = "";
  389. this.form.timeEnd = "";
  390. this.form.dockId = "";
  391. this.form.timeStart = "";
  392. },
  393. async getMtId(item) {
  394. this.kxTimeList = [];
  395. this.form.reservationDate = "";
  396. console.log(item);
  397. let { data } = await getAvailableDateList({ dockId: item.value });
  398. this.mtId = item.value;
  399. this.yydateList = data;
  400. },
  401. selectCarType({ detail }) {
  402. console.log(detail);
  403. this.form.carType = this.dockCarTypeList[detail.value].label;
  404. console.log(this.dockCarTypeList[detail.value]);
  405. let form = { ...this.form };
  406. this.form = {};
  407. this.form = form;
  408. this.getDockSelectList();
  409. },
  410. async getDockSelectList() {
  411. let { data } = await getDockSelectList({
  412. carType: this.form.carType,
  413. loadType: this.form.loadType.replace("预约", ""),
  414. });
  415. this.mtList = data;
  416. await this.getMtId(this.mtList[0])
  417. },
  418. againRenderData() {
  419. let form = { ...this.form };
  420. this.form = {};
  421. this.form = form;
  422. },
  423. },
  424. };
  425. </script>
  426. <style lang="scss">
  427. .qy_yy {
  428. .yyyStatus {
  429. background: #8e8be4 !important;
  430. color: white;
  431. }
  432. .isSeletStyle{
  433. background: #2ab217 !important;
  434. color: white;
  435. }
  436. .ysdStatus {
  437. background: #ededed !important;
  438. color: #333333;
  439. }
  440. .foot-btn {
  441. margin-top: 32rpx;
  442. margin-bottom: 32rpx;
  443. display: flex;
  444. justify-content: space-around;
  445. button {
  446. width: 30vw;
  447. }
  448. .cancel {
  449. button {
  450. //width: 30vw;
  451. color: rgba(138, 5, 84, 1) !important;
  452. }
  453. }
  454. }
  455. .form-value {
  456. width: 435rpx;
  457. input {
  458. width: 100%;
  459. }
  460. }
  461. .sj-select {
  462. display: flex;
  463. flex-wrap: wrap;
  464. margin-top: 32rpx;
  465. .select-item {
  466. text-align: center;
  467. line-height: 80rpx;
  468. width: 225rpx;
  469. font-size: 32rpx;
  470. height: 80rpx;
  471. background: rgba(255, 255, 255, 1);
  472. border-radius: 0rpx 0rpx 0rpx 0rpx;
  473. border: 2rpx solid #eaeff6;
  474. }
  475. .iselected {
  476. background: #ededed;
  477. }
  478. .isuse {
  479. background: rgba(142, 139, 228, 1);
  480. }
  481. }
  482. .sj-select-title {
  483. flex-wrap: wrap;
  484. //display: flex;
  485. align-items: center;
  486. .legend {
  487. display: flex;
  488. align-items: center;
  489. margin-right: 32rpx;
  490. }
  491. .sj-label {
  492. margin-right: 64rpx;
  493. }
  494. .white-legend {
  495. margin-right: 16rpx;
  496. width: 28rpx;
  497. height: 28rpx;
  498. background: #ffffff;
  499. border-radius: 0rpx 0rpx 0rpx 0rpx;
  500. border: 2rpx solid #e9e9e9;
  501. }
  502. .ysd-legend {
  503. margin-right: 16rpx;
  504. width: 28rpx;
  505. height: 28rpx;
  506. background: #ededed;
  507. border-radius: 0rpx 0rpx 0rpx 0rpx;
  508. }
  509. .yxz-legend {
  510. margin-right: 16rpx;
  511. width: 28rpx;
  512. height: 28rpx;
  513. background: #2ab217;
  514. border-radius: 0rpx 0rpx 0rpx 0rpx;
  515. }
  516. .purple-legend {
  517. margin-right: 16rpx;
  518. width: 28rpx;
  519. height: 28rpx;
  520. background: #8e8be4;
  521. border-radius: 0rpx 0rpx 0rpx 0rpx;
  522. }
  523. }
  524. .bottom-form {
  525. background: #ffffff;
  526. padding: 32rpx;
  527. box-sizing: border-box;
  528. .mt-select {
  529. display: flex;
  530. flex-wrap: wrap;
  531. .select-item {
  532. border-radius: 8rpx 8rpx 8rpx 8rpx;
  533. padding: 12rpx 30rpx;
  534. margin-left: 5rpx;
  535. margin-right: 5rpx;
  536. margin-bottom: 32rpx;
  537. background: rgba(245, 247, 250, 1);
  538. }
  539. }
  540. }
  541. .historyList {
  542. display: flex;
  543. justify-content: flex-start;
  544. flex-wrap: wrap;
  545. .historyList-item {
  546. padding: 10rpx 15rpx;
  547. display: flex;
  548. text-align: center;
  549. font-weight: 400;
  550. color: #666666;
  551. background: #f5f7fa;
  552. border-radius: 8rpx 8rpx 8rpx 8rpx;
  553. margin-left: 5rpx;
  554. margin-right: 5rpx;
  555. .btn {
  556. margin-left: 15rpx;
  557. }
  558. }
  559. }
  560. .form {
  561. padding: 32rpx 32rpx;
  562. display: flex;
  563. background: #ffffff;
  564. min-height: 112rpx;
  565. align-items: center;
  566. box-sizing: border-box;
  567. .form-label {
  568. font-weight: 400;
  569. font-size: 32rpx;
  570. color: #333333;
  571. margin-right: 64rpx;
  572. .form-requird {
  573. color: red;
  574. }
  575. }
  576. }
  577. .pdt32 {
  578. padding-top: 32rpx;
  579. }
  580. .pdb32 {
  581. padding-bottom: 32rpx;
  582. }
  583. .mb32 {
  584. margin-bottom: 32rpx;
  585. }
  586. .mt32 {
  587. margin-top: 32rpx;
  588. }
  589. .bd_bottom {
  590. border-bottom: 2rpx #e6e6e6 solid;
  591. }
  592. }
  593. </style>