<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>
|