1
wankeda
2025-04-11 91b610a8cf7ad7a4e52486d3ff904df229873b23
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<template>
    <view class="example">
        <u-tabs :list="list" :is-Scroll="false" :current="current2"></u-tabs>
        <view v-show="current2 === 0">
            <uni-section title="一楼库存查看" type="line" padding style="height: calc(100vh - 100px);">
                <uni-list>
                    <!-- to 属性携带参数跳转详情页面,当前只为参考 -->
                    <uni-list-item direction="column" v-for="(item, index) in listData" :key="index"
                        @click="handleClick(item.orderNo, item.productCode, item.number)" link>
                        <!-- 通过header插槽定义列表的标题 -->
                        <template v-slot:header>
                            <view class="uni-title">工单:{{item.orderNo}}
                                <!-- <uni-icons type="trash" size="22" style="position: absolute;right: 5%;"
                                    @click="deleteList(item.container_barcode)">
                                </uni-icons> -->
                            </view>
                        </template>
                        <!-- 通过body插槽定义列表内容显示 -->
                        <template v-slot:body>
                            <view class="uni-list-box">
                                <view class="uni-content">
                                    <view class="uni-title-sub uni-ellipsis-2">型号:{{item.productCode}}</view>
                                    <view class="uni-title-sub uni-ellipsis-2">可叫任务数量:{{item.number}}</view>
                                </view>
                            </view>
                        </template>
                    </uni-list-item>
                </uni-list>
                <uni-load-more iconType="circle" :status="status" @clickLoadMore="clickLoadMore" />
            </uni-section>
        </view>
        <view>
            <u-modal v-model="Modalshow" @confirm="confirmInput" :mask-close-able="true" :show-cancel-button="true">
                <view class="slot-content">
                    <text>{{content}}</text>
                    <u-gap height="10"></u-gap>
                    <!-- 输入框,使用 v-model 绑定输入值 -->
                    <uni-easyinput v-model="inputValue" placeholder="请输入叫料的烘烤设备" />
                    <u-gap height="10"></u-gap>
                    <uni-easyinput type="number" v-model="numberValue" placeholder="请输入叫料数量" />
                </view>
            </u-modal>
            <!-- 使用 uni-popup 组件,设置为对话框类型 -->
            <uni-popup ref="popup" type="dialog" background-color="#fff" class="popup-main">
                <!-- 使用插槽自定义弹出框内容 -->
                <!-- <template #content> -->
                <view class="popup-container">
                    <!-- 显示对话框内容 -->
                    <view class="popup-content">{{ content }}</view>
                    <!-- 输入框,使用 v-model 绑定输入值 -->
                    <uni-easyinput v-model="inputValue" placeholder="请输入内容" />
                    <u-gap height="10"></u-gap>
                    <uni-easyinput type="number" v-model="numberValue" placeholder="请输入叫料数量" />
                    <!-- 按钮组 -->
                    <view class="button-group">
                        <!-- 关闭按钮 -->
                        <u-button class="custom-button cancel-button" @click="closePopup" type="default" shape="square"
                            size="medium">关闭</u-button>
                        <!-- 同意按钮 -->
                        <u-button class="custom-button confirm-button" @click="confirmInput" type="primary"
                            shape="square" size="medium">同意</u-button>
                    </view>
                </view>
                <!-- </template> -->
            </uni-popup>
        </view>
    </view>
</template>
<script>
    export default {
        data() {
            return {
                listData: [],
                list: [{
                    name: '库存查看'
                }],
                current2: 0,
                current: 1,
                size: 10,
                status: 'more',
                Modalshow: false,
                title: "提示",
                content: '欢迎使用 uni-popup!',
                msgType: 'success',
                value: '',
                inputValue: '',
                numberValue: '',
                currentAvailableQuantity: 0
            };
        },
        onLoad() {
            this.submit();
        },
        methods: {
            onClickItem(e) {
                if (this.current != e.currentIndex) {
                    this.current = e.currentIndex;
                }
            },
            submit(cb) {
                this.$t.message.loading();
                let formDataParam = {
                    current: this.current,
                    size: this.size
                };
                uni.getStorage({
                    key: 'storage_key_ipAddress',
                    success: (res) => {
                        this.$t.message.loading();
                        let formDataParam = {
                            current: this.current,
                            size: this.size
                        };
                        // 使用创智完整接口
                            // this.$u.post('http://192.168.31.240:9090/makerwit/selectKHWareType', null).then(res => {
                        this.$u.post(res.data.CZFJiP + '/makerwit/selectKHWareType', null).then(res => {
                            console.log(res);
                            this.$t.message.closeLoading();
                            cb && cb();
                            if (cb != null) this.listData = [];
                            this.listData = [...this.listData, ...res.data];
                            console.log(this.listData);
                        }).catch((err) => {
                            this.$t.message.toast(err.message);
                        });
                    },
                    fail: (err) => {
                        this.$t.message.toast('请先设置IP地址');
                        uni.navigateTo({
                            url: '/pages/SetAddress/SetAddress',
                        });
                    },
                });
 
            },
            clickLoadMore(e) {
                this.status = 'loading';
                this.current += 1;
                this.size += 10;
                this.submit();
            },
            handleClick(orderNo, productCode, number) {
                console.log(this.$refs);
                // this.$refs.popup.open();
                this.Modalshow = true;
                this.content = `工单:${orderNo}\n型号:${productCode}\n可叫数量:${number}\n请确认是否叫任务`;
                this.currentAvailableQuantity = number;
                // this.numberValue = number > 4 ? 4 : number; // 设置默认值为4或可用数量
            },
            confirmInput() {
                this.$t.message.loading();
 
                // 提取输入框的值
                const inputValue = this.inputValue;
                const numberValue = parseInt(this.numberValue);
                // 提取工单编号
                const orderNo = this.content.match(/工单:(.*)\n/)[1];
                // 提取型号
                const productCode = this.content.match(/型号:(.*)\n/)[1];
                
                if (inputValue == "") {
                    this.$t.message.toast('请输入烘烤设备');
                    return;
                }
                if (numberValue <= 0) {
                    this.$t.message.toast('叫料数量必须大于0');
                    return;
                }
                if (numberValue > this.currentAvailableQuantity) {
                    this.$t.message.toast('叫料数量不能超过可叫数量');
                    return;
                }
                
                let formDataParam = {
                    dTaskId: this.generateUUID(),
                    productCode: productCode,
                    orderNo: orderNo,
                    taskNo:2,
                    number: numberValue,
                    inputValue: inputValue,
                    DTaskId: this.generateUUID(),
                    ProductCode: productCode,
                    OrderNo: orderNo,
                    Number: numberValue,
                    InputValue: inputValue,
                    TaskType: "负极"
                    // ...其他需要传递的参数
                };
 
                this.$u.post('/api/PDA/AddCZTask', formDataParam).then(res => {
                    if (res.status) {
                        const value = uni.getStorageSync('storage_key_ipAddress');
                        // 使用创智完整接口
                        this.$u.post(value.CZFJiP + '/makerwit/insertTask', formDataParam).then(res => {
                            this.$t.message.closeLoading();
                            console.log(formDataParam);
                            if (res.code == 200) {
                                this.$t.message.toast('呼叫成功');
                                this.$refs.popup.close();
                                // this.submit();
                            } else {
                                this.$t.message.toast(res.msg);
                            }
                        });
                        // this.submit();
                    } else {
                        this.$t.message.toast(res.msg);
                    }
                }).catch((err) => {
                    this.$t.message.toast(err.message);
                });
            },
            closePopup() {
                this.$refs.popup.close();
            },
            generateUUID() {
                var d = new Date().getTime();
                var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
                    var r = (d + Math.random() * 16) % 16 | 0;
                    d = Math.floor(d / 16);
                    return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
                });
                return uuid;
            },
        },
        onPullDownRefresh() {
            this.current = 1;
            this.size = 10;
            this.submit(() => uni.stopPullDownRefresh());
        },
    };
</script>
 
<style lang="scss" scoped>
    @import '@/common/uni-ui.scss';
 
    .example {
        padding: 15px;
        background-color: #fff;
    }
 
    page {
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
        background-color: #efeff4;
        min-height: 100%;
        height: auto;
    }
 
    .tips {
        color: #67c23a;
        font-size: 14px;
        line-height: 40px;
        text-align: center;
        background-color: #f0f9eb;
        height: 0;
        opacity: 0;
        transform: translateY(-100%);
        transition: all 0.3s;
    }
 
    .tips-ani {
        transform: translateY(0);
        height: 40px;
        opacity: 1;
    }
 
    .content {
        width: 100%;
        display: flex;
    }
 
    .list-picture {
        width: 100%;
        height: 145px;
    }
 
    .thumb-image {
        width: 100%;
        height: 100%;
    }
 
    .ellipsis {
        display: flex;
        overflow: hidden;
    }
 
    .uni-ellipsis-1 {
        overflow: hidden;
        white-space