修改样式,修改不能输入负数的问题
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// pages/writeReading/components/readingInfo/index.js
|
||||
|
||||
import { createReading } from "../../../../service/workBench"
|
||||
import { alertError, alertInfo, alertSuccess } from "../../../../utils/index"
|
||||
import { createReading, checkReadingFinish, changeMeterRouteStatus } from "../../../../service/workBench"
|
||||
import { alertError, alertInfo, alertSuccess, wxModal } from "../../../../utils/index"
|
||||
import request from "../../../../utils/request"
|
||||
const { OK } = request
|
||||
|
||||
@@ -14,25 +14,33 @@ Component({
|
||||
meterInfo: Object,
|
||||
showLeft: Boolean,
|
||||
showRight: Boolean,
|
||||
routeId: String
|
||||
},
|
||||
observers: {
|
||||
"routeId": function(newValue) {
|
||||
if (!newValue) {
|
||||
return;
|
||||
}
|
||||
console.log("newValue", newValue)
|
||||
this.checkFinish(newValue)
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
currentNumber: null
|
||||
},
|
||||
|
||||
lifetimes: {
|
||||
attached() {
|
||||
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
jumpToHistory() {
|
||||
const { meterInfo } = this.data;
|
||||
wx.navigateTo({
|
||||
url: `/pages/readingHistory/index?meter=${meterInfo?.id}&park=${meterInfo?.parkId}`,
|
||||
})
|
||||
},
|
||||
|
||||
handlePrev() {
|
||||
this.triggerEvent("prev")
|
||||
},
|
||||
@@ -41,7 +49,8 @@ Component({
|
||||
},
|
||||
onChange(e) {
|
||||
this.setData({
|
||||
currentNumber: e.detail ? Number(e.detail) : 0
|
||||
currentNumber: e.detail,
|
||||
calcNumber: isNaN(e.detail) ? 0 : Number(e.detail)
|
||||
})
|
||||
},
|
||||
handleClear() {
|
||||
@@ -49,6 +58,28 @@ Component({
|
||||
currentNumber: null,
|
||||
})
|
||||
},
|
||||
async changeEndStatus() {
|
||||
const { routeId: id } = this.data;
|
||||
const { code, message } = await changeMeterRouteStatus({ id, status: 0 })
|
||||
if (code !== OK) {
|
||||
alertError(message)
|
||||
return
|
||||
}
|
||||
alertSuccess("操作成功")
|
||||
this.init()
|
||||
},
|
||||
onPhotoFinish(e) {
|
||||
const { number, success } = e.detail;
|
||||
if (success) {
|
||||
this.setData({
|
||||
currentNumber: `${Number(number)}`,
|
||||
calcNumber: isNaN(number) ? 0 : Number(number)
|
||||
})
|
||||
alertSuccess("获取成功")
|
||||
} else {
|
||||
alertInfo("未能获取到")
|
||||
}
|
||||
},
|
||||
async onSubmit() {
|
||||
const { meterInfo, currentNumber } = this.data;
|
||||
const { parkId, id } = meterInfo;
|
||||
@@ -61,8 +92,39 @@ Component({
|
||||
return
|
||||
}
|
||||
alertSuccess("录入成功")
|
||||
this.handleNext()
|
||||
this.handleClear()
|
||||
const that = this;
|
||||
setTimeout(() => {
|
||||
const isFinished = that.checkFinish()
|
||||
if (isFinished) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '所有电表都已抄完,是否结束抄表?',
|
||||
complete: async (res) => {
|
||||
if (res.cancel) {
|
||||
|
||||
}
|
||||
|
||||
if (res.confirm) {
|
||||
await that.changeEndStatus()
|
||||
wx.navigateBack()
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
that.handleNext()
|
||||
that.handleClear()
|
||||
}
|
||||
}, 300)
|
||||
|
||||
},
|
||||
async checkFinish(id) {
|
||||
const { code, message, data, num } = await checkReadingFinish(id || this.data.routeId);
|
||||
if (code !== OK) {
|
||||
alertError(message)
|
||||
return;
|
||||
}
|
||||
this.triggerEvent("finishNumber", num)
|
||||
return data;
|
||||
},
|
||||
handleCreateReading() {
|
||||
const { meterInfo, currentNumber } = this.data;
|
||||
@@ -80,7 +142,7 @@ Component({
|
||||
}
|
||||
|
||||
if (res.confirm) {
|
||||
if (meterInfo.consumption < currentNumber) {
|
||||
if (meterInfo.consumption < currentNumber - meterInfo.overall) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '本次用电量已抄过历史平均水平的100%,是否确认录入?',
|
||||
|
Reference in New Issue
Block a user