Commit 880f9e36 authored by 王波's avatar 王波

Merge branch 'b-template-addStatistic' into 'b-template-component-bugfixed-0.1'

B端模板添加数据需求导出

See merge request !13
parents d914429c 8b548be0
......@@ -35,6 +35,8 @@ const API = {
// 搜索条件查询中奖信息
downloadFile: (params) => request("downloadFile", "POST", params),
getAwardsList: (params) => request("getAwardsList", "POST", params),
// 导出数据需求
getStats: (params) => request("getStats", "POST", params, { cloudFnType: 'c' })
};
export default API;
.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"
}
}
......@@ -18,6 +18,7 @@
<button a:if="{{buttons.includes('delete')}}" class="tb-list-edit" type="primary" text="true" data-x="{{x}}" onTap="handleTapDelete">删除</button>
<button a:if="{{buttons.includes('copyLink')}}" class="tb-list-edit" type="primary" text="true" data-x="{{x}}" onTap="onCopyLink">复制活动链接</button>
<button a:if="{{buttons.includes('copyNewActivity')}}" class="tb-list-edit" type="primary" text="true" data-x="{{x}}" onTap="onCreateNewActivity">复制新活动</button>
<button a:if="{{buttons.includes('exportStatistics')}}" class="tb-list-edit" type="primary" text="true" data-x="{{x}}" onTap="onExportStatistics">导出数据需求</button>
</view>
</table-column>
</table>
......@@ -39,4 +40,5 @@
/>
<rank-dialog a:if="{{winnerListDialogVisible}}" visible="{{winnerListDialogVisible}}" onClose="onCloseWinnerListDialog" onShowExportDialog="showExportDialog" selectedItem="{{selectedItem}}"/>
\ No newline at end of file
<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,7 +5,7 @@ import {
delActivity,
findWinnerInfoList,
uploadDataCreateFile,
createCopyActivity,
createCopyActivity
} from "/api";
import { appId } from "/config";
import { setClipboard } from "/utils";
......@@ -27,6 +27,7 @@ Component({
},
deleteId: "",
winnerListDialogVisible: false,
statisticDialogVisible: false,
selectedItem: {}
},
props: {
......@@ -202,5 +203,18 @@ Component({
const { value } = evt.detail;
this.getList(value);
},
// 关闭数据需求弹窗
onCloseStatisticDialog() {
this.setData({
statisticDialogVisible: false
});
},
// 导出数据需求
async onExportStatistics(evt) {
this.setData({
statisticDialogVisible: true,
selectedItem: evt.target.dataset.x.record
});
},
},
});
......@@ -4,6 +4,7 @@
"copy-link-dialog": "/components/dialog/copy-link-dialog/copy-link-dialog",
"confirm-dialog": "/components/dialog/confirm-dialog/confirm-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
......@@ -8,6 +8,9 @@ export default {
// 默认云函数名称
cloudFnName: 'duibats',
// C端云函数名称(数据需求调用)
cCloudFnName: 'CommonToC',
// 小程序appId
appId: "<%=appId%>",
......
......@@ -2,11 +2,12 @@ const {
cloud
} = getApp();
import { requestType, cloudFnName } from '../config';
import { requestType, cloudFnName, cCloudFnName } from '../config';
const request = (url, method, params, ext = {}) => {
const {
isShowLoading
isShowLoading,
cloudFnType
} = ext;
const hideMyLoading = () => {
if (isShowLoading) {
......@@ -17,9 +18,12 @@ const request = (url, method, params, ext = {}) => {
my.showLoading();
}
// 云函数名
const cloudFn = cloudFnType === 'c' ? cCloudFnName : cloudFnName
const requestAms = () => {
return my.request({
url: `https://ams.dui88.com/server/index.php?g=Web&c=Mock&o=simple&projectID=218&uri=${cloudFnName}.${url}`,
url: `https://ams.dui88.com/server/index.php?g=Web&c=Mock&o=simple&projectID=218&uri=${cloudFn}.${url}`,
method,
data: params,
dataType: 'json'
......@@ -32,7 +36,7 @@ const request = (url, method, params, ext = {}) => {
}
const requestCloud = () => {
return cloud.function.invoke(cloudFnName, params, url).then(res => {
return cloud.function.invoke(cloudFn, params, url).then(res => {
hideMyLoading();
return res;
}).catch(() => {
......
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