// pages/workBenchTodoList/index.js import request from "../../utils/request" import { getWorkOrderList } from "../../service/workBench" import { alertInfo, loadingFunc } from "../../utils/index"; import { noticeFlowType } from "../../utils/data" const { OK } = request Page({ /** * 页面的初始数据 */ data: { page: 1, size: 20, noticeFlowType, actionItems: [{ name: '确认', value: 'status' }], }, showActionMenu(e) { console.log("e", e) this.setData({ currentActionSheet: e.currentTarget.dataset.id }); }, hideActionMenu() { this.setData({ currentActionSheet: null }); }, onMenuSelect(e) { const { value } = e.detail; const id = e.currentTarget.dataset.id; if (value === 'detail') { this.jumpToDetail(id); } }, jumpToDetail(id) { // wx.navigateTo({ // url: '/pages/workOrderDetail/index?id=' + id, // }) }, onConfirm(e) { const { type, data = {}, way } = e.detail; const that = this; switch(type) { case "park": this.setData({ park: data.id, parkName: data.name, }) break; case "tenement": this.setData({ tenement: data.id, tenementName: data.name, }) break; case "noticeFlowType": this.setData({ noticeFlowType: data, noticeFlowTypeName: data, page: 1, }, () => { loadingFunc(async () => { await that.init() }) }); break; case "noticeFlowStatus": this.setData({ noticeFlowStatus: data, noticeFlowStatusName: data, page: 1, }, () => { loadingFunc(async () => { await that.init() }) }); break; case "meter": this.setData({ meter: data.id, meterName: data.address, meterInfo: data, page: 1, }, () => { loadingFunc(async () => { await that.init() }) }); break; } this.onCancel(); }, onCancel() { this.setData({ show: false, title: "", type: "", }) }, onParkFocus(e) { this.setData({ show: true, title: "园区", type: 'park' }) }, onNoticeFlowFocus() { this.setData({ show: true, title: "类型", type: 'noticeFlowType' }) }, onNoticeFlowStatusFocus() { this.setData({ show: true, title: "确认状态", type: 'noticeFlowStatus' }) }, onMeterFocus(e) { const { park } = this.data; if (!park) { alertInfo("请先选择园区") return; } this.setData({ show: true, title: "电表", type: 'meter' }) }, onChangePage(e) { const that = this; this.setData({ page: e.detail.currentIndex, }, () => { loadingFunc(async () => { await that.init() }) }) console.log("e", e) }, async init() { const { page, size, park, tenement, meter, type, time, status } = this.data; const { code, message, data, total } = await getWorkOrderList({ page, size, park, tenement, meter, type, time, status }) if (code !== OK) { alertInfo(message) return; } this.setData({ list: data?.map(item => { item.time = item?.created_at?.slice(0, 10) item.address = item?.target?.meter_data?.address; return item; }), totalPage: Math.ceil(total / size), }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { loadingFunc(async () => { await this.init() }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })