<template>
|
<div>
|
<card>
|
<Form
|
ref="searchForm"
|
@keydown.enter.native="handleSearch"
|
:model="searchForm"
|
inline
|
:label-width="70"
|
class="search-form"
|
>
|
<Form-item label="标签名称" prop="tagName">
|
<Input
|
type="text"
|
v-model="searchForm.tagName"
|
clearable
|
@on-clear="handleSearch"
|
@on-change="handleSearch"
|
style="width: 160px"
|
/>
|
</Form-item>
|
<Form-item label="标签来源" prop="createType">
|
<Select
|
v-model="searchForm.createType"
|
clearable
|
@on-clear="handleSearch"
|
@on-change="handleSearch"
|
style="width: 160px"
|
>
|
<Option value="SYSTEM">系统创建</Option>
|
<Option value="USER">用户创建</Option>
|
</Select>
|
</Form-item>
|
<Button
|
@click="handleSearch"
|
type="primary"
|
icon="ios-search"
|
class="search-btn"
|
>搜索</Button
|
>
|
</Form>
|
|
<Row class="operation padding-row">
|
<Button @click="openAdd" type="info">添加</Button>
|
<Button @click="delBatch" type="error">批量删除</Button>
|
</Row>
|
|
<Table
|
:loading="loading"
|
border
|
:columns="columns"
|
:data="tagList"
|
ref="table"
|
sortable="custom"
|
@on-sort-change="changeSort"
|
@on-selection-change="showSelect"
|
>
|
<template slot-scope="{ row, index }" slot="action">
|
<Button type="info" size="small" style="margin-right: 5px" @click="openEdit(row)">编辑标签</Button>
|
<Button type="error" size="small" style="margin-right: 5px" @click="del(row)">删除标签</Button>
|
</template>
|
</Table>
|
|
<Row type="flex" justify="end" class="mt_10">
|
<Page
|
:current="searchForm.pageNumber"
|
:total="total"
|
:page-size="searchForm.pageSize"
|
@on-change="changePage"
|
@on-page-size-change="changePageSize"
|
:page-size-opts="[10, 20, 50]"
|
size="small"
|
show-total
|
show-elevator
|
show-sizer
|
></Page>
|
</Row>
|
|
<Modal
|
v-model="modelShow"
|
:title="modelTitle"
|
>
|
<Form ref="form" :model="form" :label-width="70" :rules="rules">
|
<FormItem label="标签名称" prop="tagName">
|
<Input v-model="form.tagName" autocomplete="off"/>
|
</FormItem>
|
</Form>
|
<div slot="footer">
|
<Button type="text" @click="modelClose">取消</Button>
|
<Button type="primary" :loading="submitLoading" @click="saveOrUpdate">提交</Button>
|
</div>
|
</Modal>
|
</card>
|
</div>
|
</template>
|
|
<script>
|
import JsonExcel from "vue-json-excel";
|
import {getPageTagList,addCustomerTag,editTag,} from "@/api/customer";
|
|
|
|
export default {
|
name:"customer-tag",
|
components:{
|
"download-excel": JsonExcel,
|
},
|
data(){
|
return{
|
loading:false,
|
columns:[
|
{
|
type: 'selection',
|
width: 60,
|
align: 'center'
|
},
|
{
|
title:'标签名称',
|
key: 'tagName',
|
minWidth: 60,
|
tooltip: true,
|
},
|
{
|
title: '操作',
|
key: 'action',
|
slot: 'action',
|
minWidth: 150,
|
align: 'center'
|
}
|
],
|
total:0,
|
tagList:[],
|
|
searchForm: {
|
// 搜索框初始化对象
|
pageNumber: 1, // 当前页数
|
pageSize: 10, // 页面大小
|
tagName: '', // 标签名称
|
createType: '', // 创建方式
|
|
},
|
// 对话框标题
|
modelTitle:'',
|
modelShow:false,
|
submitLoading:false,
|
// 表单
|
form: {
|
id: '',
|
tagName: '',
|
createType: 'SYSTEM'
|
},
|
rules: {
|
tagName: [
|
{required: true, message: "标签名称不能为空", trigger: "blur"}
|
],
|
},
|
|
//多选
|
selectCount: 0, // 已选数量
|
selectList: [], // 已选数据列表
|
}
|
},
|
mounted(){
|
this.init();
|
},
|
methods:{
|
init(){
|
this.getTagList()
|
},
|
getTagList(){
|
this.loading = true;
|
getPageTagList(this.searchForm).then((res) => {
|
this.loading = false;
|
if (res.code === 200) {
|
this.tagList = res.data;
|
this.total = res.total;
|
}
|
});
|
this.loading = false;
|
},
|
handleSearch(){
|
this.searchForm.pageNumber = 1;
|
this.searchForm.pageSize = 10;
|
this.getTagList();
|
},
|
openAdd(){
|
this.modelTitle = "新增标签"
|
this.modelShow = true
|
},
|
saveOrUpdate() {
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
this.submitLoading = true
|
if (this.form.id) {
|
// 修改
|
editTag(this.form).then(res => {
|
if (res.code === 200) {
|
this.$Message.success("修改成功");
|
this.modelClose()
|
this.getTagList()
|
}
|
})
|
} else {
|
// 新增
|
addCustomerTag(this.form).then(res => {
|
if (res.code === 200) {
|
this.$Message.success("添加成功");
|
this.modelClose()
|
this.getTagList()
|
}
|
})
|
}
|
}
|
});
|
},
|
// 关闭弹窗
|
modelClose() {
|
this.submitLoading = false
|
this.modelShow = false
|
},
|
delBatch(){
|
if (this.selectCount <= 0) {
|
this.$Message.warning("您还未选择要删除的数据");
|
return;
|
}
|
this.$Modal.confirm({
|
title: "确认删除",
|
content: "您确认要删除所选的 " + this.selectCount + " 条数据?",
|
loading: true,
|
onOk: () => {
|
|
}
|
});
|
},
|
|
openEdit(row){
|
|
},
|
del(row){
|
|
},
|
|
|
|
|
// 分页 改变页码
|
changePage(v) {
|
this.searchForm.pageNumber = v;
|
this.getTagList();
|
},
|
// 分页 改变页数
|
changePageSize(v) {
|
this.searchForm.pageNumber = 1;
|
this.searchForm.pageSize = v;
|
this.getTagList();
|
},
|
|
changeSort(){
|
|
},
|
showSelect(){
|
this.selectList = e.map(d => d.id);
|
this.selectCount = e.length;
|
},
|
}
|
}
|
|
</script>
|
<style lang="scss" scoped>
|
.export {
|
margin: 10px 20px 10px 0;
|
}
|
.export-excel-wrapper {
|
display: inline;
|
}
|
.order-tab {
|
width: 950px;
|
height: 36px;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
background-color: #f0f0f0;
|
padding: 0 10px;
|
margin-bottom: 10px;
|
div {
|
text-align: center;
|
padding: 4px 12px;
|
border-radius: 4px;
|
cursor: pointer;
|
}
|
.current {
|
background-color: #ffffff;
|
}
|
}
|
</style>
|