Commit 217b2ad4 by 姜鹏凯

标签组可更改

1 parent 796954e9
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
}) })
} }
}, },
data () { data() {
return { return {
// 添加标签输入框 // 添加标签输入框
newInput: '', newInput: '',
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
watch: {}, watch: {},
computed: { computed: {
Pvisible: { Pvisible: {
get () { get() {
if (this.visible) { if (this.visible) {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs['form'].clearValidate() this.$refs['form'].clearValidate()
...@@ -43,15 +43,15 @@ ...@@ -43,15 +43,15 @@
} }
return this.visible return this.visible
}, },
set (val) { set(val) {
this.$emit('update:visible', val) this.$emit('update:visible', val)
} }
} }
}, },
created () { }, created() {},
mounted () { }, mounted() {},
methods: { methods: {
closeTag (tag, index) { closeTag(tag, index) {
// if (tag.id) { // if (tag.id) {
// tag.status = 1 // tag.status = 1
// this.$forceUpdate() // this.$forceUpdate()
...@@ -60,13 +60,13 @@ ...@@ -60,13 +60,13 @@
// } // }
}, },
showInput () { showInput() {
this.visibleAdd = true this.visibleAdd = true
this.$nextTick((_) => { this.$nextTick((_) => {
this.$refs.saveTagInput.$refs.input.focus() this.$refs.saveTagInput.$refs.input.focus()
}) })
}, },
newInputConfirm () { newInputConfirm() {
let name = this.newInput let name = this.newInput
if (name) { if (name) {
Array.isArray(this.form.weTags) || (this.form.weTags = []) Array.isArray(this.form.weTags) || (this.form.weTags = [])
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
this.visibleAdd = false this.visibleAdd = false
this.newInput = '' this.newInput = ''
}, },
submit () { submit() {
if (!this.visibleAdd) { if (!this.visibleAdd) {
this.$refs['form'].validate((valid) => { this.$refs['form'].validate((valid) => {
this.newInput = '' this.newInput = ''
...@@ -103,19 +103,49 @@ ...@@ -103,19 +103,49 @@
</script> </script>
<template> <template>
<el-dialog :title="(form.groupId ? '修改' : '添加') + '标签/组'" :visible.sync="Pvisible" width="500px" append-to-body :close-on-click-modal="false"> <el-dialog
:title="(form.groupId ? '修改' : '添加') + '标签/组'"
:visible.sync="Pvisible"
width="500px"
append-to-body
:close-on-click-modal="false"
>
<el-form ref="form" :model="form" :rules="rules" label-width="100px"> <el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="标签组名称" prop="groupName"> <el-form-item label="标签组名称" prop="groupName">
<el-input v-model.trim="form.groupName" maxlength="15" show-word-limit placeholder="请输入标签组名称,该名称不支持再次修改" :disabled="!!form.groupId" /> <el-input
v-model.trim="form.groupName"
maxlength="15"
show-word-limit
placeholder="请输入标签组名称,该名称不支持再次修改"
/>
</el-form-item> </el-form-item>
<el-form-item label="标签" prop="weTags"> <el-form-item label="标签" prop="weTags">
<template v-for="(item, index) in form.weTags"> <template v-for="(item, index) in form.weTags">
<el-tag v-if="item.status !== 1" type="primary" closable size="medium" :key="index" @close="closeTag(item, index)"> <el-tag
v-if="item.status !== 1"
type="primary"
closable
size="medium"
:key="index"
@close="closeTag(item, index)"
>
{{ item.name }} {{ item.name }}
</el-tag> </el-tag>
</template> </template>
<el-input class="input-new-tag" v-if="visibleAdd" v-model.trim="newInput" ref="saveTagInput" size="mini" maxlength="10" show-word-limit @keyup.enter.native="newInputConfirm" @blur="newInputConfirm"></el-input> <el-input
<el-button v-else type="primary" plain class="button-new-tag" size="mini" @click="showInput">+ 添加标签</el-button> class="input-new-tag"
v-if="visibleAdd"
v-model.trim="newInput"
ref="saveTagInput"
size="mini"
maxlength="10"
show-word-limit
@keyup.enter.native="newInputConfirm"
@blur="newInputConfirm"
></el-input>
<el-button v-else type="primary" plain class="button-new-tag" size="mini" @click="showInput"
>+ 添加标签</el-button
>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
......
<script> <script>
import * as api from '@/api/customer/tag' import * as api from '@/api/customer/tag'
import AddTag from '@/components/AddTag' import AddTag from '@/components/AddTag'
export default { export default {
name: 'GroupTag', name: 'GroupTag',
components: { AddTag }, components: { AddTag },
props: { props: {
...@@ -17,6 +17,7 @@ export default { ...@@ -17,6 +17,7 @@ export default {
query: { query: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
groupName: '',
groupTagType: this.type groupTagType: this.type
}, },
// 遮罩层 // 遮罩层
...@@ -52,6 +53,10 @@ export default { ...@@ -52,6 +53,10 @@ export default {
this.getList() this.getList()
}, },
methods: { methods: {
resetQuery() {
this.query.groupName = ''
this.getList(1)
},
getList(page) { getList(page) {
page && (this.query.pageNum = page) page && (this.query.pageNum = page)
this.loading = true this.loading = true
...@@ -68,9 +73,7 @@ export default { ...@@ -68,9 +73,7 @@ export default {
}) })
}, },
edit(data, type) { edit(data, type) {
this.form = JSON.parse( this.form = JSON.parse(JSON.stringify(Object.assign({ groupTagType: this.type, weTags: [] }, data || {})))
JSON.stringify(Object.assign({ groupTagType: this.type, weTags: [] }, data || {}))
)
this.dialogVisible = true this.dialogVisible = true
}, },
syncTag() { syncTag() {
...@@ -102,7 +105,7 @@ export default { ...@@ -102,7 +105,7 @@ export default {
this.$confirm('是否确认删除吗?', '警告', { this.$confirm('是否确认删除吗?', '警告', {
type: 'warning' type: 'warning'
}) })
.then(function() { .then(function () {
return api.remove(operIds) return api.remove(operIds)
}) })
.then(() => { .then(() => {
...@@ -111,31 +114,38 @@ export default { ...@@ -111,31 +114,38 @@ export default {
}) })
} }
} }
} }
</script> </script>
<template> <template>
<div class=""> <div class="">
<div class="mid-action"> <div class="mid-action">
<div> <div>
<el-form :inline="true" label-width="0" label-position="left">
<el-form-item label="">
<el-input
v-model="query.groupName"
placeholder="请输入标签组名称"
clearable
@keyup.enter.native="getList(1)"
/>
</el-form-item>
<el-form-item label-width="0">
<el-button type="primary" @click="getList(1)">查询</el-button>
<el-button @click="resetQuery" type="info" plain>清空</el-button>
</el-form-item>
</el-form>
</div>
<div class="mid-action">
<div>
<!-- v-hasPermi="['customerManage:tag:add']" --> <!-- v-hasPermi="['customerManage:tag:add']" -->
<el-button <el-button type="primary" class="mr10" @click="edit()">新建标签组</el-button>
type="primary"
class="mr10"
@click="edit()"
>新建标签组</el-button
>
<ButtonSync v-if="type == 1" :lastSyncTime="lastSyncTime" @click="syncTag"> <ButtonSync v-if="type == 1" :lastSyncTime="lastSyncTime" @click="syncTag">
同步企微标签 同步企微标签
</ButtonSync> </ButtonSync>
</div> </div>
<div> <div>
<!-- v-hasPermi="['customerManage:tag:remove']" --> <!-- v-hasPermi="['customerManage:tag:remove']" -->
<el-button <el-button :disabled="!ids.length" type="danger" @click="remove()">批量删除</el-button>
:disabled="!ids.length"
type="danger"
@click="remove()"
>批量删除</el-button
>
</div> </div>
</div> </div>
...@@ -169,16 +179,8 @@ export default { ...@@ -169,16 +179,8 @@ export default {
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- v-hasPermi="['customerManage:tag:edit']" --> <!-- v-hasPermi="['customerManage:tag:edit']" -->
<el-button <el-button type="text" @click="edit(scope.row, scope.index)">编辑</el-button>
type="text" <el-button @click="remove(scope.row.groupId)" type="text">删除</el-button>
@click="edit(scope.row, scope.index)"
>编辑</el-button
>
<el-button
@click="remove(scope.row.groupId)"
type="text"
>删除</el-button
>
<!-- v-hasPermi="['customerManage:tag:remove']" --> <!-- v-hasPermi="['customerManage:tag:remove']" -->
</template> </template>
</el-table-column> </el-table-column>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!