Commit 458f3136 authored by qinhaitao's avatar qinhaitao

fix: 🐛 bug

parent 52cdaffc
import { findWinnerInfoList, getAwardsList, exportAwardsList } from '/api'
import moment from 'moment'
import { findWinnerInfoList, getAwardsList, exportAwardsList } from '/api';
import moment from 'moment';
Component({
mixins: [],
data: {
// 搜索条件
searchInfo: {
prizeId: null, //奖品编号
userNick: null, //用户id
timeRange: [], //发奖时间
prizeId: null, // 奖品编号
userNick: null, // 用户id
timeRange: [], // 发奖时间
prizeType: null,
prizeDataType: null,
shipStatus: null,
......@@ -27,41 +27,41 @@ Component({
selectedItem: {}
},
didMount() {
this.searchList();
// this.searchList();
},
methods: {
// 更换页码时调用接口
handleChangePage(e) {
const { value } = e.detail
const { value } = e.detail;
this.setData({
'searchInfo.pageNo': value
})
this.searchList()
});
this.searchList();
},
// 搜索
async handleSearch() {
// 未选择任何条件搜索
const { prizeId, userNick, timeRange, prizeType, shipStatus, prizeDataType } = this.data.searchInfo
const { prizeId, userNick, timeRange, prizeType, shipStatus, prizeDataType } = this.data.searchInfo;
if (!prizeId && !userNick && !timeRange.length && prizeType == null && shipStatus == null && prizeDataType == null) {
this.resetData()
this.resetData();
my.showToast({
type: 'fail',
content: '请填写至少一个筛选信息'
})
return
});
return;
}
this.setData({
'searchInfo.pageNo': 1
})
this.searchList()
});
this.searchList();
},
// start《条件搜索》初始化数据更新
resetData() {
this.setData({
searchInfo: {
prizeId: null, //奖品编号
userNick: null, //用户id
timeRange: [], //发奖时间
prizeId: null, // 奖品编号
userNick: null, // 用户id
timeRange: [], // 发奖时间
prizeType: null,
prizeDataType: null,
shipStatus: null,
......@@ -73,11 +73,11 @@ Component({
isLoading: false,
showShip: false,
winactivityId: ''
})
});
},
onCloseDialog() {
this.resetData()
this.props.onClose && this.props.onClose()
this.resetData();
this.props.onClose && this.props.onClose();
},
// 监听input改变
......@@ -86,137 +86,115 @@ Component({
const { name } = e.target.dataset;
this.setData({
[`searchInfo.${name}`]: value
})
});
},
// 监听发奖时间变化
handleTimeRangeChange(e) {
const [startTime, endTime] = e.detail.value
const [startTime, endTime] = e.detail.value;
this.setData({
'searchInfo.timeRange': [startTime, endTime]
})
});
},
//搜索
// 搜索
async searchList() {
let params = {
...this.data.searchInfo,
activityId: this.props.selectedItem.activityId
}
params.startTime = new Date(params.timeRange[0]).getTime()
params.endTime = new Date(params.timeRange[1]).getTime()
};
params.startTime = new Date(params.timeRange[0]).getTime();
params.endTime = new Date(params.timeRange[1]).getTime();
delete params.timeRange
console.log('搜索参数', params)
delete params.timeRange;
console.log('搜索参数', params);
try {
this.setData({
isLoading: true
})
console.log(params)
const { data, success } = (await findWinnerInfoList(params)) || {}
const { list, total } = data
console.log(data, 'data-----')
});
console.log(params);
const { data, success } = (await findWinnerInfoList(params)) || {};
const { list, total } = data;
console.log(data, 'data-----');
list.map(v => {
v.createTime = moment(+v.createTime).format('YYYY-MM-DD HH:mm:ss')
v.receiveTime = moment(+v.receiveTime).format('YYYY-MM-DD HH:mm:ss')
})
v.createTime = moment(+v.createTime).format('YYYY-MM-DD HH:mm:ss');
v.receiveTime = moment(+v.receiveTime).format('YYYY-MM-DD HH:mm:ss');
});
if (success) {
this.setData({
list,
total
})
});
this.setData({
isLoading: false
})
});
}
} catch (error) {
this.setData({
isLoading: false
})
});
}
},
async handleExport(evt) {
console.log(this.props)
console.log(this.props);
// 未选择任何条件搜索
const { prizeId, userNick, timeRange, prizeType, shipStatus, prizeDataType } = this.data.searchInfo
const { prizeId, userNick, timeRange, prizeType, shipStatus, prizeDataType } = this.data.searchInfo;
if (!prizeId && !userNick && !timeRange.length && prizeType == null && shipStatus == null && prizeDataType == null) {
this.resetData()
this.resetData();
my.showToast({
type: 'fail',
content: '请填写至少一个筛选信息'
})
return
});
return;
}
const { activityId, title } = this.props.selectedItem
let params = { ...this.data.searchInfo, activityId, title }
params.startTime = new Date(params.timeRange[0]).getTime()
params.endTime = new Date(params.timeRange[1]).getTime()
params.pageNo = 1
params.pageSize = 500
let res = []
delete params.timeRange
const { activityId, title } = this.props.selectedItem;
let params = { ...this.data.searchInfo, activityId, title };
params.startTime = new Date(params.timeRange[0]).getTime();
params.endTime = new Date(params.timeRange[1]).getTime();
params.pageNo = 1;
params.pageSize = 500;
let res = [];
delete params.timeRange;
my.showLoading({
content: '生成文件中...'
})
});
try {
let { success, data, message } = (await getAwardsList(params).catch(error => { })) || {}
const { list = [], total } = data || {}
if (success) {
res = [...res, ...list]
while (total > res.length) {
params.pageNo++
let { success, data, message } = (await getAwardsList(params).catch(error => { })) || {}
const { list = [] } = data || {}
if (success) {
res = [...res, ...list]
} else {
}
}
if (res.length == 0) {
my.showToast({
type: 'fail',
content: '查询结果为空'
})
my.hideLoading()
return
}
let { success, data, message } = (await exportAwardsList({ title, list: res })) || {}
console.log(success, data, message, '复制链接')
let { success, data, message } = (await exportAwardsList({ title, ...params })) || {};
console.log(success, data, message, '复制链接');
if (success) {
this.props.onShowExportDialog({
exportLinkUrl: data.url.replace(/amp;/g, '')
})
console.log(data, '下载链接')
});
console.log(data, '下载链接');
} else {
my.showToast({
type: 'fail',
content: message
})
});
}
} else {
}
my.hideLoading()
my.hideLoading();
} catch (error) {
my.hideLoading()
console.log(error, 'exportList-error')
my.hideLoading();
console.log(error, 'exportList-error');
}
},
// 导入发货信息
handleImport() {
const { activityId } = this.props.selectedItem
console.log('打开导入文件弹窗')
const { activityId } = this.props.selectedItem;
console.log('打开导入文件弹窗');
this.setData({
showShip: true,
winactivityId: activityId
})
console.log('winner====showShip', this.data.showShip)
});
console.log('winner====showShip', this.data.showShip);
},
// 关闭导入发货窗口
handleShipClose() {
this.setData({
showShip: false,
winactivityId: ''
})
});
}
}
})
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment