You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 lines
3.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div>
<!-- 编辑-->
<xy-dialog :is-show.sync="isShow" title="项目白名单" type="normal" ref="addActivityWhite" @on-ok="editor">
<div>
<el-tag :key="tag" v-for="tag in dynamicTags" closable :disable-transitions="false" @close="handleClose(tag)">
{{tag.mobile}}
</el-tag>
<el-input class="input-new-tag" v-if="inputVisible" v-model="inputValue" ref="saveTagInput" size="small"
@keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm">
</el-input>
<el-button v-else class="button-new-tag" size="small" @click="showInput">+ 新增</el-button>
</div>
</xy-dialog>
</div>
</template>
<script>
import {
save,
show,
index,
destroy
} from "@/api/activity/components/addActivityWhite";
export default {
data() {
return {
isShow: false,
dynamicTags: [],
inputVisible: false,
inputValue: ''
}
},
watch: {
isShow(newVal) {
if (newVal) {
this.dynamicTags=[];
this.inputVisible=false;
this.load();
}
}
},
methods: {
handleClose(tag) {
destroy({
id: tag.id
}).then(response => {
this.$message.success("操作成功");
this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
}).catch(error => {
//reject(error)
this.$message.error("操作失败");
})
},
showInput() {
this.inputVisible = true;
this.$nextTick(_ => {
this.$refs.saveTagInput.$refs.input.focus();
});
},
handleInputConfirm() {
let inputValue = this.inputValue;
if (inputValue) {
let mod = {
mobile: inputValue,
activity_list_id: this.id
}
save(mod).then(res => {
this.load();
this.inputVisible = false;
this.inputValue = '';
}).error(res => {
})
}
},
async load() {
let res = await index({
activity_list_id: this.id,
page_size: 9999,
page: 1
})
this.dynamicTags = res.data;
}
},
computed: {
},
mounted() {
let that = this;
}
}
</script>
<style>
.el-tag+.el-tag {
margin-left: 10px;
margin-bottom: 10px;
}
.button-new-tag {
margin-left: 10px;
height: 32px;
line-height: 30px;
padding-top: 0;
padding-bottom: 0;
}
.input-new-tag {
width: 120px;
margin-left: 10px;
vertical-align: bottom;
}
</style>
<style scoped lang="scss">
.contract-add-plan {
min-height: 30px;
border: 1px solid #dcdee2;
border-radius: 4px;
display: flex;
flex-wrap: wrap;
align-items: center;
align-content: center;
padding: 0 8px;
&-no-plan {
height: 30px;
line-height: 30px;
color: #CDD0D5;
}
}
.xy-table-item-label {
width: 140px;
}
.xy-table-item-price {
position: relative;
&::after {
z-index: 1;
position: absolute;
right: 0;
top: 0;
content: ''
}
::v-deep .el-input__clear {
position: relative;
right: 30px;
z-index: 2;
}
}
.xy-table-item-price-wan {
position: relative;
&::after {
position: absolute;
right: 0;
top: 0;
content: ''
}
::v-deep .el-input__clear {
position: relative;
right: 46px;
z-index: 2;
}
}
</style>