471615499@qq.com 50c09303e8 字体调整
调整UI大小;
加入消息选中删除功能
2024-08-28 22:13:01 +08:00

265 lines
5.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const app = getApp()
import {
repairRemindListRq,
repairRemindReadRq,
repairRemindClearRq,
repairRemindRemoveRq
} from "../../../api/repair/repair.js"
import Dialog from '@vant/weapp/dialog/dialog';
import Notify from '@vant/weapp/notify/notify';
Page({
/**
* 页面的初始数据
*/
data: {
IMG_NAME: app.IMG_NAME,
// info
info: {
pageNum: 1,
pageSize: 10,
dataList: [],
isDataAll: false,
},
checkedId: {},
showEdit: false
},
openEdit() {
this.setData({
showEdit: true,
checkedId: {}
})
},
cancelEdit() {
this.setData({
showEdit: false,
checkedId: {}
})
},
removeChecked() {
this.setData({
showEdit: true
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
// 获取数据
getDataList() {
let _this = this;
// 获取参数
let pageNum = null
let pageSize = null
let type = null
let isDataAll = null
let info = _this.data.info
//
pageNum = info.pageNum
pageSize = info.pageSize
isDataAll = info.isDataAll
// 判断数据是否已全部加载
if (isDataAll) {
return;
}
// 传递参数
let param = {
pageNum,
pageSize,
}
// 查询数据
repairRemindListRq(param).then(res => {
console.log('repairRemindListRq', res);
let dataList = res.rows
let isDataAll = false
if (pageNum * pageSize >= res.total) {
isDataAll = true
}
//
info.dataList = info.dataList.concat(_this.formartData(dataList))
info.pageNum = info.pageNum + 1
info.isDataAll = isDataAll
_this.setData({
info
})
})
},
// 格式化数据
formartData(dataList) {
// 格式化数据
return dataList.map(item => {
return item;
})
},
jumpInfoDetail(e) {
if (this.data.showEdit) {
// 编辑模式下不可跳转
return
}
console.log('detail', e);
let id = e.currentTarget.dataset.obj.id
let repairId = e.currentTarget.dataset.obj.repairId
let title = e.currentTarget.dataset.obj.content
let url = `/pages/reportRepair/assign/detail/detail?id=${repairId}`
if ((title.includes('你收到工单') && title.includes('请尽快处理')) || title.includes('已经超时,黄灯告警') || title.includes('已经严重超时,红灯告警')) {
// 此处为维修单要跳转到case
url = `/pages/reportRepair/repair/case/case?id=${repairId}`
}
repairRemindReadRq({
id
}).then(res => {
wx.navigateTo({
url: url,
})
})
},
changeCheck(e) {
console.log(e)
let id = e.currentTarget.dataset.obj.id
let _this = this
let _checkedId = `checkedId[${id}]`
_this.setData({
[_checkedId]: e.detail
})
},
removeChecked() {
let _this = this
let _idArr = _this.data.checkedId
let _idStr = ''
for (let key in _idArr) {
// console.log(_idArr[key])
if(_idArr[key]) {
_idStr += key + ','
}
}
if (_idStr != '') {
_idStr = _idStr.slice(0, -1)
} else {
Notify('请至少勾选一条消息!')
return
}
// console.log(_idStr)
Dialog.confirm({
title: '请确认',
message: '是否删除选中的消息?',
})
.then(() => {
repairRemindRemoveRq({
id:_idStr
}).then(res => {
// 重新加载列表
_this.setData({
info: {
pageNum: 1,
pageSize: 10,
dataList: [],
isDataAll: false,
},
checkedId: {}
})
// 重新加载
_this.getDataList()
})
})
.catch(() => {
// on cancel
})
},
removeAll() {
let _this = this
// 确认
Dialog.confirm({
title: '请确认',
message: '您即将清空消息列表,是否确认?',
})
.then(() => {
repairRemindClearRq({}).then(res => {
// 清空消息后,重新加载
_this.setData({
info: {
pageNum: 1,
pageSize: 10,
dataList: [],
isDataAll: false,
}
})
// 重新加载
_this.getDataList()
})
})
.catch(() => {
// on cancel
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
let _this = this;
_this.setData({
info: {
pageNum: 1,
pageSize: 10,
dataList: [],
isDataAll: false,
}
})
//
_this.getDataList()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
console.log('onReachBottom', '页面上拉触底事件的处理函数');
let _this = this;
// 获取数据
_this.getDataList()
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})