Commit 8b548be0 authored by 杨梦雅's avatar 杨梦雅

数据需求弹窗导出

parent 485fbd44
.statistic-dialog-wrap {
max-height: 400px;
overflow: scroll
}
.statistic-dialog-wrap .operator-btns {
margin-bottom: 10px;
}
.statistic-dialog-wrap .long-item .next-select {
width: 150px;
}
<dialog-wrap
title="导出数据需求"
visible="{{visible}}"
onClose="onCloseDialog"
width="500"
>
<view class="statistic-dialog-wrap">
<!-- 数据需求时间范围 -->
<form class="edit-content-form" data-name="form" inline="true" labelTextAlign="center" size="large">
<form-item class="edit-content-formItem" label="统计时间" labelTextAlign="center" asterisk="{{false}}">
<range-picker style="width: 400px" onChange="handleTimeRangeChange" hasClear="true" value="{{timeRange}}" class="block" data-time="{{timeRange}}"/>
</form-item>
<view class="operator-btns" style="textAlign:center">
<button style="margin-left:20px;height:32px" type="primary" onTap="handleExport" size="medium">导出</button>
</view>
</form>
</view>
</dialog-wrap>
\ No newline at end of file
import { getStats } from '/api';
Component({
mixins: [],
data: {
// 数据统计开始结束时间
timeRange: []
},
props: {
onClose: () => { },
onShowExportDialog: () => { },
selectedItem: {}
},
didMount() {
},
methods: {
// 关闭弹窗
onCloseDialog() {
this.setData({
startDay: '',
endDay: ''
});
this.props.onClose && this.props.onClose();
},
// 监听时间变化
handleTimeRangeChange(e) {
console.log(e.detail.value)
const [startTime, endTime] = e.detail.value;
this.setData({
timeRange: [startTime, endTime]
});
},
// 导出
async handleExport(evt) {
console.log(this.props);
// 未选择任何条件搜索
if (!this.data.timeRange.length && !this.data.timeRange[0] && !this.data.timeRange[1]) {
my.showToast({
type: 'fail',
content: '请选择统计时间范围'
});
return;
}
const { activityId } = this.props.selectedItem;
let params = {
activityId,
startDay: this.data.timeRange[0],
endDay: this.data.timeRange[1]
};
my.showLoading({
content: '生成文件中...'
});
try {
let { success, data, message } = (await getStats(params)) || {};
console.log(success, data, message, '复制链接');
if (success) {
this.props.onShowExportDialog({
exportLinkUrl: data.url.replace(/amp;/g, '')
});
console.log(data, '下载链接');
} else {
my.showToast({
type: 'fail',
content: message
});
}
my.hideLoading();
} catch (error) {
my.hideLoading();
console.log(error, 'exportStatistics-error');
}
}
}
});
{
"component": true,
"usingComponents": {
"dialog-wrap": "../../basic/dialiog-wrap/dialiog-wrap"
}
}
...@@ -41,3 +41,4 @@ ...@@ -41,3 +41,4 @@
<rank-dialog a:if="{{winnerListDialogVisible}}" visible="{{winnerListDialogVisible}}" onClose="onCloseWinnerListDialog" onShowExportDialog="showExportDialog" selectedItem="{{selectedItem}}"/> <rank-dialog a:if="{{winnerListDialogVisible}}" visible="{{winnerListDialogVisible}}" onClose="onCloseWinnerListDialog" onShowExportDialog="showExportDialog" selectedItem="{{selectedItem}}"/>
<statistic-dialog a:if="{{statisticDialogVisible}}" visible="{{statisticDialogVisible}}" onClose="onCloseStatisticDialog" onShowExportDialog="showExportDialog" selectedItem="{{selectedItem}}"/>
\ No newline at end of file
...@@ -5,8 +5,7 @@ import { ...@@ -5,8 +5,7 @@ import {
delActivity, delActivity,
findWinnerInfoList, findWinnerInfoList,
uploadDataCreateFile, uploadDataCreateFile,
createCopyActivity, createCopyActivity
getStats
} from "/api"; } from "/api";
import { appId } from "/config"; import { appId } from "/config";
import { setClipboard } from "/utils"; import { setClipboard } from "/utils";
...@@ -28,6 +27,7 @@ Component({ ...@@ -28,6 +27,7 @@ Component({
}, },
deleteId: "", deleteId: "",
winnerListDialogVisible: false, winnerListDialogVisible: false,
statisticDialogVisible: false,
selectedItem: {} selectedItem: {}
}, },
props: { props: {
...@@ -203,32 +203,18 @@ Component({ ...@@ -203,32 +203,18 @@ Component({
const { value } = evt.detail; const { value } = evt.detail;
this.getList(value); this.getList(value);
}, },
// 关闭数据需求弹窗
onCloseStatisticDialog() {
this.setData({
statisticDialogVisible: false
});
},
// 导出数据需求 // 导出数据需求
async onExportStatistics(evt) { async onExportStatistics(evt) {
const { activityId, startTime, endTime } = evt.target.dataset.x.record; this.setData({
my.showLoading({ statisticDialogVisible: true,
content: '生成文件中...' selectedItem: evt.target.dataset.x.record
});
try {
let { success, data, message } = (await getStats({ activityId, startDay: startTime, endDay: endTime })) || {};
console.log(success, data, message, '复制链接');
if (success) {
this.showExportDialog({
exportLinkUrl: data.url.replace(/amp;/g, '')
});
console.log(data, '下载链接');
} else {
my.showToast({
type: 'fail',
content: message
}); });
}
my.hideLoading();
} catch (error) {
my.hideLoading();
console.log(error, 'exportStatistics-error');
}
}, },
}, },
}); });
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"copy-link-dialog": "/components/dialog/copy-link-dialog/copy-link-dialog", "copy-link-dialog": "/components/dialog/copy-link-dialog/copy-link-dialog",
"confirm-dialog": "/components/dialog/confirm-dialog/confirm-dialog", "confirm-dialog": "/components/dialog/confirm-dialog/confirm-dialog",
"rank-dialog": "/components/dialog/rank-dialog/rank-dialog", "rank-dialog": "/components/dialog/rank-dialog/rank-dialog",
"winner-list-dialog": "/components/dialog/winner-list-dialog/winner-list-dialog" "winner-list-dialog": "/components/dialog/winner-list-dialog/winner-list-dialog",
"statistic-dialog": "/components/dialog/statistic-dialog/statistic-dialog"
} }
} }
\ No newline at end of file
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