| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <template v-slot:footer> |
| | | <el-button @click="close">返回</el-button> |
| | | </template> |
| | | </GlobalWindow> |
| | | </template> |
| | | |
| | | <script> |
| | | import BaseOpera from '@/components/base/BaseOpera' |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | import { createLabels, list, labelsDeleteById } from '@/api/business/knowledge' |
| | | export default { |
| | | name: 'tagLibrary', |
| | | extends: BaseOpera, |
| | | components: { GlobalWindow }, |
| | | data () { |
| | | return { |
| | | value: '', |
| | | list: [] |
| | | } |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | api: '/business/knowledge', |
| | | 'field.id': 'id' |
| | | }) |
| | | }, |
| | | methods: { |
| | | async open(title, target) { |
| | | this.title = title |
| | | await this.getData() |
| | | this.visible = true |
| | | }, |
| | | async getData() { |
| | | this.list = await list() |
| | | }, |
| | | // 添加标签 |
| | | async add() { |
| | | if (!this.value) return this.$message.warning('请先输入内容') |
| | | let res = await createLabels({ name: this.value }) |
| | | await this.getData() |
| | | this.$emit('refresh') |
| | | this.value = '' |
| | | this.$message.success('添加成功') |
| | | }, |
| | | // 删除 |
| | | async dele(id) { |
| | | let res = await labelsDeleteById(id) |
| | | await this.getData() |
| | | this.$emit('refresh') |
| | | this.$message.success('删除成功') |
| | | } |
| | | } |
| | | import BaseOpera from '@/components/base/BaseOpera' |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | import { createLabels, list, labelsDeleteById } from '@/api/business/knowledge' |
| | | export default { |
| | | name: 'tagLibrary', |
| | | extends: BaseOpera, |
| | | components: { GlobalWindow }, |
| | | data () { |
| | | return { |
| | | value: '', |
| | | list: [] |
| | | } |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | api: '/business/knowledge', |
| | | 'field.id': 'id' |
| | | }) |
| | | }, |
| | | methods: { |
| | | async open (title, target) { |
| | | this.title = title |
| | | await this.getData() |
| | | this.visible = true |
| | | }, |
| | | async getData () { |
| | | this.list = await list() |
| | | }, |
| | | // 添加标签 |
| | | async add () { |
| | | if (!this.value) return this.$message.warning('请先输入内容') |
| | | createLabels({ name: this.value }) |
| | | .then(() => { |
| | | this.$message.success('添加成功') |
| | | this.$emit('success') |
| | | this.getData() |
| | | this.$emit('refresh') |
| | | this.value = '' |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | }, |
| | | // 删除 |
| | | async dele (id) { |
| | | labelsDeleteById(id) |
| | | .then(() => { |
| | | this.$message.success('删除成功') |
| | | this.$emit('success') |
| | | this.getData() |
| | | this.$emit('refresh') |
| | | this.value = '' |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |