Commit 3e7ddc02 authored by 管新明's avatar 管新明

feat: 中奖名单配置

parent 97b155f9
...@@ -8,40 +8,10 @@ ...@@ -8,40 +8,10 @@
<view class="rank-dialog-wrap"> <view class="rank-dialog-wrap">
<!-- 添加筛选条件导出中奖名单 start --> <!-- 添加筛选条件导出中奖名单 start -->
<form class="edit-content-form" data-name="form" inline="true" labelTextAlign="right" size="large"> <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}}"> <% for(var i = 0; i < configWinnersFilter.length; ++i) {%>
<input value="{{searchInfo.prizeId}}" onChange="handleInputChange" data-name='prizeId' hasLimitHint="true" name="奖品编号" /> <%-configWinnersFilter[i].template%>
</form-item> <% } %>
<form-item class="edit-content-formItem" label="用户id" labelTextAlign="right" asterisk="{{false}}">
<input value="{{searchInfo.userNick}}" onChange="handleInputChange" data-name='userNick' hasLimitHint="true" name="用户id" />
</form-item>
<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" show-time="{{ format: 'HH:mm' }}" data-time="{{searchInfo.timeRange}}"/>
</form-item>
<form-item class="edit-content-formItem" label="发货状态" labelTextAlign="right">
<select value="{{searchInfo.shipStatus}}" onChange="handleInputChange" data-name='shipStatus'>
<option value="">全部</option>
<option value="1">未填写地址</option>
<option value="2">待发货</option>
<option value="3">已发货</option>
</select>
</form-item>
<form-item class="edit-content-formItem long-item" label="奖品类型">
<select value="{{searchInfo.prizeType}}" onChange="handleInputChange" data-name='prizeType'>
<option value="">全部</option>
<option value="1">优惠券</option>
<!-- <option value="2">积分</option> -->
<option value="3">实物</option>
<option value="5">谢谢参与</option>
</select>
</form-item>
<form-item class="edit-content-formItem long-item" label="发奖来源">
<select value="{{searchInfo.prizeDataType}}" onChange="handleInputChange" data-name='prizeDataType'>
<option value="">全部</option>
<% for(var i = 0; i < formatPrize.length; ++i) {%>
<%- `<option value="${formatPrize[i].prizeDataType}">${formatPrize[i].prizeSource}</option> `
%><% } %>
</select>
</form-item>
<view class="operator-btns" style="textAlign:right"> <view class="operator-btns" style="textAlign:right">
<button onTap="handleSearch" style="height:32px;" type="primary" size="medium">搜索</button> <button onTap="handleSearch" style="height:32px;" type="primary" size="medium">搜索</button>
<button style="margin-left:20px;height:32px" type="primary" onTap="handleExport" size="medium">导出</button> <button style="margin-left:20px;height:32px" type="primary" onTap="handleExport" size="medium">导出</button>
......
...@@ -6,14 +6,11 @@ Component({ ...@@ -6,14 +6,11 @@ Component({
data: { data: {
// 搜索条件 // 搜索条件
searchInfo: { searchInfo: {
prizeId: null, // 奖品编号
userNick: null, // 用户id
timeRange: [], // 发奖时间
prizeType: null,
prizeDataType: null,
shipStatus: null,
pageNo: 1, pageNo: 1,
pageSize: 10 pageSize: 10,
<% for(var i = 0; i < winnersFilterData.length; ++i) {%>
<%- `${winnersFilterData[i]}: ${winnersFilterData[i] == 'timeRange' ? [] : null},` %>
<% } %>
}, },
list: [], list: [],
total: 0, total: 0,
...@@ -41,8 +38,17 @@ Component({ ...@@ -41,8 +38,17 @@ Component({
// 搜索 // 搜索
async handleSearch() { async handleSearch() {
// 未选择任何条件搜索 // 未选择任何条件搜索
const { prizeId, userNick, timeRange, prizeType, shipStatus, prizeDataType } = this.data.searchInfo; const {
if (!prizeId && !userNick && !timeRange.length && prizeType == null && shipStatus == null && prizeDataType == null) { <% for(var i = 0; i < winnersFilterData.length; ++i) {%>
<%- `${winnersFilterData[i]}` %>
<% } %>
} = this.data.searchInfo;
if (
<% for(var i = 0; i < winnersFilterData.length; ++i) {%>
<%- `${winnersFilterData[i] == 'timeRange' ? `${!winnersFilterData[i].length}` : `${!winnersFilterData[i]}`} ${i === winnersFilterData.length - 1 ? '' : '&&'}` %>
<% } %>
) {
this.resetData(); this.resetData();
my.showToast({ my.showToast({
type: 'fail', type: 'fail',
...@@ -59,14 +65,11 @@ Component({ ...@@ -59,14 +65,11 @@ Component({
resetData() { resetData() {
this.setData({ this.setData({
searchInfo: { searchInfo: {
prizeId: null, // 奖品编号
userNick: null, // 用户id
timeRange: [], // 发奖时间
prizeType: null,
prizeDataType: null,
shipStatus: null,
pageNo: 1, pageNo: 1,
pageSize: 10 pageSize: 10,
<% for(var i = 0; i < winnersFilterData.length; ++i) {%>
<%- `${winnersFilterData[i]}: ${winnersFilterData[i] == 'timeRange' ? [] : null},` %>
<% } %>
}, },
list: [], list: [],
total: 0, total: 0,
...@@ -101,10 +104,11 @@ Component({ ...@@ -101,10 +104,11 @@ Component({
...this.data.searchInfo, ...this.data.searchInfo,
activityId: this.props.selectedItem.activityId activityId: this.props.selectedItem.activityId
}; };
params.startTime = new Date(params.timeRange[0]).getTime(); <%- winnersFilterData.includes('timeRange') &&
`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 {
...@@ -138,8 +142,17 @@ Component({ ...@@ -138,8 +142,17 @@ Component({
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 {
if (!prizeId && !userNick && !timeRange.length && prizeType == null && shipStatus == null && prizeDataType == null) { <% for(var i = 0; i < winnersFilterData.length; ++i) {%>
<%- `${winnersFilterData[i]}` %>
<% } %>
} = this.data.searchInfo;
if (
<% for(var i = 0; i < winnersFilterData.length; ++i) {%>
<%- `${winnersFilterData[i] == 'timeRange' ? `${!winnersFilterData[i].length}` : `${!winnersFilterData[i]}`} ${i === winnersFilterData.length - 1 ? '' : '&&'}` %>
<% } %>
) {
this.resetData(); this.resetData();
my.showToast({ my.showToast({
type: 'fail', type: 'fail',
...@@ -149,8 +162,10 @@ Component({ ...@@ -149,8 +162,10 @@ Component({
} }
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(); <%- winnersFilterData.includes('timeRange') &&
params.endTime = new Date(params.timeRange[1]).getTime(); `params.startTime = new Date(params.timeRange[0]).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 = [];
......
...@@ -52,17 +52,17 @@ export default class BaseController { ...@@ -52,17 +52,17 @@ export default class BaseController {
async getAwardsList(context: Context, { session }, [awardsService]: [AwardsService]) { async getAwardsList(context: Context, { session }, [awardsService]: [AwardsService]) {
let { cloud } = context let { cloud } = context
let { let {
activityId, activityId = '',
title, title = '',
prizeId, pageNo = 1,
userNick, pageSize = 10,
startTime, prizeId = null,
endTime, userNick = '',
shipStatus, prizeType = null,
prizeType, prizeDataType = null,
prizeDataType, shipStatus = null,
pageNo, startTime = null,
pageSize endTime = null,
} = context.data } = context.data
// 获取活动中奖列表 // 获取活动中奖列表
let awardList = await awardsService.getAwardListByActivityId({ let awardList = await awardsService.getAwardListByActivityId({
...@@ -108,19 +108,9 @@ export default class BaseController { ...@@ -108,19 +108,9 @@ export default class BaseController {
console.log(list, '导出报表') console.log(list, '导出报表')
let xlsxData = [ let xlsxData = [
[ [
'奖品编号', <% for(var i = 0; i < winnersExportData.length; ++i) {%>
'用户id', <%- `${winnersExportData[i]},` %>
'中奖时间', <% } %>
'地址填写时间',
'奖品类型',
'发奖来源',
'奖品名称',
'收货人',
'联系方式',
'收货地址',
'发货状态',
'物流公司',
'物流单号'
] ]
] ]
res.forEach((v, index, arr) => { res.forEach((v, index, arr) => {
...@@ -129,7 +119,7 @@ export default class BaseController { ...@@ -129,7 +119,7 @@ export default class BaseController {
let shipTxt = '/'; let shipTxt = '/';
if (v) { if (v) {
<% for(var i = 0; i < formatPrize.length; ++i) {%> <% for(var i = 0; i < formatPrize.length; ++i) {%>
<%- `if (v.prizeDataType == ${formatPrize[i].prizeDataType}) prizeDataType = '${formatPrize[i].name}'` <%- `if (v.prizeDataType == ${formatPrize[i].prizeDataType}) prizeDataType = '${formatPrize[i].prizeSource}'`
%><% } %> %><% } %>
// if (v.prizeDataType == 1) prizeDataType = '关卡获得' // if (v.prizeDataType == 1) prizeDataType = '关卡获得'
// if (v.prizeDataType == 2) prizeDataType = '排行榜' // if (v.prizeDataType == 2) prizeDataType = '排行榜'
...@@ -146,19 +136,19 @@ export default class BaseController { ...@@ -146,19 +136,19 @@ export default class BaseController {
if (v.type == PRIZE_TYPE.THANK) prizeType = '谢谢参与' if (v.type == PRIZE_TYPE.THANK) prizeType = '谢谢参与'
} }
xlsxData.push([ xlsxData.push([
v._id, <%- winnersExportData.includes('奖品编号') && `v._id,` %>
v.userNick, <%- winnersExportData.includes('用户id') && `v.userNick,` %>
v.createTime ? formatTime(new Date(v.createTime + EIGHT_HOURS)) : '', <%- winnersExportData.includes('中奖时间') && `v.createTime ? formatTime(new Date(v.createTime + EIGHT_HOURS)) : '',` %>
v.type == 3 ? (v.receiveTime ? formatTime(new Date(v.receiveTime + EIGHT_HOURS)) : '暂未填写') : '/', <%- winnersExportData.includes('地址填写时间') && `v.type == 3 ? (v.receiveTime ? formatTime(new Date(v.receiveTime + EIGHT_HOURS)) : '暂未填写') : '/',` %>
prizeType, <%- winnersExportData.includes('奖品类型') && `prizeType` %>
prizeDataType, <%- winnersExportData.includes('发奖来源') && `prizeDataType,` %>
v.type == 2 ? `${v.credits || 0}积分` : v.name || '', <%- winnersExportData.includes('奖品名称') && `v.type == 2 ? `${v.credits || 0}积分` : v.name || '',` %>
v.type == 3 ? v.receiveName || '' : '/', <%- winnersExportData.includes('收货人') && `v.type == 3 ? v.receiveName || '' : '/',` %>
v.type == 3 ? (v.phone ? v.phone + '' : '暂未填写') : '/', <%- winnersExportData.includes('联系方式') && `v.type == 3 ? (v.phone ? v.phone + '' : '暂未填写') : '/',` %>
v.type == 3 ? v.province + v.city + v.area + v.streetName + v.addressDetail || '暂未填写' : '/', <%- winnersExportData.includes('收货地址') && `v.type == 3 ? v.province + v.city + v.area + v.streetName + v.addressDetail || '暂未填写' : '/',` %>
shipTxt, <%- winnersExportData.includes('发货地址') && `shipTxt,` %>
v.type == 3 ? v.shipCompany || '' : '/', <%- winnersExportData.includes('物流公司') && `v.type == 3 ? v.shipCompany || '' : '/',` %>
v.type == 3 ? (v.shipNum ? v.shipNum + '' : '') : '/' <%- winnersExportData.includes('物流单号') && `v.type == 3 ? (v.shipNum ? v.shipNum + '' : '') : '/'` %>
]) ])
}) })
let buffer = xlsx.build([ let buffer = xlsx.build([
......
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