guoyujie
6 天以前 f398ddd14530d2f0695865c8a4dede6205d91d09
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
<template>
    <view style="margin-bottom: 2rem;">
        <uni-section 
            :title="'流程卡号:'+processId" 
            :sub-title="'项目名称:'+title.project" 
            padding="0 0 5px 10px">
            {{title.productName}}
            
            <template v-slot:right>
              <button @click="open(1)"  type="primary" size='mini'>提交</button>   
            </template>
            </uni-section>
    </view>
 
    
    <view>
        <uni-table  ref="table"  border stripe type="selection" emptyText="暂无更多数据" @selection-change="selectionChange">
                        <uni-tr>
                            <uni-th align="center" width="150">可入数量</uni-th>
                            <uni-th align="center">总数量</uni-th>
                            <uni-th align="center">订序</uni-th>
                            <uni-th  align="center">宽*高</uni-th>
                            <uni-th align="center">楼号</uni-th>
                            <uni-th align="center">已入数量</uni-th>
                        </uni-tr>
                        <uni-tr v-for="(item, index) in tableData" :key="index">
                            <uni-td align="center">
                              <uni-easyinput type="number" 
                                    :clearable='false' 
                                    v-model='item.inventoryQuantity' 
                                    style="text-align: center;"
                                    @change="change($event,item)"
                                    />
                            </uni-td>
                            <uni-td align="center">{{ item.orderDetail.quantity }}</uni-td>
                            <uni-td align="center">{{ item.orderNumber }}</uni-td>
                            <uni-td align="center">{{ item.orderDetail.width }}*{{ item.orderDetail.height }}</uni-td>
                            <uni-td align="center">{{ item.orderDetail.buildingNumber }}</uni-td>
                            <uni-td align="center">{{ item.receivedQuantity }}</uni-td>
                        </uni-tr>
                    </uni-table>
                    <uni-popup ref="message" type="message">
                            <uni-popup-message :type="msgType" :message="messageText" :duration="3000"></uni-popup-message>
                    </uni-popup>
    </view>
    
            <!-- 提示窗示例 -->
            <uni-popup ref="alertDialog" type="dialog" :mask-click="false">
                <view class="flex-item foot_main">
                    <uni-row  >
                            <uni-col :span="6">箱号:</uni-col>
                            <uni-col :span="18">
                                <uni-easyinput
                                :clearable='false' 
                                 v-model="flowData.container"/>
                            </uni-col>
                    </uni-row>
                    <uni-row >
                            <uni-col :span="6">库位:</uni-col>
                            <uni-col :span="18">
                                <uni-easyinput 
                                :clearable='false' 
                                v-model="flowData.storageRegion"/>
                            </uni-col>
                    </uni-row>
                    <uni-row >
                            <uni-col :span="6">备注:</uni-col>
                            <uni-col :span="18">
                                <uni-easyinput 
                                :clearable='false' 
                                v-model="flowData.remark"/>
                            </uni-col>
                    </uni-row>
                </view>
                <view>
                    <uni-row>
                        <uni-col :span='12'>
                            <button  @click="open(0)">取消</button>
                        </uni-col>
                        <uni-col :span='12'>
                            <button type="primary" :loading="subLoading" @click="glassToStore">入库</button>
                        </uni-col>
                    </uni-row>
                </view>
            </uni-popup>
</template>
 
<script setup>
    import { onMounted, ref } from 'vue';
    import { onLoad } from '@dcloudio/uni-app'
    import request from '../../utils/request'
    import userInfo from '@/stores/userInfo'
    import { debounce } from 'lodash'
    const user=userInfo()
    const message = ref(null)
    const msgType=ref('success')
    const messageText=ref('')
    const checkList = ref([])
    const alertDialog = ref(null)
    
    let processId = ref(null)
    let title = ref({
        project:null,
        productName:null
    })
    let subLoading = ref(false)
    const table = ref(null)
    const tableData = ref([])
    const flowData = ref({
        decValue:2,//计算保留位数
        userId:user.user.userId ,
        userName: user.user.userName,
        storageRegion: null,
        remark: null,
        container: null,//库位
        flowCard: []
    })
    
    onLoad(async (option)=>{
        processId.value = option.processId
        await getfinishedGlass(option.processId)
    })
    
    const getfinishedGlass = async (processIdVal) => {
        const para = {
            processId:processIdVal
        }
        await request.post(`/app/getSelectWarehousingList`,para).then(res => {
            if(res.data.data.length===0){
                uni.showModal({
                    title: '提示',
                    content: "此流程卡无可入库数据",
                    showCancel:false,
                    success:()=>{
                        uni.reLaunch({
                          url: `/pages/mainView/mainView`
                        }) 
                    }
                });
                return
            }
            tableData.value = res.data.data
            title.value.project = `${tableData.value[0].order.project}(${tableData.value[0].order.batch})`
            title.value.productName = tableData.value[0].orderDetail.productName
        })
        table.value.selectionAll()
    }
    
    const glassToStore = debounce(() => {
        subLoading.value = true
        checkList.value.sort()
        const arr = []
        
        checkList.value.forEach(item => {
            arr.push(tableData.value[item])
        })
        flowData.value.flowCard = arr
        request.post(`/app/addSelectWarehousing`,flowData.value).then(res => {
            
        }).catch(e => {
            uni.showModal({
                title: '提示',
                content: "此流程卡无可入库数据",
                showCancel:false
            });
        }).finally(()=> {
            uni.reLaunch({
              url: `/pages/mainView/mainView`
            })
        })
    },200)
    
    const change = (e,item) => {
        const quantity = item.orderDetail.quantity*1 - item.receivedQuantity*1
        if(e>quantity || e<=0){
            item.inventoryQuantity = quantity
            messageToggle('error',`请输入大于0小于等于${quantity}`)
        }
    }
    
    const selectionChange = (e) => {
        checkList.value = e.detail.index
    }
    const messageToggle = (type,msg) => {
        msgType.value = type
        messageText.value = msg
        message.value.open()
    }
    
    const open = (type) => {
        if(type===1){
            alertDialog.value.open()
        }else{
            alertDialog.value.close()
        }
    }
</script>
 
<style>
    .foot_main{
        width: 80vw;
        margin: 0 auto;
        background-color: white;
        text-align: center;
    }
</style>