抄表记录提交

This commit is contained in:
2025-09-17 16:48:57 +08:00
parent 4308096394
commit 95e6937d06
7 changed files with 94 additions and 24 deletions

View File

@@ -1,6 +1,6 @@
// pages/workBench/components/tenement/components/bindMeter/index.js
// 0015980101
import { createReading } from "../../../../service/workBench"
import { createReading, updateReading } from "../../../../service/workBench"
import { getWorkMeterDetail } from "../../../../service/meter"
import { alertInfo, alertSuccess } from "../../../../utils/index";
import request from "../../../../utils/request"
@@ -16,14 +16,16 @@ Component({
title: String,
timeProps: String,
numberProps: String,
id: String,
idProps: String,
meter: String,
park: String
},
observers: {
"timeProps": function(newValue) {
// console.log("newValue", newValue)
this.setData({
time: newValue
time: newValue,
// startTime: newValue
})
},
"numberProps": function(newValue) {
@@ -31,6 +33,9 @@ Component({
number: newValue
})
},
"idProps": function(newValue) {
console.log("new id", newValue)
}
},
/**
* 组件的初始数据
@@ -65,12 +70,12 @@ Component({
})
},
async onSubmit() {
const { time, number, id, park, meter } = this.data;
const { time, number, idProps, park, meter, timeProps } = this.data;
if (time == null || number == null) {
alertInfo("请正确填写后保存")
return;
}
if (!id) {
if (!idProps) {
const { code, message } = await createReading(park, meter, {
overall: `${number}`,
flat: `${number}`,
@@ -81,10 +86,23 @@ Component({
return
}
alertSuccess("录入成功")
this.setData({ number: null, time: null, startTime: null })
} else {
const { code, message } = await updateReading(park, meter, timeProps, {
overall: `${number}`,
flat: `${number}`,
})
if (code !== OK) {
alertError(message)
return
}
alertSuccess("录入成功")
this.setData({ number: null, time: null, startTime: null })
}
this.triggerEvent("ok")
const that = this;
setTimeout(() => {
that.triggerEvent("ok")
}, 300)
},
dateTimeConfirm(e) {