Authored by jiran.zhao

'一件代发'

@@ -297,7 +297,7 @@ export default { @@ -297,7 +297,7 @@ export default {
297 padding-right: 6px; 297 padding-right: 6px;
298 } 298 }
299 299
300 -.action-column { 300 +.status-column {
301 .cell-action-row { 301 .cell-action-row {
302 margin-top: 10px; 302 margin-top: 10px;
303 303
1 import moment from 'moment'; 1 import moment from 'moment';
2 2
3 -const curDay = moment().format('YYYY-MM-DD');  
4 -  
5 -// eslint-disable-next-line no-unused-vars  
6 const withdrawStatus = { 3 const withdrawStatus = {
7 0: '提现中', 4 0: '提现中',
8 1: '提现成功', 5 1: '提现成功',
9 2: '提现失败', 6 2: '提现失败',
10 }; 7 };
11 8
  9 +/**
  10 + * name => id 做为枚举常量
  11 + */
  12 +// eslint-disable-next-line no-unused-vars
  13 +const ClearingTypeName2Id = {
  14 + REVENUE: 1,
  15 + EXPEND: 2,
  16 +};
  17 +
12 export default function() { 18 export default function() {
13 return { 19 return {
14 - day: curDay,  
15 - date: curDay,  
16 - dateRange: [curDay, curDay],  
17 - beginTime: curDay,  
18 - endTime: curDay,  
19 - today: moment().format('YYYY-MM-DD'),  
20 - yesterday: moment()  
21 - .add(-1, 'days')  
22 - .format('YYYY-MM-DD'),  
23 - day7: moment()  
24 - .add(-6, 'days')  
25 - .format('YYYY-MM-DD'),  
26 - day30: moment()  
27 - .add(-29, 'days')  
28 - .format('YYYY-MM-DD'),  
29 - timeLimit: true,  
30 - tableCols: [  
31 - {  
32 - title: '账务ID',  
33 - key: 'id',  
34 - width: 60,  
35 - align: 'center', 20 + activate: 'all',
  21 + filters: {
  22 + createTime: {
  23 + label: '创建时间',
  24 + model: '',
36 }, 25 },
37 - {  
38 - title: '入账时间',  
39 - key: 'createTime', 26 + beginTime: {
  27 + model: '',
40 }, 28 },
41 - {  
42 - title: '订单号',  
43 - key: 'orderCode', 29 + endTime: {
  30 + model: '',
44 }, 31 },
45 - {  
46 - title: 'SKU',  
47 - key: 'productSku', 32 + timeFlag: {
  33 + label: '时间标志',
  34 + model: '',
48 }, 35 },
  36 + withdrawStatus: {
  37 + label: '提现状态',
  38 + model: '',
  39 + options: [
49 { 40 {
50 - title: '商品名称',  
51 - key: 'productName', 41 + value: 0,
  42 + label: '提现中',
52 }, 43 },
53 { 44 {
54 - title: '账务类型',  
55 - key: 'clearingType', 45 + value: 1,
  46 + label: '提现成功',
56 }, 47 },
57 { 48 {
58 - title: '子账务类型',  
59 - key: 'subClearingTypes', 49 + value: 2,
  50 + label: '提现失败',
60 }, 51 },
61 - {  
62 - title: '金额(元)',  
63 - key: 'amount', 52 + ],
64 }, 53 },
65 - {  
66 - title: '账户余额(元)',  
67 - key: '', 54 + targetAccount: {
  55 + label: '提现账户',
  56 + model: '',
68 }, 57 },
69 - {  
70 - title: '不可用余额(元)',  
71 - key: '', 58 + orderCode: {
  59 + label: '订单号',
  60 + model: '',
72 }, 61 },
73 - {  
74 - title: '提现状态',  
75 - key: 'status', 62 + sku: {
  63 + label: 'SKU',
  64 + model: '',
76 }, 65 },
  66 + productName: {
  67 + label: '商品名称',
  68 + model: '',
  69 + },
  70 + clearingType: {
  71 + label: '账务类型',
  72 + model: '',
  73 + options: [
77 { 74 {
78 - title: '提现申请日期',  
79 - key: 'applyTime', 75 + value: 1,
  76 + label: '收入',
80 }, 77 },
81 { 78 {
82 - title: '提现成功日期',  
83 - key: 'applySuccessTime', 79 + value: 2,
  80 + label: '支出',
84 }, 81 },
85 ], 82 ],
86 - pageData: {  
87 - total: 0,  
88 - current: 1,  
89 - pageSize: 20,  
90 }, 83 },
91 - filters: {  
92 - dateRange: {  
93 - label: '起止日期',  
94 - model: '',  
95 - labelSpan: 8,  
96 - },  
97 - beginTime: '',  
98 - endTime: '',  
99 - timeFlag: {  
100 - label: '时间标志', 84 + subClearingType: {
  85 + label: '子账务类型',
101 model: '', 86 model: '',
102 options: [ 87 options: [
103 { 88 {
104 value: 1, 89 value: 1,
105 - label: '今天', 90 + label: '交易服务费',
106 }, 91 },
107 { 92 {
108 value: 2, 93 value: 2,
109 - label: '昨天', 94 + label: '提现服务费',
  95 + },
  96 + ],
  97 + },
  98 + pageNo: 1,
  99 + pageSize: 10,
110 }, 100 },
  101 + tableCols: [
111 { 102 {
112 - value: 3,  
113 - label: '近7天', 103 + title: '账务ID',
  104 + key: 'id',
  105 + width: 60,
  106 + align: 'center',
114 }, 107 },
115 { 108 {
116 - value: 4,  
117 - label: '近30天', 109 + title: '结算时间',
  110 + key: 'createTime',
  111 + align: 'center',
  112 + render(h, params) {
  113 + const time = moment.unix(params.row.createTime);
  114 + return (
  115 + <div>
  116 + <div>{time.format('YYYY/MM/DD')}</div>
  117 + <div>{time.format('HH:mm:ss')}</div>
  118 + </div>
  119 + );
118 }, 120 },
119 - ],  
120 }, 121 },
121 - withdrawStatus: {  
122 - label: '提现状态',  
123 - model: '',  
124 - labelSpan: 6,  
125 - fieldSpan: 18,  
126 - options: [  
127 { 122 {
128 - value: 0,  
129 - label: '提现中', 123 + title: '订单号',
  124 + key: 'orderCode',
130 }, 125 },
131 { 126 {
132 - value: 1,  
133 - label: '提现成功', 127 + title: 'SKU',
  128 + key: 'productSku',
134 }, 129 },
135 { 130 {
136 - value: 2,  
137 - label: '提现失败', 131 + title: '商品名称',
  132 + key: 'productName',
138 }, 133 },
139 - ], 134 + {
  135 + title: '账务类型',
  136 + key: 'clearingType',
140 }, 137 },
141 - orderCode: {  
142 - label: '订单号',  
143 - model: '', 138 + {
  139 + title: '子账务类型',
  140 + key: 'subClearingTypes',
144 }, 141 },
145 - sku: {  
146 - label: 'SKU',  
147 - model: '', 142 + {
  143 + title: '商家实收(元)',
  144 + key: 'amount',
148 }, 145 },
149 - productName: {  
150 - label: '商品名称',  
151 - model: '', 146 + {
  147 + title: '提现状态',
  148 + key: 'status',
  149 + align: 'center',
  150 + render: (h, params) => {
  151 + const row = params.row;
  152 + const as = row.status;
  153 + const asText = as === 2 ? `${withdrawStatus[row.status]}(${row.rejectReason})` : withdrawStatus[as];
  154 + row.lineIndex = params.index;
  155 + return <p class={{ 'high-light': as === 2 }}>{asText}</p>;
152 }, 156 },
153 - brandId: {  
154 - label: '品牌',  
155 - model: '', 157 + className: 'status-column',
156 }, 158 },
157 - clearingType: {  
158 - label: '结算类型/账务类型',  
159 - model: '',  
160 - options: [  
161 { 159 {
162 - value: '30',  
163 - label: '订单出库', 160 + title: '提现申请日期',
  161 + key: 'applyTime',
  162 + align: 'center',
  163 + render(h, params) {
  164 + const applyTime = moment.unix(params.row.applyTime);
  165 + return (
  166 + <div>
  167 + <div>{applyTime.format('YYYY/MM/DD')}</div>
  168 + <div>{applyTime.format('HH:mm:ss')}</div>
  169 + </div>
  170 + );
164 }, 171 },
165 - {  
166 - value: '90',  
167 - label: 'VIP',  
168 }, 172 },
169 { 173 {
170 - value: '91',  
171 - label: '优惠券', 174 + title: '提现成功日期',
  175 + key: 'applySuccessTime',
  176 + align: 'center',
  177 + render(h, params) {
  178 + const appSuTime = moment.unix(params.row.applySuccessTime);
  179 + return (
  180 + <div>
  181 + <div>{appSuTime.format('YYYY/MM/DD')}</div>
  182 + <div>{appSuTime.format('HH:mm:ss')}</div>
  183 + </div>
  184 + );
  185 + },
172 }, 186 },
173 { 187 {
174 - value: '97',  
175 - label: '红包', 188 + title: '操作',
  189 + key: 'action',
  190 + width: 180,
  191 + align: 'center',
  192 + render: (h, params) => {
  193 + const row = params.row;
  194 + return (
  195 + <div>
  196 + <div class="cell-action-row">
  197 + <i-button type="primary" size="small" onClick={() => this.getDetailById(row.id)}>
  198 + 查看明细
  199 + </i-button>
  200 + </div>
  201 + </div>
  202 + );
  203 + },
  204 + className: 'action-column',
176 }, 205 },
177 ], 206 ],
178 - }, 207 + tableData: [],
  208 + pageData: {
  209 + total: 0,
  210 + current: 1,
  211 + pageSize: 10,
179 }, 212 },
180 }; 213 };
181 } 214 }
1 <template> 1 <template>
2 <div class="stat-shop"> 2 <div class="stat-shop">
3 <layout-body> 3 <layout-body>
4 - <p slot="title">服务费账单</p>  
5 - <layout-filter class="box-filter" :inline="true" :col="1">  
6 - <filter-item :label="filters.dateRange.label">  
7 - <Date-picker v-model="filters.dateRange.model" type="datetimerange"  
8 - :placeholder="filters.dateRange.label" format="yyyy-MM-dd" @on-change="dateRange">  
9 - </Date-picker> 4 + <p slot="title">交易服务明细</p>
  5 + <layout-filter ref="filter" :model="filters" class="box-filter" :inline="true" :col="1">
  6 + <filter-item label="起止时间">
  7 + <Date-picker
  8 + v-model="filters.createTime.model"
  9 + type="datetimerange"
  10 + format="yyyy-MM-dd"
  11 + placeholder="选择日期和时间"
  12 + @on-change="createTimeChange"
  13 + ></Date-picker>
10 <div class="quick"> 14 <div class="quick">
11 - <a href="javascript:;" @click="() => { changeLimit(0); }">今日</a>  
12 - <a href="javascript:;" @click="() => { changeLimit(1); }">昨天</a>  
13 - <a href="javascript:;" @click="() => { changeLimit(7); }">近7天</a>  
14 - <a href="javascript:;" @click="() => { changeLimit(30); }">近30天</a> 15 + <a
  16 + href="javascript:;"
  17 + @click="
  18 + () => {
  19 + timeFlag(1);
  20 + }
  21 + "
  22 + >今天</a
  23 + >
  24 + <a
  25 + href="javascript:;"
  26 + @click="
  27 + () => {
  28 + timeFlag(2);
  29 + }
  30 + "
  31 + >昨天</a
  32 + >
  33 + <a
  34 + href="javascript:;"
  35 + @click="
  36 + () => {
  37 + timeFlag(3);
  38 + }
  39 + "
  40 + >最近7天</a
  41 + >
  42 + <a
  43 + href="javascript:;"
  44 + @click="
  45 + () => {
  46 + timeFlag(4);
  47 + }
  48 + "
  49 + >最近30天</a
  50 + >
  51 + </div>
  52 + <div class="select-container">
  53 + <Select v-model.trim="filters.withdrawStatus.model" :placeholder="filters.withdrawStatus.label">
  54 + <Option v-for="option in filters.withdrawStatus.options" :key="option.value" :value="option.value">{{
  55 + option.label
  56 + }}</Option>
  57 + </Select>
  58 + </div>
  59 + <div class="select-container">
  60 + <Input v-model.trim="filters.targetAccount.model" :placeholder="filters.targetAccount.label" />
  61 + </div>
  62 + </filter-item>
  63 + <filter-item>
  64 + <div class="select-container">
  65 + <Input v-model.trim="filters.orderCode.model" :placeholder="filters.orderCode.label" />
  66 + </div>
  67 + <div class="select-container">
  68 + <Input v-model.trim="filters.sku.model" :placeholder="filters.sku.label" />
  69 + </div>
  70 + <div class="select-container">
  71 + <Input v-model.trim="filters.productName.model" :placeholder="filters.productName.label" />
  72 + </div>
  73 + <div class="select-container">
  74 + <Select v-model.trim="filters.clearingType.model" :placeholder="filters.clearingType.label">
  75 + <Option v-for="option in filters.clearingType.options" :key="option.value" :value="option.value">{{
  76 + option.label
  77 + }}</Option>
  78 + </Select>
  79 + </div>
  80 + <div class="select-container">
  81 + <Select v-model.trim="filters.subClearingType.model" :placeholder="filters.subClearingType.label">
  82 + <Option v-for="option in filters.subClearingType.options" :key="option.value" :value="option.value">{{
  83 + option.label
  84 + }}</Option>
  85 + </Select>
  86 + </div>
  87 + <div class="select-container">
  88 + <Button type="primary" @click="search">查询</Button>
  89 + <Button type="primary" @click="reset">全部</Button>
  90 + <Button>导出</Button>
15 </div> 91 </div>
16 </filter-item> 92 </filter-item>
  93 + </layout-filter>
  94 + <layout-tab>
  95 + <Tabs :value="activate" :animated="false" @on-click="switchTab">
  96 + <Tab-pane label="全部" name="all"></Tab-pane>
  97 + <Tab-pane :label="revenueTabLabel" name="REVENUE"></Tab-pane>
  98 + <Tab-pane :label="expendTabLabel" name="EXPEND"></Tab-pane>
  99 + </Tabs>
  100 + </layout-tab>
  101 + <layout-list>
  102 + <Table border :columns="tableCols" :data="tableData"></Table>
  103 + <Page
  104 + :total="pageData.total"
  105 + :current="pageData.current"
  106 + :page-size="pageData.pageSize"
  107 + show-total
  108 + @on-change="pageChange"
  109 + ></Page>
  110 + </layout-list>
17 </layout-body> 111 </layout-body>
18 -  
19 </div> 112 </div>
20 </template> 113 </template>
21 114
22 <script> 115 <script>
  116 +import _ from 'lodash';
  117 +import moment from 'moment';
  118 +import { TransactionList } from './store';
23 import FinanceService from 'services/finance/finance-service'; 119 import FinanceService from 'services/finance/finance-service';
24 -import { ShopAccountList } from './store';  
25 -import moment from "moment";  
26 120
27 export default { 121 export default {
28 data() { 122 data() {
29 - return ShopAccountList.call(this);  
30 - }, watch: {  
31 - date() {  
32 - this.loadData();  
33 - },  
34 - day(newDay) {  
35 - const curDay = moment().format('YYYY-MM-DD');  
36 - if (newDay === this.beginTime || !newDay) {  
37 - return;  
38 - }  
39 - this.dateRange = newDay !== this.curDay ? [newDay, curDay] : [newDay, newDay];  
40 - },  
41 - dateRange(newDate) {  
42 - this.beginTime = moment(Array.isArray(newDate) ? newDate[0] : newDate).format('YYYY-MM-DD');  
43 - this.endTime = moment(Array.isArray(newDate) ? newDate[1] : newDate).format('YYYY-MM-DD');  
44 - this.day = (this.beginTime === this.endTime) === this.today ? '' : this.beginTime; 123 + return TransactionList.call(this);
  124 + },
  125 + created() {
  126 + this.financeService = new FinanceService();
  127 + this.search();
  128 + },
  129 + computed: {
  130 + revenueTabLabel() {
  131 + return `收入`;
  132 + },
  133 + expendTabLabel() {
  134 + return `支出`;
  135 + },
  136 + },
  137 + methods: {
  138 + filterValues() {
  139 + const values = {
  140 + pageNo: 1,
  141 + pageSize: 10,
  142 + };
  143 + const fields = this.filters;
  144 + const keysMap = {
  145 + beginTime: 'beginTime',
  146 + endTime: 'endTime',
  147 + timeFlag: 'timeFlag',
  148 + withdrawStatus: 'withdrawStatus',
  149 + targetAccount: 'targetAccount',
  150 + orderCode: 'orderCode',
  151 + sku: 'sku',
  152 + productName: 'productName',
  153 + clearingType: 'clearingType',
  154 + subClearingType: 'subClearingType',
  155 + };
  156 +
  157 + if (this.activate !== 'all') {
  158 + // eslint-disable-next-line no-undef
  159 + values.clearingType = ClearingTypeName2Id[this.activate];
  160 + }
  161 +
  162 + if (this.enableFilter) {
  163 + _.each(keysMap, (val, key) => {
  164 + values[key] = fields[val].model;
  165 + });
  166 + }
  167 + return values;
  168 + },
  169 + switchTab(name) {
  170 + this.$router.replace({
  171 + name: `finance.withdraw.transactionlist`,
  172 + query: {
  173 + tab: name,
  174 + },
  175 + });
  176 + },
  177 + search() {
  178 + let params = {};
  179 + this.enableFilter = true;
  180 + params = this.filterValues();
  181 + this.list(params);
  182 + this.pageData.current = 1;
  183 + },
  184 + reset() {
  185 + let params = {};
  186 + this.enableFilter = false;
  187 + params = this.filterValues();
  188 + this.list(params);
45 this.pageData.current = 1; 189 this.pageData.current = 1;
46 - this.list(); 190 + },
  191 + timeFlag(flag) {
  192 + let params = {};
  193 + this.enableFilter = false;
  194 + params = this.filterValues();
  195 + params.timeFlag = flag;
  196 + this.list(params);
  197 + this.pageData.current = 1;
  198 + },
  199 + createTimeChange(time) {
  200 + if (!_.isArray(time)) {
  201 + time = time.split(' - ');
  202 + }
  203 + if ((time[0] + '').length) {
  204 + this.filters.beginTime.model = moment(time[0]).format('YYYY-MM-DD');
  205 + this.filters.endTime.model = moment(time[1]).format('YYYY-MM-DD');
  206 + }
  207 + },
  208 + pageChange(page) {
  209 + const params = this.filterValues();
  210 + params.pageNo = page;
  211 + this.pageData.current = page;
  212 + this.list(params);
  213 + },
  214 + list(params) {
  215 + this.financeService.shopWithdrawAccountList(params).then(ret => {
  216 + this.tableData = _.get(ret, 'data.records', []);
  217 + this.pageData.total = _.get(ret, 'data.totalCount', 0);
  218 + this.pageData.current = _.get(ret, 'data.pageNo', 0) + 1;
  219 + });
  220 + },
  221 + getDetailById(id) {
  222 + this.$router.push({
  223 + name: 'finance.withdraw.transaction-detail',
  224 + params: {
  225 + id,
  226 + },
  227 + });
47 }, 228 },
48 }, 229 },
49 }; 230 };
@@ -146,7 +327,9 @@ export default { @@ -146,7 +327,9 @@ export default {
146 327
147 .select-container { 328 .select-container {
148 display: inline-block; 329 display: inline-block;
149 - width: 220px; 330 + width: 200px;
  331 + margin-right: 15px;
  332 + margin-top: 5px;
150 } 333 }
151 } 334 }
152 335
@@ -154,4 +337,14 @@ export default { @@ -154,4 +337,14 @@ export default {
154 padding-left: 6px; 337 padding-left: 6px;
155 padding-right: 6px; 338 padding-right: 6px;
156 } 339 }
  340 +
  341 +.action-column {
  342 + .cell-action-row {
  343 + margin-top: 10px;
  344 +
  345 + &:last-child {
  346 + margin-bottom: 10px;
  347 + }
  348 + }
  349 +}
157 </style> 350 </style>