日常巡查

master
lion 4 years ago
parent 0931daa220
commit 05c65b9726

@ -0,0 +1,10 @@
<template>
</template>
<script>
</script>
<style>
</style>

@ -1,22 +1,267 @@
<template>
<view>
</view>
</template>
<script>
export default {
data() {
return {
<template>
<view class="content">
<u-form :model="form" ref="uForm">
<u-form-item label="巡查项目" label-position="top" prop="name" required>
<u-input v-model="form.name" type="text" :border="true" placeholder="请填写巡查项目"/>
</u-form-item>
<u-form-item label-position="top" label="巡查记录" prop="content">
<u-input v-model="form.content" type='textarea' height='100' :border="true" />
</u-form-item>
<u-form-item label-position="top" label="现场照片">
<u-upload ref="uUpload" multiple :maxCount="10" :action="action" upload-text=""
:previewFullImage="true" :file-list="filesList" :form-data="otherData" :show-tips="false" @on-uploaded="function(lists, name) {return toupload(lists, name,'filesList')}"
@on-remove="function(index, lists, name) {return toremove(index, lists, name,'filesList')}">
</u-upload>
</u-form-item>
<u-form-item label-position="top" label="状态">
<u-radio-group v-model="form.status">
<u-radio
@change="radioChange"
v-for="(item, index) in statuss" :key="index"
:name="item.id"
>
{{item.name}}
</u-radio>
</u-radio-group>
</u-form-item>
<div v-if="form.status==2">
<u-form-item label="" label-position="top" prop="nextStatus">
<u-input v-model="nextStatus" type="select" :border="true" @click="nextShow = true" />
<u-select v-model="nextShow" mode="single-column" value-name="id" label-name="name" :list="slist"
@confirm="confirmNext"></u-select>
</u-form-item>
</div>
<div v-if="form.status==2 && nextStatusId==2">
<u-form-item label-position="top" label="处理记录" prop="deal_content">
<u-input v-model="form.deal_content" type='textarea' height='100' :border="true" />
</u-form-item>
}
},
methods: {
<u-form-item label-position="top" label="处理后照片">
<u-upload ref="uUpload" multiple :maxCount="10" :action="action" upload-text=""
:previewFullImage="true" :file-list="dealFilesList" :form-data="otherData" :show-tips="false" @on-uploaded="function(lists, name) {return toupload(lists, name,'dealFilesList')}"
@on-remove="function(index, lists, name) {return toremove(index, lists, name,'dealFilesList')}">
</u-upload>
</u-form-item>
</div>
<div v-if="nextStatusId==3">
<u-form-item label="位置" label-position="top" required>
<!-- <text>{{form.address}}</text> -->
<u-input v-model="form.address" disabled type='text'/>
<u-button shape="square" slot='right' size="mini" @click="chooseLocation" type="info">重新获取</u-button>
</u-form-item>
</div>
</u-form>
<u-button type="primary" @click="submit"></u-button>
</view>
</template>
<script>
export default {
data() {
return {
otherData: {
token: ""
},
showMap: false,
nextStatus:"可现场处理",
nextStatusId:2,
nextShow:false,
action: "",
location: {},
slist:[
{
id:2,
name:"可现场处理"
},
{
id:3,
name:"不可现场处理"
}
],
statuss:[
{
id:1,
name:"无异常"
},
{
id:2,
name:"有异常"
}
],
filesList:[],
dealFilesList:[],
form: {
name:"",
content:"",
status:1,
deal_content:"",
deal_longitude:"",
deal_latitude:"",
address:"",
files_list:"",
deal_files_list:""
},
width: 300,
height: 300,
rules: {
name: [{
required: true,
message: '请填写项目名称',
//
trigger: ['blur'],
}]
}
}
},
onLoad() {
var that = this;
this.action = this.util.HOST + "/api/mobile/upload-file";
this.otherData.token = uni.getStorageSync("userInfo_token").access_token;
},
onReady() {
this.$refs.uForm.setRules(this.rules);
let that = this;
uni.getLocation({
type: "gcj02",
geocode:true,
success(res) {
that.location = res;
that.form.deal_latitude = res.latitude;
that.form.deal_longitude = res.longitude;
}
})
uni.getSystemInfo({
complete(res) {
that.width = res.screenWidth * .8
that.height = res.screenHeight * .6
}
})
},
methods: {
toremove(index, lists, name,whatfile) {
console.log(lists);
console.log(whatfile);
let list = [];
for (var m of lists) {
list.push({
upload_id: m.response.id
})
}
if(whatfile=="filesList"){
this.form.files_list = list;
}
if(whatfile=="dealFilesList"){
this.form.deal_files_list = list;
}
},
toupload(lists, name,whatfile) {
console.log(lists)
console.log(whatfile)
let list = [];
for (var m of lists) {
list.push({
upload_id: m.response.id
})
}
if(whatfile=="filesList"){
this.form.files_list = list;
}
if(whatfile=="dealFilesList"){
this.form.deal_files_list = list;
}
},
radioChange(val){
console.log(val)
},
confirmNext(e) {
console.log(e);
var that = this;
that.nextStatusId = e[0].value
that.nextStatus = e[0].label
},
submit() {
let that = this;
if(that.nextStatusId==3){
that.form.status = that.nextStatusId
}else{
that.form.deal_latitude = "";
that.form.deal_longitude = "";
}
// console.log(that.form);
// return;
this.$refs.uForm.validate(valid => {
if (valid) {
console.log('验证通过');
that.util.request({
api: '/api/mobile/daily-inspection/store',
method: "POST",
data: that.form,
utilSuccess: function(res) {
uni.showToast({
icon: "none",
title: "提交成功",
complete() {
that.afterSubmit(res);
},
duration: 2000
})
},
utilFail: function(res) {
this.util.alert(res);
}
});
} else {
console.log('验证失败');
}
});
},
afterSubmit(res) {
uni.redirectTo({
url: "../dailyList/dailyList"
})
},
}
}
</script>
<style>
chooseLocation(e) { //
var that = this;
uni.chooseLocation({
success: res => {
console.log('位置名称:' + res.name);
console.log('详细地址:' + res.address);
console.log('纬度:' + res.latitude);
console.log('经度:' + res.longitude);
that.form.address = res.name;
uni.getLocation({
type: 'gcj02',
altitude:true,
geocode:true,
success: function(res) {
that.form.deal_longitude = res.longitude;
that.form.deal_latitude = res.latitude;
}
});
}
});
},
}
}
</script>
<style>
.content {
padding: 20rpx;
}
.popuptitle {
background: #2979ff;
color: #fff;
padding: 20rpx 30rpx;
}
</style>

@ -0,0 +1,350 @@
<template>
<view class="boxContent">
<view class="box-header">
<view class="search-wrap">
<!-- 如果使用u-search组件必须要给v-model绑定一个变量 -->
<u-search v-model="keyword" placeholder="地址/河道等" @change="tosearch()" @search="tosearch()" height="56"
:action-style="{color: '#fff'}">
</u-search>
</view>
</view>
<view class="list" style="padding-top: 100rpx;">
<u-dropdown @open="openmask" @close="closemask" :class="mask?'':'overflowmask'" ref="uDropdown">
<u-dropdown-item v-model="proStatusId" :title="proStatus==''?'项目状态':proStatus" @change="toChangeStatus"
:options="prostatusList">
</u-dropdown-item>
</u-dropdown>
<block v-for="(item, index) in dataList">
<u-card :title="item.created_at" padding="20" margin="20rpx" :border="true"
:sub-title="item.created_at" :thumb="thumb" thumb-width="36">
<view class="" slot="body" @click="todetail(item.id)">
<u-row gutter="16">
<u-col span="3">
<view class="demo-layout bg-purple">巡查项目</view>
</u-col>
<u-col span="9">
<view class="demo-layout bg-purple-light">{{item.name}}</view>
</u-col>
</u-row>
<u-row gutter="16">
<u-col span="3">
<view class="demo-layout bg-purple">项目状态</view>
</u-col>
<u-col span="9">
<u-tag v-if="item.status==1" text="无异常" type="primary" />
<u-tag v-if="item.status==2" text="已现场处理" type="warning" />
<u-tag v-if="item.status==3" text="不可现场处理" type="error" />
</u-col>
</u-row>
<u-row gutter="16" v-if="item.status==3">
<u-col span="3">
<view class="demo-layout bg-purple">定位地址</view>
</u-col>
<u-col span="9">
{{item.address}}
</u-col>
</u-row>
</view>
<view class="footer" slot="foot">
<block >
<u-button :custom-style="editStyle" type="primary" size="medium"
@click="toedit(item.id)" :ripple="true">编辑
</u-button>
</block>
<block >
<u-button type="error" size="medium" @click="del(item.id)"
:custom-style="customStyle" :ripple="true">删除
</u-button>
</block>
</view>
</u-card>
</block>
<u-loadmore class="loadmore" :status="loadStatus" :load-text="loadText"/>
<u-empty text="暂无数据" margin-top="200" v-if="dataList.length==0" mode="list"></u-empty>
</view>
<u-toast ref="uToast" />
</view>
</template>
<script>
export default {
data() {
return {
background: {
backgroundColor: '#007AFF'
},
mask: false,
loadStatus:"loadmore",
loadText:{
loadmore:"加载更多",
nomore:"已经到底了"
},
dataList: [],
thumb: "/static/img/location.png",
currentPage: 0,
lastPage:0,
editStyle:{
fontSize:'30rpx'
},
customStyle: {
marginLeft: '20px',
fontSize:'30rpx'
},
currentRole: "inspector", //inspectormanageroperator
proStatus: '',
proStatusId: '',
keyword: "",
title: "",
prostatusList: [{
label: "所有",
value: "",
id: ""
}, {
label: "无异常",
value: 1,
}, {
label: "已处理",
value: 2,
}, {
label: "不可现场处理",
value: 3
}]
}
},
onReachBottom: function(e) {
console.log(this.currentPage,this.lastPage);
if(this.currentPage>=this.lastPage){
this.loadStatus = "nomore"
return;
}
this.loadPage(this.currentPage + 1);
},
onPullDownRefresh: function(e) {
this.loadStatus = 'loadmore';
console.log("bbb")
this.loadPage(1);
},
onShow: function() {
var that = this;
},
onLoad(options) {
this.loadPage(1);
},
methods: {
openmask(){
this.mask=true
this.isPullDown(false);
},
closemask(){
this.mask=false
this.isPullDown(true);
},
toChangeStatus: function(value) {
for(var m of this.prostatusList){
if(value == m.value){
this.proStatus = m.label
}
}
this.loadPage(1);
this.$refs.uDropdown.close();
},
tosearch() {
this.loadPage(1)
this.$refs.uDropdown.close();
},
todetail: function(id) {
uni.navigateTo({
url: "../dailyInfo/dailyInfo?id=" + id
})
},
toedit(id){
uni.navigateTo({
url: "../dailyInspection/dailyInspection?id=" + id
})
},
loadPage: function(page) {
uni.hideKeyboard()
var that = this;
console.log(page)
this.util.request({
bindThis: that,
api: '/api/mobile/daily-inspection/index',
customLoading: false,
data: {
page: page,
page_size: 5,
keyword: that.keyword,
status:that.proStatusId
},
utilSuccess: function(r) {
var res = r.data;
that.lastPage = r.last_page;
uni.stopPullDownRefresh(); // < ,
if(r.total<6){
that.loadStatus = "nomore";
}
var hasNoMore = that.dataList.length < 5 && page > 1 ;
if (hasNoMore || res.length == 0 && page > 1) {
that.loadStatus = "nomore";
//
uni.showToast({
title: '已加载到最后一页',
icon: 'none'
});
return;
}
var dataList = that.dataList;
if (page == 1) {
dataList = res;
} else {
dataList.push(...res);
}
for (var m of dataList) {
m.created_at = m.created_at.split("T")[0]
}
console.log(dataList)
that.currentPage = page;
that.dataList = dataList;
},
utilFail: function(res) {
uni.stopPullDownRefresh();
if (page == 1) {
that.currentPage = page;
}
this.util.alert(res);
}
});
},
del(id){
var that = this;
uni.showModal({
title: '提示',
content: '是否确定删除?',
success(res) {
if(res.confirm){
that.util.request({
api: '/api/mobile/daily-inspection/destroy',
customLoading: false,
method:"get",
data: {
id:id
},
utilSuccess: function(r) {
that.$refs.uToast.show({
title: '删除成功',
duration: 2000,
url: '/packageB/pages/dailyList/dailyList'
})
},
utilFail:function(r) {
this.util.alert(res);
},
})
}else if(res.cancel){
}
}
})
}
}
}
</script>
<style>
.boxContent {
background: #f3f4f6;
min-height: 100vh;
}
.footer {
display: flex;
justify-content: flex-end;
}
.box-header {
position: fixed;
top: 0;
width: 100%;
z-index: 99;
}
.u-row {
margin: 10rpx 0;
font-size: 28rpx;
}
.u-card{
z-index: 1;
}
</style>
<style scoped lang="scss">
.overflowmask{
overflow: hidden;
}
.loadmore{
padding:24rpx!important
}
.search-wrap {
background: #007AFF;
padding: 20rpx;
}
.u-config-wrap {
padding: 30rpx;
}
.bg-purple {
font-weight: bold;
}
.slot-content {
background-color: #FFFFFF;
padding: 24rpx;
.item-box {
margin-bottom: 50rpx;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
.item {
border: 1px solid $u-type-primary;
color: $u-type-primary;
padding: 8rpx 40rpx;
border-radius: 100rpx;
margin-top: 30rpx;
}
.active {
color: #FFFFFF;
background-color: $u-type-primary;
}
}
}
</style>

@ -65,6 +65,21 @@
"enablePullDownRefresh": false
}
},{
"path": "dailyList/dailyList",
"style": {
"navigationBarTitleText": "日常监管巡查",
"enablePullDownRefresh": true,
"navigationStyle": "custom",
"disableScroll": true
}
},{
"path": "dailyInfo/dailyInfo",
"style": {
"navigationBarTitleText": "日常监管巡查",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
}]
}],
"globalStyle": {

@ -25,9 +25,9 @@
<u-col span="12">
<view class="demo-layout bg-purple-light">
<view class="demo-layout bg-purple-light" @click="toview(3)">
<text class="iconfont icon-zaixianjiance"></text>
<text class="navtxt">日常监巡查</text>
<text class="navtxt">日常监巡查</text>
</view>
</u-col>
</u-row>
@ -76,6 +76,9 @@
let url = "/packageA/pages/generalPatrol/generalPatrol";
if (type == 2) {
url = "/pages/mine/mine"
}
if (type == 3) {
url = "/packageB/pages/dailyInspection/dailyInspection"
}
uni.navigateTo({
url: url

@ -25,7 +25,7 @@
<u-col span="12">
<view class="demo-layout bg-purple-light">
<view class="demo-layout bg-purple-light" @click="toview(2)">
<text class="iconfont icon-zaixianjiance"></text>
<text class="navtxt">我的日常监督巡查</text>
</view>
@ -69,7 +69,7 @@
toview(type) {
let url = "/packageA/pages/generalList/generalList";
if (type == 2) {
url = "/pages/mine/mine"
url = "/packageB/pages/dailyList/dailyList"
}
uni.navigateTo({
url: url

Loading…
Cancel
Save