工作台代码提交
This commit is contained in:
@@ -1,18 +1,178 @@
|
||||
// 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()
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user