jiangping
2023-10-26 ea87c908fb6cdfc3e227a584a53e6730efb8262a
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
331
332
333
334
335
336
337
338
<template>
    <view class="fp">
        <view class="fp_list">
            <view class="fp_list_item">
                <view class="fp_list_item_left">
                    <text style="color: #f00;">*</text>
                    <text>计划生产数量:</text>
                </view>
                <view class="fp_list_item_right">
                    <u--input placeholder="请输入" :customStyle="{width: '180rpx'}" inputAlign="right" type="number" border="surround" v-model="form.num"></u--input>
                </view>
            </view>
            <view class="fp_list_item">
                <view class="fp_list_item_left">
                    <text style="color: #f00;">*</text>
                    <text>计划开工日期:</text>
                </view>
                <view class="fp_list_item_right" @click="timeShow = true">
                    <text class="black" v-if="form.startTime">{{form.startTime}}</text>
                    <text v-else>年 / 月 / 日</text>
                    <u-icon name="arrow-right" color="#999999"></u-icon>
                </view>
            </view>
            <view class="fp_list_item" @click="show1 = true">
                <view class="fp_list_item_left">
                    <text>生产设备</text>
                </view>
                <view class="fp_list_item_right">
                    <text v-if="form.equipmentName" class="black">{{form.equipmentName}}</text>
                    <text v-else>请选择</text>
                    <u-icon name="arrow-right" color="#999999"></u-icon>
                </view>
            </view>
            <view class="fp_list_item1" v-show="form.equipmentName">
                <view class="fp_list_item_left">
                    <text>生产人员</text>
                </view>
                <view class="fp_list_item_right">
                    <template v-if="personnelData.length > 0">
                        <u-checkbox-group
                            placement="column"
                            @change="checkboxChange">
                            <u-checkbox
                                :customStyle="{marginBottom: '16rpx'}"
                                v-for="(item, index) in personnelData"
                                :key="index"
                                :label="item.text"
                                :name="item.id">
                            </u-checkbox>
                        </u-checkbox-group>
                    </template>
                    <view class="wu" v-else>
                        <text>暂无数据</text>
                    </view>
                </view>
            </view>
        </view>
        <view class="fp_footer">
            <view class="fp_footer_close" @click="go">取消</view>
            <button class="fp_footer_submit" @click="submit">确认</button>
        </view>
        <!-- 选择日期 -->
        <u-calendar :show="timeShow" @close="timeShow = false" @confirm="timeConfirm"></u-calendar>
        <!-- 选择设备 -->
        <u-picker :show="show1" :columns="equipment" @confirm="confirm" @cancel="show1 = false" keyName="text"></u-picker>
    </view>
</template>
 
<script>
    import { gsdate } from '@/util/utils.js'
    import { distributeById, getFindAll, getDeviceByCondition } from '@/util/api/PlanningAPI'
    export default {
        data() {
            return {
                id: null,
                show1: false,
                checkboxValue1: [],
                form: {
                    num: '',        // 生产数量
                    startTime: gsdate(new Date()),      // 开始时间
                    equipmentId: '',    // 设备id
                    equipmentName: '',    // 设备名称 
                    personnelId: []    // 人员id
                },
                isOpenDate: false,
                equipment: [],    // 设备数据
                personnelData: [],    // 人员数据
                timeShow: false
            };
        },
        onLoad(option) {
            this.form.num = option.num
            this.id = option.jhid
            this.getDeviceByConditions()
        },
        methods: {
            checkboxChange(ids) {
                this.form.personnelId = ids;
            },
            go() {
                uni.navigateBack({ delta: 1 });
            },
            // 确认选择设备
            confirm(val) {
                this.form.equipmentId = val.value[0].id
                this.form.equipmentName = val.value[0].text
                this.personnelData = []
                getFindAll({
                    deviceId: this.form.equipmentId
                }).then(res => {
                    if (res.code === 200 && res.data && res.data.length !== 0) {
                        this.form.personnelId = []
                        let arr = []
                        res.data.forEach((item) => {
                            arr.push({ text: item.dmodel.name + '-' + item.umodel.name, id: item.userId })
                        })
                        this.personnelData = arr
                    }
                    this.show1 = false
                })    
            },
            timeConfirm(val) {
                this.form.startTime = val[0]
                this.timeShow = false
            },
            // 提交分配
            submit() {
                if (!this.form.num) return uni.showToast({ title: '计划生产数量不能为空!', icon: 'none', duration: 2000 });
                if (!this.form.startTime) return uni.showToast({ title: '计划开始日期不能为空!', icon: 'none', duration: 2000 });
                distributeById({
                    planId: this.id,
                    planNum: this.form.num,
                    planDate: this.form.startTime,
                    proGroupId: this.form.equipmentId,
                    proUserList: this.form.personnelId
                }).then(res => {
                    if (res.code === 200) {
                        uni.showToast({ title: '分配成功', icon: 'success', duration: 2000, mask: true });
                        setTimeout(() => {
                            uni.$emit('update', { msg:'刷新列表' })
                            uni.navigateBack({ delta: 1 });
                        }, 2000)
                    }
                })
            },
            // 查询设备
            getDeviceByConditions() {
                getDeviceByCondition({})
                    .then(res => {
                        if (res.code === 200) {
                            this.equipment = []
                            let arr = []
                            res.data.forEach((element) => {
                                arr.push({ text: element.code + '-' + element.name, id: element.id, checked: false })
                            })
                            this.equipment.push(arr)
                        }
                    })
            }
        }
    }
</script>
 
<style lang="scss" scoped>
.fp {
    width: 100%;
    height: 100%;
    position: absolute;
    background: #F7F7F7;
    .fp_list {
        display: flex;
        flex-direction: column;
        .fp_list_item1 {
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            padding: 20rpx 30rpx;
            box-sizing: border-box;
            background: #ffffff;
            border-bottom: 1rpx solid #ececec;
            .fp_list_item_left {
                flex-shrink: 0;
                margin-bottom: 40rpx;
                display: flex;
                align-items: center;
                text {
                    color: #222222;
                    font-size: 30rpx;
                    font-weight: 400;
                }
            }
            .fp_list_item_right::v-deep {
                display: flex;
                flex-direction: column;
                .u-checkbox-group--row {
                    display: flex;
                    flex-direction: column;
                }
                .u-icon__icon {
                    margin-right: 0 !important;
                }
                .fp_list_item_right_dis {
                    display: flex;
                    align-items: center;
                    margin-bottom: 20rpx;
                    &:last-child {
                        margin-bottom: 0 !important;
                    }
                }
                .wu {
                    width: 100%;
                    margin: 30rpx 0;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    text {
                        font-size: 26rpx;
                        color: black;
                    }
                }
                .black {
                    color: black !important;
                }
                // input {
                //     width: 180rpx;
                //     height: 60rpx;
                //     border-radius: 8rpx;
                //     border: 2rpx solid #E5E5E5;
                //     padding: 0 30rpx;
                //     text-align: right;
                //     font-size: 25rpx;
                // }
                text {
                    font-size: 28rpx;
                    font-weight: 400;
                    color: #999999;
                    margin-right: 20rpx;
                }
            }
        }
        .fp_list_item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 30rpx;
            height: 98rpx;
            box-sizing: border-box;
            background: #ffffff;
            border-bottom: 1rpx solid #ececec;
            .fp_list_item_left {
                flex-shrink: 0;
                b {
                    color: $nav-stateColor4;
                    font-size: 28rpx;
                    margin-right: 5rpx;
                }
                text {
                    color: #222222;
                    font-size: 30rpx;
                    font-weight: 400;
                }
            }
            .fp_list_item_right::v-deep {
                display: flex;
                align-items: center;
                .u-icon__icon {
                    margin-right: 0 !important;
                }
                .wu {
                    text-align: center;
                    text {
                        font-size: 26rpx;
                        color: black;
                    }
                }
                .black {
                    color: black !important;
                }
                // input {
                //     width: 180rpx;
                //     height: 60rpx;
                //     border-radius: 8rpx;
                //     border: 1rpx solid #E5E5E5;
                //     padding: 0 30rpx;
                //     text-align: right;
                //     font-size: 25rpx;
                // }
                text {
                    font-size: 28rpx;
                    font-weight: 400;
                    color: #999999;
                    margin-right: 20rpx;
                }
            }
        }
    }
    .fp_footer {
        width: 100%;
        padding-left: 30rpx;
        padding-right: 30rpx;
        padding-bottom: 68rpx;
        box-sizing: border-box;
        position: fixed;
        bottom: 0;
        left: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        .fp_footer_close {
            width: 334rpx;
            height: 88rpx;
            background: #FFFFFF;
            box-shadow: 0 0 12rpx 0 rgba(0, 0, 0, 0.08);
            border-radius: 8rpx;
            font-size: 30rpx;
            font-weight: 500;
            color: #666666;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .fp_footer_submit {
            width: 334rpx;
            height: 88rpx;
            border: none;
            background: $nav-color;
            box-shadow: 0 0 12rpx 0 rgba(0, 0, 0, 0.08);
            border-radius: 8rpx;
            font-size: 30rpx;
            font-weight: 500;
            color: #ffffff;
            display: flex;
            align-items: center;
            justify-content: center;
        }
    }
}
</style>