linwe
2024-08-08 3c738f4fe2762bba8087e5a22fc0dc06560eab0e
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
<template>
    <view class="">
 
 
        <view class="top item flex j-c-s-b a-i-c bgc-ff" @click="onScan()" v-if="roleName =='mj'">
            <view class="flex a-i-c">
                <u-icon name="/static/icon/nav-05.png" width="90rpx" height="90rpx"></u-icon>
                <text class="f-28 ml-10">扫码获取信息</text>
            </view>
            <u-icon name="arrow-right" size="20"></u-icon>
        </view>
 
        <view class="content bgc-ff">
            <u-form labelPosition="left" :model="info" :rules="rules" ref="form" labelWidth="90"
                :labelStyle="{fontSize:'28rpx'}">
 
                <u-form-item label="场所名称" prop="placeName" borderBottom>
                    <u-input v-model="info.placeName" border="none" placeholder="请输入" placeholderClass="f-28 c-99"
                        inputAlign="right"></u-input>
                </u-form-item>
 
                <u-form-item label="角色类型" prop="type" borderBottom ref="phone" @click="showPicker = true"
                    v-if="roleName !='mj'">
                    <u-input v-model="clockInRoleTypeValue" border="none" placeholder="请输入" placeholderClass="f-28 c-99"
                        inputAlign="right" disabled disabledColor="#ffffff"></u-input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
 
                <u-form-item label="家长姓名" prop="name" borderBottom ref="name" v-if="info.type == 2">
                    <u-input v-model="info.name" border="none" placeholder="请输入" placeholderClass="f-28 c-99"
                        inputAlign="right"></u-input>
                </u-form-item>
 
                <u-form-item label="家长手机号" prop="phone" borderBottom ref="phone" v-if="info.type == 2">
                    <u-input v-model="info.phone" border="none" placeholder="请输入" placeholderClass="f-28 c-99"
                        inputAlign="right"></u-input>
                </u-form-item>
                <u-form-item label="学生姓名" prop="realName" borderBottom ref="realName" v-if="info.type == 2">
                    <u-input v-model="info.realName" border="none" placeholder="请输入" placeholderClass="f-28 c-99"
                        inputAlign="right"></u-input>
                </u-form-item>
                <u-form-item label="学生班级" prop="gradeAndClass" borderBottom ref="gradeAndClass" v-if="info.type == 2">
                    <u-input v-model="info.gradeAndClass" border="none" placeholder="请输入" placeholderClass="f-28 c-99"
                        inputAlign="right"></u-input>
                </u-form-item>
                <u-form-item label="位置" prop="location" :borderBottom="false" required>
                    <view class="address-row flex">
                        <view class="address-content f-28" v-if="info.location">
                            {{info.location}}
                        </view>
                        <view class="address-content f-28 c-99" v-if="!info.location">
                            请选择地址
                        </view>
                        <view class="location-btn c-main f-24" @click="getLocation()">
                            获取地址
                        </view>
                    </view>
                    <!-- <u-input v-model="info.address" border="none"  placeholderClass="f-28 c-99"
                        inputAlign="right"    disabled  disabledColor="#fff">
                        <template slot="suffix">
                            <button class="location-btn c-main f-24"   @click="getLocation()">获取地址</button>
                        </template>
                    </u-input> -->
                </u-form-item>
            </u-form>
        </view>
 
        <view class="upload bgc-ff">
            <view class="f-28 mb-20">照片</view>
            <!-- <u-textarea v-model="info.remark" placeholder="请输入内容" border="none"
                placeholderClass="c-99 f-26"></u-textarea> -->
            <view class="mt-20">
                <u-upload :fileList="form.images" :previewFullImage="uploadConfig.previewFullImage"
                    :accept="uploadConfig.acceptImg" :multiple="uploadConfig.multiple" :maxCount="uploadConfig.maxCount"
                    :capture="uploadConfig.capture" @afterRead="afterReadImg" @delete="deletePic">
                    <view class="upload-item upload-icon flex_base">
                        <u-icon name="/static/icon/upload.png" width="60rpx" height="60rpx"></u-icon>
                    </view>
                </u-upload>
            </view>
        </view>
 
        <!-- <button class="submit-btn" @click="sumitInfo">提交</button> -->
        <!-- <button class="list-btn" @click="navigatorPage">我上报的事件</button> -->
        <footer-btn @click="sumitInfo"></footer-btn>
        <u-picker :defaultIndex="clockInRoleTypeIndex" :closeOnClickOverlay="true" :show="showPicker"
            :columns="[statusList]" @close="showPicker = false" @cancel="showPicker = false" keyName="name"
            @confirm="confirmPicker"></u-picker>
 
    </view>
</template>
 
<script>
    import uploadMixin from "@/mixin/uploadMixin";
    import {
        addClockIn
    } from "@/api/school/school.js";
    import {
        getQrCodeDetail
    } from "@/api/system/index"
    export default {
        mixins: [uploadMixin],
        data() {
            return {
                info: {
                    placeName: "",
                    type: "",
                    name: "",
                    phone: "",
                    location: "",
                    gradeAndClass: "",
                    latitude: "",
                    longitude: "",
                    houseCode: ""
                },
                rules: {
                    'name': {
                        type: 'string',
                        required: true,
                        message: '请输入家长姓名',
                        trigger: ['blur', 'change']
                    },
                    'phone': [{
                            type: 'string',
                            required: true,
                            message: '请输入手机号',
                            trigger: ['blur', 'change']
                        },
                        {
                            validator: (rule, value, callback) => {
                                return uni.$u.test.mobile(value);
                            },
                            message: '手机号码不正确',
                            trigger: ['change', 'blur']
                        }
                    ],
                    'location': {
                        type: 'string',
                        required: true,
                        message: '请选择地址',
                        trigger: ['blur', 'change']
                    },
                },
                desc: "",
                title: "",
                curSelectSite: {},
                statusList: [{
                        name: "家长",
                        id: 2
                    },
                    {
                        name: "老师",
                        id: 3
                    },
 
                    {
                        name: "志愿者",
                        id: 4
                    }
                ],
                clockInRoleTypeList: [],
                clockInRoleTypeIndex: [0],
                clockInRoleTypeValue: "",
                showPicker: false,
                roleName: ""
            }
        },
        onLoad(option) {
            if (option.type) {
                this.info.type = option.type
            }
            let {
                roleAlias
            } = uni.getStorageSync("activeRole");
            this.roleName = roleAlias
            if (roleAlias == "mj") {
                this.info.type = 1;
            } else {
                this.info.houseCode = uni.getStorageSync("siteInfo").houseCode;
                this.info.placeName = uni.getStorageSync("siteInfo").name;
            }
 
        },
        // onShow() {
        //     this.curSelectSite = uni.getStorageSync('siteInfo')
        //     this.info.addressCode = this.curSelectSite.houseCode
        // },
        methods: {
 
 
            getLocation() {
                uni.chooseLocation({
                    success: (res) => {
                        this.$set(this.info, "location", res.address);
                        this.$set(this.info, "latitude", res.latitude);
                        this.$set(this.info, "longitude", res.longitude)
                    }
                })
            },
 
            sumitInfo() {
                if (this.info.type == 2) {
                    this.info.gradeAndClass = "";
                    this.info.realName = "";
                }
 
                this.$refs.form.validate().then(valid => {
                    if (this.form.images.length > 0) {
                        let urls = []
                        this.form.images.forEach(e => {
                            urls.push(e.name)
                        })
                        this.info.images = urls.join(",")
                    }
                    addClockIn(this.info).then(res => {
                        this.$showTips("提交成功", "success")
                        setTimeout(() => {
                            uni.navigateBack()
                        }, 300)
                    })
                })
            },
 
            //选择隐患类型
            confirmPicker(e) {
                this.clockInRoleTypeIndex = e.indexs;
                this.clockInRoleTypeValue = e.value[0].name;
                this.info.type = e.value[0].id;
                this.showPicker = false;
            },
 
 
            navigatorPage() {
                let url = "/subPackage/bs/views/repairList" + "?title=" + this.title + "&type=" + this.info.type
                this.$u.func.globalNavigator(url, "navTo")
            },
 
 
            onScan() {
                uni.scanCode({
                    onlyFromCamera: true,
                    success: (res) => {
                        let obj = this.getUrlParams(res.result);
                        this.getHouseType(obj.stdId);
                    }
                })
            },
 
            getUrlParams(url) {
                let urlStr = url.split('?')[1]
                let obj = {};
                let paramsArr = urlStr.split('&')
                for (let i = 0, len = paramsArr.length; i < len; i++) {
                    let arr = paramsArr[i].split('=')
                    obj[arr[0]] = arr[1];
                }
                return obj
            },
 
            getHouseType(code) {
                getQrCodeDetail({
                    roleName: uni.getStorageSync("activeRole").roleName,
                    addressCode: code
                }).then(res => {
                    let {
                        isJur,
                        doorplateType,
                        addressLevel
                    } = res.data;
                    if (isJur == 1) {
                        if (doorplateType == "中门牌" || doorplateType == "小门牌") {
                            this.info.houseCode = code;
                            this.info.placeName = res.data.aoiName;
                            this.info.location = res.data.addressName;
                            this.info.lng = res.data.x;
                            this.info.lat = res.data.y;
                        }
                    } else {
                        uni.showModal({
                            title: "提示!",
                            content: "该区域不是您管辖范围",
                            showCancel: false
                        })
                    }
 
                })
            },
 
 
 
        }
    }
</script>
 
<style lang="less">
    page {
        background-color: #F5F5F5;
    }
 
    .top {
        padding: 20rpx;
        margin: 20rpx 30rpx 0;
    }
 
    .content {
        margin: 20rpx 30rpx;
        padding: 0 30rpx;
    }
 
    .site-box {
        padding: 30rpx;
        margin: 20rpx 30rpx;
        border-radius: 4rpx;
 
        .c-aa {
            color: #aaa;
        }
 
        .address {
            width: 60%;
            margin-left: 25rpx;
        }
    }
 
    .upload-item {
        width: 140rpx;
        height: 140rpx;
        border: 1px solid #EEEEEE;
    }
 
    .upload {
        margin: 0 30rpx;
        padding: 30rpx;
 
 
    }
 
    .submit-btn {
        width: 690rpx;
        height: 78rpx;
        line-height: 78rpx;
        background: linear-gradient(163deg, #01BDFC 0%, #017BFC 100%);
        border-radius: 8rpx 8rpx 8rpx 8rpx;
        font-size: 32rpx;
        color: #fff;
        margin-top: 50rpx;
    }
 
    .list-btn {
        width: 690rpx;
        height: 78rpx;
        line-height: 78rpx;
        background: linear-gradient(163deg, #c7d7dc 0%, #c3cdd8 100%);
        border-radius: 8rpx 8rpx 8rpx 8rpx;
        font-size: 32rpx;
        color: #fff;
        margin-top: 50rpx;
    }
 
    .address-row {
        flex: 1;
        justify-content: flex-end;
        align-items: center;
    }
 
    .address-content {
        width: calc(100% - 116rpx - 20rpx);
        margin-right: 20rpx;
        text-align: right;
    }
 
    .location-btn {
        width: 116rpx;
        height: 46rpx;
        line-height: 46rpx;
        border-radius: 4rpx;
        border: 1px solid currentColor;
        padding: 0;
        background-color: #fff;
        text-align: center;
    }
</style>