guoyujie
9 天以前 a6c698f7418c1b0ea6202f068993d74a3347b0e6
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
<template>
  <view>
    <uni-section class="mb-10" :title="'用户名称:'+store.user.userName">
      <template v-slot:right>
        班组:{{store.user.address || ''}}
      </template>
    </uni-section>
    </view>
  <view class="content">
        
        <uni-row>
                            <uni-col :span="12">
                                <button @click="scannerGetGlassInfo" type="primary" size="mini">玻璃信息</button>
                            </uni-col>
                            <uni-col :span="12">
                              <button @click="scanerCode" type="primary" size="mini">扫码报工</button>
                            </uni-col>
                         <uni-col :span="12">
                          <button  type="primary" size="mini" @click="quantityCompletion1">当班产量</button>
                        </uni-col>
                            <uni-col :span="12">
                                <navigator  url="/pages/ReportingWorkList/ReportingWorkList" open-type="navigate" >
                                    <button type="primary" size="mini">报工记录</button>
                                </navigator>
                             </uni-col>
                             
                             
                             <uni-col :span="12">
                                 <button @click="glassFinishToStore" type="primary"  size="mini">成品入库</button>
                             </uni-col>
                             <uni-col :span="12">
                               <button  type="primary" size="mini">成品出库</button>
                             </uni-col>
                             
                             
                       <!-- <uni-col :span="24" v-if="store.user.permissions.includes('qualityInspectionReview.edit')">
                                <navigator url="/pages/ReviewReporitingWork/ReviewReporitingWork" open-type="navigate">
                                        <button type="primary" size="mini">质检审核</button>
                                </navigator>
                        </uni-col> -->
                            <!-- <uni-col :span="24">
                                <uni-data-select
                                    placeholder="报表"
                                    v-model="report"
                                    :localdata="reports"
                                    @change="changePage"
                                ></uni-data-select>
                            </uni-col> -->
                            
                            <uni-col :span="12">
                                <uni-data-select
                                    placeholder="工序"
                                    v-model="process"
                                    :disabled="flag"
                                    :localdata="processList"
                                    @change="changeProcess"
                                ></uni-data-select>
                            </uni-col>
                            
                            <uni-col :span="12">
                                <uni-data-select
                                    placeholder="请选择设备"
                                    v-model="device"
                                    :localdata="store.deviceList"
                                    @change="change"
                                ></uni-data-select>
                            </uni-col>
                        <uni-col :span="24">
                          <navigator url="/pages/index/index" open-type="reLaunch">
                            <button type='warn' size="mini">退出</button>
                          </navigator>
                        </uni-col>
                      </uni-row>
        
      <!-- <view class="text-area">
          
      </view> -->
        <view>
            <!-- 提示信息弹窗 -->
            <uni-popup ref="message" type="message">
                <uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
            </uni-popup>
        </view>
  </view>
    
    
</template>
 
<script setup>
import userInfo from '@/stores/userInfo'
import { onLoad } from '@dcloudio/uni-app'
    import request from '@/utils/request'
    import mpaasScan from '@/utils/scanner.js'
import { ref, watch,onUnmounted, warn } from 'vue'
    const store=userInfo()
    const message= ref(null)
    const type=ref('center')
    const msgType=ref(null)
    const messageText=ref('')
    let device = ref(null)
    let report = ref(null)
    const reports = ref([
        {value:'orderList',text:'订单报表'},
        {value:'deliveryList',text:'发货报表'},
        {value:'originalGlassList',text:'原片库存'}
    ])
    
    let process = ref(null)
    let processList = ref([])
    let flag = ref(false)
    
    
    const Intent = plus.android.importClass('android.content.Intent')
    const IntentFilter = plus.android.importClass('android.content.IntentFilter')
    
    const main = plus.android.runtimeMainActivity()
    // pda定义的广播名称
    const SCANACTION = "android.intent.ACTION_SCAN_OUTPUT"
    
    var filter = new IntentFilter()
    filter.addAction(SCANACTION)
    
    // 接收
    var receiver = plus.android.implements('io.dcloud.feature.internal.reflect.BroadcastReceiver', {
        onReceive: onReceive
    })
    
    function onReceive(context, intent) {
        const page =getCurrentPages()[getCurrentPages().length - 1]
        //判断当前页面是否在主页
        if(page.route!=='pages/mainView/mainView'){
            return
        }
        if (intent.getAction() === SCANACTION) {
            const code = intent.getStringExtra("barcode");
                    uni.navigateTo({
                         url: `/pages/glassInfo/glassInfo?projectNo=${code}`
                     }) 
            // 扫描信息处理
            //uni.$emit('scan', code)
        }
    }
    const getDeviceList = async()=> {
        if(store.choiceDevice.value!=null){
            device.value = store.choiceDevice.value
            return
        }
        await request.post(`/reportingWork/selectEquipmentByProcess/${process.value}`).then((res) => {
            if(res.code==='200'){
                let deviceList = []
                res.data.forEach((item,index)=>{
                            deviceList.push({
                                value:item['id'],
                                text:item['basicName']
                            })
                            
                })
                store.deviceList = deviceList
            }
        })
    }
    
    const getProcessList = async()=> {
        const regex =/^\s*$/
        //当工序为空时则进行查询工序
        if(!(store.user.address == null || regex.test(store.user.address))){
            return 
        }
        request.get(`/basicData/BasicDataByType/product/process`).then(res => {
            let processArr = []
            res.data.forEach((item,index)=>{
                        processArr.push({
                            value:item['basicName'],
                            text:item['basicName']
                        })
                        
            })
            processList.value = processArr
        })
    }
    
    const changeProcess = () => {
        
        store.deviceList = []
        device.value = null
        if(process.value == null || process.value=="" ) return
        getDeviceList()
    }
    
    
    const change = (e) => {
        store.deviceList.forEach((item,index)=>{
            if(item.value===e){
                store.choiceDevice = item
            }
        }) 
    }
    
    
    onLoad(async (option)=>{
        if(store.user.userName === null){
            uni.reLaunch({
              url: `/pages/index/index`
            })
            return
        }
        if(store.user.address == null || store.user.address==""){
            await getProcessList()
        }else{
            flag.value = true
            process.value = store.user.address
            await getDeviceList()
        }
        
        
        main.registerReceiver(receiver, filter)
        //判断是否是报工后返回
            /* if(!option.state){
                return
            }
            msgType.value = option.state */
            
    })
    onUnmounted(()=>{
        main.unregisterReceiver(receiver); 
    })
    /* watch(msgType,(newVal)=>{
        switch (newVal) {
          case 'success':  
                    setTimeout(()=>{
                        messageToggle(msgType,'报工成功')
                    },500)
                    
          break;
        }
    }) */
    
    
    const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
    const scannerGetGlassInfo = () =>{
        if(uni.getSystemInfoSync().platform==='android'){
            
            mpaasScan().then(val => {
                uni.navigateTo({
                        url: `/pages/glassInfo/glassInfo?projectNo=${val}`
                })
            })
            
        }else{
            uni.navigateTo({
                url: `/pages/glassInfo/glassInfo?projectNo=25031302009005`
            })
        }
    } 
        
    const scanerCode = () => {
        if(device.value === null){
            messageToggle('warn','未选择设备,请选择报工设备!')
            return
        }
        
        if(uni.getSystemInfoSync().platform==='android'){
            mpaasScan().then(val => {
                uni.navigateTo({
                                    url: `/pages/reportingWork/reportingWork?processId=${val}&process=${process.value}`
                })
            })
            
                        
        }else{
      uni.navigateTo({
        url: `/pages/reportingWork/reportingWork?processId=NG24111542A012/1`
      })
        }
    }
    
    const glassFinishToStore = () => {
        mpaasScan().then(val => {
            uni.navigateTo({
                    url: `/pages/glassFinishToStore/glassFinishToStore?processId=${val}`
            })
        })
    }
    
    
 
    
    
    //打开提示框
    const messageToggle = (type,msg) => {
        msgType.value = type
        messageText.value = msg
        message.value.open()
    }
    
    //打开当班产量
    const quantityCompletion1 = () => {
        uni.navigateTo({
          url: `/pages/QuantityCompletion/QuantityCompletion`
        })
    }
    
    const changePage = () => {
        uni.navigateTo({
          url: `/pages/statement/${report.value}`
        })
    }
        
</script>
 
<style>
     
   .uni-col {
     margin-bottom: 20px;
     text-align: center;
   }
     .content {
         display: flex;
         flex-direction: column;
         align-items: center;
         justify-content: center;
     }
     
     .text-area {
         display: flex;
         justify-content: center;
         padding-bottom: 1rem;
        margin-top: -10rem;
     }
</style>