refundDetail.vue
4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<template>
<el-dialog :before-close="handleClose"
class="relateStore"
:close-on-click-modal="false"
title="请选择退款明细"
:visible.sync="refundVisible"
width="70%">
<div>
<el-table ref="seletingTable"
border
class="table"
:data="tableData"
@select="handleChange"
@select-all="handleAll">
<el-table-column align="center"
:selectable="selectableFn"
type="selection"
width="55" />
<template v-for="item in tableColumn">
<el-table-column align="center"
:label="item.label"
:prop="item.prop">
<template #default="scope">
<span>
{{ scope.row[item.prop] ? item.unit ? item.unit + scope.row[item.prop] : scope.row[item.prop] : "-" }}
</span>
</template>
</el-table-column>
</template>
</el-table>
<div class="total">
可选可退总价:<div class="price">
¥{{ total }}
</div>
</div>
</div>
<template #footer>
<span class="dialog-footer">
<el-button @click="handleClose">取 消</el-button>
<el-button :disabled="!refundSubOrderCode"
type="primary"
@click="handleConfirm">
下一步
</el-button>
</span>
</template>
</el-dialog>
</template>
<script>
import { getGoodsSubOrder } from "@api/point";
export default {
name: "RefundDetail",
props: {
refundVisible: {
type: Boolean,
default: false,
},
dataInfo: {
type: Object,
default: {},
},
},
data() {
return {
tableData: [],
tableColumn: [
{
label: "子订单编码",
prop: "subOrderCode",
},
{
label: "商品名称",
prop: "goodsName",
},
{
label: "商品别名",
prop: "goodsAlias",
},
{
label: "商品ID",
prop: "goodsCommodityCode",
},
{
label: "分类",
prop: "upgradeGoodsTypeName",
},
{
label: "售价",
prop: "upgradePrice",
unit: "¥",
},
{
label: "数量/件",
prop: "number",
},
{
label: "支付金额",
prop: "totalPrice",
unit: "¥",
},
],
total: 0,
refundSubOrderCode: "",
refundApplyDetailList: [],
isAll: false,
// 是否只有一个子订单并且未退过款的
isOneSubFirst: false,
};
},
watch: {
dataInfo(val) {
console.log(val);
if (val && val.orderCode)
this.getList(val.orderCode);
},
},
methods: {
// 设置禁用
selectableFn(row) {
console.log(row);
if (row.status == 2)
return false;
else return true;
},
async getList(orderCode) {
const res = await getGoodsSubOrder({ orderCode });
this.tableData = res;
this.isOneSubFirst = this.tableData.length == 1 && this.tableData.every(item => item.status == 1);
this.$refs.seletingTable.toggleAllSelection();
},
handleChange(selection) {
console.log(selection);
this.isAll = selection.length == this.tableData.length;
this.getParams(selection);
},
handleAll(selection) {
console.log(selection);
this.isAll = selection.length == this.tableData.length;
this.getParams(selection);
},
getParams(selection) {
let _total = 0;
let _refundSubOrderCode = [];
selection.forEach((item) => {
_total += item.totalPrice;
_refundSubOrderCode.push(item.subOrderCode);
});
this.total = Number.parseFloat(_total.toFixed(2));
this.refundSubOrderCode = _refundSubOrderCode.join("/");
this.refundApplyDetailList = selection;
console.log(this.refundSubOrderCode);
},
handleConfirm() {
const { refundSubOrderCode, refundApplyDetailList, total, isAll, isOneSubFirst } = this;
this.$emit("handleConfirm", {
total,
refundSubOrderCode,
isAll,
refundApplyDetailList,
isOneSubFirst,
});
},
handleClose() {
this.$emit("handleClose");
},
},
};
</script>
<style lang="scss" scoped>
.total {
display: flex;
align-items: center;
color: #666666;
font-size: 14px;
.price {
color: #2a58ad;
margin-left: 10px;
}
}
</style>