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

feat: 中奖名单配置

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