小小儁爺
2025-11-18 aab92bb255f1cbd758cb9d96a89bfc73133bfb4a
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
<template>
    <view>
        <page-nav title="安灯呼叫"></page-nav>
 
        <u-notify ref="uNotify"></u-notify>
 
 
        <view v-show="topContent.length===0">
            <div class="sacnBody">
                <div class="scanImg" @click="topScanClick"></div>
                <div class="scanText">扫描工位</div>
            </div>
        </view>
 
        <view v-show="topContent.length!==0">
            <view class="mainContent">
                <view>
 
                    <u-gap height="10" bgColor="#eff0f1"></u-gap>
                    <view class="head">
                        <view class="head_block">
                            <view class="head_left">
                                <view class="head_bar"></view>
                                <view class="head_title">
                                    扫描工位
                                </view>
                            </view>
 
                            <view class="marginRight20">
                                <u-icon name="scan" @click="topScanClick" color="red" size="28"></u-icon>
                            </view>
 
                        </view>
 
 
 
                        <view class="marginTop20 marginLeft20 marginRight20" style="max-height:470rpx;overflow: auto;">
                            <u-radio-group v-model="radioValue" class="flex_column">
                                <view class="marginBottom20 flex_between" @click="groupChange(item.code)"
                                    v-for="item in topContent" :key="item.code">
                                    <view style="display: flex;">
                                        <view class="flex_column titleFont">
                                            <view>工位编码:</view>
                                            <view>工位名称:</view>
                                            <view>生产车间:</view>
                                        </view>
                                        <view class="flex_column contentFont">
                                            <view>{{item.code}}</view>
                                            <view>{{item.name}}</view>
                                            <view>{{item.wksp_name}}</view>
                                        </view>
                                    </view>
                                    <u-radio size='20' :key="item.code" :name="item.code"
                                        @change="groupChange(item.code)" activeColor="red"></u-radio>
                                </view>
                            </u-radio-group>
                        </view>
 
                    </view>
 
                    <u-gap height="10" bgColor="#eff0f1"></u-gap>
                    <view class="head">
                        <view class="head_block">
                            <view class="head_left">
                                <view class="head_bar"></view>
                                <view class="head_title">
                                    选择呼叫类型
                                </view>
                            </view>
                        </view>
 
                        <view class="marginTop20 marginBottom20">
                            <view class="flex_column " style="margin: 10rpx;" v-for="item in centerContent"
                                :key="item.code">
                                <div style="display: flex;justify-content: space-between">
                                    <div class="marginLeft20 contentFont">{{item.name}}</div>
                                    <u-switch class="marginRight20" activeColor="red" :key="item.code+Math.random()"
                                        :disabled="item.flag==='Y'" v-model="item.isTrue" size="20"
                                        @change='switchChange(item.code)'></u-switch>
                                </div>
                            </view>
                        </view>
 
 
                    </view>
 
                </view>
 
            </view>
 
            <u-button size="large" type="primary" @click="submit" :loading="isDisabledSubmitButton"
                loadingText="正在提交,请稍等..." text="确认提交" :disabled="centerContent.length===centerSelected.length">
            </u-button>
 
        </view>
 
        <scan-code></scan-code>
    </view>
</template>
 
<script>
    import {
        AppAnDonCallSave,
        AppAnDonCallScanSearch,
        AppAnDonCallItemSearch,
    } from '../../config/api.js'
    import scanCode from '@/components/scan-code/scan-code.vue'
    export default {
        components: {
            scanCode
        },
        onLoad(option) {
 
            const _this = this
            uni.$off('scancodedate') // 每次进来先 移除全局自定义事件监听器
            uni.$on('scancodedate', function(content) {
                console.log("扫描到的内容为:", content)
                _this.getAppDeviceAnDengCallScanSearch(content)
            })
        },
        onPullDownRefresh() {
            setTimeout(() => {
                this.init(() => {
                    uni.stopPullDownRefresh();
                })
            }, 1000);
        },
        data() {
            return {
 
                topContent: [], //头部数据
                centerContent: [], //选择呼叫类型
                scanContent: '', //扫描扫出来的值
                radioValue: '', //单选框的值
 
                centerSelected: [], //点击头部切换时 已选中的开关
 
                isDisabledSubmitButton: false, //提交按钮是否处于加载中
            }
        },
        created() {
 
        },
        mounted() {
            this.init()
            // this.getAppDeviceAnDengCallScanSearch('LD001');
 
        },
        methods: {
            init() {
                uni.stopPullDownRefresh();
            },
            // 扫码 工位  的扫码框点击
            topScanClick() {
                let that = this;
                uni.scanCode({
                    onlyFromCamera: true,
                    scanType: ['qrCode'],
                    success: function(res) {
                        that.scanContent = res.result;
                        let flag = false
                        that.topContent.forEach(item => {
                            if (item.code === res.result) {
                                flag = true
                            }
                        })
                        if (flag) {
                            that.$u.toast('此条码已扫描,已在列表中!')
                        } else {
                            //处理扫码事件
                            that.getAppDeviceAnDengCallScanSearch(that.scanContent);
                        }
                    },
                    complete: function(res) {},
                    fail: function(res) {
 
                    }
 
                });
            },
            // 获取扫描工位
            async getAppDeviceAnDengCallScanSearch(val) {
                const res = await AppAnDonCallScanSearch(this.global.formatData({
                    eqpcode: val
                }))
                if (res.code === '200') {
                    this.topContent.unshift(res.data[0])
                    this.radioValue = this.topContent[0].code
 
                    this.$forceUpdate()
                    this.getAppDeviceAnDengCallItemSearch(this.radioValue)
                }
            },
            async getAppDeviceAnDengCallItemSearch(val) {
                const data = {
                    eqpcode: val,
                    wkshpcode: this.topContent.find(i => i.code === val).wksp_code
                }
 
                const res = await AppAnDonCallItemSearch(this.global.formatData(data))
                if (res.code === '200') {
                    this.centerContent = res.data
                    this.centerSelected = []
                    this.centerContent.forEach(r => {
                        r.isTrue = r.flag === 'Y'
                        if (r.flag === 'Y') {
                            this.centerSelected.push(r.code)
                        }
                    })
                    this.$forceUpdate()
                }
            },
            // 单选按钮点击
            groupChange(val) {
                this.radioValue = val
                this.$forceUpdate()
                this.getAppDeviceAnDengCallItemSearch(val)
            },
            // 开关按钮点击
            switchChange(val) {
                this.centerContent.find(i => i.code === val).isTrue != this.centerContent.find(i => i.code === val).isTrue
                this.$forceUpdate()
            },
            // 确认提交按钮
            async submit() {
                if (this.centerContent.filter(i => i.isTrue === true).length === this.centerSelected.length) {
                    return uni.$u.toast('提交失败!未对该设备选择新的呼叫类型')
                }
 
                this.isDisabledSubmitButton = true
                let data = []
                this.centerContent.forEach(i => {
                    if (i.isTrue && !this.centerSelected.includes(i.code)) {
                        i.flag = i.isTrue ? 'Y' : 'N'
                        data.push(i)
                    }
                })
 
                const data1 = {
                    eqpcode: this.topContent.find(i => i.code === this.radioValue).code,
                    wkshpcode: this.topContent.find(i => i.code === this.radioValue).wksp_code
                }
 
 
                AppAnDonCallSave(this.global.formatData(data1), data).then(
                    res => {
                        if (res.code === '200') {
                            uni.$u.toast('提交成功!')
                            this.isDisabledSubmitButton = false
                            this.topContent = this.topContent.filter(i => i.code !== this.radioValue)
                            if (this.topContent.length > 0) {
                                this.groupChange(this.topContent[0].code)
                            }
                        }
                    })
 
 
            },
        }
    }
</script>
 
<style lang="scss" scoped>
    @import url('@/style/global.css');
 
    ::v-deep .uicon-arrow-left>span {
        display: block;
    }
</style>