<template>
|
<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="name" borderBottom required>
|
<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="patrolTime" borderBottom required @click="showSelectDate = true">
|
<u-input v-model="info.patrolTime" 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="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" style="color: #c0c4cc" v-if="!info.location">
|
请选择地址
|
</view>
|
<view class="location-btn c-main f-24" @click="getLocation()">
|
获取地址
|
</view>
|
</view>
|
</u-form-item>
|
<u-form-item label="巡查内容" borderBottom prop="context" required>
|
<!-- <u-input type="textarea" v-model="info.context" border="none" placeholderClass="f-28 c-99"
|
inputAlign="right" placeholder="请输入巡查内容" >
|
</u-input> -->
|
<u--textarea v-model="info.context" inputAlign="right" placeholder="请输入巡查内容"
|
placeholderClass="f-28 c-99"></u--textarea>
|
</u-form-item>
|
</u-form>
|
</view>
|
<view class="upload bgc-ff">
|
<view class="f-28">巡查图片</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-datetime-picker ref="datetimePicker" :show="showSelectDate" v-model="patrolTime" mode="datetime"
|
:formatter="formatter" @confirm="confirmDate" @cancel="showSelectDate = false"></u-datetime-picker>
|
|
<!-- <view class="footer">
|
<button class="footer-btn" @click="submitInfo">提交</button>
|
</view> -->
|
|
<!-- <footer-btn @click="submitInfo"></footer-btn> -->
|
|
<button class="submit-btn" @click="submitInfo">提交</button>
|
<button class="list-btn" @click="navToRecord">巡查记录</button>
|
|
|
|
</view>
|
|
</template>
|
|
<script>
|
import uploadMixin from "@/mixin/uploadMixin";
|
import {
|
addPartrol
|
} from "@/api/patrol/patrol.js"
|
export default {
|
mixins: [uploadMixin],
|
data() {
|
return {
|
form: {
|
images: []
|
},
|
info: {
|
name: "",
|
context: "",
|
patrolTime: "",
|
location: ""
|
},
|
rules: {
|
'name': {
|
type: 'string',
|
required: true,
|
message: '请输入巡查标题',
|
trigger: ['blur', 'change']
|
},
|
'context': {
|
type: 'string',
|
required: true,
|
message: '请输入巡查内容',
|
trigger: ['blur', 'change']
|
},
|
// 'patrolTime': {
|
// type: 'string',
|
// required: true,
|
// message: '请选择巡查时间',
|
// trigger: ['blur', 'change']
|
// },
|
'location': {
|
type: 'string',
|
required: true,
|
message: '请选择巡查位置',
|
trigger: ['blur', 'change']
|
}
|
},
|
|
images: [
|
|
],
|
showSelectDate: false,
|
patrolTime: Number(new Date())
|
}
|
},
|
|
onLoad() {
|
this.info.patrolTime = uni.$u.timeFormat(Number(new Date()), 'yyyy-mm-dd hh:MM:ss')
|
},
|
|
methods: {
|
|
confirmDate(e) {
|
this.showSelectDate = false;
|
this.info.patrolTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss')
|
},
|
|
checkImages() {
|
if (this.form.images.length) {
|
this.$set(this.info, "url", this.setImages())
|
}
|
},
|
|
|
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)
|
}
|
})
|
},
|
|
setImages() {
|
let urls = [];
|
for (let i of this.form.images) {
|
urls.push(i.name);
|
}
|
return urls.join(",")
|
},
|
|
submitInfo() {
|
this.$refs.form.validate().then(valid => {
|
this.checkImages();
|
addPartrol(this.info).then(res => {
|
uni.showToast({
|
icon: 'success',
|
title: '提交成功',
|
success() {
|
setTimeout(() => {
|
uni.navigateBack()
|
}, 1000)
|
}
|
})
|
})
|
})
|
},
|
navToRecord() {
|
uni.navigateTo({
|
url: '/subPackage/patrol/list'
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="less">
|
page {
|
background-color: #F5F5F5;
|
}
|
|
.content {
|
margin: 20rpx 30rpx;
|
padding: 0 30rpx;
|
}
|
|
.row {
|
padding: 20rpx 0;
|
border-bottom: 1px solid
|
}
|
|
.location-btn {
|
width: 116rpx;
|
height: 46rpx;
|
line-height: 46rpx;
|
border-radius: 4rpx;
|
border: 1px solid currentColor;
|
padding: 0;
|
background-color: #fff;
|
}
|
|
.upload {
|
margin: 0 30rpx;
|
padding: 30rpx;
|
|
.upload-item {
|
width: 140rpx;
|
height: 140rpx;
|
border: 1px solid #EEEEEE;
|
}
|
}
|
|
.footer {
|
width: 100%;
|
padding: 30rpx;
|
position: fixed;
|
bottom: 0;
|
left: 0;
|
z-index: 10;
|
box-sizing: border-box;
|
|
.footer-btn {
|
width: 100%;
|
height: 78rpx;
|
line-height: 78rpx;
|
background: linear-gradient(163deg, #01BDFC 0%, #017BFC 100%);
|
border-radius: 8rpx;
|
color: #fff;
|
font-size: 32rpx;
|
}
|
}
|
|
.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;
|
}
|
|
|
.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;
|
}
|
</style>
|