MrShi
2025-08-19 f2ac76666299407545fb733f0d21f6e8cfe538a3
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
<template>
    <view class="she">
        <u--form labelPosition="left" :model="model" :rules="rules" ref="uForm">
            <u-form-item label="员工姓名" labelWidth="120" prop="name" borderBottom required>
                <u--input v-model="model.name" border="none" placeholder="请输入员工姓名" disabledColor="#ffffff" disabled></u--input>
            </u-form-item>
            <u-form-item label="部门" labelWidth="120" prop="companyName" borderBottom required>
                <u--input v-model="model.companyName" border="none" placeholder="请选择部门" disabledColor="#ffffff"
                    disabled></u--input>
                <u-icon slot="right" name="arrow-right"></u-icon>
            </u-form-item>
            <u-form-item label="上报时间" labelWidth="120" prop="submitDate" borderBottom required>
                <u--input v-model="model.submitDate" border="none" placeholder="请选择上报时间" disabledColor="#ffffff"
                    disabled></u--input>
                <u-icon slot="right" name="arrow-right"></u-icon>
            </u-form-item>
            <u-form-item label="发现时间" labelWidth="120" prop="happenTime" borderBottom @click="openF" required>
                <u--input v-model="model.happenTime" border="none" placeholder="请选择发现时间" disabledColor="#ffffff"
                    disabled></u--input>
                <u-icon slot="right" name="arrow-right"></u-icon>
            </u-form-item>
            <u-form-item label="风险类型" labelWidth="120" prop="typeName" borderBottom @click="$refs.pengTree1._show()" required>
                <u--input v-model="model.typeName" border="none" placeholder="请选择风险类型" disabledColor="#ffffff"
                    disabled></u--input>
                <u-icon slot="right" name="arrow-right"></u-icon>
            </u-form-item>
            <u-form-item label="发生地点" labelWidth="120" prop="localtionName" borderBottom @click="$refs.pengTree._show()" required>
                <u--input v-model="model.localtionName" border="none" placeholder="请选择发生地点" disabledColor="#ffffff"
                    disabled></u--input>
                <u-icon slot="right" name="arrow-right"></u-icon>
            </u-form-item>
            <u-form-item label="风险描述" labelWidth="120" prop="riskInfo" labelPosition="top" borderBottom required>
                <u--textarea v-model="model.riskInfo" placeholder="请输入风险描述" style="margin-top: 15rpx;" maxlength="200" count></u--textarea>
            </u-form-item>
            <u-form-item label="上传图片" labelWidth="120" prop="multifileList" labelPosition="top" borderBottom>
                <UploadImage
                    :fileList="model.multifileList"
                    folder="WORKORDER_FILE_PATH"
                    @dele="deletePic"
                    @getFileList="afterRead"
                    style="margin-top: 15rpx;"
                />
            </u-form-item>
            <u-form-item label="通知人" labelWidth="120" prop="notifier" borderBottom required>
                <u--textarea v-model="model.notifier" border="none" placeholder="请输入通知人" disabledColor="#ffffff"
                    disabled></u--textarea>
            </u-form-item>
        </u--form>
        <u-button type="primary" text="提交" @click="submit" style="margin-top: 60rpx;"></u-button>
        <!-- 日期 -->
        <u-datetime-picker :show="show1" v-model="time" mode="datetime" @cancel="closeF"
            @confirm="selectTime"></u-datetime-picker>
        <!-- 提交成功 -->
        <u-modal :show="show4" showCancelButton confirmText="查看详情" cancelText="继续上报" @cancel="next" @confirm="toDesc">
            <view class="slot-content">
                <u-icon name="checkmark-circle-fill" color="#3875C5" size="70"></u-icon>
                <text>提交成功</text>
                <text>感谢您的反馈</text>
            </view>
        </u-modal>
        <!-- 发生地点 -->
        <peng-tree
            ref="pengTree"
            :range="address"
            idKey="id"
            :selectParent="false"
            nameKey="name"
            :multiple="false"
            title="选择地点"
            @confirm="selectAddress"
            @cancel="$refs.pengTree._hide()">
        </peng-tree>
        <!-- 风险类型 -->
        <peng-tree
            ref="pengTree1"
            :range="typeList"
            idKey="id"
            :selectParent="false"
            nameKey="name"
            :multiple="false"
            title="选择伤害类型"
            @confirm="selectType"
            @cancel="$refs.pengTree1._hide()">
        </peng-tree>
    </view>
</template>
 
<script>
    import { mapState } from 'vuex'
    import UploadImage from '@/components/uploadImage/uploadImage.vue'
    import pengTree from '@/uni_modules/peng-tree/peng-tree/peng-tree.vue'
    export default {
        components: { pengTree, UploadImage },
        computed: {
            ...mapState(['userInfo'])
        },
        data() {
            return {
                id: null,
                model: {
                    name: '',
                    submitDate: uni.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd hh:MM:ss'),
                    companyName: '',
                    happenTime: '',
                    localtionId: '',
                    localtionName: '',
                    typeId: '',
                    typeName: '',
                    riskInfo: '',
                    notifier: '',
                    multifileList: [],
                    type: 3
                },
                rules: {
                    name: [{
                        type: 'string',
                        required: true,
                        message: '员工姓名不能为空',
                        trigger: ['blur', 'change']
                    }],
                    happenTime: [{
                        type: 'string',
                        required: true,
                        message: '发现时间不能为空',
                        trigger: ['blur', 'change']
                    }],
                    typeName: [{
                        type: 'string',
                        required: true,
                        message: '风险类型不能为空',
                        trigger: ['blur', 'change']
                    }],
                    localtionName: [{
                        type: 'string',
                        required: true,
                        message: '发生地点不能为空',
                        trigger: ['blur', 'change']
                    }],
                    riskInfo: [{
                        type: 'string',
                        required: true,
                        message: '风险描述不能为空',
                        trigger: ['blur', 'change']
                    }],
                    notifier: [{
                        type: 'string',
                        required: true,
                        message: '通知人不能为空',
                        trigger: ['blur', 'change']
                    }],
                },
                show: false,
                show1: false,
                show2: false,
                show3: false,
                show4: false,
                time: new Date().getTime(),
                typeList: [],
                address: []
            };
        },
        onLoad() {
            this.model.companyName = this.userInfo.companyName
            this.model.name = this.userInfo.name
            this.getLocation()
            this.getType()
            this.getNotifier()
        },
        methods: {
            openF() {
                this.stopScroll()
                this.show1 = true
            },
            closeF() {
                this.canScroll()
                this.show1 = false
            },
            // 获取通知人
            async getNotifier() {
                let res = await this.$u.api.managersList({ type: 0 })
                if (res.code === 200) {
                    this.model.notifier = res.data.map(item => item.memberName).join(',')
                }
            },
            // 选择伤害类型
            selectType(e) {
                this.model.typeId = e[0].id
                this.model.typeName = e[0].name
                this.$refs.pengTree._hide()
            },
            // 选择地点
            selectAddress(e) {
                this.model.localtionId = e[0].id
                this.model.localtionName = e[0].name
                this.$refs.pengTree._hide()
            },
            // 跌绊滑伤害类型
            async getType() {
                let res = await this.$u.api.categoryTree({ categoryType: 1 })
                if (res.code === 200) {
                    this.typeList = res.data
                }
            },
            // 跌绊滑发生地点
            async getLocation() {
                let res = await this.$u.api.categoryTree({ categoryType: 2 })
                if (res.code === 200) {
                    this.address = res.data
                }
            },
            next() {
                this.canScroll()
                this.show4 = false
            },
            next1() {
                this.model.submitDate = uni.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd hh:MM:ss')
                this.model.happenTime = ''
                this.model.localtionId = ''
                this.model.localtionName = ''
                this.model.typeId = ''
                this.model.typeName = ''
                this.model.riskInfo = ''
                this.model.multifileList = []
                this.model.type = 3
            },
            toDesc() {
                uni.navigateTo({
                    url: `/pages/riskDetails/riskDetails?id=${this.id}`
                })
                this.canScroll()
                this.show4 = false
            },
            // 删除图片
            deletePic(index) {
                this.model.multifileList.splice(index, 1)
            },
            // 新增图片
            async afterRead(arr) {
                this.model.multifileList = [...this.model.multifileList, ...arr]
            },
            // 提交
            submit() {
                var that = this
                that.$refs.uForm.validate().then(async () => {
                    let res = await that.$u.api.workOrderCreate(that.model)
                    if (res.code === 200) {
                        that.next1()
                        that.id = res.data
                        that.stopScroll()
                        that.show4 = true
                    }
                }).catch(errors => {
                    
                })
            },
            changeHandler(e) {
                const {
                    columnIndex,
                    value,
                    values, // values为当前变化列的数组内容
                    index,
                    // 微信小程序无法将picker实例传出来,只能通过ref操作
                    picker = this.$refs.uPicker
                } = e
                // 当第一列值发生变化时,变化第二列(后一列)对应的选项
                if (columnIndex === 0) {
                    // picker为选择器this实例,变化第二列对应的选项
                    picker.setColumnValues(1, this.columnData[index])
                }
            },
            // 回调参数为包含columnIndex、value、values
            confirm(e) {
                console.log('confirm', e)
                this.show = false
            },
            selectTime(e) {
                this.model.happenTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss')
                this.canScroll()
                this.show1 = false
            },
            selectAddr(e) {
                console.log('confirm', e)
                this.show2 = false
            },
            selectUser(e) {
                console.log('confirm', e)
                this.show3 = false
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .she {
        width: 100%;
        padding: 0 30rpx 30rpx 30rpx;
        box-sizing: border-box;
        .slot-content {
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            text {
                &:nth-child(2) {
                    color: rgba(16,16,16,1);
                    font-size: 32rpx;
                    margin-top: 24rpx;
                }
                &:nth-child(3) {
                    color: rgba(190,190,190,1);
                    font-size: 26rpx;
                    margin-top: 15rpx;
                }
            }
        }
    }
</style>