抄表记录提交
This commit is contained in:
@@ -8,8 +8,19 @@ Component({
|
|||||||
*/
|
*/
|
||||||
properties: {
|
properties: {
|
||||||
show: Boolean,
|
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: {
|
lifetimes: {
|
||||||
attached() {
|
attached() {
|
||||||
|
this.setData({
|
||||||
|
maxDate: new Date().getTime(),
|
||||||
|
currentDate: new Date().getTime(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
// pages/workBench/components/tenement/components/bindMeter/index.js
|
// pages/workBench/components/tenement/components/bindMeter/index.js
|
||||||
// 0015980101
|
// 0015980101
|
||||||
import { createReading } from "../../../../service/workBench"
|
import { createReading, updateReading } from "../../../../service/workBench"
|
||||||
import { getWorkMeterDetail } from "../../../../service/meter"
|
import { getWorkMeterDetail } from "../../../../service/meter"
|
||||||
import { alertInfo, alertSuccess } from "../../../../utils/index";
|
import { alertInfo, alertSuccess } from "../../../../utils/index";
|
||||||
import request from "../../../../utils/request"
|
import request from "../../../../utils/request"
|
||||||
@@ -16,14 +16,16 @@ Component({
|
|||||||
title: String,
|
title: String,
|
||||||
timeProps: String,
|
timeProps: String,
|
||||||
numberProps: String,
|
numberProps: String,
|
||||||
id: String,
|
idProps: String,
|
||||||
meter: String,
|
meter: String,
|
||||||
park: String
|
park: String
|
||||||
},
|
},
|
||||||
observers: {
|
observers: {
|
||||||
"timeProps": function(newValue) {
|
"timeProps": function(newValue) {
|
||||||
|
// console.log("newValue", newValue)
|
||||||
this.setData({
|
this.setData({
|
||||||
time: newValue
|
time: newValue,
|
||||||
|
// startTime: newValue
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"numberProps": function(newValue) {
|
"numberProps": function(newValue) {
|
||||||
@@ -31,6 +33,9 @@ Component({
|
|||||||
number: newValue
|
number: newValue
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
"idProps": function(newValue) {
|
||||||
|
console.log("new id", newValue)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 组件的初始数据
|
* 组件的初始数据
|
||||||
@@ -65,12 +70,12 @@ Component({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
async onSubmit() {
|
async onSubmit() {
|
||||||
const { time, number, id, park, meter } = this.data;
|
const { time, number, idProps, park, meter, timeProps } = this.data;
|
||||||
if (time == null || number == null) {
|
if (time == null || number == null) {
|
||||||
alertInfo("请正确填写后保存")
|
alertInfo("请正确填写后保存")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!id) {
|
if (!idProps) {
|
||||||
const { code, message } = await createReading(park, meter, {
|
const { code, message } = await createReading(park, meter, {
|
||||||
overall: `${number}`,
|
overall: `${number}`,
|
||||||
flat: `${number}`,
|
flat: `${number}`,
|
||||||
@@ -81,10 +86,23 @@ Component({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
alertSuccess("录入成功")
|
alertSuccess("录入成功")
|
||||||
|
this.setData({ number: null, time: null, startTime: null })
|
||||||
} else {
|
} 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) {
|
dateTimeConfirm(e) {
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
use-button-slot
|
use-button-slot
|
||||||
title-width="100rpx"
|
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-button>
|
||||||
</van-field>
|
</van-field>
|
||||||
@@ -46,7 +46,9 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<date-time-picker
|
<date-time-picker
|
||||||
|
wx:if="{{dateTimeShow}}"
|
||||||
show="{{dateTimeShow}}"
|
show="{{dateTimeShow}}"
|
||||||
|
time="{{startTime}}"
|
||||||
bind:confirm="dateTimeConfirm"
|
bind:confirm="dateTimeConfirm"
|
||||||
bind:cancel="dateTimeCancal"
|
bind:cancel="dateTimeCancal"
|
||||||
/>
|
/>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
// pages/readingHistory/index.js
|
// pages/readingHistory/index.js
|
||||||
import { getMeterReadingRouteMeterDetail, getReadingList } from "../../service/workBench"
|
import { getMeterReadingRouteMeterDetail, getReadingList, deleteReading } from "../../service/workBench"
|
||||||
import request from "../../utils/request"
|
import request from "../../utils/request"
|
||||||
import { alertInfo, alertSuccess, alertError, loadingFunc } from "../../utils/index"
|
import { alertInfo, alertSuccess, alertError, loadingFunc } from "../../utils/index"
|
||||||
const { OK } = request;
|
const { OK } = request;
|
||||||
@@ -43,14 +43,24 @@ Page({
|
|||||||
this.setData({ meterInfo: data })
|
this.setData({ meterInfo: data })
|
||||||
},
|
},
|
||||||
async getList() {
|
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)
|
const { code, message, records: data } = await getReadingList(park, meter, page)
|
||||||
if (code !== OK) {
|
if (code !== OK) {
|
||||||
alertError(message)
|
alertError(message)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setData({
|
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"
|
type: "create"
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleUpdate() {
|
handleUpdate(e) {
|
||||||
|
const { data } = e.currentTarget.dataset;
|
||||||
|
console.log("data", data);
|
||||||
this.setData({
|
this.setData({
|
||||||
title: "编辑记录",
|
title: "编辑记录",
|
||||||
visible: true,
|
visible: true,
|
||||||
time: "2025-09-11",
|
time: data.readAt,
|
||||||
number: 100,
|
number: data.overall,
|
||||||
id: "",
|
id: data.id,
|
||||||
type: "edit",
|
type: "edit",
|
||||||
|
}, () => {
|
||||||
|
console.log("this.data---------", this.data)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleDelete(e) {
|
handleDelete(e) {
|
||||||
const { id } = e.currentTarget.dataset;
|
const { data } = e.currentTarget.dataset;
|
||||||
|
const that = this;
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
title: '删除确认',
|
title: '删除确认',
|
||||||
content: '确认要删除这一项记录吗?',
|
content: '确认要删除这一项记录吗?',
|
||||||
complete: (res) => {
|
complete: async (res) => {
|
||||||
if (res.cancel) {
|
if (res.cancel) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.confirm) {
|
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",
|
"meterInfo": "./components/meterInfo/index",
|
||||||
"van-button": "@vant/weapp/button/index",
|
"van-button": "@vant/weapp/button/index",
|
||||||
"van-icon": "@vant/weapp/icon/index",
|
"van-icon": "@vant/weapp/icon/index",
|
||||||
"editModal": "./components/editModal/index"
|
"editModal": "./components/editModal/index",
|
||||||
|
"pagination": "/components/pagination/index"
|
||||||
},
|
},
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
<!--pages/readingHistory/index.wxml-->
|
<!--pages/readingHistory/index.wxml-->
|
||||||
<navigator title="历史抄表记录" canBack="{{true}}" />
|
<navigator title="历史抄表记录" canBack="{{true}}" />
|
||||||
|
{{id}}
|
||||||
<view class="wrapper">
|
<view class="wrapper">
|
||||||
<meterInfo meterInfo="{{meterInfo}}" />
|
<meterInfo meterInfo="{{meterInfo}}" />
|
||||||
<view class="historyTitle">
|
<view class="historyTitle">
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
<view class="th" style="width: 25%; text-align: center; justify-content: center; display: flex; align-items: center;">
|
<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="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>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -47,12 +47,14 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<editModal
|
<editModal
|
||||||
|
wx:if="{{visible}}"
|
||||||
title="{{title}}"
|
title="{{title}}"
|
||||||
visible="{{visible}}"
|
visible="{{visible}}"
|
||||||
timeProps="{{time}}"
|
timeProps="{{time}}"
|
||||||
numberProps="{{number}}"
|
numberProps="{{number}}"
|
||||||
id="{{id}}"
|
idProps="{{id}}"
|
||||||
park="{{park}}"
|
park="{{park}}"
|
||||||
meter="{{meter}}"
|
meter="{{meter}}"
|
||||||
bind:ok="refresh"
|
bind:ok="refresh"
|
||||||
|
startTime="{{startTime}}"
|
||||||
/>
|
/>
|
@@ -31,3 +31,13 @@ export const createReading = async function(park, code, data) {
|
|||||||
export const getReadingList = async function(park, keyword, page) {
|
export const getReadingList = async function(park, keyword, page) {
|
||||||
return await GET(`/reading/${park}?keyword=${keyword}&page=${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