<template>
|
<view class="">
|
|
<u-form labelPosition="left" :model="info" :rules="rules" ref="form" labelWidth="100"
|
:labelStyle="{fontSize:'28rpx'}">
|
<view class="content">
|
<u-form-item label="姓名" prop="checkUserName" borderBottom required>
|
<u-input v-model="info.checkUserName" border="none" disabled disabledColor="#fff" placeholder="请输入"
|
placeholderClass="f-28 c-99" inputAlign="right"></u-input>
|
</u-form-item>
|
<u-form-item label="手机" prop="checkTelephone" borderBottom required>
|
<u-input v-model="info.checkTelephone" border="none" disabled disabledColor="#fff" placeholder="请输入"
|
placeholderClass="f-28 c-99" inputAlign="right"></u-input>
|
</u-form-item>
|
<u-form-item label="申请事由" prop="applyName" borderBottom required>
|
<u-input v-model="info.applyName" border="none" placeholder="请输入" placeholderClass="f-28 c-99"
|
inputAlign="right"></u-input>
|
</u-form-item>
|
<u-form-item label="申请时间" prop="applyTime" borderBottom required>
|
<u-input v-model="info.applyTime" disabled disabledColor="#ffffff" border="none" placeholder="请输入"
|
placeholderClass="f-28 c-99" inputAlign="right"></u-input>
|
<!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
|
</u-form-item>
|
<u-form-item label="申请位置" prop="location" borderBottom ref="location" required>
|
<!-- <u-input v-model="info.location" disabled disabledColor="#ffffff" border="none" placeholder="请选择地址" placeholderClass="f-28 c-99"
|
inputAlign="right">
|
<template slot="suffix">
|
<button class="location-btn c-main f-24" @click="getLocation()">获取地址</button>
|
</template>
|
</u-input> -->
|
<view class="address-row flex">
|
<view class="address-content f-28" v-if="info.location">
|
{{info.location}}
|
</view>
|
<view class="address-content f-28" style="color: #c0c4cc;" v-if="!info.location">
|
请选择位置
|
</view>
|
<view class="location-btn c-main f-24" @click="getLocation()">
|
获取地址
|
</view>
|
</view>
|
|
</u-form-item>
|
</view>
|
|
<view class="upload bgc-ff">
|
<view class="f-28 mb-20">位置图片</view>
|
<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>
|
</u-form>
|
<button class="submit-btn" @click="sumitInfo">提交</button>
|
<button class="list-btn mb-20" @click="navigatorPage">我上报的事件</button>
|
<u-datetime-picker ref="datetimePicker" :show="showSelectDate" v-model="applyTime" mode="datetime"
|
:formatter="formatter" @confirm="confirmDate" @cancel="showSelectDate = false"></u-datetime-picker>
|
</view>
|
</template>
|
|
<script>
|
import uploadMixin from "@/mixin/uploadMixin";
|
import {
|
saveBailReporting,
|
getBailReportingDetail,
|
updateBailReporting
|
} from "@/api/reporting/reporting";
|
export default {
|
mixins: [uploadMixin],
|
data() {
|
return {
|
form: {
|
images: []
|
},
|
info: {
|
checkUserName: "",
|
checkTelephone: "",
|
applyName: "",
|
applyTime: '',
|
location: "",
|
houseCode: "",
|
districtName: "",
|
checkUserId: "",
|
reportType: 1
|
},
|
rules: {
|
checkUserName: [{
|
type: 'string',
|
required: true,
|
message: '请输入姓名',
|
trigger: ['blur', 'change']
|
}],
|
checkTelephone: [{
|
type: 'number',
|
required: true,
|
message: '请输入手机',
|
trigger: ['blur', 'change']
|
},
|
{
|
|
validator: (rule, value, callback) => {
|
return uni.$u.test.mobile(value);
|
},
|
message: '手机号码不正确',
|
trigger: ['change', 'blur']
|
|
}
|
|
],
|
applyName: [{
|
type: 'string',
|
required: true,
|
message: '请输入事由',
|
trigger: ['blur', 'change']
|
}],
|
applyTime: [{
|
type: 'string',
|
required: true,
|
message: '请输入选择时间',
|
trigger: ['blur', 'change']
|
}],
|
location: [{
|
type: 'string',
|
required: true,
|
message: '请输入位置',
|
trigger: ['blur', 'change']
|
}]
|
},
|
showSelectDate: false,
|
applyTime: Number(new Date()),
|
status: "",
|
isEdit: false
|
}
|
},
|
onLoad(option) {
|
|
if (option.id) {
|
this.isEdit = true;
|
this.getDetail(option.id)
|
}
|
|
let siteInfo = uni.getStorageSync("siteInfo");
|
let userInfo = uni.getStorageSync("userInfo");
|
this.$set(this.info, "houseCode", siteInfo.houseCode);
|
this.$set(this.info, "districtName", siteInfo.name);
|
this.$set(this.info, "checkUserName", userInfo.real_name);
|
this.$set(this.info, "checkTelephone", userInfo.phone);
|
this.$set(this.info, "checkUserId", userInfo.user_id);
|
this.$set(this.info, "applyTime", uni.$u.timeFormat(Number(new Date()), 'yyyy-mm-dd hh:MM:ss'))
|
},
|
|
onReady() {
|
// 微信小程序需要用此写法
|
this.$refs.datetimePicker.setFormatter(this.formatter)
|
},
|
|
methods: {
|
|
|
getDetail(id) {
|
getBailReportingDetail({
|
taskId: id
|
}).then(res => {
|
if (res.code == 200) {
|
for (let i in this.info) {
|
this.info[i] = res.data[i]
|
}
|
this.info.reportType = 1;
|
this.status = data.confirmFlag;
|
if (res.data.applyTime) {
|
this.applyTime = Number(new Date(res.data.applyTime))
|
}
|
this.form.images = this.$setImageUrl(data.locationImageUrls, 2);
|
this.info.locationImageUrls = data.locationImageUrls;
|
this.info.id = data.id;
|
this.info.taskId = data.taskId;
|
}
|
})
|
},
|
|
|
getLocation() {
|
uni.chooseLocation({
|
success: (res) => {
|
this.$set(this.info, "location", res.address);
|
}
|
})
|
},
|
|
|
formatter(type, value) {
|
if (type === 'year') {
|
return `${value}年`
|
}
|
if (type === 'month') {
|
return `${value}月`
|
}
|
if (type === 'day') {
|
return `${value}日`
|
}
|
return value
|
},
|
|
confirmDate(e) {
|
this.showSelectDate = false;
|
this.info.applyTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss')
|
},
|
|
checkImages() {
|
if (this.form.images.length) {
|
this.$set(this.info, "locationImageUrls", this.setImages())
|
}
|
},
|
|
setImages() {
|
let urls = [];
|
for (let i of this.form.images) {
|
urls.push(i.name);
|
}
|
return urls.join(",")
|
},
|
|
sumitInfo() {
|
this.$refs.form.validate().then(valid => {
|
this.checkImages();
|
if (this.isEdit) {
|
this.info.status = 1;
|
this.updateRequest()
|
} else {
|
this.addRequest()
|
}
|
})
|
},
|
|
|
addRequest() {
|
saveBailReporting(this.info).then(res => {
|
uni.showToast({
|
icon: 'success',
|
title: '提交成功'
|
})
|
setTimeout(() => {
|
uni.navigateBack()
|
}, 300)
|
})
|
},
|
|
updateRequest() {
|
// this.info.applyTime = Number(new Date(res.data.applyTime));
|
updateBailReporting(this.info).then(res => {
|
uni.showToast({
|
icon: 'success',
|
title: '保存成功'
|
})
|
setTimeout(() => {
|
uni.navigateBack()
|
}, 300)
|
})
|
},
|
|
navigatorPage() {
|
this.$u.func.globalNavigator('bailList', "navTo")
|
}
|
}
|
}
|
</script>
|
|
<style lang="less">
|
page {
|
background-color: #F5F5F5;
|
}
|
|
.content {
|
margin: 20rpx 30rpx;
|
padding: 0 30rpx;
|
background-color: #fff;
|
}
|
|
/deep/.u-radio-group--row {
|
justify-content: flex-end;
|
}
|
|
.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>
|