Authored by lea guo

订单列表删除

@@ -12,23 +12,38 @@ @@ -12,23 +12,38 @@
12 12
13 <script> 13 <script>
14 import { orderActionsMap } from "../../../../constants/order-constants"; 14 import { orderActionsMap } from "../../../../constants/order-constants";
  15 +import { createNamespacedHelpers } from "vuex";
  16 +
  17 +const { mapActions } = createNamespacedHelpers("order/orderList");
15 18
16 export default { 19 export default {
17 props: { 20 props: {
18 actionList: { 21 actionList: {
19 type: Array, 22 type: Array,
20 default: () => [] 23 default: () => []
  24 + },
  25 + code: {
  26 + type: Number,
  27 + default: 0
21 } 28 }
22 }, 29 },
23 methods: { 30 methods: {
  31 + ...mapActions(["deleteOrder"]),
24 onAction(action) { 32 onAction(action) {
  33 + const { owner } = this.$route.params;
25 if (action.name === orderActionsMap.DEL_ORDER.name) { 34 if (action.name === orderActionsMap.DEL_ORDER.name) {
26 - this.createDialog({ 35 + this.$createDialog({
27 type: "confirm", 36 type: "confirm",
28 content: "确认删除订单?", 37 content: "确认删除订单?",
29 - confirmBtn: { text: "确定" },  
30 - cancelBtn: { text: "取消" } 38 + onConfirm: async () => {
  39 + const isOk = await this.deleteOrder({
  40 + orderCode: this.code,
  41 + owner
31 }); 42 });
  43 + const txt = isOk ? "删除成功" : "删除失败";
  44 + this.$createToast({ txt, type: "txt" }).show();
  45 + }
  46 + }).show();
32 } 47 }
33 }, 48 },
34 createDialog(options) { 49 createDialog(options) {
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 <li v-for="order in orderList" :key="order.orderCode"> 11 <li v-for="order in orderList" :key="order.orderCode">
12 <order-list-item :order="order" /> 12 <order-list-item :order="order" />
13 <!-- 订单操作 --> 13 <!-- 订单操作 -->
14 - <order-actions :actionList="order.buttons" /> 14 + <order-actions :actionList="order.buttons" :code="order.orderCode" />
15 </li> 15 </li>
16 </ul> 16 </ul>
17 <Modal v-model="isShowModal" @on-sure="() => {}"></Modal> 17 <Modal v-model="isShowModal" @on-sure="() => {}"></Modal>
@@ -28,6 +28,11 @@ export default function() { @@ -28,6 +28,11 @@ export default function() {
28 state.pullUpLoad = false; 28 state.pullUpLoad = false;
29 } 29 }
30 }, 30 },
  31 + filterOrderList(state, orderCode) {
  32 + state.orderList = state.orderList.filter(
  33 + order => order.orderCode !== orderCode,
  34 + );
  35 + },
31 setOrderStatus(state, currentStatus) { 36 setOrderStatus(state, currentStatus) {
32 state.page = 1; 37 state.page = 1;
33 state.orderList = []; 38 state.orderList = [];
@@ -65,6 +70,29 @@ export default function() { @@ -65,6 +70,29 @@ export default function() {
65 commit('setOrderList', res.data); 70 commit('setOrderList', res.data);
66 } 71 }
67 }, 72 },
  73 +
  74 + /**
  75 + * 买家删除订单
  76 + * @param {
  77 + * orderCode: 订单编码
  78 + * owner: 订单来源
  79 + * } param1
  80 + */
  81 + async deleteOrder({ commit }, { orderCode, owner }) {
  82 + // owner: ownType
  83 + const res = await this.$api.get(`/api/${owner}/order/delete`, {
  84 + orderCode,
  85 + });
  86 + const { code, data } = res;
  87 +
  88 + // data 为true时删除成功
  89 + if (code === 200) {
  90 + if (data) {
  91 + commit('filterOrderList', orderCode);
  92 + }
  93 + }
  94 + return data;
  95 + },
68 }, 96 },
69 getters: {}, 97 getters: {},
70 }; 98 };
@@ -116,7 +116,7 @@ module.exports = { @@ -116,7 +116,7 @@ module.exports = {
116 }, 116 },
117 117
118 // 确认收货 118 // 确认收货
119 - '/api/buyer/confirm/receipt': { 119 + '/api/buy/confirm/receipt': {
120 ufo: true, 120 ufo: true,
121 auth: true, 121 auth: true,
122 api: 'ufo.buyer.confirm', 122 api: 'ufo.buyer.confirm',
@@ -126,7 +126,7 @@ module.exports = { @@ -126,7 +126,7 @@ module.exports = {
126 }, 126 },
127 127
128 // 不卖了 确认提示信息 128 // 不卖了 确认提示信息
129 - '/api/seller/trade/cancle/confirm/info': { 129 + '/api/sell/trade/cancle/confirm/info': {
130 auth: true, 130 auth: true,
131 ufo: true, 131 ufo: true,
132 api: 'ufo.sellerOrder.cancelConfirm', 132 api: 'ufo.sellerOrder.cancelConfirm',
@@ -136,7 +136,7 @@ module.exports = { @@ -136,7 +136,7 @@ module.exports = {
136 }, 136 },
137 137
138 // 不卖了 138 // 不卖了
139 - '/api/seller/trade/cancel': { 139 + '/api/sell/trade/cancel': {
140 auth: true, 140 auth: true,
141 ufo: true, 141 ufo: true,
142 api: 'ufo.sellerOrder.cancel', 142 api: 'ufo.sellerOrder.cancel',
@@ -146,7 +146,7 @@ module.exports = { @@ -146,7 +146,7 @@ module.exports = {
146 }, 146 },
147 147
148 // 取消订单 148 // 取消订单
149 - '/api/buyer/trade/cancel': { 149 + '/api/buy/trade/cancel': {
150 auth: true, 150 auth: true,
151 ufo: true, 151 ufo: true,
152 api: 'ufo.buyer.cancel', 152 api: 'ufo.buyer.cancel',
@@ -155,31 +155,31 @@ module.exports = { @@ -155,31 +155,31 @@ module.exports = {
155 }, 155 },
156 }, 156 },
157 157
158 - // 买家删除订单  
159 - '/api/buyer/order/delete': { 158 + // 买家取消订单预信息
  159 + '/api/buy/trade/cancel/confirm/info': {
160 auth: true, 160 auth: true,
161 ufo: true, 161 ufo: true,
162 - api: 'ufo.buyer.delete', 162 + api: 'ufo.buyer.cancelCompute',
163 params: { 163 params: {
164 orderCode: { type: Number, require: true }, // 订单编号 164 orderCode: { type: Number, require: true }, // 订单编号
165 }, 165 },
166 }, 166 },
167 167
168 - // 卖家删除订单  
169 - '/api/seller/order/delete': { 168 + // 买家删除订单
  169 + '/api/buy/order/delete': {
170 auth: true, 170 auth: true,
171 ufo: true, 171 ufo: true,
172 - api: 'ufo.sellerOrder.delete', 172 + api: 'ufo.buyer.delete',
173 params: { 173 params: {
174 orderCode: { type: Number, require: true }, // 订单编号 174 orderCode: { type: Number, require: true }, // 订单编号
175 }, 175 },
176 }, 176 },
177 177
178 - // 买家取消订单预信息  
179 - '/pai/buyer/trade/cancel/info': { 178 + // 卖家删除订单
  179 + '/api/sell/order/delete': {
180 auth: true, 180 auth: true,
181 ufo: true, 181 ufo: true,
182 - api: 'ufo.buyer.cancelCompute', 182 + api: 'ufo.sellerOrder.delete',
183 params: { 183 params: {
184 orderCode: { type: Number, require: true }, // 订单编号 184 orderCode: { type: Number, require: true }, // 订单编号
185 }, 185 },
@@ -239,7 +239,7 @@ module.exports = { @@ -239,7 +239,7 @@ module.exports = {
239 auth: true, 239 auth: true,
240 api: 'ufo.order.compute', 240 api: 'ufo.order.compute',
241 params: { 241 params: {
242 - skup: { type: Number, require: true } 242 + skup: { type: Number, require: true },
243 }, 243 },
244 }, 244 },
245 245
@@ -250,7 +250,7 @@ module.exports = { @@ -250,7 +250,7 @@ module.exports = {
250 path: 'shopping', 250 path: 'shopping',
251 api: 'ufo.order.payment', 251 api: 'ufo.order.payment',
252 params: { 252 params: {
253 - skup: { type: Number, require: true } 253 + skup: { type: Number, require: true },
254 }, 254 },
255 }, 255 },
256 256
@@ -261,7 +261,7 @@ module.exports = { @@ -261,7 +261,7 @@ module.exports = {
261 path: 'shopping', 261 path: 'shopping',
262 api: 'ufo.order.selectCoupon', 262 api: 'ufo.order.selectCoupon',
263 params: { 263 params: {
264 - skup: { type: Number, require: true } 264 + skup: { type: Number, require: true },
265 }, 265 },
266 }, 266 },
267 267