schangxiang@126.com
2025-05-21 a3a2b238a2626ef8744e7a135f9ca2e2fbb5184c
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
<template>
    <default-header-page-layout ref="page" :title="pageTitle" >
        <view class="page-frame with-action-user-row" :style="{height:pageBodyHeight+'px'}" v-if="pageBodyHeight">
            <action-user-row />
            <view class="with-action-user-row-page-content">
                <page-main v-show="pageStyle==='main'" ref="main" @pageChange="onMainPageChange" />
                <page-edit v-show="pageStyle==='edit'" ref="edit" />
            </view>
        </view>
        <template v-slot:footer>
            <view class="bottom-btns-row">
                <template v-if="pageStyle==='main'">
                    <template v-if="pageType==='bind'">
                        <view class="btn-frame"><u-button text="重 置" @click="onMainReset"></u-button></view>
                        <view class="divider"></view>
                    </template>
                    <view class="btn-frame"><u-button :type="pageType==='instore'?'':'primary'" text="组 盘" @click="onBind"></u-button></view>
                    <template v-if="pageType==='instore'">
                        <view class="divider"></view>
                        <view class="btn-frame"><u-button type="primary" text="入 库" @click="onManualInstore"></u-button></view>
                    </template>
                </template>
                <template v-if="pageStyle==='edit'">
                    <view class="btn-frame"><u-button text="返 回" @click="onEditBack"></u-button></view>
                    <view class="divider"></view>
                    <view class="btn-frame"><u-button type="primary" :text="editIndex===-1?'添 加':'修 改'" @click="onEditConfirm"></u-button></view>
                </template>
            </view>
        </template>
    </default-header-page-layout>
</template>
 
<script>
import DefaultHeaderPageLayout from '@/components/DefaultHeaderPageLayout.vue'
import ActionUserRow from '@/components/ActionUserRow.vue'
import PageMain from './modules/main.vue'
import PageEdit from './modules/edit.vue'
import { $successInfo } from '@/static/js/utils/index.js'
let initInterVal = null;
export default {
    name:'plywoodInstorePage',
    components:{DefaultHeaderPageLayout,ActionUserRow,PageMain,PageEdit},
    data(){
        return {
            pageBodyHeight:0,
            pageType:'instore',
            pageStyle:'main',
            pageTitle:'',
            editIndex:-1
        }
    },
    methods:{
        onEditBack(){
            this.pageStyle = 'main'
        },
        onEditConfirm(){
            let check = this.$refs.edit.checkConfirm()
            if (check.flag) {
                if (this.editIndex===-1) {
                    this.$refs.main.add(check.data)
                } else {
                    this.$refs.main.modify(check.data,this.editIndex)
                }
            }
            this.pageStyle = 'main'
        },
        onMainPageChange(obj,index){
            if (obj) {
                this.editIndex = index
            } else {
                this.editIndex = -1
            }
            this.$refs.edit.init(obj)
            this.pageStyle = 'edit'
        },
        onMainReset(){
            this.$refs.main.clearMain()
        },
        onBind(){
            let check = this.$refs.main.checkConfirm()
            if (check.flag) {
                this.dealBind(check.data,(f)=>{
                    if (f) {
                        $successInfo('组盘成功')
                        if (this.pageType==='bind'){
                            this.$refs.main.clearMain()
                        }
                    }
                })
            }
        },
        onManualInstore(){
            let check = this.$refs.main.checkConfirm()
            if (check.flag) {
                this.dealManualInstore(check.data,(f)=>{
                    if (f) {
                        $successInfo('提交成功')
                        this.$refs.main.clearMain()
                    }
                })
            }
        },
        /* 组盘接口调用 */
        dealBind(obj,callback){
            let params = this.dealSubmitParams(obj)
            this.$api.post('PlywoodBindEntrance',params,{block:'plywood'}).then(()=>{
                callback && callback(true)
            }).catch((e)=>{
                callback && callback(false,e)
            })
        },
        /* 手动入库接口调用 */
        dealManualInstore(obj,callback){
            let params = this.dealSubmitParams(obj)
            this.$api.post('PlywoodManualWare',params,{block:'plywood'}).then(()=>{
                callback && callback(true)
            }).catch((e)=>{
                callback && callback(false,e)
            })
        },
        dealSubmitParams(obj){
            return {
                containercode:obj.containter.containerCode,
                wmsMaterials:obj.list
            }
        },
        /* 页面初始化获取页面body高度的定时器 */
        startInitInterval(callback){
            initInterVal = setInterval(()=>{
                if (this.pageBodyHeight) {
                    this.clearInitInterval()
                    callback && callback()
                } else {
                    this.pageBodyHeight = this.$refs.page.getBodyHeight()
                }
            },200)
        },
        /* 清除定时器 */
        clearInitInterval(){
            try{
                clearInterval(initInterVal)
                initInterVal = null
            }catch(e){
                //TODO handle the exception
            }
        }
    },
    onLoad(option){
        if (option.pageType) {
            this.pageType=option.pageType
            this.pageTitle='胶合板组盘'
        } else {
            this.pageType='instore'
            this.pageTitle='胶合板入库'
        }
    },
    onReady(){
        this.startInitInterval(()=>{
            /* 页面初始化后需要执行的代码在这边调用 */
        })
    },
    onUnload(){
        this.clearInitInterval()
    }
}
</script>
 
<style scoped lang="scss">
.bottom-btns-row{
    display: flex;
    padding: 10rpx 20rpx;
    background-color: #fff;
    .btn-frame{
        width: 1%;
        box-sizing: border-box;
        flex-grow: 1;
    }
    .divider{
        width: 20rpx;
        flex-shrink: 0;
    }
}
</style>