工作台修改
This commit is contained in:
144
pages/workBenchNew/components/workBenchReading/index.js
Normal file
144
pages/workBenchNew/components/workBenchReading/index.js
Normal file
@@ -0,0 +1,144 @@
|
||||
// pages/workBenchNew/components/workBenchReading/index.js
|
||||
import { getMeterReadingRouteList, changeMeterRouteStatus } from "../../../../service/workBench"
|
||||
import { alertError, alertSuccess, loadingFunc } from "../../../../utils/index"
|
||||
import request from "../../../../utils/request"
|
||||
const { OK } = request
|
||||
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
park: "",
|
||||
parkName: "",
|
||||
},
|
||||
onParkFocus(e) {
|
||||
this.setData({
|
||||
show: true,
|
||||
title: "园区",
|
||||
type: 'park'
|
||||
})
|
||||
},
|
||||
async init() {
|
||||
const { parkName, park } = this.data;
|
||||
const { code, message, data } = await getMeterReadingRouteList(parkName)
|
||||
if (code !== OK) {
|
||||
alertError(message)
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
list: data
|
||||
})
|
||||
},
|
||||
onConfirm(e) {
|
||||
const { data } = e.detail;
|
||||
const that = this;
|
||||
this.setData({
|
||||
parkName: data.name,
|
||||
park: data.id,
|
||||
}, () => {
|
||||
loadingFunc(async () => {
|
||||
await that.init();
|
||||
})
|
||||
})
|
||||
this.onConcal();
|
||||
},
|
||||
onConcal() {
|
||||
this.setData({
|
||||
show: false,
|
||||
title: "",
|
||||
type: "",
|
||||
})
|
||||
},
|
||||
jumpToReading(e) {
|
||||
const { id } = e.currentTarget.dataset;
|
||||
wx.navigateTo({
|
||||
url: `/pages/writeReading/index?id=${id}`,
|
||||
})
|
||||
},
|
||||
async changeStartStatus(e) {
|
||||
const that = this;
|
||||
const { id } = e.currentTarget.dataset;
|
||||
const { code, message } = await changeMeterRouteStatus({ id, status: 1 })
|
||||
if (code !== OK) {
|
||||
alertError(message)
|
||||
return
|
||||
}
|
||||
alertSuccess("操作成功")
|
||||
this.init()
|
||||
setTimeout(() => {
|
||||
that.jumpToReading({ currentTarget: { dataset: { id } } })
|
||||
}, 500)
|
||||
},
|
||||
async changeEndStatus(e) {
|
||||
const { id } = e.currentTarget.dataset;
|
||||
const { code, message } = await changeMeterRouteStatus({ id, status: 0 })
|
||||
if (code !== OK) {
|
||||
alertError(message)
|
||||
return
|
||||
}
|
||||
alertSuccess("操作成功")
|
||||
this.init()
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
const { parkName } = this.data;
|
||||
if (!parkName) {
|
||||
return
|
||||
}
|
||||
this.init()
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
17
pages/workBenchNew/components/workBenchReading/index.json
Normal file
17
pages/workBenchNew/components/workBenchReading/index.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"van-field": "@vant/weapp/field/index",
|
||||
"van-button": "@vant/weapp/button/index",
|
||||
"search-select": "/components/searchSelect/index",
|
||||
"van-empty": "@vant/weapp/empty/index",
|
||||
"table": "/components/table/table",
|
||||
"pagination": "/components/pagination/index",
|
||||
"empty": "/components/empty/index",
|
||||
"van-radio": "@vant/weapp/radio/index",
|
||||
"van-radio-group": "@vant/weapp/radio-group/index",
|
||||
"van-dialog": "@vant/weapp/dialog/index",
|
||||
"van-cell": "@vant/weapp/cell/index",
|
||||
"navigator": "/components/navigator/index"
|
||||
},
|
||||
"navigationStyle": "custom"
|
||||
}
|
65
pages/workBenchNew/components/workBenchReading/index.wxml
Normal file
65
pages/workBenchNew/components/workBenchReading/index.wxml
Normal file
@@ -0,0 +1,65 @@
|
||||
<!--pages/workBench/components/reading/index.wxml-->
|
||||
<navigator title="抄表记录录入" canBack="{{true}}" />
|
||||
<van-field
|
||||
value="{{ parkName }}"
|
||||
placeholder="请选择园区"
|
||||
label="园区"
|
||||
readonly
|
||||
border="{{ false }}"
|
||||
use-button-slot
|
||||
title-width="100rpx"
|
||||
>
|
||||
<van-button slot="button" size="small" type="primary" bind:click="onParkFocus">
|
||||
选择
|
||||
</van-button>
|
||||
</van-field>
|
||||
|
||||
<search-select
|
||||
show="{{show}}"
|
||||
title="{{title}}"
|
||||
type="{{type}}"
|
||||
park="{{park}}"
|
||||
bindconfirm="onConfirm"
|
||||
bindcancel="onConcal"
|
||||
/>
|
||||
|
||||
<van-empty description="请先选择园区" wx:if="{{!park}}" />
|
||||
|
||||
<view wx:else>
|
||||
<view wx:if="{{list.length}}">
|
||||
<van-cell
|
||||
wx:for="{{list}}"
|
||||
wx:key="id"
|
||||
title="{{item.readingRouteName}}"
|
||||
label="包含{{item.meterRoute}}个抄表点"
|
||||
>
|
||||
<view slot="right-icon">
|
||||
<van-button
|
||||
type="primary"
|
||||
size="small"
|
||||
type="primary"
|
||||
bind:tap="changeStartStatus"
|
||||
custom-style="margin-right: 20rpx;"
|
||||
data-id="{{item.id}}"
|
||||
wx:if="{{item.status === 0}}"
|
||||
> 开始抄表 </van-button>
|
||||
<van-button
|
||||
type="primary"
|
||||
size="small"
|
||||
bind:tap="jumpToReading"
|
||||
data-id="{{item.id}}"
|
||||
custom-style="margin-right: 20rpx;"
|
||||
wx:if="{{item.status === 1}}"
|
||||
> 去抄表 </van-button>
|
||||
<van-button
|
||||
size="small"
|
||||
type="danger"
|
||||
bind:tap="changeEndStatus"
|
||||
data-id="{{item.id}}"
|
||||
wx:if="{{item.status === 1}}"
|
||||
> 结束抄表 </van-button>
|
||||
</view>
|
||||
</van-cell>
|
||||
</view>
|
||||
<empty wx:else bind:refresh="init" />
|
||||
</view>
|
@@ -0,0 +1 @@
|
||||
/* pages/workBenchNew/components/workBenchReading/index.wxss */
|
Reference in New Issue
Block a user