抄表记录提交
This commit is contained in:
@@ -8,8 +8,19 @@ Component({
|
||||
*/
|
||||
properties: {
|
||||
show: Boolean,
|
||||
// time: String,
|
||||
},
|
||||
|
||||
// observers: {
|
||||
// time: function(newValue) {
|
||||
// console.log("time newValue", newValue)
|
||||
// if (!newValue) {
|
||||
// return;
|
||||
// }
|
||||
// this.setData({
|
||||
// currentDate: new Date(newValue).getTime(),
|
||||
// })
|
||||
// }
|
||||
// },
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
@@ -20,7 +31,10 @@ Component({
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
|
||||
this.setData({
|
||||
maxDate: new Date().getTime(),
|
||||
currentDate: new Date().getTime(),
|
||||
})
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
@@ -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) {
|
||||
|
@@ -17,7 +17,7 @@
|
||||
use-button-slot
|
||||
title-width="100rpx"
|
||||
>
|
||||
<van-button slot="button" size="small" type="info" bind:click="onTimeFocus">
|
||||
<van-button slot="button" size="small" type="info" bind:click="onTimeFocus" wx:if="{{!idProps}}">
|
||||
选择
|
||||
</van-button>
|
||||
</van-field>
|
||||
@@ -46,7 +46,9 @@
|
||||
/>
|
||||
|
||||
<date-time-picker
|
||||
wx:if="{{dateTimeShow}}"
|
||||
show="{{dateTimeShow}}"
|
||||
time="{{startTime}}"
|
||||
bind:confirm="dateTimeConfirm"
|
||||
bind:cancel="dateTimeCancal"
|
||||
/>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
// pages/readingHistory/index.js
|
||||
import { getMeterReadingRouteMeterDetail, getReadingList } from "../../service/workBench"
|
||||
import { getMeterReadingRouteMeterDetail, getReadingList, deleteReading } from "../../service/workBench"
|
||||
import request from "../../utils/request"
|
||||
import { alertInfo, alertSuccess, alertError, loadingFunc } from "../../utils/index"
|
||||
const { OK } = request;
|
||||
@@ -43,14 +43,24 @@ Page({
|
||||
this.setData({ meterInfo: data })
|
||||
},
|
||||
async getList() {
|
||||
const { meter, park, page } = this.data;
|
||||
const { meter, park, page, size } = this.data;
|
||||
const { code, message, records: data } = await getReadingList(park, meter, page)
|
||||
if (code !== OK) {
|
||||
alertError(message)
|
||||
return;
|
||||
}
|
||||
this.setData({
|
||||
list: data
|
||||
list: data,
|
||||
totalPage: Math.ceil(data?.length / size)
|
||||
})
|
||||
},
|
||||
async onChangePage(e) {
|
||||
const newPage = e.detail.currentIndex;
|
||||
const that = this;
|
||||
this.setData({
|
||||
page: newPage
|
||||
}, () => {
|
||||
that.getList();
|
||||
})
|
||||
},
|
||||
/**
|
||||
@@ -66,28 +76,41 @@ Page({
|
||||
type: "create"
|
||||
})
|
||||
},
|
||||
handleUpdate() {
|
||||
handleUpdate(e) {
|
||||
const { data } = e.currentTarget.dataset;
|
||||
console.log("data", data);
|
||||
this.setData({
|
||||
title: "编辑记录",
|
||||
visible: true,
|
||||
time: "2025-09-11",
|
||||
number: 100,
|
||||
id: "",
|
||||
time: data.readAt,
|
||||
number: data.overall,
|
||||
id: data.id,
|
||||
type: "edit",
|
||||
}, () => {
|
||||
console.log("this.data---------", this.data)
|
||||
})
|
||||
},
|
||||
handleDelete(e) {
|
||||
const { id } = e.currentTarget.dataset;
|
||||
const { data } = e.currentTarget.dataset;
|
||||
const that = this;
|
||||
wx.showModal({
|
||||
title: '删除确认',
|
||||
content: '确认要删除这一项记录吗?',
|
||||
complete: (res) => {
|
||||
complete: async (res) => {
|
||||
if (res.cancel) {
|
||||
|
||||
}
|
||||
|
||||
if (res.confirm) {
|
||||
|
||||
const { code, message } = await deleteReading(data?.id, data?.overall)
|
||||
if (code !== OK) {
|
||||
alertError(message)
|
||||
return
|
||||
}
|
||||
alertSuccess("删除成功")
|
||||
setTimeout(() => {
|
||||
that.refresh()
|
||||
}, 300)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@@ -4,7 +4,8 @@
|
||||
"meterInfo": "./components/meterInfo/index",
|
||||
"van-button": "@vant/weapp/button/index",
|
||||
"van-icon": "@vant/weapp/icon/index",
|
||||
"editModal": "./components/editModal/index"
|
||||
"editModal": "./components/editModal/index",
|
||||
"pagination": "/components/pagination/index"
|
||||
},
|
||||
"navigationStyle": "custom"
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
<!--pages/readingHistory/index.wxml-->
|
||||
<navigator title="历史抄表记录" canBack="{{true}}" />
|
||||
|
||||
{{id}}
|
||||
<view class="wrapper">
|
||||
<meterInfo meterInfo="{{meterInfo}}" />
|
||||
<view class="historyTitle">
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
<view class="th" style="width: 25%; text-align: center; justify-content: center; display: flex; align-items: center;">
|
||||
<van-icon name="edit" size="40rpx" bind:tap="handleUpdate" data-data="{{item}}" color="#15755e" />
|
||||
<van-icon name="delete" size="40rpx" bind:tap="handleDelete" data-id="{{item.id}}" color="#15755e" custom-style="margin-left: 20rpx" />
|
||||
<van-icon name="delete" size="40rpx" bind:tap="handleDelete" data-data="{{item}}" color="#15755e" custom-style="margin-left: 20rpx" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -47,12 +47,14 @@
|
||||
</view>
|
||||
|
||||
<editModal
|
||||
wx:if="{{visible}}"
|
||||
title="{{title}}"
|
||||
visible="{{visible}}"
|
||||
timeProps="{{time}}"
|
||||
numberProps="{{number}}"
|
||||
id="{{id}}"
|
||||
idProps="{{id}}"
|
||||
park="{{park}}"
|
||||
meter="{{meter}}"
|
||||
bind:ok="refresh"
|
||||
startTime="{{startTime}}"
|
||||
/>
|
@@ -30,4 +30,14 @@ export const createReading = async function(park, code, data) {
|
||||
// 查询符合指定条件的抄表记录
|
||||
export const getReadingList = async function(park, keyword, page) {
|
||||
return await GET(`/reading/${park}?keyword=${keyword}&page=${page}`,);
|
||||
}
|
||||
|
||||
// 删除抄表记录
|
||||
export const deleteReading = async function(id, overall) {
|
||||
return await DELETE(`/meter/delete/records/${id}`, { overall });
|
||||
}
|
||||
|
||||
// 修改抄表记录
|
||||
export const updateReading = async function(park, code, read_at, data) {
|
||||
return await PUT(`/reading/${park}/${code}/${read_at}`, data);
|
||||
}
|
Reference in New Issue
Block a user