123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- const util = require("../../../utils/jmsUtil");
- const api = require("../../../api/jms");
- Page({
- data: {
- noData: false,
- dataId: '',
- reportList: {},
- reportDateList: [],
- showPopup: false,
- beginDate: '',
- endDate: '',
- columns: [],
- selectedWeek: '',
- index: 0
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- console.log("optons", options);
- this.setData({
- dataId: options.id
- })
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- this.getReportList()
- this.getReportDate()
- },
- onHide: function () {
- console.log('onHide');
- },
- onUnload: function () {
- console.log('onunload');
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- getReportList() {
- let params = {
- isFra: 1,
- pushFraFlag: 1,
- beginDate: this.data.beginDate.replace(/\//g, '-'),
- endDate: this.data.endDate.replace(/\//g, '-') ,
- dataId: this.data.dataId
- }
- console.log("params",params);
- util.request(api.GetReportList, params, 'post').then(res => {
- if (res.errno === 0) {
- if (res.data == null) {
- this.setData({
- noData: true
- })
- }else{
- // console.log("我的打印", res.data.records[0]);
- this.setData({
- reportList: res.data.records[0]
- })
- }
-
- } else {
- wx.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- });
- },
- getReportDate() {
- util.request(api.getReportDate, {}, 'get').then(res => {
- if (res.errno === 0) {
- console.log("我的打印", res.data);
- this.setData({
- reportDateList: res.data.reverse()
- })
- // 使用map方法转换每个日期对象
- const formattedDates = res.data.map(date => {
- // 格式化月份和日期,确保它们总是两位数
- const beginDate = date.beginDate.split('-').map(part => part.padStart(2, '0')).join('-');
- const endDate = date.endDate.split('-').map(part => part.padStart(2, '0')).join('-');
- // 返回格式化后的日期字符串
- return `${beginDate}-${endDate}`;
- });
- this.setData({
- columns: formattedDates
- })
- } else {
- wx.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- });
- },
- showWeekDate() {
- this.setData({
- showPopup: true
- })
- },
- onClose() {
- this.setData({
- showPopup: false
- });
- },
- onConfirm(event) {
- const {
- picker,
- value,
- index
- } = event.detail;
-
- this.setData({
- showPopup: false,
- selectedWeek: value,
- index: index,
- beginDate: this.data.reportDateList[index].beginDate,
- endDate: this.data.reportDateList[index].endDate
- });
- console.log("选中",value,index,this.data.reportDateList[index].beginDate);
- this.getReportList()
- },
- onCancel() {
- this.setData({
- showPopup: false
- });
- },
- })
|