receiveGas.vue
5.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<template>
<view class="container">
<Navbar title="气瓶领取" bgColor="#EA5504" leftIconColor="#fff" textColor="#fff" canBack></Navbar>
<view class="topBodyCss">
<view class="padding-lg flex justify-between">
<view class="">
<view class="text-lg text-white">
领取前需确认领取气瓶信息是否准确
</view>
<view class="text-white margin-top-lg">
类型:气瓶领取
</view>
</view>
<view class="">
<u-image width="100px" height="90px" src="/static/images/gas-icon/receiveBg.png"></u-image>
</view>
</view>
<view class="CardCss">
<view class="text-center text-lg margin-sm">
<!-- <u-tabs :list="list" lineColor="#EA5504" :activeStyle="{fontSize:'18px',fontWeight:'bold'}"
:current="current" :itemStyle="{width:'50%',height:'50px'}" @change="tabChange"></u-tabs> -->
{{list[1].name}}
</view>
<view class="qpCardCss">
<view class="qpTopCss flex justify-between align-center padding-lg">
<view class="">
气瓶条码
</view>
<view class="">
操作
</view>
</view>
<view class="" v-if="!current">
<view class="qpItemCss flex justify-between align-center padding-lr-lg padding-tb-sm"
v-for="(item,index) in kptm" :key="index">
<view class="">
{{item}}
</view>
<view class="">
<u-icon name="trash" @click="delTm(index)"></u-icon>
</view>
</view>
<view class="text-center padding" v-if="!kptm.length">
扫码添加条码
</view>
</view>
<view class="" v-else>
<view class="qpItemCss flex justify-between align-center padding-lr-lg padding-tb-sm"
v-for="(item,index) in mptm" :key="index">
<view class="">
{{item}}
</view>
<view class="">
<u-icon name="trash" @click="delTm(index)"></u-icon>
</view>
</view>
<view class="text-center padding" v-if="!mptm.length">
扫码添加条码
</view>
</view>
</view>
</view>
<view class="btnCss">
<view class="roundBtnCss flex flex-direction" @click="handleCode">
<view class="">
<u-icon name="scan" color="#fff" size="45"></u-icon>
</view>
<view class="">
{{current?'领取满瓶':'领取空瓶'}}
</view>
</view>
<view class="w90 margin-top" @click="handleSubmit">
<u-button color="#EA5504">全部领取</u-button>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
components: {},
props: {
},
data() {
return {
current: 1,
list: [{
name: '空瓶领取(0)'
},
{
name: '满瓶领取(0)'
},
],
kptm: [],
mptm: [],
mplqList:[],
}
},
computed: {
},
onLoad() {
uni.$on('scanCode', (code, name, fQptmObj) => {
if (name === 'receiveGas') {
if (this.current) {
if (!this.mptm.includes(code)) {
this.mptm.push(code);
this.mplqList.push(fQptmObj);
} else {
setTimeout(() => {
uni.$u.toast('已录入');
}, 100)
}
} else {
if (!this.kptm.includes(code)) {
this.kptm.push(code);
} else {
setTimeout(() => {
uni.$u.toast('已录入');
}, 100)
}
}
this.changeState();
}
});
},
methods: {
changeState() {
this.list[0].name = `领取空瓶(${this.kptm.length})`
this.list[1].name = `领取满瓶(${this.mptm.length})`;
},
tabChange(e) {
this.current = e.index;
},
handleCode() {
// 组件扫码
// this.$refs.scanCode.open();
let lx = this.current ? 'mplq' : 'kplq';
uni.navigateTo({
url: '/pages/scan/scanCode?mode=2&lx=' + lx
})
},
delTm(index) {
if (this.current) {
this.mptm.splice(index, 1)
} else {
this.kptm.splice(index, 1)
}
this.changeState();
},
async handleSubmit() {
if (!this.kptm.length && !this.mptm.length) {
uni.$u.toast('请先扫码添加条码');
return
}
// let submitData = {
// kp: this.kptm,
// mp: this.mptm
// };
// const result = await this.$api.gasApi.gasReceiveQp(submitData);
let submitData = {
czlx:"mplq",
mplqList:this.mplqList
};
const result = await this.$api.gasApi.savaLiquefiedGasBottle(submitData);
let {
code,
state,
message
} = result;
if (code === 200 && state) {
uni.$u.toast('全部领取成功');
this.mptm = [];
this.kptm = [];
this.mplqList = [];
this.changeState();
} else {
uni.$u.toast(message);
}
}
}
}
</script>
<style lang="scss" scoped>
.topBodyCss {
height: 316px;
background: #EA5504;
.CardCss {
width: calc(100% - 24px);
position: absolute;
margin: 0 12px;
background: #fff;
border-radius: 15px;
padding-bottom: 20px;
}
.qpCardCss {
margin: 0 12px;
border: 1px solid #FBDDCD;
border-radius: 8px 8px 0 0;
.qpTopCss {
background: #FBDDCD;
height: 30px;
border-radius: 8px 8px 0 0;
}
.qpItemCss {
border-bottom: 1px solid #FBDDCD;
}
}
.btnCss {
position: absolute;
bottom: 0;
height: 120px;
width: 100%;
background: #fff;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.roundBtnCss {
position: absolute;
top: -50px;
width: 85px;
height: 85px;
border-radius: 50%;
background: #EA5504;
display: flex;
justify-content: center;
align-items: center;
color: #fff;
}
}
}
</style>