This commit is contained in:
java110 2020-05-07 09:04:06 +08:00
commit ffe8f2f60a
7 changed files with 381 additions and 45 deletions

View File

@ -64,6 +64,9 @@ const listInspectionTasks = baseUrl + "app/inspectionTask.listInspectionTasks";
//巡检任务详情
const listInspectionTaskDetails = baseUrl + 'app/inspectionTaskDetail.listInspectionTaskDetails';
//巡检
const updateInspectionTaskDetail = baseUrl + 'app/inspectionTaskDetail.updateInspectionTaskDetail'
module.exports = {
baseUrl: baseUrl,
@ -96,5 +99,6 @@ module.exports = {
listAdvertPhoto: listAdvertPhoto,
saveOwnerRepair:saveOwnerRepair,
listInspectionTasks:listInspectionTasks,
listInspectionTaskDetails:listInspectionTaskDetails
listInspectionTaskDetails:listInspectionTaskDetails,
updateInspectionTaskDetail:updateInspectionTaskDetail
};

View File

@ -4,43 +4,92 @@
* add by wuxw 2020-01-01 美丽的夏都西宁
*/
class Base64Factory {
constructor() {}
constructor() {}
static urlTobase64(url) {
return new Promise((resolve, reject) => {
uni.request({
url: url,
method:'GET',
responseType: 'arraybuffer',
success: ress => {
let base64 = wx.arrayBufferToBase64(ress.data); //把arraybuffer转成base64
base64 = 'data:image/jpeg;base64,' + base64 //不加上这串字符,在页面无法显示的哦
console.log(base64);
resolve(base64);
},
fail: function (e) {
console.log(e);
reject(e);
}
});
/* wx.getFileSystemManager().readFile({
filePath: url,
//选择图片返回的相对路径
encoding: 'base64',
//编码格式
success: res => {
//成功的回调
//console.log('data:image/png;base64,' + res.data);
let base64 = 'data:image/png;base64,' + res.data;
resolve(base64);
},
fail: function (e) {
console.log(e);
reject(e);
}
}); */
});
}
static getLocalFilePath(path) {
if (path.indexOf('_www') === 0 || path.indexOf('_doc') === 0 || path.indexOf('_documents') === 0 || path.indexOf(
'_downloads') === 0) {
return path
}
if (path.indexOf('file://') === 0) {
return path
}
if (path.indexOf('/storage/emulated/0/') === 0) {
return path
}
if (path.indexOf('/') === 0) {
var localFilePath = plus.io.convertAbsoluteFileSystem(path)
if (localFilePath !== path) {
return localFilePath
} else {
path = path.substr(1)
}
}
return '_www/' + path
}
static urlTobase64(url) {
//url = Base64Factory.getLocalFilePath(url);
return new Promise((resolve, reject) => {
console.log('url', url);
// #ifdef H5
let imgData;
let reader = new FileReader();
getImageBlob(url, function(blob) {
reader.readAsDataURL(blob);
});
reader.onload = function(e) {
imgData = e.target.result;
resolve(imgData);
};
function getImageBlob(_url, cb) {
let xhr = new XMLHttpRequest();
xhr.open("get", _url, true);
xhr.responseType = "blob";
xhr.onload = function() {
if (this.status == 200) {
if (cb) cb(this.response);
}
};
xhr.send();
}
// #endif
// #ifdef APP-PLUS
let _imageBase64List = '';
plus.io.resolveLocalFileSystemURL(url,
function(entry) {
// 可通过entry对象操作test.html文件
entry.file(function(file) {
var fileReader = new plus.io.FileReader();
fileReader.readAsDataURL(file);
fileReader.onloadend = function(evt) {
_imageBase64List = _imageBase64List.concat(evt.target.result);
resolve(_imageBase64List);
}
})
});
// #endif
// #ifdef MP-WEIXIN
wx.getFileSystemManager().readFile({
filePath: url, //选择图片返回的相对路径
encoding: 'base64', //编码格式
success: res => { //成功的回调
//console.log('data:image/png;base64,' + res.data);
let base64 = 'data:image/png;base64,' + res.data;
resolve(base64);
},
fail: function(e) {
console.log(e);
reject(e);
}
})
// #endif
});
}
}

View File

@ -150,7 +150,13 @@
,{
"path" : "pages/excuteInspection/excuteInspection",
"style" : {
"navigationBarTitleText": "执行巡检"
"navigationBarTitleText": "巡检过程"
}
}
,{
"path" : "pages/excuteOneInspection/excuteOneInspection",
"style" : {
"navigationBarTitleText": "执行巡检"
}
},{
"path" : "pages/purchaseRequest/purchaseRequest",

View File

@ -8,12 +8,29 @@
{{item.inspectionName}}
</view>
<view class="text-right" v-if="item.state != '20200407'">
<button class="cu-btn line-green block margin-tb-sm lg ">
<button class="cu-btn line-green block margin-tb-sm lg " @click="_excuteInspection(item)">
<text class="cuIcon-upload"></text>巡检</button>
</view>
<view v-else class="margin-top-sm margin-right grid text-center col-3 grid-square">
<view class="" v-for="(_item,index) in item.photos" :key="index">
<image mode="scaleToFill" :src="_item.url" @tap="preview(_item.url)"></image>
</view>
</view>
</view>
</view>
<view class="cu-modal" :class="viewImage?'show':''">
<view class="cu-dialog">
<view class="bg-img" :style="'background-image: url('+ viewImageSrc +');height:800rpx;'">
<view class="cu-bar justify-end text-white">
<view class="action" @tap="closeViewImage()">
<text class="cuIcon-close "></text>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
@ -27,7 +44,9 @@
communityId:'',
userId:'',
userName:'',
taskDetails:[]
taskDetails:[],
viewImage:false,
viewImageSrc:''
}
},
@ -38,6 +57,9 @@
let _userInfo = this.java110Context.getUserInfo();
this.userName = _userInfo.userName;
this.userId = _userInfo.userId;
},
onShow() {
this._queryTaskDetail();
},
methods: {
@ -51,8 +73,7 @@
data: {
communityId: _that.communityId,
page: 1,
row: 100,
taskId: _that.taskId
row: 100
},
success: function(res) {
// TODO
@ -60,13 +81,35 @@
// res.data.inspectionTaskDetails.forEach(function(item, index) {
// item.timeStr = item.planInsTime.replace(/:\d{1,2}$/, ' ');
// });
_that.taskDetails = res.data.inspectionTaskDetails;
let _inspectionTaskDetails = res.data.inspectionTaskDetails;
_inspectionTaskDetails.forEach(function(_item){
if(_item.state == '20200407'){
_item.photos.forEach(function(_photoTmp) {
_photoTmp.url = _that.java110Constant.url.hcBaseUrl + _photoTmp.url;
});
}
})
_that.taskDetails = _inspectionTaskDetails;
}
});
},
ScrollSteps() {
this.scroll= this.scroll == 9 ? 0 : this.scroll + 1
},
_excuteInspection:function(_item){
console.log('巡检点',_item);
uni.navigateTo({
url:'/pages/excuteOneInspection/excuteOneInspection?taskDetailId='+_item.taskDetailId+"&taskId="+_item.taskId+"&inspectionId="+_item.inspectionId+"&inspectionName="+_item.inspectionName
});
},
preview: function(_src) {
this.viewImage = true;
this.viewImageSrc = _src;
},
closeViewImage: function() {
this.viewImage = false;
}
}
}

View File

@ -0,0 +1,219 @@
<template>
<view>
<view class="block__title">{{inspectionName}}巡检</view>
<form>
<view class="cu-form-group">
<view class="title">巡检情况</view>
<picker @change="patrolChange" :value="patrolIndex" :range="patrols">
<view class="picker">
{{patrolTypeName?patrolTypeName:'请选择'}}
</view>
</picker>
</view>
<view class="cu-form-group margin-top">
<textarea maxlength="-1" v-model="description" placeholder="请输入巡检说明"></textarea>
</view>
<view class="cu-bar bg-white margin-top">
<view class="action">
巡检图片
</view>
<view class="action">
{{imgList.length}}/4
</view>
</view>
<view class="cu-form-group">
<view class="grid col-4 grid-square flex-sub">
<view class="bg-img" v-for="(img,index) in imgList" :key= "index" bindtap="ViewImage" :data-url="imgList[index]">
<image :src='imgList[index]' mode='aspectFill'></image>
<view class="cu-tag bg-red" @tap="removePhoto(index)" :data-index="index">
<text class="cuIcon-close"></text>
</view>
</view>
<view class="solids" @tap="ChooseImage" v-if="imgList.length<4">
<text class="cuIcon-cameraadd"></text>
</view>
</view>
</view>
</form>
<view class="padding flex flex-direction">
<button class="cu-btn bg-green margin-tb-sm lg" @tap="_submitExcuteInspection()">提交</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
taskId:'',
taskDetailId:'',
inspectionId:'',
inspectionName:'',
patrols:['正常','异常'],
patrolTypes:['10001','20002'],
patrolType:'',
patrolTypeName:'请选择',
description:'',
photos:[],
imgList:[],
patrolIndex:0,
communityId:'',
userId:'',
userName:''
}
},
onLoad(option) {
this.taskDetailId = option.taskDetailId;
this.taskId = option.taskId;
this.inspectionId = option.inspectionId;
this.inspectionName = option.inspectionName;
this.communityId = this.java110Context.getCurrentCommunity().communityId;
let _userInfo = this.java110Context.getUserInfo();
this.userName = _userInfo.userName;
this.userId = _userInfo.userId;
},
methods: {
patrolChange:function(e){
this.patrolTypeName = this.patrols[e.detail.value];
this.patrolType = this.patrolTypes[e.detail.value];
},
removePhoto: function(e) {
console.log(e.detail.index);
let _imgList = [];
this.imgList.forEach(function(item, index) {
if (index != e.detail.index) {
_imgList.push(item);
}
});
let _photos = [];
this.photos.forEach(function(item, index) {
if (index != e.detail.index) {
_photos.push(item);
}
});
this.photos = _photos;
this.imgList = _imgList;
},
deleteImage: function(e) {
console.log(e);
let imageArr = this.$data.imgList;
imageArr.splice(e, 1);
},
ChooseImage: function(e) {
let that = this;
wx.chooseImage({
count: 4, //9
sizeType: ['original', 'compressed'], //
sourceType: ['album'], //
success: (res) => {
console.log(res);
that.$data.imgList.push(res.tempFilePaths[0]);
let _base64Photo = '';
that.java110Factory.base64.urlTobase64(res.tempFilePaths[0]).then(function(_res) {
_base64Photo = _res;
console.log('base64', _base64Photo);
that.photos.push(_base64Photo);
});
}
});
},
_submitExcuteInspection: function() {
/**
* taskId:'',
taskDetailId:'',
inspectionId:'',
inspectionName:'',
*/
let obj = {
"taskId": this.taskId,
"taskDetailId": this.taskDetailId,
"inspectionId": this.inspectionId,
"inspectionName": this.inspectionName,
"communityId": this.communityId,
"patrolType":this.patrolType,
"description":this.description,
"photos": [],
"userId": this.userId,
"userName": this.userName
}
let _photos = this.photos;
_photos.forEach(function(_item) {
obj.photos.push({
"photo": _item
});
});
let msg = "";
if (obj.taskId == "") {
msg = "数据异常,巡检任务为空";
} else if (obj.taskDetailId == "") {
msg = "数据异常,巡检任务详情为空";
} else if (obj.inspectionId == "") {
msg = "巡检点不能为空";
} else if (obj.inspectionName == "") {
msg = "巡检点名称不能为空";
} else if (obj.patrolType == "") {
msg = "巡检情况不能为空";
} else if (obj.description == "") {
msg = "巡检说明不能为空";
} else if (obj.userId == "") {
msg = "数据异常,巡检人为空";
}
console.log(obj);
if (msg != "") {
wx.showToast({
title: msg,
icon: 'none',
duration: 2000
});
} else {
this.java110Context.request({
url: this.java110Constant.url.updateInspectionTaskDetail, // http://hc.demo.winqi.cn:8012/appApi/ownerRepair.saveOwnerRepair
header: this.java110Context.getHeaders(),
method: "POST",
data: obj, //
success: function(res) {
if (res.statusCode == 200) {
uni.navigateBack({
delta:1
})
return;
}
wx.showToast({
title: "服务器异常了",
icon: 'none',
duration: 2000
})
},
fail: function(e) {
wx.showToast({
title: "服务器异常了",
icon: 'none',
duration: 2000
})
}
});
}
},
}
}
</script>
<style>
.block__title {
margin: 0;
font-weight: 400;
font-size: 14px;
color: rgba(69,90,100,.6);
padding: 40rpx 30rpx 20rpx;
}
</style>

View File

@ -27,7 +27,8 @@
<view class="cu-bar bg-white solid-bottom margin-top">
<view class="action">
小区文化
<view class="bock-icon "></view>
<text class="margin-left-xs">小区文化</text>
</view>
<view class="action" @tap="_moreActivity()">
<text class="lg text-gray cuIcon-more"></text>
@ -54,6 +55,9 @@
</block>
</view>
</scroll-view>
<view class="flex justify-center tec-height align-center">
<text class="text-gray">java110团队提供技术支持,交流群827669685</text>
</view>
</view>
</template>
@ -347,4 +351,15 @@
.notice-startTime {
margin-left: 16upx;
}
.bock-icon{
height: 34upx;
width: 14upx;
line-height: 100upx;
background-color: #00AA00;
}
.tec-height{
height: 120upx;
}
</style>

View File

@ -70,7 +70,7 @@
page: 1,
row: 10,
planUserId: _that.userId,
state: '20200405'
},
success: function(res) {
// TODO