准备联调抄表记录
This commit is contained in:
@@ -1,18 +1,26 @@
|
||||
// pages/writeReading/components/readingInfo/index.js
|
||||
|
||||
import { createReading } from "../../../../service/workBench"
|
||||
import { alertError, alertInfo, alertSuccess } from "../../../../utils/index"
|
||||
import request from "../../../../utils/request"
|
||||
const { OK } = request
|
||||
|
||||
Component({
|
||||
|
||||
/**
|
||||
* 组件的属性列表
|
||||
*/
|
||||
properties: {
|
||||
|
||||
meterInfo: Object,
|
||||
showLeft: Boolean,
|
||||
showRight: Boolean,
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
currentNumber: null
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -20,9 +28,79 @@ Component({
|
||||
*/
|
||||
methods: {
|
||||
jumpToHistory() {
|
||||
const { meterInfo } = this.data;
|
||||
wx.navigateTo({
|
||||
url: '/pages/readingHistory/index',
|
||||
url: `/pages/readingHistory/index?meter=${meterInfo?.id}&park=${meterInfo?.park}`,
|
||||
})
|
||||
},
|
||||
handlePrev() {
|
||||
this.triggerEvent("prev")
|
||||
},
|
||||
handleNext() {
|
||||
this.triggerEvent("next")
|
||||
},
|
||||
onChange(e) {
|
||||
this.setData({
|
||||
currentNumber: e.detail ? Number(e.detail) : 0
|
||||
})
|
||||
},
|
||||
handleClear() {
|
||||
this.setData({
|
||||
currentNumber: null,
|
||||
})
|
||||
},
|
||||
async onSubmit() {
|
||||
const { meterInfo, currentNumber } = this.data;
|
||||
const { parkId, id } = meterInfo;
|
||||
const { code, message } = await createReading(parkId, id, {
|
||||
overall: `${currentNumber}`,
|
||||
flat: `${currentNumber}`
|
||||
})
|
||||
if (code !== OK) {
|
||||
alertError(message)
|
||||
return
|
||||
}
|
||||
alertSuccess("录入成功")
|
||||
this.handleNext()
|
||||
this.handleClear()
|
||||
},
|
||||
handleCreateReading() {
|
||||
const { meterInfo, currentNumber } = this.data;
|
||||
if (currentNumber == null || currentNumber == undefined) {
|
||||
alertInfo("请填写本次表字后保存")
|
||||
return;
|
||||
}
|
||||
const that = this;
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要录入吗?',
|
||||
complete: (res) => {
|
||||
if (res.cancel) {
|
||||
|
||||
}
|
||||
|
||||
if (res.confirm) {
|
||||
if (meterInfo.consumption < currentNumber) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '本次用电量已抄过历史平均水平的100%,是否确认录入?',
|
||||
complete: (res) => {
|
||||
if (res.cancel) {
|
||||
|
||||
}
|
||||
|
||||
if (res.confirm) {
|
||||
that.onSubmit()
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
that.onSubmit()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -3,8 +3,8 @@
|
||||
"usingComponents": {
|
||||
"van-button": "@vant/weapp/button/index",
|
||||
"van-divider": "@vant/weapp/divider/index",
|
||||
"custom-input": "/components/input/index",
|
||||
"van-icon": "@vant/weapp/icon/index",
|
||||
"photo": "../photo/index"
|
||||
"photo": "../photo/index",
|
||||
"van-field": "@vant/weapp/field/index"
|
||||
}
|
||||
}
|
||||
@@ -16,12 +16,20 @@
|
||||
当前电表
|
||||
</view>
|
||||
<view class="address">
|
||||
标1东-307
|
||||
{{meterInfo.address}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="change">
|
||||
<van-button type="info" size="small"> <van-icon name="arrow-left" /> 上一块</van-button>
|
||||
<van-button type="info" size="small" >下一块 <van-icon name="arrow" /> </van-button>
|
||||
<van-button wx:if="{{showLeft}}" type="info" size="small" bind:click="handlePrev">
|
||||
<van-icon name="arrow-left" />
|
||||
上一块
|
||||
</van-button>
|
||||
<view wx:else></view>
|
||||
<van-button wx:if="{{showRight}}" type="info" size="small" bind:click="handleNext">
|
||||
下一块
|
||||
<van-icon name="arrow" />
|
||||
</van-button>
|
||||
<view wx:else></view>
|
||||
</view>
|
||||
<van-divider />
|
||||
<view class="readingNumber">
|
||||
@@ -30,11 +38,11 @@
|
||||
上次表字
|
||||
</view>
|
||||
<view class="number">
|
||||
3318
|
||||
{{meterInfo.overall}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="lastTime">
|
||||
2025年08月12日
|
||||
{{meterInfo.readAt}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="nextReadingNumber">
|
||||
@@ -42,8 +50,15 @@
|
||||
<view class="title">
|
||||
本次表字
|
||||
</view>
|
||||
|
||||
<view class="number">
|
||||
<custom-input />
|
||||
<van-field
|
||||
value="{{currentNumber}}"
|
||||
placeholder="请输入本次读数"
|
||||
bind:change="onChange"
|
||||
border="{{false}}"
|
||||
custom-style="border: 1rpx solid #ccc; padding: 2px 14rpx; font-size: 32rpx; border-radius: 10rpx;"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="photo">
|
||||
@@ -54,19 +69,19 @@
|
||||
<view class="title">
|
||||
表字差
|
||||
</view>
|
||||
<view class="rightNumber">
|
||||
0
|
||||
<view class="rightNumber" wx:if="{{currentNumber - meterInfo.overall >= 0}}">
|
||||
{{(currentNumber || 0) - meterInfo.overall}}
|
||||
</view>
|
||||
<view class="wrongNumber">
|
||||
0
|
||||
<view class="wrongNumber" wx:else>
|
||||
{{(currentNumber || 0) - meterInfo.overall}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="operate">
|
||||
<view style="flex: 1;">
|
||||
<van-button size="small" type="info" block> 确定录入 </van-button>
|
||||
<van-button size="small" type="info" block bind:click="handleCreateReading"> 确定录入 </van-button>
|
||||
</view>
|
||||
<view style="flex: 1; margin-left: 20rpx;">
|
||||
<van-button size="small" block> 清除记录 </van-button>
|
||||
<van-button size="small" block bind:click="handleClear"> 清除记录 </van-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user