准备联调抄表记录
This commit is contained in:
@@ -1,20 +1,63 @@
|
||||
// pages/writeReading/index.js
|
||||
import { getMeterReadingRouteDetail } from "../../service/workBench"
|
||||
import request from "../../utils/request"
|
||||
import { alertSuccess, alertInfo, alertError } from "../../utils/index"
|
||||
const { OK } = request
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
meterList: [],
|
||||
meterInfo: {},
|
||||
active: 0,
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
const { id } = options;
|
||||
this.getMeterList(id)
|
||||
},
|
||||
async getMeterList(id) {
|
||||
const { code, message, data } = await getMeterReadingRouteDetail(id);
|
||||
if (code !== OK) {
|
||||
alertError(message)
|
||||
return;
|
||||
}
|
||||
this.setData({
|
||||
meterList: data?.meterRouteDetail || [],
|
||||
meterInfo: data?.meterRouteDetail?.[0] || {}
|
||||
})
|
||||
},
|
||||
changeMeter(e) {
|
||||
this.setData({
|
||||
meterInfo: e.detail.meter,
|
||||
})
|
||||
},
|
||||
changeMeterAndIndex(e) {
|
||||
this.setData({
|
||||
meterInfo: e.detail.meter,
|
||||
active: e.detail.index,
|
||||
})
|
||||
},
|
||||
handleNext() {
|
||||
const { active = 0, meterList } = this.data;
|
||||
let newIndex = active + 1
|
||||
if (active > meterList?.length - 1) {
|
||||
newIndex = meterList?.length - 1
|
||||
}
|
||||
this.setData({
|
||||
active: newIndex
|
||||
})
|
||||
},
|
||||
handlePrev() {
|
||||
this.setData({
|
||||
active: this.data.active === 0 ? 0 : this.data.active - 1
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
@@ -62,5 +105,5 @@ Page({
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
},
|
||||
})
|
Reference in New Issue
Block a user