Commit 458f3136 authored by qinhaitao's avatar qinhaitao

fix: 🐛 bug

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