|
@@ -1,52 +1,39 @@
|
|
<template>
|
|
<template>
|
|
<div class="background">
|
|
<div class="background">
|
|
|
|
+ <div class="title">
|
|
|
|
+ <div class="title-text">换酒详情</div>
|
|
|
|
+ <div class="finish" @click="finish">完 成 换 酒</div>
|
|
|
|
+ </div>
|
|
<table>
|
|
<table>
|
|
- <caption>
|
|
|
|
- <span>换酒详情</span>
|
|
|
|
- <div class="finish" @click="finish">完 成 换 酒</div>
|
|
|
|
- </caption>
|
|
|
|
<thead>
|
|
<thead>
|
|
<tr>
|
|
<tr>
|
|
<th class="col-1">仓号</th>
|
|
<th class="col-1">仓号</th>
|
|
- <th class="col-2">当前信息 [ID/名称/余量(ML)]</th>
|
|
|
|
- <th class="col-3">换酒目标 [ID/名称/余量(ML)]</th>
|
|
|
|
|
|
+ <th class="col-2" colspan="2">当前信息</th>
|
|
|
|
+ <th class="col-3" colspan="2">换酒目标</th>
|
|
</tr>
|
|
</tr>
|
|
</thead>
|
|
</thead>
|
|
<tbody>
|
|
<tbody>
|
|
- <tr v-for="(info, index) in detail" :key="index">
|
|
|
|
- <td>{{ info.cell }}</td>
|
|
|
|
- <td class="info-box">
|
|
|
|
- <span>{{ info.old.id }}</span>
|
|
|
|
- <span>{{ info.old.name }}</span>
|
|
|
|
- <span>{{ info.old.remain }}</span>
|
|
|
|
- </td>
|
|
|
|
- <td class="info-box">
|
|
|
|
- <span>{{ info.new.id }}</span>
|
|
|
|
- <span>{{ info.new.name }}</span>
|
|
|
|
- <span>{{ info.new.remain }}</span>
|
|
|
|
|
|
+ <tr v-for="r in detail.length * 3" :key="r" class="row">
|
|
|
|
+ <td v-if="r % 3 === 1" rowspan="3" class="cell">
|
|
|
|
+ {{ detail[Math.floor((r - 1) / 3)].cell }}
|
|
</td>
|
|
</td>
|
|
|
|
+ <td class="key">{{ name_of(r) }}</td>
|
|
|
|
+ <td class="value">{{ old_of(r) }}</td>
|
|
|
|
+ <td class="key">⇒</td>
|
|
|
|
+ <td class="value">{{ new_of(r) }}</td>
|
|
</tr>
|
|
</tr>
|
|
</tbody>
|
|
</tbody>
|
|
</table>
|
|
</table>
|
|
- <div class="auth" v-if="!authed">
|
|
|
|
- <div class="result">
|
|
|
|
- <div class="tip">请输入授权码</div>
|
|
|
|
- <div class="code-box">
|
|
|
|
- <div v-for="i in 6" :class="{code: true, active: is_act(i)}" :key="i">{{ codeList[i - 1] }}</div>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- <NumberKeyboard @press="press" @cancel="cancel" @delete="delete_back"/>
|
|
|
|
- </div>
|
|
|
|
|
|
+ <AuthFixedLayer v-if="!authed" ref="auth" @finish="try_code" @cancel="cancel"/>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import NumberKeyboard from "@/components/NumberKeyboard";
|
|
|
|
|
|
+import AuthFixedLayer from "@/components/AuthFixedLayer";
|
|
|
|
|
|
-let codeIndex = -1;
|
|
|
|
export default {
|
|
export default {
|
|
name: "WineChangePage",
|
|
name: "WineChangePage",
|
|
- components: {NumberKeyboard},
|
|
|
|
|
|
+ components: {AuthFixedLayer},
|
|
props: {
|
|
props: {
|
|
wid: {
|
|
wid: {
|
|
type: String,
|
|
type: String,
|
|
@@ -61,6 +48,19 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ name_of(r) {
|
|
|
|
+ if (r % 3 === 1) return "ID";
|
|
|
|
+ if (r % 3 === 2) return "名称";
|
|
|
|
+ return "余量";
|
|
|
|
+ },
|
|
|
|
+ old_of(r) {
|
|
|
|
+ let index = Math.floor((r - 1) / 3), left = r % 3, key = left === 1 ? "id" : (left === 2 ? "name" : "remain");
|
|
|
|
+ return this.detail[index].old[key];
|
|
|
|
+ },
|
|
|
|
+ new_of(r) {
|
|
|
|
+ let index = Math.floor((r - 1) / 3), left = r % 3, key = left === 1 ? "id" : (left === 2 ? "name" : "remain");
|
|
|
|
+ return this.detail[index].new[key];
|
|
|
|
+ },
|
|
finish() {
|
|
finish() {
|
|
if (this.$utils.Socket === null) return alert("network error");
|
|
if (this.$utils.Socket === null) return alert("network error");
|
|
const message = {
|
|
const message = {
|
|
@@ -73,51 +73,46 @@ export default {
|
|
this.$utils.Socket.send(JSON.stringify(message));
|
|
this.$utils.Socket.send(JSON.stringify(message));
|
|
this.$emit("to_wine");
|
|
this.$emit("to_wine");
|
|
},
|
|
},
|
|
- is_act(index) {
|
|
|
|
- return codeIndex === index - 2;
|
|
|
|
- },
|
|
|
|
- press(num) {
|
|
|
|
- if (codeIndex === 5) return;
|
|
|
|
- this.codeList[++codeIndex] = num;
|
|
|
|
- if (codeIndex === 5) {
|
|
|
|
- let code = this.codeList.join("");
|
|
|
|
- if (this.$utils.Socket === null) return alert("network error");
|
|
|
|
- const message = {
|
|
|
|
- event: "checkAuthCode",
|
|
|
|
- data: {
|
|
|
|
- type: "Changing",
|
|
|
|
- wid: this.wid,
|
|
|
|
- code: code
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- this.$utils.Socket.send(JSON.stringify(message));
|
|
|
|
- }
|
|
|
|
|
|
+ try_code(code) {
|
|
|
|
+ if (this.$utils.Socket === null) return alert("network error");
|
|
|
|
+ const message = {
|
|
|
|
+ event: "checkAuthCode",
|
|
|
|
+ data: {
|
|
|
|
+ type: "Changing",
|
|
|
|
+ wid: this.wid,
|
|
|
|
+ code: code
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ this.$utils.Socket.send(JSON.stringify(message));
|
|
},
|
|
},
|
|
cancel() {
|
|
cancel() {
|
|
this.$emit("to_wine");
|
|
this.$emit("to_wine");
|
|
},
|
|
},
|
|
- delete_back() {
|
|
|
|
- if (codeIndex < 0) return;
|
|
|
|
- this.codeList[codeIndex--] = "";
|
|
|
|
- },
|
|
|
|
- _onChangeAuthed() {
|
|
|
|
- setTimeout(() => {
|
|
|
|
- if (this.$utils.Socket === null) return alert("network error");
|
|
|
|
- const message = {
|
|
|
|
- event: "openResult",
|
|
|
|
- data: {
|
|
|
|
- type: "Changing",
|
|
|
|
- wid: this.wid,
|
|
|
|
- result: true
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- this.$utils.Socket.send(JSON.stringify(message));
|
|
|
|
- this.authed = true;
|
|
|
|
- }, 1000);
|
|
|
|
|
|
+ _onAuthCodeResult(data) {
|
|
|
|
+ if (!data.ok) {
|
|
|
|
+ alert("auth failed");
|
|
|
|
+ this.$refs.auth.reset();
|
|
|
|
+ } else {
|
|
|
|
+ alert("认证成功,正在开门 ...");
|
|
|
|
+ this.detail = data.work;
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ if (this.$utils.Socket === null) return alert("network error");
|
|
|
|
+ const message = {
|
|
|
|
+ event: "openResult",
|
|
|
|
+ data: {
|
|
|
|
+ type: "Changing",
|
|
|
|
+ wid: this.wid,
|
|
|
|
+ result: true
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ this.$utils.Socket.send(JSON.stringify(message));
|
|
|
|
+ this.authed = true;
|
|
|
|
+ }, 1000);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
- this.$utils.SockEventMap["changeAuthed"] = this._onChangeAuthed;
|
|
|
|
|
|
+ this.$utils.SockEventMap["authCodeResult"] = this._onAuthCodeResult;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
@@ -125,105 +120,70 @@ export default {
|
|
<style scoped>
|
|
<style scoped>
|
|
.background {
|
|
.background {
|
|
display: flex;
|
|
display: flex;
|
|
|
|
+ flex-direction: column;
|
|
justify-content: center;
|
|
justify-content: center;
|
|
align-items: center;
|
|
align-items: center;
|
|
}
|
|
}
|
|
|
|
|
|
-table {
|
|
|
|
|
|
+.title {
|
|
width: 80%;
|
|
width: 80%;
|
|
- border: none;
|
|
|
|
- background-color: aqua;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-th, td {
|
|
|
|
- background-color: white;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-caption {
|
|
|
|
- width: 100%;
|
|
|
|
display: flex;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
align-items: center;
|
|
|
|
+ margin-bottom: 10px;
|
|
}
|
|
}
|
|
|
|
|
|
-caption > span {
|
|
|
|
|
|
+.title-text {
|
|
font-size: 1.2em;
|
|
font-size: 1.2em;
|
|
font-weight: bold;
|
|
font-weight: bold;
|
|
}
|
|
}
|
|
|
|
|
|
.finish {
|
|
.finish {
|
|
- width: 7em;
|
|
|
|
- height: 1.5em;
|
|
|
|
display: flex;
|
|
display: flex;
|
|
|
|
+ border-radius: 4px;
|
|
justify-content: center;
|
|
justify-content: center;
|
|
align-items: center;
|
|
align-items: center;
|
|
border: 1px solid deepskyblue;
|
|
border: 1px solid deepskyblue;
|
|
color: deepskyblue;
|
|
color: deepskyblue;
|
|
- font-weight: bold;
|
|
|
|
|
|
+ font-size: 1.1em;
|
|
cursor: pointer;
|
|
cursor: pointer;
|
|
|
|
+ padding: 4px 16px;
|
|
}
|
|
}
|
|
|
|
|
|
-.col-1 {
|
|
|
|
- width: 2em;
|
|
|
|
|
|
+table {
|
|
|
|
+ width: 80%;
|
|
|
|
+ border: none;
|
|
|
|
+ background-color: aqua;
|
|
}
|
|
}
|
|
|
|
|
|
-.col-2, .col-3 {
|
|
|
|
- width: calc((100% - 2em) / 2);
|
|
|
|
|
|
+th, td {
|
|
|
|
+ background-color: white;
|
|
|
|
+ text-align: center;
|
|
}
|
|
}
|
|
|
|
|
|
-.info-box {
|
|
|
|
- display: flex;
|
|
|
|
- flex-direction: column;
|
|
|
|
- align-items: center;
|
|
|
|
|
|
+.col-1 {
|
|
|
|
+ width: 4em;
|
|
}
|
|
}
|
|
|
|
|
|
-.auth {
|
|
|
|
- width: 100%;
|
|
|
|
- height: 100%;
|
|
|
|
- position: fixed;
|
|
|
|
- top: 0;
|
|
|
|
- left: 0;
|
|
|
|
- background-color: rgba(55, 55, 55, 0.25);
|
|
|
|
- display: flex;
|
|
|
|
- flex-direction: column;
|
|
|
|
- justify-content: space-between;
|
|
|
|
- align-items: center;
|
|
|
|
|
|
+.col-2, .col-3 {
|
|
|
|
+ width: calc((100% - 4em) / 2);
|
|
}
|
|
}
|
|
|
|
|
|
-.result {
|
|
|
|
- width: 300px;
|
|
|
|
- height: 200px;
|
|
|
|
- border: 1px solid gray;
|
|
|
|
- background-color: white;
|
|
|
|
- border-radius: 4px;
|
|
|
|
- box-sizing: border-box;
|
|
|
|
- padding: 10px 20px;
|
|
|
|
- display: flex;
|
|
|
|
- flex-direction: column;
|
|
|
|
- justify-content: space-between;
|
|
|
|
|
|
+.row {
|
|
|
|
+ height: 2em;
|
|
}
|
|
}
|
|
|
|
|
|
-.tip {
|
|
|
|
- font-size: 1.2em;
|
|
|
|
|
|
+.cell {
|
|
font-weight: bold;
|
|
font-weight: bold;
|
|
}
|
|
}
|
|
|
|
|
|
-.code-box {
|
|
|
|
- width: 100%;
|
|
|
|
- display: flex;
|
|
|
|
- justify-content: space-between;
|
|
|
|
- align-items: center;
|
|
|
|
|
|
+.key {
|
|
|
|
+ width: 6em;
|
|
|
|
+ font-weight: bold;
|
|
}
|
|
}
|
|
|
|
|
|
-.code {
|
|
|
|
- width: 30px;
|
|
|
|
- height: 30px;
|
|
|
|
- font-size: 1.5em;
|
|
|
|
- display: flex;
|
|
|
|
- justify-content: center;
|
|
|
|
- align-items: center;
|
|
|
|
- border: 1px solid lightgray;
|
|
|
|
- border-radius: 2px;
|
|
|
|
- box-shadow: 0 0 2px dimgray;
|
|
|
|
|
|
+.value {
|
|
|
|
+ text-align: left;
|
|
|
|
+ text-indent: 2em;
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|