2024-01-29 17:42:38 +08:00
|
|
|
|
// pages/emergency/resourse/index/index.js
|
|
|
|
|
|
const app = getApp();
|
|
|
|
|
|
|
|
|
|
|
|
Component({
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 组件的属性列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
properties: {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 组件的初始数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
data: {
|
2024-06-14 15:00:33 +08:00
|
|
|
|
baseUrl: app.FILE_SERVER_URL,
|
2024-01-29 17:42:38 +08:00
|
|
|
|
condition: '',
|
|
|
|
|
|
curTab: 0,
|
2024-01-30 16:35:55 +08:00
|
|
|
|
tabs: [],
|
2024-01-29 17:42:38 +08:00
|
|
|
|
|
|
|
|
|
|
canChange: false,
|
|
|
|
|
|
freshIng: false,
|
|
|
|
|
|
page: 1,
|
|
|
|
|
|
pageSize: 10,
|
2024-06-14 15:00:33 +08:00
|
|
|
|
list: [],
|
2024-01-29 17:42:38 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
pageLifetimes: {
|
|
|
|
|
|
show: function () {
|
2024-01-30 16:35:55 +08:00
|
|
|
|
this.getType();
|
2024-01-29 17:42:38 +08:00
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 组件的方法列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 搜索
|
|
|
|
|
|
*/
|
|
|
|
|
|
inputSearch: function (e) {
|
|
|
|
|
|
this.data.condition = e.detail.value;
|
|
|
|
|
|
this.refresh();
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 切换筛选
|
|
|
|
|
|
*/
|
|
|
|
|
|
tabSelect: function (params) {
|
|
|
|
|
|
const index = Number.parseInt(params.currentTarget.dataset.index);
|
|
|
|
|
|
this.data.curTab = index;
|
|
|
|
|
|
this.setData(this.data)
|
2024-01-30 16:35:55 +08:00
|
|
|
|
this.refresh();
|
2024-01-29 17:42:38 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 刷新
|
|
|
|
|
|
* @param {*} params
|
|
|
|
|
|
*/
|
|
|
|
|
|
refresh: function (params) {
|
|
|
|
|
|
this.data.page = 1;
|
2024-01-30 16:35:55 +08:00
|
|
|
|
this.data.list = [];
|
2024-01-29 17:42:38 +08:00
|
|
|
|
this.setData(this.data)
|
|
|
|
|
|
this.getList();
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
getList: function () {
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
page: this.data.page,
|
2024-01-30 16:35:55 +08:00
|
|
|
|
limit: this.data.pageSize,
|
2024-06-04 14:45:44 +08:00
|
|
|
|
othtypeid: this.data.tabs[this.data.curTab].emerTypeId,
|
|
|
|
|
|
planname: this.data.condition,
|
|
|
|
|
|
userId: app.globalData.userInfo.userId
|
2024-01-29 17:42:38 +08:00
|
|
|
|
}
|
2024-01-30 16:35:55 +08:00
|
|
|
|
app.axios("GET", "app", "/Othplan/getOthplanPage", params, false).then(res => {
|
|
|
|
|
|
this.data.freshIng = false;
|
|
|
|
|
|
if (res.code == 1) {
|
|
|
|
|
|
let page = Number.parseInt(res.data.pageNum);
|
|
|
|
|
|
if (this.data.page == 1) {
|
|
|
|
|
|
this.data.list = res.data.list;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
var list = this.data.list;
|
|
|
|
|
|
if (this.data.page == page) this.data.list = [...list, ...res.data.list]
|
|
|
|
|
|
}
|
|
|
|
|
|
if (res.data.list?.length > 0) this.data.page = page + 1
|
|
|
|
|
|
}
|
|
|
|
|
|
this.setData(this.data)
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2024-06-14 15:00:33 +08:00
|
|
|
|
download :function (item) {
|
|
|
|
|
|
console.log(item,'item====>');
|
|
|
|
|
|
console.log(this.data.baseUrl+item.currentTarget.dataset.item.filePath);
|
|
|
|
|
|
//触发点击事件,使用uni.showLoading()展示交互提示
|
|
|
|
|
|
wx.showLoading({
|
|
|
|
|
|
title: '正在下载……'
|
|
|
|
|
|
});
|
|
|
|
|
|
// 使用wx.downloadFile()开始下载文件
|
|
|
|
|
|
wx.downloadFile({
|
|
|
|
|
|
url: this.data.baseUrl+item.currentTarget.dataset.item.filePath, //url:请求的完整地址
|
|
|
|
|
|
success: function(res) {
|
|
|
|
|
|
wx.hideLoading() //调用结束,隐藏加载框
|
|
|
|
|
|
const filePath = res.tempFilePath //临时文件路径 (本地路径)
|
|
|
|
|
|
if (res.statusCode == 200) {
|
|
|
|
|
|
//判断后端数据接收成功时提示下载完成
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
|
icon: 'none',
|
|
|
|
|
|
mask: true,
|
|
|
|
|
|
title: '下载完成,正在打开文件...',
|
|
|
|
|
|
duration: 2000,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
//设置定时器2秒后打开文件
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
//调用wx.openDocument()打开刚刚下载的文件
|
|
|
|
|
|
wx.openDocument({
|
|
|
|
|
|
filePath: filePath, //上一步存储的临时文件路径 (本地路径)
|
|
|
|
|
|
fileType: item.type, //要打开的文件类型,
|
|
|
|
|
|
showMenu: true, //是否显示右上角菜单
|
|
|
|
|
|
//下面的测试用了,写不写无所谓
|
|
|
|
|
|
success: function(res) {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
complete: function(msg) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}, 2000)
|
|
|
|
|
|
},
|
|
|
|
|
|
//文件下载失败,会走这里,具体可以把err打印出来看看有什么错误
|
|
|
|
|
|
fail: (err) => {
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
icon: 'none',
|
|
|
|
|
|
mask: true,
|
|
|
|
|
|
title: '文件下载失败',
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2024-01-30 16:35:55 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取预案类型
|
|
|
|
|
|
*/
|
|
|
|
|
|
getType: function () {
|
|
|
|
|
|
app.axios("GET", "app", "/Othplan/getOthtypeList", {}, false).then(res => {
|
|
|
|
|
|
if (res.code == 1) {
|
2024-06-04 14:45:44 +08:00
|
|
|
|
console.log(res,'res==');
|
2024-01-30 16:35:55 +08:00
|
|
|
|
this.data.tabs = res.data;
|
|
|
|
|
|
this.setData(this.data)
|
|
|
|
|
|
}
|
|
|
|
|
|
this.setData(this.data)
|
|
|
|
|
|
})
|
2024-01-29 17:42:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|