Authored by lea guo

订单列表 确认弹框

<template>
<popup
type="dialog"
:z-index="zIndex"
:mask="true"
:center="true"
v-show="isVisible"
@mask-click="maskClick"
>
<div class="cube-dialog-main">
<span class="cube-dialog-close" v-show="showClose" @click="close"
><i class="cubeic-close"></i
></span>
<div :class="containerClass">
<h2 v-if="title || $slots.title" class="cube-dialog-title">
<slot name="title">
<p class="cube-dialog-title-def">{{ title }}</p>
</slot>
</h2>
<div class="cube-dialog-content">
<slot name="content">
<div class="cube-dialog-content-def">
<p v-html="content" v-if="content"></p>
</div>
</slot>
</div>
<div
class="cube-dialog-btns confirm-dialog-btns-wrapper"
:class="{ 'border-right-1px': isConfirm }"
>
<slot name="btns">
<a
:href="_cancelBtn.href"
class="cube-dialog-btn border-top-1px"
:class="{
'cube-dialog-btn_highlight': _cancelBtn.active,
'cube-dialog-btn_disabled': _cancelBtn.disabled
}"
v-if="isConfirm"
@click="cancel"
>{{ _cancelBtn.text }}</a
>
<a
:href="_confirmBtn.href"
class="cube-dialog-btn border-top-1px"
:class="{
'cube-dialog-btn_highlight': _confirmBtn.active,
'cube-dialog-btn_disabled': _confirmBtn.disabled
}"
@click="confirm"
>{{ _confirmBtn.text }}</a
>
</slot>
</div>
</div>
</div>
</popup>
</template>
<script>
import { Popup } from "cube-ui";
import popupMixin from "cube-ui/src/common/mixins/popup";
import visibilityMixin from "cube-ui/src/common/mixins/visibility";
import localMixin from "cube-ui/src/common/mixins/locale";
const COMPONENT_NAME = "confirm-dialog";
const EVENT_CONFIRM = "confirm";
const EVENT_CANCEL = "cancel";
const EVENT_CLOSE = "close";
const defHref = "javascript:;";
const defConfirmBtn = {
textType: "ok",
active: true,
disabled: false,
href: defHref
};
const defCancelBtn = {
textType: "cancel",
active: false,
disabled: false,
href: defHref
};
const parseBtn = function(btn, defBtn) {
if (typeof btn === "string") {
btn = { text: btn };
}
const text = defBtn && this.$t(defBtn.textType);
return Object.assign({}, defBtn, { text }, { btn });
};
export default {
name: COMPONENT_NAME,
mixins: [popupMixin, visibilityMixin, localMixin],
props: {
type: {
type: String,
default: "confirm"
},
title: {
type: String,
default: ""
},
content: {
type: String,
default: ""
},
showClose: {
type: Boolean,
default: false
},
confirmBtn: {
type: [Object, String],
default() {
return { ...defConfirmBtn };
}
},
cancleBtn: {
type: [Object, String],
default() {
return {
...defCancelBtn
};
}
}
},
components: {
Popup
},
computed: {
_confirmBtn() {
return parseBtn.call(this, this.confirmBtn, defConfirmBtn);
},
_cancelBtn() {
return parseBtn.call(this, this.cancelBtn, defCancelBtn);
},
isConfirm() {
return this.type === "confirm";
},
containerClass() {
return `cube-dialog-${this.type}`;
}
},
methods: {
maskClick(e) {
this.maskClosable && this.cancel(e);
},
confirm() {
if (this._confirmBtn.disabled) {
return;
}
this.hide();
this.$emit(EVENT_CONFIRM, e);
},
cancel(e) {
if (this._cancelBtn.disabled) {
return;
}
this.hide();
this.$emit(EVENT_CANCEL, e);
},
close(e) {
this.hide();
this.$emit(EVENT_CLOSE, e);
}
}
};
</script>
<style lang="scss" scoped>
.confirm-dialog-btns-wrapper {
display: flex;
flex-direction: row-reverse;
}
</style>
\ No newline at end of file
... ...
import ConfirmDialog from './confirm-dialog';
import createApi from 'utils/create-api';
ConfirmDialog.install = function(Vue) {
Vue.component(ConfirmDialog.name, ConfirmDialog);
createApi(
Vue,
ConfirmDialog,
['confirm', 'cancel', 'close', 'btn-click', 'link-click'],
true,
);
};
export default ConfirmDialog;
... ...
... ... @@ -12,6 +12,7 @@ import OrderPayType from 'components/order-pay-type';
import OrderCouponList from 'components/order-coupon-list';
import OrderPromotionList from 'components/order-promotion-list';
import Bind from 'components/bind';
import ConfirmDialog from 'components/confirm-dialog';
import sdk from 'yoho-activity-sdk';
... ... @@ -46,6 +47,7 @@ Vue.use(OrderPayType);
Vue.use(OrderCouponList);
Vue.use(OrderPromotionList);
Vue.use(Bind);
Vue.use(ConfirmDialog);
initClient(store);
... ...
... ... @@ -16,15 +16,8 @@ import {
ownType
} from "../../../../constants/order-constants";
import { createNamespacedHelpers } from "vuex";
import CancelConfirmInfo from "./order-list/cancel-confirm-info";
const { mapActions, mapState } = createNamespacedHelpers("order/orderList");
const { mapMutations: orderMapMutations } = createNamespacedHelpers("order");
const { mapMutations: inSaleOrderMapMutations } = createNamespacedHelpers(
"order/inSaleOrderList"
);
const { mapActions } = createNamespacedHelpers("order/orderList");
export default {
props: {
... ... @@ -34,7 +27,6 @@ export default {
}
},
computed: {
...mapState(["cancelConfirmInfo"]),
actionList: function() {
return this.order.buttons;
}
... ...
<template>
<div class="cnacel-confirm-info">
<p v-if="confirmInfo.confirmDesc">{{ confirmInfo.confirmDesc }}</p>
</div>
</template>
<script>
export default {
props: {
confirmInfo: { type: Object, default: null }
}
};
</script>
<style lang="scss" scoped>
.cnacel-confirm-info {
display: flex;
justify-content: center;
}
</style>
\ No newline at end of file
... ... @@ -92,7 +92,6 @@ import DetailHeader from "./components/header";
import DetailFooter from "./components//detail-footer";
import OrderActions from "../components/order-actions";
import CancelConfirmInfo from "../components/order-list/cancel-confirm-info";
import {
orderActionsMap,
... ... @@ -174,32 +173,22 @@ export default {
orderCode,
owner
});
this.$createDialog(
{
type: "confirm",
confirmBtn: { text: "取消订单" },
cancelBtn: { text: "保留订单" },
onConfirm: async () => {
const isOk = await this.cancelTrade({
orderCode,
owner
});
if (isOk) {
this.fetchOrderDetail(this.$route.params);
}
const txt = isOk ? "取消成功" : "取消失败";
this.$createToast({ txt, type: "txt" }).show();
this.$createDialog({
type: "confirm",
confirmBtn: { text: "取消订单" },
cancelBtn: { text: "保留订单" },
onConfirm: async () => {
const isOk = await this.cancelTrade({
orderCode,
owner
});
if (isOk) {
this.fetchOrderDetail(this.$route.params);
}
},
createElement => {
return [
createElement(CancelConfirmInfo, {
slot: "content",
props: { confirmInfo }
})
];
const txt = isOk ? "取消成功" : "取消失败";
this.$createToast({ txt, type: "txt" }).show();
}
).show();
}).show();
break;
default:
return;
... ...
... ... @@ -101,7 +101,6 @@ import DetailHeader from "./components/header";
import DetailFooter from "./components//detail-footer";
import OrderActions from "../components/order-actions";
import CancelConfirmInfo from "../components/order-list/cancel-confirm-info";
import {
orderActionsMap,
... ... @@ -184,32 +183,22 @@ export default {
orderCode,
owner
});
this.$createDialog(
{
type: "confirm",
confirmBtn: { text: "不卖了" },
cancelBtn: { text: "继续出售" },
onConfirm: async () => {
const isOk = await this.cancelTrade({
orderCode,
owner
});
if (isOk) {
this.fetchOrderDetail(this.$route.params);
}
// const txt = isOk ? "取消成功" : "取消失败";
// this.$createToast({ txt, type: "txt" }).show();
this.$createDialog({
type: "confirm",
confirmBtn: { text: "不卖了" },
cancelBtn: { text: "继续出售" },
onConfirm: async () => {
const isOk = await this.cancelTrade({
orderCode,
owner
});
if (isOk) {
this.fetchOrderDetail(this.$route.params);
}
},
createElement => {
return [
createElement(CancelConfirmInfo, {
slot: "content",
props: { confirmInfo }
})
];
// const txt = isOk ? "取消成功" : "取消失败";
// this.$createToast({ txt, type: "txt" }).show();
}
).show();
}).show();
break;
default:
return;
... ...
... ... @@ -47,7 +47,6 @@ import EmptyList from "../../../components//ufo-no-item";
import OrderActions from "../components/order-actions";
import CountDown from "../components/count-down";
import CancelConfirmInfo from "../components/order-list/cancel-confirm-info";
import {
orderActionsMap,
... ... @@ -126,32 +125,22 @@ export default {
orderCode,
owner
});
this.$createDialog(
{
type: "confirm",
confirmBtn: { text: "不卖了" },
cancelBtn: { text: "继续出售" },
onConfirm: async () => {
const isOk = await this.cancelTrade({
orderCode,
owner
});
if (isOk) {
this.filterOrderList(orderCode);
}
// const txt = isOk ? "取消成功" : "取消失败";
// this.$createToast({ txt, type: "txt" }).show();
this.$createDialog({
type: "confirm",
confirmBtn: { text: "不卖了" },
cancelBtn: { text: "继续出售" },
onConfirm: async () => {
const isOk = await this.cancelTrade({
orderCode,
owner
});
if (isOk) {
this.filterOrderList(orderCode);
}
},
createElement => {
return [
createElement(CancelConfirmInfo, {
slot: "content",
props: { confirmInfo }
})
];
// const txt = isOk ? "取消成功" : "取消失败";
// this.$createToast({ txt, type: "txt" }).show();
}
).show();
}).show();
break;
default:
return;
... ...
... ... @@ -55,7 +55,6 @@ import EmptyList from "../../../components//ufo-no-item";
import OrderActions from "../components/order-actions";
import CountDown from "../components/count-down";
import CancelConfirmInfo from "../components/order-list/cancel-confirm-info";
const { mapActions, mapState, mapMutations } = createNamespacedHelpers(
"order/orderList"
... ... @@ -82,7 +81,7 @@ export default {
},
// 获取订单数据
asyncData({ store, router }) {
asyncData() {
// const { owner, status } = router.params;
// store.dispatch("order/orderList/fetchOrderList", { owner, status });
},
... ... @@ -124,9 +123,10 @@ export default {
switch (action.name) {
// 删除订单
case orderActionsMap.DEL_ORDER.name:
this.$createDialog({
type: "confirm",
this.$createConfirmDialog({
content: "确认删除订单?",
confirmBtn: { disabled: true },
cancelBtn: { active: true },
onConfirm: async () => {
const isOk = await this.deleteOrder({
orderCode,
... ... @@ -146,39 +146,31 @@ export default {
orderCode,
owner
});
this.$createDialog(
{
type: "confirm",
confirmBtn: { text: "取消订单" },
cancelBtn: { text: "保留订单" },
onConfirm: async () => {
const isOk = await this.cancelTrade({
orderCode,
owner
});
if (isOk) {
this.resetData();
this.fetchData(this.$route.params);
}
const txt = isOk ? "取消成功" : "取消失败";
this.$createToast({ txt, type: "txt" }).show();
this.$createDialog({
type: "confirm",
confirmBtn: { text: "取消订单" },
cancelBtn: { text: "保留订单" },
onConfirm: async () => {
const isOk = await this.cancelTrade({
orderCode,
owner
});
if (isOk) {
this.resetData();
this.fetchData(this.$route.params);
}
},
createElement => {
return [
createElement(CancelConfirmInfo, {
slot: "content",
props: { confirmInfo }
})
];
const txt = isOk ? "取消成功" : "取消失败";
this.$createToast({ txt, type: "txt" }).show();
}
).show();
}).show();
break;
}
}
},
watch: {
$route() {}
// routerHistory(v) {
// console.log("---------routerHistory---------", v);
// }
}
};
</script>
... ...