lty
3 天以前 7437dd7b944aaeb64e98a1e0a5943ec88db4afab
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
244
245
246
247
248
249
250
251
252
253
254
<template>
  <view>
    <scroll-view scroll-y>
 
      <!-- 托盘条码 -->
      <view class="square-2">
        <view class="square-title">
          <view class="title-sign"><view class="sign"></view></view>
          <view class="title-text"><text>托盘条码</text></view>
        </view>
        <view class="square-content">
          <view class="content-input">
            <input
              v-model="barcode"
              placeholder="扫码 / 输入托盘码"
              maxlength="10"
              :focus="barcodeFocus"
              @input="barcodeInput"
            />
            <uni-icons type="closeempty" size="20" color="#dadada" @click="removeBarcode" />
          </view>
        </view>
      </view>
 
      <!-- 标题 -->
      <view class="square-1">
        <view class="square-title">
          <view class="title-sign"><view class="sign"></view></view>
          <view class="title-text"><text>拣料/盘点列表</text></view>
        </view>
      </view>
 
      <!-- 无数据 -->
      <view class="square-none" v-if="matList.length === 0">
        <view class="v-show">暂无数据</view>
      </view>
 
      <!-- 列表 -->
      <view
        v-for="(item, index) in matList"
        :key="index"
        class="data-list"
        :class="item.confirmed ? 'bg-true' : 'bg-false'"
      >
        <view class="data-list-left">
          <view>
            <text>编码:{{ item.matnr }}</text>
            <text style="margin-left: 40rpx;">名称:{{ item.maknx }}</text>
          </view>
          <view>
            <text>采购单号:{{ item.boxType3 }}</text>
          </view>
          <view>
            <text>PO:{{ item.standby1 }}</text>
            <text style="margin-left: 40rpx;">SKU:{{ item.standby3 }}</text>
          </view>
          <view>
            <text>UPC:{{ item.standby2 }}</text>
          </view>
          <view>
            <text>拣/盘数量:{{ item.count }}</text><text style="margin-left: 40rpx;">总数量: {{ item.total }}</text>
          </view>
        </view>
 
        <!-- 右侧确认 -->
        <view class="data-list-right">
          <button
            v-if="!item.confirmed"
            class="confirm-btn"
            @click="confirmRow(index)"
          >
            确认
          </button>
          <text v-else class="confirmed-text">已确认</text>
        </view>
      </view>
 
    </scroll-view>
 
    <!-- 底部按钮 -->
    <view class="footer">
      <button class="cu-btn bg-blue" @click="callAgv">
        呼叫小车
      </button>
    </view>
  </view>
</template>
 
 
<script>
export default {
  data() {
    return {
      barcode: "",
      barcodeFocus: true,
      matList: [],
      commonUrl: "",
      baseIP: "",
      basePORT: "",
      baseUrl: "",
    };
  },
 
  mounted() {
    const UIP = uni.getStorageSync("UIP");
    this.baseIP = UIP;
    const UPORT = uni.getStorageSync("UPORT");
    this.basePORT = UPORT;
    const PROJ = uni.getStorageSync("UPROJ");
    this.baseUrl = PROJ;
    this.getUrl();
  },
 
  methods: {
      getUrl() {
        this.commonUrl = this.baseHttp + this.baseIP + ":" + this.basePORT + "/" + this.baseUrl;
      },
    /* 扫码托盘码 */
    barcodeInput() {
      if (this.barcode.length !== 6) return;
      this.getPickList();
    },
 
    /* 调接口 */
    getPickList() {
      uni.showLoading();
 
      uni.request({
        url: this.commonUrl + "/open/asrs/pick/v1/getPickList",
        method: "POST",
        data: {
          barcode: this.barcode,
        },
        header: { token: uni.getStorageSync("token") },
        success: res => {
          uni.hideLoading();
          const r = res.data;
          if (r.code === 200) {
            this.matList = (r.data || []).map(item => ({
              ...item,
              confirmed: false,
            }));
          } else {
            uni.showToast({ title: r.msg || "获取失败", icon: "none" });
          }
        },
        fail() {
          uni.hideLoading();
          uni.showToast({ title: "请求失败", icon: "none" });
        },
      });
    },
 
    /* 单行确认 */
    confirmRow(index) {
      const item = this.matList[index];
      if (item.count <= 0 || item.count > item.total) {
        uni.showToast({
          title: "拣/盘数量不合法",
          icon: "none",
        });
        return;
      }
      this.$set(this.matList[index], "confirmed", true);
      uni.vibrateShort();
    },
 
    /* 呼叫小车 */
    callAgv() {
      if (!this.matList.length) {
        uni.showToast({ title: "暂无拣料数据", icon: "none" });
        return;
      }
 
      const hasUnConfirm = this.matList.some(i => !i.confirmed);
      if (hasUnConfirm) {
        uni.showToast({
          title: "请先确认所有拣料",
          icon: "none",
        });
        return;
      }
 
      uni.navigateTo({
        url: "/pages/agv/againIn",
      });
    },
 
    removeBarcode() {
      this.barcode = "";
      this.barcodeFocus = false;
      this.matList = [];
      this.$nextTick(() => (this.barcodeFocus = true));
    },
  },
};
 
</script>
 
<style>
.data-list {
  background-color: #fff;
  margin: 15rpx;
  padding: 20rpx;
  border-radius: 20rpx;
  display: flex;
}
 
.bg-true {
  background-color: #f0f9eb;
}
 
.data-list-left {
  flex: 1;
  font-size: 24rpx;
  color: #666;
}
 
.data-list-right {
  width: 120rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}
 
.confirm-btn {
  background-color: #1e9fff;
  color: #fff;
  font-size: 24rpx;
  border-radius: 10rpx;
  width: 150rpx;
  height: 50rpx;
  line-height: 50rpx;
}
 
.confirmed-text {
  color: #67c23a;
  font-size: 26rpx;
}
 
.footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  background: #fff;
  padding: 20rpx;
 
  display: flex;
  justify-content: center;   /* 水平居中 */
  align-items: center;       /* 垂直居中 */
}
 
 
</style>