daofu-applet/pages/work/s-b/index/index.js

272 lines
5.2 KiB
JavaScript
Raw Normal View History

2024-01-29 17:42:38 +08:00
// 上报动态
import Utils from "../../../../utils/util"
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
topBarH: app.globalData.CustomBar,
2024-01-30 16:35:55 +08:00
baseUrl: app.FILE_SERVER_URL,
2024-01-29 17:42:38 +08:00
dateFilter: Utils.formatTime(new Date(), '-'),
showTypePop: false,
2024-01-30 16:35:55 +08:00
showTaskPop: false,
TypeData: [],
2024-01-29 17:42:38 +08:00
postData: {}
},
2024-01-30 16:35:55 +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)
},
2024-01-29 17:42:38 +08:00
/**
* 显示/关闭弹窗
*/
popModal: function (params) {
const type = params.currentTarget.dataset.type;
this.data[type] = !this.data[type];
this.setData(this.data)
},
/**
* 通知类型
*/
typeChange: function (params) {
const index = params.currentTarget.dataset.index;
this.data.postData.type = index + 1;
2024-01-30 16:35:55 +08:00
this.data.postData.typeId = this.data.TypeData[index].typeId;
2024-01-29 17:42:38 +08:00
this.data.showTypePop = false;
this.setData(this.data)
},
/**
2024-01-30 16:35:55 +08:00
* 输入内容
2024-01-29 17:42:38 +08:00
*/
inputContent: function (e) {
2024-01-30 16:35:55 +08:00
const name = e.currentTarget.dataset.name;
this.data.postData[name] = e.detail.value;
2024-01-29 17:42:38 +08:00
},
/**
* 选择文件
*/
chooseFile: function () {
wx.chooseImage({
count: 1,
type: 'all',
success: (res) => {
const tempFilePaths = res.tempFiles;
const path = tempFilePaths[0].path;
this.postImg(path)
}
})
},
2024-01-30 16:35:55 +08:00
/**
* 获取工作类型
*/
getType: function () {
app.axios("GET", "app", "/work/wkTypes", {
classify: 2
2024-01-30 16:35:55 +08:00
}).then(res => {
if (res.code == 1) {
this.data.TypeData = res.data;
this.setData(this.data)
}
})
},
2024-01-29 17:42:38 +08:00
/**
* 上传图片
*/
postImg(filePath) {
wx.showLoading({
title: '文件上传中...',
})
2024-01-30 16:35:55 +08:00
app.uploadFile(this.data.uuid, app.FileType.resumptionAcs, filePath).then(res => {
2024-01-29 17:42:38 +08:00
wx.hideLoading();
this.getFiles();
})
},
/**
2024-01-30 16:35:55 +08:00
* 获取图片
2024-01-29 17:42:38 +08:00
*/
getFiles: function () {
app.axios("GET", "common", "/upload/getFile", {
2024-01-30 16:35:55 +08:00
otcid: this.data.uuid,
otctype: app.FileType.resumptionAcs
2024-01-29 17:42:38 +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) {
2024-01-30 16:35:55 +08:00
app.axios("GET", 'common', "/upload/delFile", {
documentId: id,
2024-01-29 17:42:38 +08:00
}).then(res => {
if (res.code == 1) {
this.getFiles();
}
})
}
}
})
},
/**
2024-01-30 16:35:55 +08:00
* 发布
2024-01-29 17:42:38 +08:00
*/
2024-01-30 16:35:55 +08:00
push: function () {
2024-01-29 17:42:38 +08:00
this.data.postData.userId = app.globalData.userInfo.userId;
this.data.postData.dynamicsId = this.data.uuid;
2024-01-30 16:35:55 +08:00
if (!this.data.postData.title) {
wx.showToast({
title: '请输入工作标题',
icon: 'none'
})
return
}
if (!this.data.postData.typeId) {
2024-01-29 17:42:38 +08:00
wx.showToast({
2024-01-30 16:35:55 +08:00
title: '请选择工作类型',
2024-01-29 17:42:38 +08:00
icon: 'none'
})
return
}
2024-06-04 14:45:44 +08:00
if (!this.data.postData.detail) {
2024-01-29 17:42:38 +08:00
wx.showToast({
2024-01-30 16:35:55 +08:00
title: '请输入内容',
2024-01-29 17:42:38 +08:00
icon: 'none'
})
return
}
2024-01-30 16:35:55 +08:00
if (!this.data.postData.startTime || !this.data.postData.endTime) {
2024-01-29 17:42:38 +08:00
wx.showToast({
2024-01-30 16:35:55 +08:00
title: '请设置时间',
2024-01-29 17:42:38 +08:00
icon: 'none'
})
return
}
app.axios("POST", "app", "/work/wkDynamicsAdd", this.data.postData).then(res => {
2024-01-29 17:42:38 +08:00
if (res.code == 1) {
wx.showToast({
title: '发布成功',
icon: 'none'
})
setTimeout(() => {
wx.navigateBack()
}, 1500);
} else {
wx.showToast({
title: res.message,
icon: 'none'
})
}
})
},
/**
* 预览文件
*/
filePre: function (params) {
const url = params.currentTarget.dataset.url;
2024-01-30 16:35:55 +08:00
const imgs = [];
this.data.files.forEach(item => {
imgs.push(this.data.baseUrl + item.filepath)
})
wx.previewImage({
urls: imgs,
current: this.data.baseUrl + url
2024-01-29 17:42:38 +08:00
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.data.isUserDetail = options.user;
2024-01-30 16:35:55 +08:00
this.data.uuid = Utils.uuid();
2024-01-29 17:42:38 +08:00
this.setData(this.data)
2024-01-30 16:35:55 +08:00
this.getType();
2024-01-29 17:42:38 +08:00
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})