|
@@ -2,7 +2,7 @@
|
|
|
<div class="queue">
|
|
|
<van-nav-bar
|
|
|
title="当前队列"
|
|
|
- right-text="打烊"
|
|
|
+ right-text="营业规则"
|
|
|
@click-left="toAdmin"
|
|
|
@click-right="toOpen"
|
|
|
left-text="添加预定"
|
|
@@ -38,10 +38,13 @@
|
|
|
</van-cell-group>
|
|
|
|
|
|
<van-popup closeable v-model="open" position="right" class="open">
|
|
|
- <van-checkbox-group v-model="checkbox" v-if="showPopover.length">
|
|
|
+ <van-checkbox-group
|
|
|
+ v-model="checkbox"
|
|
|
+ v-if="showPopover.length"
|
|
|
+ >
|
|
|
<van-row v-for="(item, i) in weeks" :key="i">
|
|
|
<van-col span="8">
|
|
|
- <van-checkbox name="1" style="height: 2em">
|
|
|
+ <van-checkbox :name="i" style="height: 2em">
|
|
|
{{ item }}
|
|
|
</van-checkbox>
|
|
|
</van-col>
|
|
@@ -105,10 +108,9 @@
|
|
|
</van-popover>
|
|
|
</van-col>
|
|
|
</van-row>
|
|
|
+ <br />
|
|
|
+ <van-button :loading="load" @click="upRulefun" round type="info" loading-text="加载中..." block>保 存</van-button>
|
|
|
</van-checkbox-group>
|
|
|
- <br />
|
|
|
- <van-button type="default" block round>打烊</van-button>
|
|
|
- <van-button type="primary" block round>开始营业</van-button>
|
|
|
</van-popup>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -146,7 +148,15 @@ import "vant/lib/checkbox/style/index";
|
|
|
import "vant/lib/checkbox-group/style/index";
|
|
|
import "vant/lib/nav-bar/style/index";
|
|
|
|
|
|
-import { orderList, skip, nextone, cancel } from "../api/index";
|
|
|
+import {
|
|
|
+ orderList,
|
|
|
+ skip,
|
|
|
+ nextone,
|
|
|
+ cancel,
|
|
|
+ getRule,
|
|
|
+ upRule,
|
|
|
+} from "../api/index";
|
|
|
+
|
|
|
export default {
|
|
|
name: "Queue",
|
|
|
data() {
|
|
@@ -157,32 +167,24 @@ export default {
|
|
|
open: false,
|
|
|
time: [],
|
|
|
time2: [],
|
|
|
- timerange: ["00:00 - 00:00"],
|
|
|
+ timerange: [],
|
|
|
checkbox: [],
|
|
|
- weeks: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
|
|
|
+ weeks: [],
|
|
|
+ load: false
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.showPopover.fil;
|
|
|
- let showPopover = new Array(this.weeks.length),
|
|
|
- timerange = new Array(this.weeks.length);
|
|
|
- showPopover.fill(false);
|
|
|
- timerange.fill("00:00 - 00:00");
|
|
|
- this.showPopover = showPopover;
|
|
|
- this.time = new Array(this.weeks.length).fill("00:00");
|
|
|
- this.time2 = new Array(this.weeks.length).fill("00:00");
|
|
|
- this.timerange = timerange;
|
|
|
this.reloadOrder();
|
|
|
window.setInterval(() => {
|
|
|
- console.log("---");
|
|
|
this.reloadOrder();
|
|
|
}, 60000);
|
|
|
},
|
|
|
computed: {},
|
|
|
methods: {
|
|
|
closeTime(t) {
|
|
|
- console.log(t);
|
|
|
const showP = JSON.parse(JSON.stringify(this.showPopover));
|
|
|
+ this.time[t] = this.timerange[t].split(" - ")[0];
|
|
|
+ this.time2[t] = this.timerange[t].split(" - ")[1];
|
|
|
showP[t] = false;
|
|
|
this.showPopover = showP;
|
|
|
},
|
|
@@ -195,8 +197,83 @@ export default {
|
|
|
this.timerange[t] = this.time[t] + " - " + this.time2[t];
|
|
|
this.closeTime(t);
|
|
|
},
|
|
|
+ upRulefun() {
|
|
|
+ this.load = true;
|
|
|
+ upRule({
|
|
|
+ week: this.formatRule()
|
|
|
+ }).then(r => {
|
|
|
+ console.log(r);
|
|
|
+ this.load = false;
|
|
|
+ }).catch(()=>{
|
|
|
+ this.load = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ formatRule() {
|
|
|
+ let li = [],
|
|
|
+ week = {
|
|
|
+ 周一: 1,
|
|
|
+ 周二: 2,
|
|
|
+ 周三: 3,
|
|
|
+ 周四: 4,
|
|
|
+ 周五: 5,
|
|
|
+ 周六: 6,
|
|
|
+ 周日: 7,
|
|
|
+ },
|
|
|
+ check = this.checkbox.join(",");
|
|
|
+ for (let i = 0; i < this.showPopover.length; i++) {
|
|
|
+ const time = this.time[i],
|
|
|
+ time2 = this.time2[i], rex = new RegExp(i);
|
|
|
+ li.push({
|
|
|
+ week: week[this.weeks[i]],
|
|
|
+ start: time,
|
|
|
+ end: time2,
|
|
|
+ status: rex.test(check) ? "OPEN" : "STOP",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return li;
|
|
|
+ },
|
|
|
toOpen() {
|
|
|
- this.open = true;
|
|
|
+ getRule().then(res => {
|
|
|
+ const li = res || [],
|
|
|
+ week = {
|
|
|
+ 1: "一",
|
|
|
+ 2: "二",
|
|
|
+ 3: "三",
|
|
|
+ 4: "四",
|
|
|
+ 5: "五",
|
|
|
+ 6: "六",
|
|
|
+ 7: "日",
|
|
|
+ };
|
|
|
+ let W = [];
|
|
|
+ let showPopover = [],
|
|
|
+ timerange = [],
|
|
|
+ time = [],
|
|
|
+ time2 = [],
|
|
|
+ checkbox = [];
|
|
|
+ for (let i = 0; i < li.length; i++) {
|
|
|
+ const v = li[i];
|
|
|
+ let sT = v.start ? this.format(v.start) : "00:00";
|
|
|
+ let eT = v.end ? this.format(v.end) : "00:00";
|
|
|
+ W.push("周" + week[v.week]);
|
|
|
+ showPopover.push(false);
|
|
|
+ v.status === "OPEN" && checkbox.push(i);
|
|
|
+ timerange.push(sT + " - " + eT);
|
|
|
+ time.push(sT);
|
|
|
+ time2.push(eT);
|
|
|
+ }
|
|
|
+ this.weeks = W;
|
|
|
+ this.showPopover = showPopover;
|
|
|
+ this.time = time;
|
|
|
+ this.time2 = time2;
|
|
|
+ this.timerange = timerange;
|
|
|
+ this.checkbox = checkbox;
|
|
|
+ this.open = true;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ format(T) {
|
|
|
+ let o = T.split(":");
|
|
|
+ o.splice(2, 1);
|
|
|
+ return o.join(":");
|
|
|
},
|
|
|
reloadOrder() {
|
|
|
orderList().then(res => {
|
|
@@ -227,7 +304,6 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
removequeue(id, i) {
|
|
|
- console.log(id);
|
|
|
Dialog.confirm({
|
|
|
message: "确定要删除该预约?",
|
|
|
confirmButtonColor: "#2a7ef4",
|
|
@@ -263,7 +339,7 @@ export default {
|
|
|
|
|
|
<style>
|
|
|
.queue {
|
|
|
- width: 990px;
|
|
|
+ width: 1200px;
|
|
|
height: 100%;
|
|
|
margin: 0 auto;
|
|
|
background-color: #fff;
|