waiting.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. <template>
  2. <div class="content-box">
  3. <div class="left">
  4. <!-- <el-icon :size="23" class="camera"><VideoCameraFilled /></el-icon> -->
  5. <span class="cameratxt">系统设置</span>
  6. </div>
  7. <div class="middle">
  8. <div class="filter">
  9. <div class="condition">
  10. <div style="display: flex; align-items: center">
  11. <h3>开始时间段设置</h3>
  12. <!-- <el-button
  13. color="rgba(61, 81, 232, 1)"
  14. @click="editSystem"
  15. v-if="timeShow"
  16. type="primary"
  17. >修改</el-button
  18. >
  19. <el-button
  20. color="rgba(61, 81, 232, 1)"
  21. @click="saveSystem"
  22. v-if="!timeShow"
  23. type="primary"
  24. >保存</el-button
  25. >
  26. <el-button @click="cancelSystem" v-if="!timeShow" plain
  27. >取消</el-button
  28. > -->
  29. </div>
  30. <div
  31. style="display: flex; align-items: center; margin-bottom: 8px"
  32. v-for="(i, ind) in timeList.list" :key="ind"
  33. >
  34. <div class="addTime">
  35. <span>周期配置&nbsp;&nbsp;</span>
  36. <el-checkbox-group
  37. @change="saveTime($event, i.id, '星期一')"
  38. v-model="i.day1"
  39. >
  40. <el-checkbox :label="1">星期一</el-checkbox>
  41. </el-checkbox-group>
  42. <el-checkbox-group
  43. @change="saveTime($event, i.id, '星期二')"
  44. v-model="i.day2"
  45. >
  46. <el-checkbox :label="1">星期二</el-checkbox>
  47. </el-checkbox-group>
  48. <el-checkbox-group
  49. @change="saveTime($event, i.id, '星期三')"
  50. v-model="i.day3"
  51. >
  52. <el-checkbox :label="1">星期三</el-checkbox>
  53. </el-checkbox-group>
  54. <el-checkbox-group
  55. @change="saveTime($event, i.id, '星期四')"
  56. v-model="i.day4"
  57. >
  58. <el-checkbox :label="1">星期四</el-checkbox>
  59. </el-checkbox-group>
  60. <el-checkbox-group
  61. @change="saveTime($event, i.id, '星期五')"
  62. v-model="i.day5"
  63. >
  64. <el-checkbox :label="1">星期五</el-checkbox>
  65. </el-checkbox-group>
  66. <el-checkbox-group
  67. @change="saveTime($event, i.id, '星期六')"
  68. v-model="i.day6"
  69. >
  70. <el-checkbox :label="1">星期六</el-checkbox>
  71. </el-checkbox-group>
  72. <el-checkbox-group
  73. @change="saveTime($event, i.id, '星期日')"
  74. v-model="i.day7"
  75. >
  76. <el-checkbox :label="1">星期日</el-checkbox>
  77. </el-checkbox-group>
  78. <div style="margin: 0 18px">
  79. <el-time-picker
  80. class="timePicker"
  81. v-model="i.timePicker"
  82. :clearable="false"
  83. is-range
  84. format="HH:mm"
  85. value-format="HH:mm"
  86. range-separator="-"
  87. start-placeholder="开始时间"
  88. end-placeholder="结束时间"
  89. @change="saveTime($event, i.id)"
  90. />
  91. </div>
  92. </div>
  93. <div>
  94. <span
  95. @click="addTime(ind)"
  96. style="cursor: pointer; color: rgb(30, 125, 251)"
  97. >添加</span
  98. >
  99. <span
  100. v-if="timeList.list.length > 1"
  101. @click="delTime(ind, i.id)"
  102. style="cursor: pointer; color: #f56c6c"
  103. >删除</span
  104. >
  105. </div>
  106. </div>
  107. </div>
  108. <div class="condition">
  109. <h3>截止预约时间设置</h3>
  110. <div>
  111. <span>发车前</span>
  112. <el-input
  113. :clearable="false"
  114. v-model="ruleForm.yy_end"
  115. class="w-50 m-2"
  116. style="width: 100px"
  117. @change="timeVerify"
  118. />
  119. <!-- <el-time-picker
  120. v-model="ruleForm.hh_end"
  121. format="HH:mm"
  122. value-format="HH:mm"
  123. @change="timeUpdata"
  124. /> -->
  125. <span>&nbsp;&nbsp;分钟</span>
  126. </div>
  127. </div>
  128. <div class="condition">
  129. <h3>扫码时间设置</h3>
  130. <div>
  131. <span>发车前</span>
  132. <el-input
  133. :clearable="false"
  134. v-model="ruleForm.startTime"
  135. class="w-50 m-2"
  136. style="width: 100px"
  137. @change="timeVerify"
  138. />
  139. <span>&nbsp;&nbsp;分钟 ,</span>
  140. <span>发车后</span>
  141. <el-input
  142. :clearable="false"
  143. v-model="ruleForm.endTime"
  144. class="w-50 m-2"
  145. style="width: 100px"
  146. @change="timeVerify"
  147. />
  148. <span>&nbsp;&nbsp;分钟可扫码核销 </span>
  149. </div>
  150. <div style="margin-top: 15px">
  151. <span>扫码间隔</span>
  152. <el-input
  153. :clearable="false"
  154. v-model="ruleForm.scanInterval"
  155. class="w-50 m-2"
  156. style="width: 100px"
  157. @change="timeVerify"
  158. />
  159. <span>&nbsp;&nbsp;分钟 ,</span>
  160. <span>在此时间内多次扫码均提示已预约</span>
  161. </div>
  162. </div>
  163. <!-- <div class="condition">
  164. <h3>候补截止预约时间设置</h3>
  165. <div>
  166. <span>候补截止时间</span>
  167. <el-time-picker
  168. v-model="ruleForm.hh_end"
  169. placeholder="请选择时间"
  170. format="HH:mm"
  171. value-format="HH:mm"
  172. @change="timeUpdata"
  173. />
  174. </div>
  175. </div> -->
  176. <div class="condition">
  177. <h3>黑名单设置</h3>
  178. <div>
  179. <span>爽约</span>
  180. <el-input
  181. :clearable="false"
  182. v-model="ruleForm.black_count"
  183. class="w-50 m-2"
  184. style="width: 100px"
  185. @change="timeVerify"
  186. />
  187. <span>&nbsp;&nbsp;次,锁定账号</span>
  188. </div>
  189. </div>
  190. <div class="condition">
  191. <h3>通知时间</h3>
  192. <div>
  193. <span>发车前提前</span>
  194. <el-input
  195. :clearable="false"
  196. v-model="ruleForm.notice_time"
  197. class="w-50 m-2"
  198. style="width: 100px"
  199. @change="timeVerify"
  200. />
  201. <span>&nbsp;&nbsp;分钟,发送通知</span>
  202. </div>
  203. </div>
  204. <div class="condition">
  205. <h3>报备人员开始预约时间设置</h3>
  206. <div>
  207. <span>发车前</span>
  208. <el-input
  209. :clearable="false"
  210. v-model="ruleForm.bb_before"
  211. class="w-50 m-2"
  212. style="width: 100px"
  213. @change="timeVerify"
  214. />
  215. <span>&nbsp;&nbsp;分钟,可以预约车辆</span>
  216. </div>
  217. </div>
  218. </div>
  219. </div>
  220. <div class="footer"></div>
  221. </div>
  222. </template>
  223. <script setup>
  224. import {
  225. ref,
  226. reactive,
  227. watch,
  228. nextTick,
  229. onBeforeMount,
  230. onUnmounted,
  231. } from "vue";
  232. import { useRouter } from "vue-router";
  233. import { ElMessage, ElMessageBox } from "element-plus";
  234. import { dayjs } from "element-plus";
  235. import lodash from "lodash";
  236. import axios from "axios";
  237. import { useStore } from "vuex";
  238. const store = useStore();
  239. const api = ref("");
  240. const router = useRouter();
  241. // 表格数据
  242. const ruleForm = reactive({
  243. yy_duration: "",
  244. hh_end: "", //截止预约时间设置
  245. yy_end: "", //候补截止预约时间设置
  246. black_count: "", //黑名单设置次数
  247. notice_time: "", //发车前提前
  248. startTime: "", // 扫码前时间
  249. endTime: "", // 扫码后时间
  250. scanInterval: "", // 扫码间隔
  251. bb_before: "", // 报备人预约车辆时间设置
  252. id: "",
  253. });
  254. // 开始时间段配置
  255. const timeList = reactive({
  256. list: [
  257. {
  258. day1: [],
  259. day2: [],
  260. day3: [],
  261. day4: [],
  262. day5: [],
  263. day6: [],
  264. day7: [],
  265. timePicker: [],
  266. id: "",
  267. },
  268. ],
  269. });
  270. const timeShow = ref(true);
  271. // 获取系统设置数据
  272. const getlist = async (message) => {
  273. let res = await axios({
  274. method: "post",
  275. url: api.value + "/carBook/cnqueryHb.action",
  276. headers: {
  277. token: sessionStorage.getItem("token"),
  278. },
  279. });
  280. console.log(res);
  281. if (res.data.code == 200) {
  282. ruleForm.yy_duration = res.data.data.yy_duration;
  283. ruleForm.scanInterval = res.data.data.scanInterval;
  284. ruleForm.yy_end = res.data.data.yy_end; //
  285. ruleForm.hh_end = res.data.data.hh_end; //
  286. ruleForm.black_count = res.data.data.black_count;
  287. ruleForm.notice_time = res.data.data.notice_time;
  288. ruleForm.startTime = res.data.data.sm_start;
  289. ruleForm.endTime = res.data.data.sm_end;
  290. ruleForm.bb_before = res.data.data.bb_before;
  291. ruleForm.id = res.data.data.id;
  292. sessionStorage.setItem("sm_start", res.data.data.sm_start);
  293. sessionStorage.setItem("sm_end", res.data.data.sm_end);
  294. if (message) {
  295. ElMessage({
  296. type: "success",
  297. showClose: true,
  298. message: message,
  299. center: true,
  300. });
  301. }
  302. } else {
  303. ElMessage({
  304. type: "error",
  305. showClose: true,
  306. message: res.data.message,
  307. center: true,
  308. });
  309. if (res.data.message == "token错误") {
  310. router.push({
  311. path: `/login`,
  312. });
  313. }
  314. }
  315. };
  316. const getTimeList = async () => {
  317. let res = await axios({
  318. method: "post",
  319. url: api.value + "/carBook/weekConfigqueryList.action",
  320. headers: {
  321. token: sessionStorage.getItem("token"),
  322. },
  323. });
  324. console.log(res, "开始时间段配置");
  325. if (res.data.code == 200) {
  326. let resData = res.data.data;
  327. let arr = [];
  328. resData.forEach((i) => {
  329. arr.push({
  330. day1: i.day1 ? [i.day1] : [],
  331. day2: i.day2 ? [i.day2] : [],
  332. day3: i.day3 ? [i.day3] : [],
  333. day4: i.day4 ? [i.day4] : [],
  334. day5: i.day5 ? [i.day5] : [],
  335. day6: i.day6 ? [i.day6] : [],
  336. day7: i.day7 ? [i.day7] : [],
  337. timePicker: [i.startTime, i.endTime],
  338. id: i.id,
  339. });
  340. });
  341. timeList.list = arr;
  342. console.log(arr, "开始时间段配置");
  343. } else {
  344. ElMessage({
  345. type: "error",
  346. showClose: true,
  347. message: res.data.message,
  348. center: true,
  349. });
  350. if (res.data.message == "token错误") {
  351. router.push({
  352. path: `/login`,
  353. });
  354. }
  355. }
  356. };
  357. // 页面数据一修改就调用函数
  358. const timeVerify=(val)=>{
  359. const regex = /^[0-9]+$/;
  360. if(regex.test(val)){
  361. timeUpdata()
  362. }else{
  363. getlist()
  364. ElMessage({
  365. type: "warning",
  366. showClose: true,
  367. message: "请输入正确数值",
  368. center: true,
  369. });
  370. }
  371. }
  372. const timeUpdata = async () => {
  373. if (ruleForm.black_count <= 0) {
  374. ruleForm.black_count = 1;
  375. }
  376. let data = {
  377. yy_duration: ruleForm.yy_duration,
  378. scanInterval: ruleForm.scanInterval,
  379. yy_end: ruleForm.yy_end,
  380. hh_end: ruleForm.hh_end,
  381. black_count: ruleForm.black_count,
  382. notice_time: ruleForm.notice_time,
  383. sm_start: ruleForm.startTime,
  384. sm_end: ruleForm.endTime,
  385. bb_before: ruleForm.bb_before,
  386. id: ruleForm.id,
  387. };
  388. let res = await axios({
  389. method: "post",
  390. url: api.value + "/carBook/cnupdate.action",
  391. headers: {
  392. "Content-Type": "application/json;charset=utf-8",
  393. token: sessionStorage.getItem("token"),
  394. },
  395. data: data,
  396. });
  397. console.log(res, "修改候补");
  398. if (res.data.code == 200) {
  399. // getlist();
  400. store.dispatch("sm_time");
  401. ElMessage({
  402. type: "success",
  403. showClose: true,
  404. message: res.data.message,
  405. center: true,
  406. });
  407. } else {
  408. getlist();
  409. ElMessage({
  410. type: "error",
  411. showClose: true,
  412. message: "修改失败",
  413. center: true,
  414. });
  415. }
  416. };
  417. const addTime = lodash.debounce(async (ind) => {
  418. console.log("添加", ind);
  419. // timeList.list.splice(ind + 1, 0, {
  420. // day1: [],
  421. // day2: [],
  422. // day3: [],
  423. // day4: [],
  424. // day5: [],
  425. // day6: [],
  426. // day7: [],
  427. // timePicker: [],
  428. // id: "",
  429. // });
  430. let arr = {
  431. day1: 0,
  432. day2: 0,
  433. day3: 0,
  434. day4: 0,
  435. day5: 0,
  436. day6: 0,
  437. day7: 0,
  438. timePicker: null,
  439. };
  440. let res = await axios({
  441. method: "post",
  442. url: api.value + "/carBook/weekConfiginsert.action",
  443. headers: {
  444. token: sessionStorage.getItem("token"),
  445. },
  446. data: arr,
  447. });
  448. if (res.data.code == 200) {
  449. getTimeList();
  450. ElMessage({
  451. type: "success",
  452. showClose: true,
  453. message: res.data.message,
  454. center: true,
  455. });
  456. } else {
  457. ElMessage({
  458. type: "error",
  459. showClose: true,
  460. message: res.data.message,
  461. center: true,
  462. });
  463. }
  464. }, 500);
  465. const delTime = async (ind, id) => {
  466. // timeList.list.splice(ind, 1);
  467. let data = new FormData();
  468. data.append("id", id);
  469. let res = await axios({
  470. method: "post",
  471. url: api.value + "/carBook/weekConfigdel.action",
  472. headers: {
  473. token: sessionStorage.getItem("token"),
  474. },
  475. data: data,
  476. });
  477. if (res.data.code == 200) {
  478. getTimeList();
  479. ElMessage({
  480. type: "success",
  481. showClose: true,
  482. message: res.data.message,
  483. center: true,
  484. });
  485. } else {
  486. ElMessage({
  487. type: "error",
  488. showClose: true,
  489. message: res.data.message,
  490. center: true,
  491. });
  492. }
  493. };
  494. const saveTime = async (event, id, txt) => {
  495. // console.log(event,'id:'+id,txt);
  496. console.log(timeList.list);
  497. let arr = timeList.list.map((i) => {
  498. console.log(i);
  499. return {
  500. day1: i.day1.length ? 1 : 0,
  501. day2: i.day2.length ? 1 : 0,
  502. day3: i.day3.length ? 1 : 0,
  503. day4: i.day4.length ? 1 : 0,
  504. day5: i.day5.length ? 1 : 0,
  505. day6: i.day6.length ? 1 : 0,
  506. day7: i.day7.length ? 1 : 0,
  507. startTime: i.timePicker[0],
  508. endTime: i.timePicker[1],
  509. id: i.id,
  510. };
  511. });
  512. // console.log(arr);
  513. let augment = arr.filter((i) => {
  514. return i.id == id;
  515. });
  516. // console.log(augment);
  517. let res = await axios({
  518. method: "post",
  519. url: api.value + "/carBook/weekConfigupdate.action",
  520. headers: {
  521. "Content-Type": "application/json;charset=utf-8",
  522. token: sessionStorage.getItem("token"),
  523. },
  524. data: augment[0],
  525. });
  526. if (res.data.code == 200) {
  527. getTimeList();
  528. ElMessage({
  529. type: "success",
  530. showClose: true,
  531. message: res.data.message,
  532. center: true,
  533. });
  534. } else {
  535. getTimeList();
  536. ElMessage({
  537. type: "error",
  538. showClose: true,
  539. message: res.data.message,
  540. center: true,
  541. });
  542. }
  543. };
  544. const editSystem = () => {
  545. timeShow.value = false;
  546. };
  547. const saveSystem = () => {
  548. timeShow.value = true;
  549. };
  550. const cancelSystem = () => {
  551. timeShow.value = true;
  552. };
  553. onBeforeMount(() => {
  554. api.value = store.state.user.api;
  555. getlist();
  556. getTimeList();
  557. });
  558. onUnmounted(() => {});
  559. </script>
  560. <style scoped lang="scss">
  561. .content-box {
  562. width: calc(100% - 40px);
  563. height: calc(100% - 105px);
  564. margin: 20px auto;
  565. background-color: #fff;
  566. color: #fff;
  567. display: flex;
  568. flex-direction: column;
  569. .left {
  570. // width: calc(100wh - 40px);
  571. display: flex;
  572. align-items: center;
  573. height: 60px;
  574. margin: 0 30px;
  575. border-bottom: 1px solid #ccc;
  576. color: #000;
  577. font-size: 18px;
  578. font-weight: 600;
  579. .camera {
  580. margin-right: 15px;
  581. color: #4392f7;
  582. }
  583. }
  584. .middle {
  585. width: calc(100% - 60px);
  586. height: calc(100% - 60px);
  587. overflow: auto;
  588. margin: 0 auto;
  589. color: #000;
  590. // border-bottom: 1px solid rgb(231, 231, 231);
  591. .filter {
  592. display: flex;
  593. flex-wrap: wrap;
  594. flex-direction: column;
  595. .condition {
  596. display: flex;
  597. flex-direction: column;
  598. margin: 10px 30px 10px 0;
  599. h3 {
  600. margin: 12px 12px 12px 0;
  601. }
  602. span {
  603. margin: 0 10px 0 0;
  604. font-size: 18px;
  605. color: #000;
  606. }
  607. .addTime {
  608. display: flex;
  609. align-items: center;
  610. .el-checkbox-group {
  611. .el-checkbox {
  612. margin: 0 15px 0 0;
  613. }
  614. }
  615. :deep(.timePicker) {
  616. width: 200px;
  617. }
  618. }
  619. }
  620. }
  621. .gongneng {
  622. margin: 10px 0;
  623. }
  624. :deep(.cont) {
  625. width: 60%;
  626. margin: 20px auto;
  627. }
  628. :deep(.download) {
  629. display: flex;
  630. align-items: center;
  631. margin: 10px;
  632. }
  633. :deep(.download span) {
  634. font-size: 16px;
  635. margin-left: 20px;
  636. }
  637. :deep(.cont .el-button) {
  638. margin-left: 60px;
  639. margin-bottom: 30px;
  640. }
  641. :deep(.cont .accomplish) {
  642. width: 100%;
  643. display: flex;
  644. justify-content: center;
  645. }
  646. :deep(.cont .accomplish .el-button) {
  647. width: 50%;
  648. margin: 0;
  649. }
  650. }
  651. }
  652. .el-input {
  653. width: 192px;
  654. }
  655. </style>