2021-05-13 10:56:04 +08:00
|
|
|
|
<template>
|
|
|
|
|
<Modal
|
|
|
|
|
:title="title"
|
|
|
|
|
:styles="{ top: '120px' }"
|
|
|
|
|
width="750"
|
|
|
|
|
@on-cancel="clickClose"
|
|
|
|
|
@on-ok="clickOK"
|
|
|
|
|
v-model="flag"
|
|
|
|
|
:mask-closable="false"
|
|
|
|
|
scrollable
|
|
|
|
|
>
|
|
|
|
|
<goodsDialog
|
2021-05-24 18:14:06 +08:00
|
|
|
|
@selected="(val) => {goodsData = val;}"
|
|
|
|
|
:selectedWay='goodsData'
|
2021-05-13 10:56:04 +08:00
|
|
|
|
ref="goodsDialog"
|
|
|
|
|
v-if="goodsFlag"
|
|
|
|
|
/>
|
|
|
|
|
<linkDialog
|
2021-05-24 18:14:06 +08:00
|
|
|
|
@selectedLink="(val) => {linkData = val;}"
|
2021-05-13 10:56:04 +08:00
|
|
|
|
v-else
|
|
|
|
|
class="linkDialog"
|
|
|
|
|
/>
|
|
|
|
|
</Modal>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
import goodsDialog from "./goods-dialog";
|
|
|
|
|
import linkDialog from "./link-dialog";
|
|
|
|
|
export default {
|
|
|
|
|
components: {
|
|
|
|
|
goodsDialog,
|
|
|
|
|
linkDialog,
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
title: "选择", // 模态框标题
|
|
|
|
|
goodsFlag: false, // 是否商品选择器
|
2021-05-24 18:14:06 +08:00
|
|
|
|
goodsData: [], //选择的商品
|
2021-05-13 10:56:04 +08:00
|
|
|
|
linkData: "", //选择的链接
|
|
|
|
|
flag: false, // 控制模态框显隐
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
// 关闭弹窗
|
|
|
|
|
clickClose() {
|
|
|
|
|
this.$emit("closeFlag", false);
|
|
|
|
|
this.goodsFlag = false;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 单选商品
|
|
|
|
|
singleGoods(){
|
|
|
|
|
var timer = setInterval(() => {
|
|
|
|
|
if (this.$refs.goodsDialog) {
|
|
|
|
|
|
|
|
|
|
this.$refs.goodsDialog.type = "single";
|
|
|
|
|
clearInterval(timer);
|
|
|
|
|
}
|
|
|
|
|
}, 100);
|
|
|
|
|
},
|
2021-05-24 18:14:06 +08:00
|
|
|
|
clickOK() { // 确定按钮回调,
|
2021-05-13 10:56:04 +08:00
|
|
|
|
if (this.goodsFlag) {
|
|
|
|
|
this.$emit("selectedGoodsData", this.goodsData);
|
|
|
|
|
} else {
|
|
|
|
|
this.$emit("selectedLink", this.linkData);
|
|
|
|
|
}
|
|
|
|
|
this.clickClose();
|
|
|
|
|
},
|
2021-05-24 18:14:06 +08:00
|
|
|
|
open (type) { // 父组件通过ref调用,打开商品选择器
|
2021-05-13 10:56:04 +08:00
|
|
|
|
this.flag = true;
|
|
|
|
|
if(type == 'goods'){
|
|
|
|
|
this.goodsFlag = true;
|
|
|
|
|
} else {
|
|
|
|
|
this.goodsFlag = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
2021-05-24 18:14:06 +08:00
|
|
|
|
close(){ // 关闭组件
|
2021-05-13 10:56:04 +08:00
|
|
|
|
this.flag = false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
/deep/ .ivu-modal {
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
height: 650px !important;
|
|
|
|
|
}
|
|
|
|
|
/deep/ .ivu-modal-body {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 500px;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
</style>
|