liuying
2025-09-24 16edbbe772e24eb71f6519558576d513e3cf2746
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
<template>
    <default-header-page-layout ref="page" title="产量维护">
        <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">
                <u-subsection activeColor="#F18201" @change="sectionChange" :fontSize="20" class='subsection'
                    mode="subsection" :list="list" :current="current"></u-subsection>
 
                <view class="content">
                    <view class="card" v-for="(item,index) in data" :key="index">
                        <view class="card-title">计划id:{{item.id}}</view>
                        <u-row style="width:100%;flex-wrap: wrap;border-bottom: 2rpx solid #eee;padding-bottom:10rpx;">
                            <u-col span="12">
                                <u-row>
                                    <u-col span="4">计划类型:</u-col>
                                    <u-col span="8">{{item.planType==1?'班组计划':'月份计划'}}</u-col>
                                </u-row>
                            </u-col>
                            <u-col span="12">
                                <u-row>
                                    <u-col span="4">计划时间:</u-col>
                                    <u-col span="8">
                                        <view  v-if="current==0" >
                                            {{moment(moment(item.planTime,'YYYY-MM-DD')).format('YYYY-MM-DD')}}</view>
                                        <view v-if="current==1">
                                            {{moment(moment(item.planTime,'YYYY-MM')).format('YYYY-MM')}}</view>
                                    </u-col>
                                </u-row>
                            </u-col>
                            <u-col span="12" v-if="current==0">
                                <u-row>
                                    <u-col span="4">班组类型:</u-col>
                                    <u-col span="8">{{item.teamType}}</u-col>
                                </u-row>
                            </u-col>
                            <u-col span="12">
                                <u-row>
                                    <u-col span="4">计划产量:</u-col>
                                    <u-col span="8">{{item.planProductionNum}}</u-col>
                                </u-row>
                            </u-col>
                            <u-col span="12">
                                <u-row>
                                    <u-col span="4" >备注:</u-col>
                                    <u-col span="8">{{item.remarks}}</u-col>
                                </u-row>
                            </u-col>
                        </u-row>
                        <view class="card-action">
                            <u-button @click="toAddOrEditProd('edit',current,item)"
                                style="width:150rpx;height:60rpx;margin: 10rpx 0 0;" text="修改"
                                type="primary"></u-button>
                        </view>
                    </view>
                </view>
            </view>
        </view>
 
        <!-- 新增计划产量 -->
        <template v-slot:footer>
            <view class="bottom-btns-row">
                <template>
                    <div class="btn-frame">
                        <u-button size="large" :text="`新增${list[current]}`"
                            :custom-style="{backgroundColor:'#F18201',color:'#fff'}"
                            @click="toAddOrEditProd('add',current)"></u-button>
                    </div>
                </template>
            </view>
        </template>
    </default-header-page-layout>
</template>
 
<script>
    import DefaultHeaderPageLayout from '@/components/DefaultHeaderPageLayout.vue'
    import ActionUserRow from '@/components/ActionUserRow.vue'
    import {
        getProductionplaninfo
    } from '@/api/production/index.js'
    import qs from 'qs'
    import moment from 'moment'
    export default {
        name: 'production',
        components: {
            DefaultHeaderPageLayout,
            ActionUserRow
        },
        data() {
            return {
                pageBodyHeight: 0,
                list: ['班组产量', '月份产量'],
                current: 0,
                data: []
            }
        },
        created() {
            this.sectionChange(this.current)
        },
        methods: {
            moment,
            // 分段器改变
            sectionChange(index) {
                this.current = index
                this.data=[]
                if (index == 0) {
                    this.getPlanData(1)
                } else if (index == 1) {
                    this.getPlanData(2)
                }
                
            },
 
 
            // 获取计划产量数据
            async getPlanData(planType) {
                try {
                    let {
                        data
                    } = await getProductionplaninfo({
                        planType
                    })
                        this.data = data.rows
                    
                } catch (e) {
                    //TODO handle the exception
                    console.log(e);
                }
 
            },
            // 跳转到创建巡检任务页面
            toAddOrEditProd(type, current, item = {}) {
                item.planType = parseInt(current)  + 1
                item.type = type
                uni.navigateTo({
                    url: `/pages/production/addOrEditProd?${qs.stringify(item)}`
                })
            },
            /* 页面初始化获取页面body高度的定时器 */
            startInitInterval(callback) {
                this.initInterVal = setInterval(() => {
                    if (this.pageBodyHeight) {
                        this.clearInitInterval()
                        callback && callback()
                    } else {
                        this.pageBodyHeight = this.$refs.page.getBodyHeight()
                    }
                }, 200)
            },
            /* 清除定时器 */
            clearInitInterval() {
                try {
                    clearInterval(this.initInterVal)
                    this.initInterVal = null
                } catch (e) {
                    //TODO handle the exception
                }
            }
        },
        onReady() {
            this.startInitInterval(() => {
                /* 页面初始化后需要执行的代码在这边调用 */
            })
        },
        onLoad(item) {
            if(item.current) {
                this.current=item.current
            }else {
                this.current=0
            }
            
        },
        onUnload() {
            this.clearInitInterval()
        }
    }
</script>
 
<style lang="scss">
    .subsection {
        // width: 100%;
        height: 50rpx;
        margin-bottom: 20rpx;
    }
 
    .content {
        // width:100%;
        height: auto;
        margin: 0 20rpx;
 
        .card {
            // width: 100%;
            height: auto;
            background-color: #fff;
            border-radius: 10rpx;
            padding: 10rpx 20rpx;
            margin-bottom: 20rpx;
            font-size: 40rpx;
 
            .card-title {
                font-size: 45rpx;
                font-weight: 700;
                padding-bottom: 5rpx;
                border-bottom: 2rpx solid #eee;
            }
 
            .card-item {
                padding: 10rpx 0 0;
            }
 
            .card-action {
                width: 100%;
                display: flex;
                justify-content: flex-end;
                align-items: center;
            }
        }
 
 
    }
 
    ::v-deep .u-button__text {
        font-size: 40rpx !important;
    }
 
    .bottom-btns-row {
        display: flex;
        padding: 10rpx 0;
        background-color: #fff;
 
        .btn-frame {
            width: 90%;
            box-sizing: border-box;
            margin: 10rpx auto;
            font-weight: bold;
            border-radius: 5px;
        }
    }
</style>