Browse Source

(*)登录页顶部图片文字修改+开始巡检提交结构暂交

master
Archer_cdm 2 years ago
parent
commit
5af44cea21
  1. 1
      weapp/package/polling/polling.js
  2. 130
      weapp/package/startInspection/startInspection.js
  3. 14
      weapp/package/startInspection/startInspection.wxml
  4. 5
      weapp/pages/login/login.wxml
  5. 10
      weapp/utils/getApiUrl.js

1
weapp/package/polling/polling.js

@ -3,7 +3,6 @@ import { getPatrolPlan } from "../../utils/getApiUrl";
import { Request } from "../../common"; import { Request } from "../../common";
const moment = require("../../utils/moment"); const moment = require("../../utils/moment");
Page({ Page({
/** /**

130
weapp/package/startInspection/startInspection.js

@ -1,4 +1,8 @@
// package/startInspection/startInspection.js // package/startInspection/startInspection.js
import { addPatrolRecord, getPatrolRecord } from "../../utils/getApiUrl";
import { Request } from "../../common";
const moment = require("../../utils/moment");
Page({ Page({
/** /**
@ -7,12 +11,25 @@ Page({
data: { data: {
dataList: '', dataList: '',
imgs: [], //上传图片 imgs: [], //上传图片
imgUrl: getApp().globalData.imgUrl,
msgInp: '', //巡查详情
itemData: '', //单条数据
changeTwo: '', //是否异常
changeThree: '', //严重等级
}, },
handleChangeTwo(e) { handleChangeTwo(e) {
this.setData({ this.setData({
changeTwo: e.detail.value changeTwo: e.detail.value
}) })
if (e.detail.value == 'normal') {
this.setData({
msgInp: '', //巡查详情
changeThree: '', //严重等级
imgs: []
})
return;
}
}, },
handleChangeThree(e) { handleChangeThree(e) {
@ -21,15 +38,21 @@ Page({
}) })
}, },
showModal() { showModal(e) {
this.setData({ this.setData({
showModal: true showModal: true,
itemData: e.currentTarget.dataset.itemdata
}) })
}, },
bindCancel() { bindCancel() {
this.setData({ this.setData({
showModal: false showModal: false,
itemData: '',
msgInp: '', //巡查详情
changeTwo: '', //是否异常
changeThree: '', //严重等级
imgs: []
}) })
}, },
@ -39,7 +62,10 @@ Page({
var pics = []; var pics = [];
var detailPics = that.data.imgs; var detailPics = that.data.imgs;
if (detailPics.length >= 20) { if (detailPics.length >= 20) {
commonJs.showToast('最多选择20张图片上传'); wx.showToast({
title: '最多选择20张图片上传',
icon: 'none'
});
return; return;
} }
wx.chooseMedia({ wx.chooseMedia({
@ -48,14 +74,13 @@ Page({
sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有 sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有
sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有 sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有
success: function (res) { success: function (res) {
console.log(res);
var imgs = res.tempFiles; var imgs = res.tempFiles;
for (var i = 0; i < imgs.length; i++) { for (var i = 0; i < imgs.length; i++) {
if (res.tempFiles[i].size > 15728640) { if (res.tempFiles[i].size > 15728640) {
commonJs.showToast('图片大于15M,不可上传'); commonJs.showToast('图片大于15M,不可上传');
return; return;
} }
pics.push(imgs[i]) pics.push(imgs[i].tempFilePath)
} }
that.uploadimg({ that.uploadimg({
url: getApp().globalData.webUrl + '_upload/attachments/project', //这里是你图片上传的接口 url: getApp().globalData.webUrl + '_upload/attachments/project', //这里是你图片上传的接口
@ -82,7 +107,8 @@ Page({
success: (resp) => { success: (resp) => {
wx.hideLoading(); wx.hideLoading();
success++; success++;
var str = resp.data //返回的结果,可能不同项目结果不一样 var str = JSON.parse(resp.data) //返回的结果,可能不同项目结果不一样
str = str.uploaded
console.log(str); console.log(str);
if (imgs.length >= 20) { if (imgs.length >= 20) {
that.setData({ that.setData({
@ -90,7 +116,7 @@ Page({
}); });
return false; return false;
} else { } else {
imgs.push(str); imgs.push(that.data.imgUrl + str);
that.setData({ that.setData({
imgs: imgs imgs: imgs
}) })
@ -138,6 +164,93 @@ Page({
}) })
}, },
// 巡查详情
bindInput: function (e) {
this.setData({
msgInp: e.detail.value
})
},
// 开始巡检录入
addPatrolRecord: function () {
let that = this;
let { itemData, imgs, msgInp, changeTwo, changeThree, dataList, imgUrl } = that.data;
let newImgs = imgs.map(i => {
i = i.replace(imgUrl, '');
return i;
})
if (changeTwo == 'abnormal') {
if (msgInp == '') {
wx.showToast({
title: '请填写巡查详情',
icon: 'none'
})
return;
}
if (changeThree == '') {
wx.showToast({
title: '请选择严重等级',
icon: 'none'
})
return;
}
let data = {
patrolPlanId: dataList.id,
lastInspectionTime: moment().format('YYYY-MM-DD'),
inspectionTime: moment().format('YYYY-MM-DD'),
points: {
user: dataList.user,
project: dataList.project,
frequency: dataList.frequency,
itemData: itemData,
msgInp: msgInp,
changeThree: changeThree == 'slight' ? '轻微' : changeThree == 'moderate' ? '中度' : '严重',
imgs: newImgs,
},
alarm: true
}
Request.post(addPatrolRecord(), data).then(res => {
wx.showToast({
title: '提交成功',
})
that.bindCancel();
})
} else {
if (changeTwo == 'normal') {
let data = {
patrolPlanId: dataList.id,
lastInspectionTime: moment().format('YYYY-MM-DD'),
inspectionTime: moment().format('YYYY-MM-DD'),
points: {
user: dataList.user,
project: dataList.project,
frequency: dataList.frequency,
itemData: itemData,
},
alarm: false
}
Request.post(addPatrolRecord(), data).then(res => {
wx.showToast({
title: '提交成功',
})
that.bindCancel();
})
return;
}
wx.showToast({
title: '提交信息不全,请检查',
icon: 'none'
})
}
},
// 获取巡检记录
getPatrolRecord: function () {
Request.get(getPatrolRecord(this.data.dataList.id)).then(res => {
console.log(res);
})
},
// selfLocation() { // selfLocation() {
// const self = this // const self = this
// wx.showLoading({ // wx.showLoading({
@ -199,6 +312,7 @@ Page({
dataList: data, dataList: data,
points points
}) })
// that.getPatrolRecord()
}, },
/** /**

14
weapp/package/startInspection/startInspection.wxml

@ -3,7 +3,7 @@
<view class="titleFirst">巡检要求</view> <view class="titleFirst">巡检要求</view>
<view class="txt"> <view class="txt">
<view style="float: left;font-weight: bold;">结构物名称</view> <view style="float: left;font-weight: bold;">结构物名称</view>
<view style="float:left;width:70%;margin-left:40rpx;">{{dataList.name}}</view> <view style="float:left;width:70%;margin-left:40rpx;">{{dataList.project.name}}</view>
</view> </view>
<view class="txt"> <view class="txt">
<view style="float: left;font-weight: bold;">开始时间</view> <view style="float: left;font-weight: bold;">开始时间</view>
@ -40,7 +40,7 @@
<view class="txt" style="margin-bottom: 20rpx;"> <view class="txt" style="margin-bottom: 20rpx;">
<view style="float: left;font-weight: bold;">巡检点位</view> <view style="float: left;font-weight: bold;">巡检点位</view>
<view style="float:left;width:55%;margin-left:40rpx;">{{item.name}}</view> <view style="float:left;width:55%;margin-left:40rpx;">{{item.name}}</view>
<view class="startBtn" bindtap="showModal">开始巡检</view> <view class="startBtn" data-itemData="{{item}}" bindtap="showModal">开始巡检</view>
</view> </view>
<view class="txt" style="margin-bottom: 20rpx;"> <view class="txt" style="margin-bottom: 20rpx;">
<view style="float: left;font-weight: bold;">上次巡检日期</view> <view style="float: left;font-weight: bold;">上次巡检日期</view>
@ -62,24 +62,24 @@
<view class="popBox"> <view class="popBox">
<view style="padding:20rpx 30rpx;overflow: hidden;"> <view style="padding:20rpx 30rpx;overflow: hidden;">
<view style="float: left;">当前点位:</view> <view style="float: left;">当前点位:</view>
<view style="float:left;width: 75%;">点位A</view> <view style="float:left;width:480rpx;text-align: justify;">{{itemData.name}}</view>
</view> </view>
<view style="padding:20rpx 30rpx;overflow: hidden;"> <view style="padding:20rpx 30rpx;overflow: hidden;">
<view style="float: left;">当前位置:</view> <view style="float: left;">当前位置:</view>
<view style="float:left;width: 75%;">点位A</view> <view style="float:left;width:480rpx;text-align: justify;">点位A</view>
</view> </view>
<radio-group style="padding:10px 15px;display:flex;justify-content: space-evenly;" bindchange="handleChangeTwo"> <radio-group style="padding:10px 15px;display:flex;justify-content: space-evenly;" bindchange="handleChangeTwo">
<radio style="color:#1979ff;" color="#1979ff" value="normal">正常</radio> <radio style="color:#1979ff;" color="#1979ff" value="normal">正常</radio>
<radio style="color:#CC0000;" color="#CC0000" value="abnormal">异常</radio> <radio style="color:#CC0000;" color="#CC0000" value="abnormal">异常</radio>
</radio-group> </radio-group>
<textarea style="width: 84%;margin:0 auto;border:2rpx solid #ccc;padding:20rpx;height: 120rpx;border-radius: 10rpx;" placeholder="请输入巡查详情" maxlength="-1" wx:if="{{changeTwo == 'abnormal'}}"></textarea> <textarea style="width: 84%;margin:0 auto;border:2rpx solid #ccc;padding:20rpx;height: 120rpx;border-radius: 10rpx;" placeholder="请输入巡查详情" maxlength="-1" wx:if="{{changeTwo == 'abnormal'}}" bindinput="bindInput"></textarea>
<radio-group style="padding:10px 15px;display:flex;justify-content: space-evenly;" bindchange="handleChangeThree" wx:if="{{changeTwo == 'abnormal'}}"> <radio-group style="padding:10px 15px;display:flex;justify-content: space-evenly;" bindchange="handleChangeThree" wx:if="{{changeTwo == 'abnormal'}}">
<radio style="color:#FF9900;" color="#FF9900" value="slight">轻微</radio> <radio style="color:#FF9900;" color="#FF9900" value="slight">轻微</radio>
<radio style="color:#FF3300;" color="#FF3300" value="moderate">中度</radio> <radio style="color:#FF3300;" color="#FF3300" value="moderate">中度</radio>
<radio style="color:#990000;" color="#990000" value="severity">严重</radio> <radio style="color:#990000;" color="#990000" value="severity">严重</radio>
</radio-group> </radio-group>
<view class="weui-uploader"> <view class="weui-uploader" style="padding: 20rpx 30rpx;height:350rpx;overflow-y:scroll;" wx:if="{{changeTwo == 'abnormal'}}">
<view class="img-v weui-uploader__bd" style="overflow:hidden;"> <view class="img-v weui-uploader__bd" style="overflow:hidden;">
<view class='pic' wx:for="{{imgs}}" wx:for-item="item" wx:key="*this"> <view class='pic' wx:for="{{imgs}}" wx:for-item="item" wx:key="*this">
<image class='weui-uploader__img showImg' src="{{item}}" data-index="{{index}}" mode="aspectFill" bindtap="previewImg"> <image class='weui-uploader__img showImg' src="{{item}}" data-index="{{index}}" mode="aspectFill" bindtap="previewImg">
@ -95,7 +95,7 @@
<view class="btnBox"> <view class="btnBox">
<view class="cancel" bindtap="bindCancel">取消</view> <view class="cancel" bindtap="bindCancel">取消</view>
<view class="submit">提交</view> <view class="submit" bindtap="addPatrolRecord">提交</view>
</view> </view>
</view> </view>
</view> </view>

5
weapp/pages/login/login.wxml

@ -1,6 +1,9 @@
<!--pages/login/login.wxml--> <!--pages/login/login.wxml-->
<view class='logo-container'> <view class='logo-container'>
<image class='logo' src='/images/logo.png' /> <image class='logo' src='/images/logo.png'>
<view style="font-size:32rpx;color:#2675F5;position:absolute;top:180rpx;left:48rpx;">您好,欢迎使用</view>
<view style="font-size:40rpx;color:#2675F5;position:absolute;top:244rpx;left:48rpx;font-weight:bold;">运维巡检平台~</view>
</image>
</view> </view>
<view class="body-container" wx:if='{{!isAutoLogin}}'> <view class="body-container" wx:if='{{!isAutoLogin}}'>

10
weapp/utils/getApiUrl.js

@ -17,3 +17,13 @@ exports.getProjectList = () => {
exports.getPatrolPlan = () => { exports.getPatrolPlan = () => {
return `/patrolPlan` return `/patrolPlan`
} }
// 开始巡检录入
exports.addPatrolRecord = () => {
return `/patrolRecord/add`
}
// 获取巡检记录
exports.getPatrolRecord = (patrolPlanId, startTime, endTime, alarm) => {
return `/patrolRecord/${patrolPlanId}/${startTime}/${endTime}/${alarm}`
}
Loading…
Cancel
Save