2024-06-06 18:02:51 +08:00
|
|
|
// 上报动态
|
|
|
|
|
import Utils from "../../../../utils/util"
|
|
|
|
|
const app = getApp();
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
topBarH: app.globalData.CustomBar,
|
|
|
|
|
baseUrl: app.FILE_SERVER_URL,
|
2024-06-07 15:58:25 +08:00
|
|
|
userInfo:{},
|
2024-06-06 18:02:51 +08:00
|
|
|
dateFilter: Utils.formatTime(new Date(), '-'),
|
|
|
|
|
showTaskPop: false,
|
2024-06-07 15:58:25 +08:00
|
|
|
showTypePop: false,
|
|
|
|
|
showWorkType: false,
|
|
|
|
|
postData: {},
|
|
|
|
|
//筛选树结构
|
|
|
|
|
areaCode:'',
|
|
|
|
|
areaPathName:'',
|
|
|
|
|
unitTreepros: {
|
|
|
|
|
key: 'performclassname',
|
|
|
|
|
val: 'listperformid'
|
|
|
|
|
},
|
|
|
|
|
listperformid:'',
|
|
|
|
|
unitTreelist: [],
|
|
|
|
|
TypeList:[],
|
|
|
|
|
detail:true,
|
2024-06-06 18:02:51 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 时间
|
|
|
|
|
*/
|
|
|
|
|
bindDateChange: function (params) {
|
|
|
|
|
const name = params.currentTarget.dataset.name;
|
|
|
|
|
this.data.postData[name] = params.detail.value;
|
|
|
|
|
this.setData(this.data)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 显示/关闭任务弹窗
|
|
|
|
|
*/
|
|
|
|
|
popTaskModal: function (params) {
|
|
|
|
|
const type = params.currentTarget.dataset.type;
|
|
|
|
|
this.data[type] = !this.data[type];
|
|
|
|
|
this.setData(this.data)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 输入内容
|
|
|
|
|
*/
|
|
|
|
|
inputContent: function (e) {
|
|
|
|
|
const name = e.currentTarget.dataset.name;
|
|
|
|
|
this.data.postData[name] = e.detail.value;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 选择文件
|
|
|
|
|
*/
|
|
|
|
|
chooseFile: function () {
|
|
|
|
|
wx.chooseImage({
|
|
|
|
|
count: 1,
|
|
|
|
|
type: 'all',
|
|
|
|
|
success: (res) => {
|
|
|
|
|
const tempFilePaths = res.tempFiles;
|
|
|
|
|
const path = tempFilePaths[0].path;
|
|
|
|
|
this.postImg(path)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 上传图片
|
|
|
|
|
*/
|
|
|
|
|
postImg(filePath) {
|
|
|
|
|
wx.showLoading({
|
|
|
|
|
title: '文件上传中...',
|
|
|
|
|
})
|
2024-06-07 15:58:25 +08:00
|
|
|
|
|
|
|
|
app.uploadFile(this.data.uuid, app.FileType.workManagement, filePath).then(res => {
|
2024-06-06 18:02:51 +08:00
|
|
|
wx.hideLoading();
|
|
|
|
|
this.getFiles();
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取图片
|
|
|
|
|
*/
|
2024-06-07 15:58:25 +08:00
|
|
|
|
2024-06-06 18:02:51 +08:00
|
|
|
getFiles: function () {
|
|
|
|
|
app.axios("GET", "common", "/upload/getFile", {
|
2024-06-07 15:58:25 +08:00
|
|
|
otcid: this.data.postData.workId || this.data.uuid,
|
|
|
|
|
otctype: app.FileType.workManagement
|
2024-06-06 18:02:51 +08:00
|
|
|
}).then(res => {
|
|
|
|
|
if (res.code == 1) {
|
|
|
|
|
this.data.files = res.data;
|
|
|
|
|
this.setData(this.data)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除图片
|
|
|
|
|
* @param {*} params
|
|
|
|
|
*/
|
|
|
|
|
deleteFile: function (e) {
|
|
|
|
|
var id = e.currentTarget.dataset.id;
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title: '删除提示',
|
|
|
|
|
content: '是否要删除该附件?',
|
|
|
|
|
success: (res) => {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
app.axios("GET", 'common', "/upload/delFile", {
|
|
|
|
|
documentId: id,
|
|
|
|
|
}).then(res => {
|
|
|
|
|
if (res.code == 1) {
|
|
|
|
|
this.getFiles();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
2024-06-07 15:58:25 +08:00
|
|
|
/**
|
|
|
|
|
* 显示/关闭弹窗筛选
|
|
|
|
|
*/
|
|
|
|
|
popModal: function (params) {
|
|
|
|
|
console.log(params);
|
|
|
|
|
const type = params.currentTarget.dataset.type;
|
|
|
|
|
this.data[type] = !this.data[type];
|
|
|
|
|
this.setData(this.data)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
handleselectunit(e) {
|
|
|
|
|
// e.detail 选中的id数组
|
|
|
|
|
this.data.page = 1;
|
|
|
|
|
this.data.list = [];
|
|
|
|
|
let postData = this.data.postData; // 获取当前的 postData 对象
|
|
|
|
|
console.log(postData,'postData==>');
|
|
|
|
|
postData.listperformid = e.detail.item.listperformid;
|
|
|
|
|
postData.performclassname = e.detail.item.performclassname;
|
|
|
|
|
this.setData({
|
|
|
|
|
postData: postData,
|
|
|
|
|
showTypePop:false
|
|
|
|
|
}); // 设置更新后的 postData 对象
|
|
|
|
|
// this.getType();
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 地址
|
|
|
|
|
*/
|
|
|
|
|
typeChange: function (params) {
|
|
|
|
|
this.data.page = 1;
|
|
|
|
|
this.data.list = [];
|
|
|
|
|
this.setData(this.data);
|
|
|
|
|
const index = params.currentTarget.dataset.index;
|
|
|
|
|
this.data.postData.type = index + 1;
|
|
|
|
|
this.data.postData.orgcode = this.data.TypeData[index].orgcode;
|
|
|
|
|
this.data.showTypePop = false;
|
|
|
|
|
this.setData(this.data);
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 获取地区
|
|
|
|
|
*/
|
|
|
|
|
getAreaTree: function () {
|
|
|
|
|
app.axios("GET", "app", "/Sys/getListperformTree", ).then(res => {
|
|
|
|
|
if (res.code == 1) {
|
|
|
|
|
console.log(res,'res===>');
|
|
|
|
|
this.data.TypeData = res.data[0].children;
|
|
|
|
|
this.data.unitTreelist = res.data;
|
|
|
|
|
this.setData(this.data)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
2024-06-06 18:02:51 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 发布
|
|
|
|
|
*/
|
|
|
|
|
push: function () {
|
2024-06-07 15:58:25 +08:00
|
|
|
// "endTime": "",-
|
|
|
|
|
// "listperformid": "",
|
|
|
|
|
// "startTime": "",-
|
|
|
|
|
// "title": "",
|
|
|
|
|
// "typeId": "",
|
|
|
|
|
// "userId": "",-
|
|
|
|
|
// "workId": ""-
|
|
|
|
|
|
2024-06-06 18:02:51 +08:00
|
|
|
this.data.postData.userId = app.globalData.userInfo.userId;
|
2024-06-07 15:58:25 +08:00
|
|
|
this.data.postData.workId = this.data.uuid;
|
|
|
|
|
if (!this.data.postData.listperformid) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '请选择所属组织',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (!this.data.postData.worktypeId) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '请选择类型',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-06-06 18:02:51 +08:00
|
|
|
if (!this.data.postData.title) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '请输入内容',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (!this.data.postData.startTime || !this.data.postData.endTime) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '请设置时间',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-06-07 15:58:25 +08:00
|
|
|
|
2024-06-06 18:02:51 +08:00
|
|
|
let data = {
|
|
|
|
|
...this.data.postData,
|
2024-06-07 15:58:25 +08:00
|
|
|
userId:this.data.userInfo.userId,
|
|
|
|
|
typeId:this.data.postData.worktypeId,
|
2024-06-19 15:42:55 +08:00
|
|
|
filePath:''
|
2024-06-06 18:02:51 +08:00
|
|
|
}
|
2024-06-19 15:42:55 +08:00
|
|
|
this.data.files.forEach(item => {
|
|
|
|
|
let flie = item.filepath.substring(item.filepath.length-3);
|
|
|
|
|
if (flie == 'png'||flie == 'jpg') {
|
|
|
|
|
data.filePath = item.filepath;
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-06-06 18:02:51 +08:00
|
|
|
console.log(data,'data===>');
|
2024-06-07 15:58:25 +08:00
|
|
|
app.axios("POST", "app", "/work/workAdd", data).then(res => {
|
|
|
|
|
if (res.code == 1) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '发布成功',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
wx.navigateBack()
|
|
|
|
|
}, 1500);
|
|
|
|
|
} else {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: res.message,
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-06-06 18:02:51 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 预览文件
|
|
|
|
|
*/
|
|
|
|
|
filePre: function (params) {
|
|
|
|
|
const url = params.currentTarget.dataset.url;
|
|
|
|
|
const imgs = [];
|
|
|
|
|
this.data.files.forEach(item => {
|
|
|
|
|
imgs.push(this.data.baseUrl + item.filepath)
|
|
|
|
|
})
|
|
|
|
|
wx.previewImage({
|
|
|
|
|
urls: imgs,
|
|
|
|
|
current: this.data.baseUrl + url
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
//查询详情
|
|
|
|
|
getDetail: function (id) {
|
2024-06-07 15:58:25 +08:00
|
|
|
app.axios("GET", "app", `/work/workDetail/${id}`).then(res => {
|
2024-06-06 18:02:51 +08:00
|
|
|
console.log(res,'res===>');
|
2024-06-07 15:58:25 +08:00
|
|
|
this.data.postData = res.data;
|
2024-06-06 18:02:51 +08:00
|
|
|
this.setData(this.data);
|
|
|
|
|
this.getFiles()
|
|
|
|
|
})
|
|
|
|
|
},
|
2024-06-07 15:58:25 +08:00
|
|
|
/**
|
|
|
|
|
* 事件类型
|
|
|
|
|
*/
|
|
|
|
|
typeChange: function (params) {
|
|
|
|
|
const index = params.currentTarget.dataset.index;
|
|
|
|
|
console.log(params,'params===>');
|
|
|
|
|
this.data.postData.worktypeId = params.currentTarget.dataset.item.typeId;
|
|
|
|
|
this.data.postData.worktype = index + 1;
|
|
|
|
|
this.data.shoWworkType = false;
|
|
|
|
|
this.setData(this.data);
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 查询所有应急上报事件类型
|
|
|
|
|
*/
|
|
|
|
|
getWkTypes: function () {
|
|
|
|
|
app.axios("GET", "app", "/work/wkTypes",{
|
|
|
|
|
classify:1
|
|
|
|
|
}).then(res => {
|
|
|
|
|
if (res.code == 1) {
|
|
|
|
|
console.log(res);
|
|
|
|
|
this.data.TypeList = res.data;
|
|
|
|
|
this.setData(this.data);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
2024-06-06 18:02:51 +08:00
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
*/
|
|
|
|
|
onLoad(options) {
|
2024-06-07 15:58:25 +08:00
|
|
|
this.data.userInfo = app.globalData.userInfo;
|
2024-06-06 18:02:51 +08:00
|
|
|
this.data.uuid = Utils.uuid();
|
|
|
|
|
this.setData(this.data);
|
2024-06-07 15:58:25 +08:00
|
|
|
console.log(options,'options===>');
|
|
|
|
|
if (options.workId) {
|
|
|
|
|
this.getDetail(options.workId);
|
2024-06-06 18:02:51 +08:00
|
|
|
}
|
2024-06-07 15:58:25 +08:00
|
|
|
this.getAreaTree();
|
|
|
|
|
this.getWkTypes();
|
2024-06-06 18:02:51 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
|
*/
|
|
|
|
|
onReady() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
|
*/
|
|
|
|
|
onShow() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
|
*/
|
|
|
|
|
onHide() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
|
*/
|
|
|
|
|
onUnload() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
|
*/
|
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
|
*/
|
|
|
|
|
onReachBottom() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户点击右上角分享
|
|
|
|
|
*/
|
|
|
|
|
onShareAppMessage() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|