mirror of
https://gitee.com/java110/PropertyApp.git
synced 2026-02-23 21:36:39 +08:00
优化代码
This commit is contained in:
parent
40344013b3
commit
81f6c9f620
@ -1,44 +1,60 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
|
|
||||||
<view class="block__title">上期抄表</view>
|
<view class="block__title">上期抄表</view>
|
||||||
<view class="cu-form-group">
|
<view class="cu-form-group">
|
||||||
<view class="title">上期度数</view>
|
<view class="title">房屋</view>
|
||||||
<input placeholder="上期度数" v-model="preDegrees" ></input>
|
<input placeholder="房屋" v-model="roomNum" disabled="true"></input>
|
||||||
</view>
|
</view>
|
||||||
<view class="cu-form-group">
|
<view class="cu-form-group">
|
||||||
<view class="title">抄表时间</view>
|
<view class="title">上期度数</view>
|
||||||
<uni-datetime-picker v-model="preReadingTime" :disabled="true"></uni-datetime-picker>
|
<input placeholder="上期度数" v-model="preDegrees"></input>
|
||||||
</view>
|
</view>
|
||||||
<view class="block__title">本期抄表</view>
|
<view class="cu-form-group">
|
||||||
<view class="cu-form-group">
|
<view class="title">抄表时间</view>
|
||||||
<view class="title">本期度数</view>
|
<uni-datetime-picker v-model="preReadingTime" :disabled="true"></uni-datetime-picker>
|
||||||
<input placeholder="本期度数" v-model="curDegrees"></input>
|
</view>
|
||||||
</view>
|
<view class="block__title">本期抄表</view>
|
||||||
<view class="cu-form-group">
|
<view class="cu-form-group">
|
||||||
<view class="title">抄表时间</view>
|
<view class="title">本期度数</view>
|
||||||
<uni-datetime-picker v-model="curReadingTime"></uni-datetime-picker>
|
<input placeholder="本期度数" v-model="curDegrees"></input>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="cu-form-group">
|
||||||
<view class="cu-form-group align-start">
|
<view class="title">抄表时间</view>
|
||||||
<view class="title">备注</view>
|
<uni-datetime-picker v-model="curReadingTime"></uni-datetime-picker>
|
||||||
<textarea maxlength="-1" v-model="remark" placeholder="备注信息"></textarea>
|
</view>
|
||||||
</view>
|
|
||||||
|
<view class="cu-form-group align-start">
|
||||||
<view class=" flex flex-direction">
|
<view class="title">备注</view>
|
||||||
<button class="cu-btn bg-red margin-tb-sm lg" @tap="$preventClick(submitMeter)">提交</button>
|
<textarea maxlength="-1" v-model="remark" placeholder="备注信息"></textarea>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view class=" flex flex-direction">
|
||||||
|
<button class="cu-btn bg-red margin-tb-sm lg" @tap="$preventClick(submitMeter)">提交</button>
|
||||||
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {queryFeeTypesItems,queryPreMeterWater,saveMeterWater,listMeterType} from '../../api/meter/meter.js'
|
import {
|
||||||
|
queryFeeTypesItems,
|
||||||
|
queryPreMeterWater,
|
||||||
|
saveMeterWater,
|
||||||
|
listMeterType
|
||||||
|
} from '../../api/meter/meter.js'
|
||||||
import dateObj from '../../lib/java110/utils/date.js'
|
import dateObj from '../../lib/java110/utils/date.js'
|
||||||
import uniDatetimePicker from '../../components/uni-datetime-picker/uni-datetime-picker.vue'
|
import uniDatetimePicker from '../../components/uni-datetime-picker/uni-datetime-picker.vue'
|
||||||
import {getCurrentCommunity} from '../../api/community/community.js'
|
import {
|
||||||
|
getCurrentCommunity
|
||||||
|
} from '../../api/community/community.js'
|
||||||
// 防止多次点击
|
// 防止多次点击
|
||||||
import {preventClick} from '../../lib/java110/utils/common.js';
|
import {
|
||||||
|
preventClick
|
||||||
|
} from '../../lib/java110/utils/common.js';
|
||||||
|
import {
|
||||||
|
loadRooms
|
||||||
|
} from '../../api/room/room.js';
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
Vue.prototype.$preventClick = preventClick;
|
Vue.prototype.$preventClick = preventClick;
|
||||||
export default {
|
export default {
|
||||||
@ -49,17 +65,17 @@
|
|||||||
communityId: '',
|
communityId: '',
|
||||||
objType: '3333',
|
objType: '3333',
|
||||||
preDegrees: 0,
|
preDegrees: 0,
|
||||||
preReadingTime: null,
|
preReadingTime: null,
|
||||||
curDegrees: '',
|
curDegrees: '',
|
||||||
curReadingTime: null,
|
curReadingTime: null,
|
||||||
remark: '',
|
remark: '',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
components:{
|
components: {
|
||||||
uniDatetimePicker
|
uniDatetimePicker
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad(options){
|
onLoad(options) {
|
||||||
this.configId = options.configId;
|
this.configId = options.configId;
|
||||||
this.meterType = options.meterType;
|
this.meterType = options.meterType;
|
||||||
this.roomId = options.roomId;
|
this.roomId = options.roomId;
|
||||||
@ -67,58 +83,80 @@
|
|||||||
this.java110Context.onLoad();
|
this.java110Context.onLoad();
|
||||||
this.preReadingTime = dateObj.getCurrentDateTime();
|
this.preReadingTime = dateObj.getCurrentDateTime();
|
||||||
this.curReadingTime = dateObj.getCurrentDateTime();
|
this.curReadingTime = dateObj.getCurrentDateTime();
|
||||||
|
|
||||||
this._queryPreMeterWater();
|
this._queryPreMeterWater();
|
||||||
|
this._loadRoom();
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
|
_loadRoom: function() {
|
||||||
|
let _that = this;
|
||||||
|
loadRooms(this, {
|
||||||
|
page: 1,
|
||||||
|
row: 1,
|
||||||
|
roomId: this.roomId,
|
||||||
|
communityId: this.communityId
|
||||||
|
}).then(_data => {
|
||||||
|
console.log(_data)
|
||||||
|
|
||||||
|
_that.roomNum = _data.data.rooms[0].roomName;
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
// 查询上期缴费信息
|
// 查询上期缴费信息
|
||||||
_queryPreMeterWater(){
|
_queryPreMeterWater() {
|
||||||
let _objData = {
|
let _objData = {
|
||||||
communityId: this.communityId,
|
communityId: this.communityId,
|
||||||
objId: this.roomId,
|
objId: this.roomId,
|
||||||
objType: this.objType,
|
objType: this.objType,
|
||||||
meterType: this.meterType,
|
meterType: this.meterType,
|
||||||
};
|
};
|
||||||
queryPreMeterWater(this,_objData)
|
queryPreMeterWater(this, _objData)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
if(res.total < 1){
|
if (res.total < 1) {
|
||||||
this.preDegrees = 0;
|
this.preDegrees = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.preDegrees = res.data[0].curDegrees;
|
this.preDegrees = res.data[0].curDegrees;
|
||||||
this.preReadingTime = res.data[0].curReadingTime;
|
this.preReadingTime = res.data[0].curReadingTime;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
submitMeter(){
|
submitMeter() {
|
||||||
|
if (!this.java110Context.hasPrivilege('502021012558990030')) {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: '无权限,联系管理员'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
let msg = '';
|
let msg = '';
|
||||||
if(this.roomId == ''){
|
if (this.roomId == '') {
|
||||||
msg = "请选择房屋";
|
msg = "请选择房屋";
|
||||||
}else if(this.preDegrees === '' || this.preDegrees < 0){
|
} else if (this.preDegrees === '' || this.preDegrees < 0) {
|
||||||
msg = "上期度数必填";
|
msg = "上期度数必填";
|
||||||
}else if(this.preReadingTime == '' || this.preReadingTime == null){
|
} else if (this.preReadingTime == '' || this.preReadingTime == null) {
|
||||||
msg = "上期读表时间必填";
|
msg = "上期读表时间必填";
|
||||||
}else if(this.curDegrees === '' || this.curDegrees < 0){
|
} else if (this.curDegrees === '' || this.curDegrees < 0) {
|
||||||
msg = "本期度数必填";
|
msg = "本期度数必填";
|
||||||
}else if(this.curReadingTime == '' || this.curReadingTime == null){
|
} else if (this.curReadingTime == '' || this.curReadingTime == null) {
|
||||||
msg = "本期读表时间必填";
|
msg = "本期读表时间必填";
|
||||||
}else if(parseFloat(this.curDegrees) < parseFloat(this.preDegrees)){
|
} else if (parseFloat(this.curDegrees) < parseFloat(this.preDegrees)) {
|
||||||
msg = "本期度数不能小于上期度数";
|
msg = "本期度数不能小于上期度数";
|
||||||
}else{
|
} else {
|
||||||
let start = Date.parse(new Date(this.preReadingTime.replace(/-/g, '/')))
|
let start = Date.parse(new Date(this.preReadingTime.replace(/-/g, '/')))
|
||||||
let end = Date.parse(new Date(this.curReadingTime.replace(/-/g, '/')))
|
let end = Date.parse(new Date(this.curReadingTime.replace(/-/g, '/')))
|
||||||
if (end == 0 || start - end > 0) {
|
if (end == 0 || start - end > 0) {
|
||||||
msg = "本期读表时间有误";
|
msg = "本期读表时间有误";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(msg != ''){
|
if (msg != '') {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title:msg,
|
title: msg,
|
||||||
icon:'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
this.onoff = true;
|
this.onoff = true;
|
||||||
return;
|
return;
|
||||||
@ -136,27 +174,27 @@
|
|||||||
remark: this.remark,
|
remark: this.remark,
|
||||||
meterType: this.meterType
|
meterType: this.meterType
|
||||||
};
|
};
|
||||||
saveMeterWater(this,_objData)
|
saveMeterWater(this, _objData)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.msg,
|
title: res.msg,
|
||||||
duration: 1500
|
duration: 1500
|
||||||
})
|
})
|
||||||
if(res.code == 0){
|
if (res.code == 0) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
this.onoff = true;
|
||||||
|
this.clearAddMeterWaterInfo();
|
||||||
|
}, 1500)
|
||||||
|
} else {
|
||||||
this.onoff = true;
|
this.onoff = true;
|
||||||
this.clearAddMeterWaterInfo();
|
}
|
||||||
}, 1500)
|
})
|
||||||
}else{
|
|
||||||
this.onoff = true;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 清空页面数据
|
// 清空页面数据
|
||||||
clearAddMeterWaterInfo(){
|
clearAddMeterWaterInfo() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url:'/pages/meter/meterReading'
|
url: '/pages/meter/meterReading'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -167,7 +205,7 @@
|
|||||||
.cu-form-group .title {
|
.cu-form-group .title {
|
||||||
min-width: calc(6em + 15px);
|
min-width: calc(6em + 15px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.block__title {
|
.block__title {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
@ -175,12 +213,12 @@
|
|||||||
color: rgba(69, 90, 100, .6);
|
color: rgba(69, 90, 100, .6);
|
||||||
padding: 40rpx 30rpx 20rpx;
|
padding: 40rpx 30rpx 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button_up_blank {
|
.button_up_blank {
|
||||||
height: 40rpx;
|
height: 40rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.block__bottom {
|
.block__bottom {
|
||||||
height: 180rpx;
|
height: 180rpx;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
Loading…
Reference in New Issue
Block a user