Commit bf7820dc authored by 王波's avatar 王波

Merge branch 'b_template_component_bugfixed_20200531' into 'b-template-component'

B template component bugfixed 20200531

See merge request !28
parents dd9ec4a9 9d665f75
...@@ -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,10 @@ Component({ ...@@ -6,14 +6,10 @@ 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 +37,16 @@ Component({ ...@@ -41,8 +37,16 @@ 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 +63,10 @@ Component({ ...@@ -59,14 +63,10 @@ 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 +101,11 @@ Component({ ...@@ -101,10 +101,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 +139,16 @@ Component({ ...@@ -138,8 +139,16 @@ 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 +158,10 @@ Component({ ...@@ -149,8 +158,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 = [];
......
/** @format */
import { CODE_TYPES, EIGHT_HOURS,PRIZE_TYPE,SHIP_STATUS } from './../constants' import { CODE_TYPES, EIGHT_HOURS,PRIZE_TYPE,SHIP_STATUS } from './../constants'
import { services, paramsCheck } from '../decorator' import { services, paramsCheck } from '../decorator'
...@@ -107,20 +105,9 @@ export default class BaseController { ...@@ -107,20 +105,9 @@ export default class BaseController {
} }
console.log(list, '导出报表') console.log(list, '导出报表')
let xlsxData = [ let xlsxData = [
[ [<% for(var i = 0; i < winnersExportData.length; ++i) {%>
'奖品编号', <%- `"${winnersExportData[i]}",`
'用户id', %><% } %>
'中奖时间',
'地址填写时间',
'奖品类型',
'发奖来源',
'奖品名称',
'收货人',
'联系方式',
'收货地址',
'发货状态',
'物流公司',
'物流单号'
] ]
] ]
res.forEach((v, index, arr) => { res.forEach((v, index, arr) => {
...@@ -146,19 +133,19 @@ export default class BaseController { ...@@ -146,19 +133,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