Commit c292ffa4 authored by gongguan's avatar gongguan

feat: 增加了数据看板模块

parent 3381da65
.rank-dialog-wrap {
max-height: 400px;
overflow: scroll
}
.other-winner-list {
display: flex;
justify-content: flex-end;
margin: 0 0 20px 0;
}
.now-winner-list {
display: flex;
justify-content: flex-end;
margin: 20px 0;
}
.rank-pagination {
display: flex;
justify-content: flex-end;
margin: 10px 0 0 0;
}
.rank-pagination-text {
display: flex;
align-items: center;
}
.rank-dialog-wrap .operator-btns {
margin-bottom: 10px;
}
.rank-dialog-wrap .long-item .next-select {
width: 150px;
}
<dialog-wrap title="数据看板" visible="{{visible}}" onClose="onCloseDialog" width="1000">
<form class="edit-content-form" data-name="form" inline="true" labelTextAlign="right" size="large">
<form-item class="edit-content-formItem" label="选择时间" labelTextAlign="right" asterisk="{{false}}">
<range-picker style="width: 300px" onChange="handleTimeRangeChange" hasClear="true" value="{{searchInfo.timeRange}}" class="block" data-time="{{searchInfo.timeRange}}"/>
</form-item>
<button onTap="searchList" style="height:32px;" type="primary" size="medium">搜索</button>
</form>
<view class="rank-dialog-wrap">
<table dataSource="{{list}}" loading="{{isLoading}}" isZebra>
<table-column a:for="{{titleList}}" title="{{item}}" dataIndex="{{item}}" width="{{index === 0 ? 120 : 'auto'}}"/>
</table>
<view class="rank-pagination">
<text class="rank-pagination-text">共 {{total}} 条</text>
<pagination showJump="{{false}}" defaultCurrent="{{1}}" current="{{searchInfo.pageNo}}" data-type="all" pageSize="{{searchInfo.pageSize}}" onChange="handleChangePage" pageShowCount="{{10}}" total="{{total}}" a:if="{{total > 0}}" shape="arrow-only" />
</view>
</view>
</dialog-wrap>
\ No newline at end of file
import { getStats } from "/api";
import moment from "moment";
Component({
mixins: [],
data: {
// 搜索条件
searchInfo: {
timeRange: [] // 发奖时间
},
titleList: [],
list: [],
total: 0,
isLoading: false,
winactivityId: ""
},
props: {
onClose: () => {},
selectedItem: {}
},
didMount() {
const now = new Date();
const today = moment(now).format("YYYY/MM/DD");
const startTime = today.slice(0, 8) + "01";
this.setData({
"searchInfo.timeRange": [startTime, today]
});
this.searchList();
},
didUpdate() {},
didUnmount() {},
methods: {
async searchList() {
this.setData({
isLoading: true,
list: [],
total: 0
});
const startDay = this.data.searchInfo.timeRange[0].replace(/-/g, '/')
const endDay = this.data.searchInfo.timeRange[1].replace(/-/g, '/')
const params = {
activityId: this.props.selectedItem.activityId,
startDay,
endDay
};
const { data } = (await getStats(params)) || {};
// console.log("data::::::::", data);
const { xlsxData } = data;
const titleList = xlsxData[0];
const dataList = xlsxData.slice(1);
let tableData = [];
dataList.forEach((item, idx) => {
let itemObj = {};
titleList.forEach((it, i) => {
itemObj[it] = item[i];
});
tableData.push(itemObj);
});
console.log("tableData::::::::", tableData);
if (tableData && tableData.length > 0) {
this.setData({
isLoading: false,
titleList,
list: tableData,
total: tableData.length
});
}
},
// 监听发奖时间变化
handleTimeRangeChange(e) {
const [startTime, endTime] = e.detail.value;
this.setData({
"searchInfo.timeRange": [startTime, endTime]
});
},
onCloseDialog() {
this.props.onClose && this.props.onClose();
}
}
});
{
"component": true,
"usingComponents": {
"dialog-wrap": "../../basic/dialiog-wrap/dialiog-wrap",
"ship-dialog": "../../dialog/ship-dialog/ship-dialog"
}
}
......@@ -19,6 +19,7 @@
<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>
<button a:if="{{isTestEnv}}" class="tb-list-edit" type="primary" text="true" data-x="{{x}}" onTap="onShowDataBoard">数据看板</button>
</view>
</table-column>
</table>
......@@ -41,4 +42,6 @@
<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
<statistic-dialog a:if="{{statisticDialogVisible}}" visible="{{statisticDialogVisible}}" onClose="onCloseStatisticDialog" onShowExportDialog="showExportDialog" selectedItem="{{selectedItem}}"/>
<data-board-dialog a:if="{{dataBoardDialogVisible}}" visible="{{dataBoardDialogVisible}}" onClose="onCloseDataBoardDialog" selectedItem="{{selectedItem}}"/>
\ No newline at end of file
......@@ -7,11 +7,12 @@ import {
uploadDataCreateFile,
createCopyActivity
} from "/api";
import { appId } from "/config";
import { appId, env } from "/config";
import { setClipboard } from "/utils";
Component({
data: {
isTestEnv: env === 'test' ? true : false,
isLoadingList: false,
exportDialogVisible: false,
exportLinkUrl: '',
......@@ -216,5 +217,17 @@ Component({
selectedItem: evt.target.dataset.x.record
});
},
// 数据看板
onShowDataBoard(evt) {
this.setData({
dataBoardDialogVisible: true,
selectedItem: evt.target.dataset.x.record
});
},
onCloseDataBoardDialog() {
this.setData({
dataBoardDialogVisible: false
});
},
},
});
......@@ -5,6 +5,7 @@
"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",
"statistic-dialog": "/components/dialog/statistic-dialog/statistic-dialog"
"statistic-dialog": "/components/dialog/statistic-dialog/statistic-dialog",
"data-board-dialog": "/components/dialog/data-board-dialog/data-board-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