spring
4 天以前 435881d494e2be4ba5ce8bfccb02d6ef49e07314
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
<template>
    <view class="body">
        <view class="main_view">
            <u-form :model="query" ref="query">
                <u-form-item label="杂工事项" required :label-width="180" prop="handymanItemName">
                    <u-input v-model="query.handymanItemName" placeholder="请输入"/>
                    <!-- <u-icon name="arrow-right" @click="goPage(0)"></u-icon> -->
                </u-form-item>
                <u-form-item label="时长" required :label-width="180" prop="duration">
                    <u-input v-model="query.duration" placeholder="请输入"/>
                </u-form-item>
                <u-form-item label="生产人员" required :label-width="180" prop="prodUser">
                    <u-input v-model="query.prodUser" type="select" placeholder="请选择"/>
                    <u-icon name="arrow-right" @click="goPage(1)"></u-icon>
                </u-form-item>
                <u-form-item label="责任人" required :label-width="180" prop="principalName">
                    <u-input v-model="query.principalName" type="select" placeholder="请选择"/>
                    <u-icon name="arrow-right" @click="goPage(2)"></u-icon>
                </u-form-item>
            </u-form>
        </view>
        <view class="bottom">
            <u-button class="u-button" type="primary" @click="submit" :loading="loading">提交</u-button>
        </view>
        <u-select v-model="handymanItemListShow" :list="handymanItemList" @confirm="confirmOperation"></u-select>
        <u-select v-model="handymanRecordListShow" :list="handymanRecordList" @confirm="confirmHandymanRecord"></u-select>
    </view>
</template>
 
<script>
import UIcon from "../../../uview-ui/components/u-icon/u-icon.vue";
 
export default {
    name: "handyman",
    // import 引入的组件需要注入到对象中才能使用
    components: {UIcon},
    data() {
        // 这里存放数据
        return {
            query: {
                duration: '', // 时长
                dutyNo: '', // 日报编号
                dutyTime: '', // 日报时间
                handymanItem: '', // 杂工事项
                principalId: '', // 负责人id
                prodStaffNoList: '', // 关联的生产人员id[list]
                prodUser: '', // 生产人员
                principalName: '', // 负责人名称
                handymanRecordApprover:'',
                handymanRecordApproverName:'',
                handymanRecordId:0,
                handymanItemName: '', // 杂工事项名称
            },
            rules: {
                handymanItemName: [
                    {
                        required: true,
                        message: '请选择杂工事项',
                        // 可以单个或者同时写两个触发验证方式
                        trigger: ['change'],
                    }
                ],
                duration: [
                    {
                        required: true,
                        message: '请输入',
                        trigger: ['change','blur'],
                    },
                    // 正则判断数字
                    {
                        validator: (rule, value, callback) => {
                            return this.$u.test.amount(value);
                        },
                        message: '请输入正确',
                        // 触发器可以同时用blur和change
                        trigger: ['change','blur'],
                    }
                ],
                prodUser: [
                    {
                        required: true,
                        message: '请选择生产人员',
                        // 可以单个或者同时写两个触发验证方式
                        trigger: ['change'],
                    }
                ],
                principalName: [
                    {
                        required: true,
                        message: '请选择责任人',
                        // 可以单个或者同时写两个触发验证方式
                        trigger: ['change'],
                    }
                ],
            },
            handymanItemList: [],
            handymanItemListShow: false,
            handymanRecordList: [],
            handymanRecordListShow: false,
            loading: false
        }
    },
    onReady() {
        this.$refs.query.setRules(this.rules); // 复制校验
        // 进入页面查询杂工事项列表
        this.handymanItemList = []
        this.getHandymanItem()
        // 进入页面查询责任人列表
        this.getHandymanRecord()
    },
    onLoad(e) {
        let s = []
        e.staffList.split(',').forEach(i => {
            s.push(i)
        })
        console.log(s)
        this.query.prodStaffNoList =s
        this.query.prodUser =e.userList
        this.query.dutyNo = e.dutyNo
        this.query.dutyTime = e.updateTime
        uni.$on('checkedList', (data) => {
            let staffNameList = []
            let staffNoList = []
            data.forEach(i => {
                staffNameList.push(i.staffName)
                staffNoList.push(i.staffNo)
            })
            this.query.prodUser = staffNameList.join(',')
            this.query.prodStaffNoList = staffNoList
        });
    },
    // 方法集合
    methods: {
        goPage (index) {
            switch (index) {
                case 0:
                    this.handymanItemListShow = true
                            break
                case 1:
                    const list = []
                    if(this.query.prodStaffNoList.length > 0) {
                        let staffList = this.query.prodUser.split(',')
                        let staffNoList = this.query.prodStaffNoList
                        for (const i in staffList) {
                            const obj = {
                                staffName: staffList[i],
                                staffNo: staffNoList[i]
                            }
                        list.push(obj)
                        }
                    }
                    uni.navigateTo({
                        url: '/pages/daily/production-person/production-person?list=' + encodeURIComponent(JSON.stringify(list))
                    })
                    break
                case 2:
                    this.handymanRecordListShow = true
                            break
            }
        },
        submit () {
            this.$refs.query.validate(valid => {
                if (valid) {
                    let params = JSON.parse(JSON.stringify(this.query))
                    params.dutyTime = params.dutyTime + ' 00:00:00'
                    console.log(params)
                    this.$u.api.dailyPaper.handymanRecord(params).then((res) => {
                        if (res.code === 0) {
                            this.loading = true;
                            uni.navigateBack({
                                //关闭当前页面,返回上一页面或多级页面。
                                delta:1
                            });
                            this.loading = false;
                        }
                    })
                } else {
                    this.$u.toast('请填写完整数据')
                }
            });
        },
        getHandymanItem () {
            this.$u.api.dictData({dictType: 'handyman_item'}).then((res) => {
                if (res.code === 0 && res.data.length > 0) {
                    res.data.forEach(item => {
                        const obj = Object.assign({
                            label: item.label,
                            value: item.value,
                        })
                        this.handymanItemList.push(obj)
                    })
                }
            })
        },
        getHandymanRecord () {
            this.$u.api.dailyPaper.principal().then((res) => {
                if (res.code === 0 && res.data.length > 0) {
                    res.data.forEach(item => {
                        const obj = Object.assign({
                            label: item.fullName,
                            value: item.id,
                        })
                        this.handymanRecordList.push(obj)
                    })
                    console.log(res)
                    this.query.principalId =     this.handymanRecordList[0].value
                    this.query.principalName =     this.handymanRecordList[0].label
                    this.handymanRecordApprover = this.handymanRecordList[0].value
                }
            })
        },
        confirmOperation (e) {
            this.query.handymanItem = e[0].value
            this.query.handymanItemName = e[0].label
        },
        confirmHandymanRecord (e) {
            this.query.principalId = e[0].value
            this.query.principalName = e[0].label
        }
    },
}
</script>
 
<style scoped lang="scss">
.body {
    background: linear-gradient(to bottom, #E5F0FF, #F6F9FF);
    box-sizing: border-box;
    padding-top: 26rpx;
    height: 100vh;
    .main_view {
        margin-top: 5rpx;
        background: linear-gradient(180deg, #D8E8FF 0%, #FFFFFF 100%);
        border-radius: 15rpx;
        margin: 0 30rpx;
        box-sizing: border-box;
        padding: 37rpx 25rpx;
    }
    .bottom {
        width: 100vw;
        position:fixed;
        bottom:60rpx;
        .u-button {
            width: 690rpx;
            height: 80rpx;
            background: #214DED;
            border-radius: 8rpx;
            font-weight: 500;
            font-size: 34rpx;
            color: #FFFFFF;
            z-index: 99;
        }
    }
}
::v-deep.uicon-arrow-down-fill:before {
    display: none;
}
::v-deep.u-form-item--left__content__label {
    padding-left: 26rpx;
    font-weight: 500;
    font-size: 30rpx;
    color: #4F4F4F;
    line-height: 80rpx;
}
::v-deep.u-form-item--left__content--required {
    left: 8rpx;
    top: 0;
}
</style>