112 lines
2.0 KiB
TypeScript
112 lines
2.0 KiB
TypeScript
// pages/createReport/createReport.ts
|
|
import { reportSave } from "../../apis/report";
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
dataIds: [],
|
|
name: '',
|
|
remark: '',
|
|
reportFormDefaultName: ''
|
|
},
|
|
createReport() {
|
|
const { dataIds, name, remark, reportFormDefaultName } = this.data
|
|
|
|
reportSave({
|
|
dataIds,
|
|
name: name === '' ? reportFormDefaultName.split(',')[0] : name,
|
|
remark
|
|
}).then(res => {
|
|
if (res.c === 200) {
|
|
this.selectComponent('#' + 'shadow2').show()
|
|
}
|
|
})
|
|
},
|
|
jumpReportList() {
|
|
wx.switchTab({
|
|
url: '/pages/report/report'
|
|
})
|
|
},
|
|
nameInit() {
|
|
const now = new Date();
|
|
|
|
let reportFormDefaultName =
|
|
now.getFullYear() +
|
|
"" +
|
|
(now.getMonth() + 1 < 10
|
|
? "0" + (now.getMonth() + 1)
|
|
: now.getMonth() + 1) +
|
|
"" +
|
|
(now.getDate() < 10 ? "0" + now.getDate() : now.getDate()) +
|
|
"" +
|
|
(now.getHours() < 10 ? '0' + now.getHours() : now.getHours()) +
|
|
(now.getMinutes() < 10 ? '0' + now.getMinutes() : now.getMinutes()) +
|
|
(now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds());
|
|
console.log(reportFormDefaultName);
|
|
|
|
this.setData({
|
|
reportFormDefaultName:reportFormDefaultName+',可点击修改'
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad() {
|
|
this.nameInit()
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
this.setData({
|
|
dataIds: wx.getStorageSync('reportIds')
|
|
})
|
|
this.nameInit()
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |