2023-02-23 18:12:20 +08:00
|
|
|
|
<template>
|
2023-08-03 15:54:30 +08:00
|
|
|
|
<div class="knowledge-base">
|
|
|
|
|
|
<div class="knowledge-base__top">
|
|
|
|
|
|
<div class="top-title">
|
|
|
|
|
|
{{$t('overall.knowledgeBase')}}
|
|
|
|
|
|
</div>
|
2024-04-10 19:14:23 +08:00
|
|
|
|
<!-- <div class="builtIn-to-user-defined" >-->
|
|
|
|
|
|
<!-- <button :title="$t('knowledgeBase.userDefinedLibrary')" class="top-tool-btn--user_defined_library"-->
|
|
|
|
|
|
<!-- v-if="hasPermission('userDefinedLibrary')"-->
|
|
|
|
|
|
<!-- @click="changeToUserDefinedList">-->
|
|
|
|
|
|
<!-- <i class="cn-icon-add-knowledge-base cn-icon" ></i>-->
|
|
|
|
|
|
<!-- <span>{{$t('knowledgeBase.userDefinedLibrary')}}</span>-->
|
|
|
|
|
|
<!-- </button>-->
|
|
|
|
|
|
<!-- </div>-->
|
2023-03-10 20:50:54 +08:00
|
|
|
|
</div>
|
2023-08-03 15:54:30 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 内置库列表 -->
|
2023-11-15 22:22:53 +08:00
|
|
|
|
<div class="knowledge-base-built-in__content" >
|
2023-08-03 15:54:30 +08:00
|
|
|
|
<div class="list-card" >
|
|
|
|
|
|
<div class="list-mode__card" >
|
|
|
|
|
|
<loading :loading="loading"></loading>
|
|
|
|
|
|
<knowledge-base-table-for-card
|
|
|
|
|
|
ref="dataTableCard"
|
|
|
|
|
|
:api="url"
|
|
|
|
|
|
:isNoData="isNoData"
|
|
|
|
|
|
:table-data="tableData"
|
|
|
|
|
|
:is-selected-status="isSelectedStatus"
|
|
|
|
|
|
@delete="toDelete"
|
|
|
|
|
|
@checkboxStatusChange="checkboxStatusChange"
|
|
|
|
|
|
@reload="getBuiltInData"
|
|
|
|
|
|
@toggleLoading="toggleLoading"
|
|
|
|
|
|
></knowledge-base-table-for-card>
|
|
|
|
|
|
</div>
|
2023-04-26 23:46:23 +08:00
|
|
|
|
</div>
|
2023-08-03 15:54:30 +08:00
|
|
|
|
</div>
|
2023-02-23 18:12:20 +08:00
|
|
|
|
</div>
|
2024-01-12 11:54:23 +08:00
|
|
|
|
<!--
|
2023-04-26 23:46:23 +08:00
|
|
|
|
<el-dialog v-model="showConfirmDialog"
|
|
|
|
|
|
:title="$t('overall.hint')"
|
|
|
|
|
|
width="480px"
|
|
|
|
|
|
custom-class="del-model-hint"
|
|
|
|
|
|
:before-close="handleClose">
|
|
|
|
|
|
<div class="dialog-message">{{$t('knowledge.deleteDataHint')}}</div>
|
|
|
|
|
|
<el-table v-model="delItemList"
|
|
|
|
|
|
ref="delDataTable"
|
|
|
|
|
|
:data="batchDeleteObjs"
|
|
|
|
|
|
@selection-change="secondSelectionChange"
|
|
|
|
|
|
height="156px"
|
|
|
|
|
|
width="100%"
|
|
|
|
|
|
class="dialog-table"
|
|
|
|
|
|
cell-style="padding:4px 0px;font-size: 12px;color: #353636;font-weight: 400;"
|
2023-08-03 15:54:30 +08:00
|
|
|
|
header-cell-style="padding:4px 0px;background: #F5F8FA;font-size: 12px;color: #353636;font-weight: 500;">
|
2023-04-26 23:46:23 +08:00
|
|
|
|
<el-table-column
|
|
|
|
|
|
:resizable="false"
|
|
|
|
|
|
align="center"
|
|
|
|
|
|
type="selection"
|
|
|
|
|
|
width="50">
|
|
|
|
|
|
</el-table-column>
|
2023-08-03 15:54:30 +08:00
|
|
|
|
<el-table-column property="knowledgeId" label="ID" width="150"></el-table-column>
|
2023-05-29 13:00:28 +08:00
|
|
|
|
<el-table-column property="name" label="Name"></el-table-column>
|
2023-04-26 23:46:23 +08:00
|
|
|
|
</el-table>
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<span class="dialog-footer">
|
|
|
|
|
|
<el-button @click="showConfirmDialog = false">{{ $t('overall.cancel') }}</el-button>
|
|
|
|
|
|
<el-button type="primary" @click="submit">{{ $t('tip.confirm') }}</el-button>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
2024-01-12 11:54:23 +08:00
|
|
|
|
-->
|
2023-02-23 18:12:20 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<script>
|
2023-11-17 13:54:21 +08:00
|
|
|
|
import dataListMixin from '@/mixins/data-list'
|
|
|
|
|
|
import KnowledgeBaseTableForCard from '@/components/table/setting/knowledgeBaseTableForCard'
|
|
|
|
|
|
import { api } from '@/utils/api'
|
|
|
|
|
|
import { knowledgeBaseCategory, knowledgeBaseSource, knowledgeCategoryValue } from '@/utils/constants'
|
|
|
|
|
|
import axios from 'axios'
|
2023-02-23 18:12:20 +08:00
|
|
|
|
|
2023-11-17 13:54:21 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'knowledgeBase',
|
|
|
|
|
|
components: {
|
|
|
|
|
|
KnowledgeBaseTableForCard
|
|
|
|
|
|
},
|
|
|
|
|
|
mixins: [dataListMixin],
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
url: api.knowledgeBase,
|
|
|
|
|
|
listUrl: api.knowledgeBaseList,
|
|
|
|
|
|
tableId: 'knowledgeBaseTable', // 需要分页的table的id,用于记录每页数量
|
|
|
|
|
|
isSelectedStatus: false,
|
|
|
|
|
|
filterParams: {},
|
|
|
|
|
|
checkedCategoryIds: [],
|
|
|
|
|
|
checkedStatusIds: [],
|
|
|
|
|
|
keyWord: '',
|
|
|
|
|
|
showConfirmDialog: false,
|
|
|
|
|
|
delItemList: [],
|
|
|
|
|
|
secondBatchDeleteObjs: []
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
categoryFormat (row, column) {
|
|
|
|
|
|
const category = row.category
|
|
|
|
|
|
const t = knowledgeBaseCategory.find(t => t.value === category)
|
|
|
|
|
|
return t ? t.name : category
|
2023-04-26 23:46:23 +08:00
|
|
|
|
},
|
2023-11-17 13:54:21 +08:00
|
|
|
|
sourceFormat (row, column) {
|
|
|
|
|
|
const source = row.source
|
|
|
|
|
|
const t = knowledgeBaseSource.find(t => t.value === source)
|
|
|
|
|
|
return t ? t.name : source
|
2023-06-09 09:45:08 +08:00
|
|
|
|
},
|
2023-11-17 13:54:21 +08:00
|
|
|
|
handleClose () {
|
|
|
|
|
|
this.showConfirmDialog = false
|
2023-04-26 23:46:23 +08:00
|
|
|
|
},
|
2023-11-17 13:54:21 +08:00
|
|
|
|
showDelDialog () {
|
|
|
|
|
|
this.showConfirmDialog = true
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.batchDeleteObjs.forEach((item) => {
|
|
|
|
|
|
this.$refs.delDataTable.toggleRowSelection(item, true)
|
2023-11-15 22:22:53 +08:00
|
|
|
|
})
|
2023-11-17 13:54:21 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
secondSelectionChange (objs) {
|
|
|
|
|
|
this.secondBatchDeleteObjs = objs
|
|
|
|
|
|
},
|
|
|
|
|
|
selectionChange (objs) {
|
|
|
|
|
|
this.batchDeleteObjs = []
|
|
|
|
|
|
objs.forEach(obj => {
|
|
|
|
|
|
const delObj = this.batchDeleteObjs.find(item => item.knowledgeId === obj.knowledgeId)
|
|
|
|
|
|
if (delObj === undefined) {
|
|
|
|
|
|
this.batchDeleteObjs.push(obj)
|
2023-11-15 22:22:53 +08:00
|
|
|
|
}
|
2023-11-17 13:54:21 +08:00
|
|
|
|
})
|
|
|
|
|
|
if (this.batchDeleteObjs.length === 1) {
|
|
|
|
|
|
this.disableEdit = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.disableEdit = true
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.batchDeleteObjs.length >= 1) {
|
|
|
|
|
|
this.disableDelete = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.disableDelete = true
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
checkboxStatusChange (isCheck, data) {
|
|
|
|
|
|
if (isCheck) {
|
|
|
|
|
|
const delObj = this.batchDeleteObjs.find(item => item.knowledgeId === data.knowledgeId)
|
|
|
|
|
|
if (delObj === undefined) {
|
|
|
|
|
|
this.batchDeleteObjs.push(data)
|
2023-11-15 22:22:53 +08:00
|
|
|
|
}
|
2023-11-17 13:54:21 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
const cancleObjIndex = this.batchDeleteObjs.findIndex(item => item.knowledgeId === data.knowledgeId)
|
|
|
|
|
|
if (cancleObjIndex > -1) {
|
|
|
|
|
|
this.batchDeleteObjs.splice(cancleObjIndex, 1)
|
2023-08-03 15:54:30 +08:00
|
|
|
|
}
|
2023-11-17 13:54:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (this.batchDeleteObjs.length === 1) {
|
|
|
|
|
|
this.disableEdit = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.disableEdit = true
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.batchDeleteObjs.length >= 1) {
|
|
|
|
|
|
this.disableDelete = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.disableDelete = true
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
delBatchKnowledge () {
|
|
|
|
|
|
const ids = []
|
|
|
|
|
|
if (this.secondBatchDeleteObjs && this.secondBatchDeleteObjs.length > 0) {
|
|
|
|
|
|
this.secondBatchDeleteObjs.forEach(item => {
|
|
|
|
|
|
ids.push(item.knowledgeId)
|
2023-11-15 22:22:53 +08:00
|
|
|
|
})
|
2023-11-17 13:54:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
let hasReference = false
|
|
|
|
|
|
let referenceKnowledge = null
|
|
|
|
|
|
this.batchDeleteObjs.forEach(item => {
|
|
|
|
|
|
if (item.reference && item.reference.length > 0) {
|
|
|
|
|
|
hasReference = true
|
|
|
|
|
|
referenceKnowledge = item
|
2023-11-15 22:22:53 +08:00
|
|
|
|
}
|
2023-11-17 13:54:21 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
if (ids.length === 0) {
|
|
|
|
|
|
this.$alert(this.$t('tip.pleaseSelect'), {
|
|
|
|
|
|
confirmButtonText: this.$t('tip.yes'),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).catch(() => {})
|
|
|
|
|
|
} else if (hasReference) {
|
|
|
|
|
|
this.$message.error(this.$t('knowledgeBase.deleteReferenceObjects', { name: referenceKnowledge.name }))
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.toggleLoading(true)
|
|
|
|
|
|
axios.delete(this.url + '?knowledgeIds=' + ids).then(response => {
|
2023-08-24 17:15:41 +08:00
|
|
|
|
if (response.status === 200) {
|
2023-11-17 13:54:21 +08:00
|
|
|
|
this.delFlag = true
|
|
|
|
|
|
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') })
|
|
|
|
|
|
this.secondBatchDeleteObjs.forEach((item) => {
|
|
|
|
|
|
this.$refs.delDataTable.toggleRowSelection(item, false)
|
|
|
|
|
|
})
|
|
|
|
|
|
this.secondBatchDeleteObjs = []
|
|
|
|
|
|
this.batchDeleteObjs = []
|
|
|
|
|
|
// delete this.searchLabel.category
|
|
|
|
|
|
delete this.searchLabel.source
|
|
|
|
|
|
this.searchLabel.category = knowledgeCategoryValue.userDefined
|
|
|
|
|
|
this.getTableData()
|
2023-11-15 22:22:53 +08:00
|
|
|
|
} else {
|
2023-11-17 13:54:21 +08:00
|
|
|
|
this.$message.error(response.data.message)
|
|
|
|
|
|
}
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.toggleLoading(false)
|
|
|
|
|
|
if (this.isSelectedStatus != undefined) {
|
|
|
|
|
|
this.isSelectedStatus = false
|
|
|
|
|
|
this.disableDelete = true
|
|
|
|
|
|
this.secondBatchDeleteObjs = []
|
|
|
|
|
|
this.batchDeleteObjs = []
|
|
|
|
|
|
this.showConfirmDialog = false
|
2023-04-26 23:46:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2023-11-17 13:54:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
submit () {
|
|
|
|
|
|
this.delBatchKnowledge()
|
|
|
|
|
|
this.showConfirmDialog = false
|
|
|
|
|
|
},
|
|
|
|
|
|
edit (u) {
|
|
|
|
|
|
axios.get(`${this.url}/${u.id}`).then(response => {
|
|
|
|
|
|
if (response.status === 200) {
|
|
|
|
|
|
this.object = response.data.data.list[0]
|
2023-02-23 18:12:20 +08:00
|
|
|
|
}
|
2023-11-17 13:54:21 +08:00
|
|
|
|
}).catch(e => {
|
|
|
|
|
|
console.error(e)
|
|
|
|
|
|
if (e.response.data && e.response.data.message) {
|
|
|
|
|
|
this.$message.error(e.response.data.message)
|
2023-03-14 19:39:40 +08:00
|
|
|
|
} else {
|
2023-11-17 13:54:21 +08:00
|
|
|
|
this.$message.error(this.$t('tip.somethingWentWrong'))
|
2023-03-14 19:39:40 +08:00
|
|
|
|
}
|
2023-11-17 13:54:21 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
reload (params, isAll, isClearType, checkedCategoryIds, checkedStatusIds) {
|
|
|
|
|
|
this.disableDelete = true
|
|
|
|
|
|
this.isSelectedStatus = false
|
|
|
|
|
|
this.batchDeleteObjs = []
|
|
|
|
|
|
this.secondBatchDeleteObjs = []
|
|
|
|
|
|
this.filterParams = params
|
|
|
|
|
|
this.checkedCategoryIds = checkedCategoryIds
|
|
|
|
|
|
this.checkedStatusIds = checkedStatusIds
|
|
|
|
|
|
params = {
|
|
|
|
|
|
...params,
|
|
|
|
|
|
name: this.keyWord
|
|
|
|
|
|
}
|
|
|
|
|
|
this.getTableData(params, isAll, isClearType)
|
|
|
|
|
|
},
|
|
|
|
|
|
clearList () {
|
|
|
|
|
|
this.disableDelete = true
|
|
|
|
|
|
this.isSelectedStatus = false
|
|
|
|
|
|
this.batchDeleteObjs = []
|
|
|
|
|
|
this.secondBatchDeleteObjs = []
|
|
|
|
|
|
this.tableData = []
|
|
|
|
|
|
this.pageObj.total = 0
|
|
|
|
|
|
},
|
|
|
|
|
|
toSelect () {
|
|
|
|
|
|
this.$refs.dataTableCard.clearSelect()
|
|
|
|
|
|
this.isSelectedStatus = !this.isSelectedStatus
|
|
|
|
|
|
this.disableDelete = true
|
|
|
|
|
|
this.batchDeleteObjs = []
|
|
|
|
|
|
this.secondBatchDeleteObjs = []
|
|
|
|
|
|
},
|
|
|
|
|
|
editSelectRecord () {
|
|
|
|
|
|
if (this.batchDeleteObjs.length === 0) {
|
|
|
|
|
|
this.$alert(this.$t('tip.pleaseSelectForEdit'), {
|
2023-03-23 16:13:55 +08:00
|
|
|
|
confirmButtonText: this.$t('tip.yes'),
|
|
|
|
|
|
type: 'warning'
|
2023-03-27 11:11:00 +08:00
|
|
|
|
}).catch(() => {})
|
2023-11-17 13:54:21 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.jumpToEditPage(this.batchDeleteObjs[0].knowledgeId)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
changeToUserDefinedList () {
|
|
|
|
|
|
this.$router.push({
|
|
|
|
|
|
path: '/knowledgeBase/userDefined',
|
|
|
|
|
|
query: {
|
|
|
|
|
|
t: +new Date()
|
2023-11-15 22:22:53 +08:00
|
|
|
|
}
|
2023-11-17 13:54:21 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
toDelete (data) {
|
|
|
|
|
|
if (data && data.knowledgeId) {
|
|
|
|
|
|
this.secondBatchDeleteObjs = []
|
|
|
|
|
|
this.batchDeleteObjs = []
|
|
|
|
|
|
this.secondBatchDeleteObjs.push(data)
|
|
|
|
|
|
this.batchDeleteObjs.push(data)
|
|
|
|
|
|
}
|
|
|
|
|
|
this.showDelDialog()
|
|
|
|
|
|
},
|
|
|
|
|
|
del (row) {
|
|
|
|
|
|
this.$confirm(this.$t('tip.confirmDelete'), {
|
|
|
|
|
|
confirmButtonText: this.$t('tip.yes'),
|
|
|
|
|
|
cancelButtonText: this.$t('tip.no'),
|
2024-04-12 16:53:49 +08:00
|
|
|
|
customClass: 'del-model-message-box',
|
2023-11-17 13:54:21 +08:00
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
this.toggleLoading(true)
|
|
|
|
|
|
axios.delete(this.url + '?knowledgeIds=' + row.id).then(response => {
|
2023-08-24 17:15:41 +08:00
|
|
|
|
if (response.status === 200) {
|
2023-11-17 13:54:21 +08:00
|
|
|
|
this.delFlag = true
|
|
|
|
|
|
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') })
|
|
|
|
|
|
// delete this.searchLabel.category
|
|
|
|
|
|
delete this.searchLabel.source
|
|
|
|
|
|
this.searchLabel.category = knowledgeCategoryValue.userDefined
|
|
|
|
|
|
this.getTableData()
|
2023-03-06 14:19:29 +08:00
|
|
|
|
} else {
|
2023-11-17 13:54:21 +08:00
|
|
|
|
this.$message.error(response.data.message)
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(e => {
|
|
|
|
|
|
console.error(e)
|
|
|
|
|
|
if (e.response.data && e.response.data.message) {
|
|
|
|
|
|
this.$message.error(e.response.data.message)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(this.$t('tip.somethingWentWrong'))
|
2023-03-14 19:39:40 +08:00
|
|
|
|
}
|
2023-03-06 20:16:31 +08:00
|
|
|
|
}).finally(() => {
|
2023-06-16 17:51:08 +08:00
|
|
|
|
this.toggleLoading(false)
|
2023-03-06 14:19:29 +08:00
|
|
|
|
})
|
2023-11-17 13:54:21 +08:00
|
|
|
|
}).catch(() => {})
|
2023-11-15 22:22:53 +08:00
|
|
|
|
},
|
2023-11-17 13:54:21 +08:00
|
|
|
|
getBuiltInData () {
|
|
|
|
|
|
this.isNoData = false
|
|
|
|
|
|
this.toggleLoading(true)
|
|
|
|
|
|
const params = {
|
2023-12-29 09:40:42 +08:00
|
|
|
|
category: knowledgeCategoryValue.webSketch,
|
2023-11-17 13:54:21 +08:00
|
|
|
|
pageSize: -1
|
|
|
|
|
|
}
|
|
|
|
|
|
axios.get(this.listUrl, { params }).then(response => {
|
|
|
|
|
|
if (response.status === 200) {
|
|
|
|
|
|
this.tableData = response.data.data.list
|
|
|
|
|
|
this.isNoData = !this.tableData || this.tableData.length === 0
|
|
|
|
|
|
} else {
|
|
|
|
|
|
console.error(response.data)
|
|
|
|
|
|
this.isNoData = true
|
|
|
|
|
|
if (response.data.message) {
|
|
|
|
|
|
this.$message.error(response.data.message)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(this.$t('tip.somethingWentWrong'))
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
|
this.isNoData = true
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.toggleLoading(false)
|
|
|
|
|
|
})
|
2023-08-03 15:54:30 +08:00
|
|
|
|
}
|
2023-11-17 13:54:21 +08:00
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
|
|
|
|
|
this.filterParams = {}
|
|
|
|
|
|
this.getBuiltInData()
|
2023-02-23 18:12:20 +08:00
|
|
|
|
}
|
2023-11-17 13:54:21 +08:00
|
|
|
|
}
|
2023-02-23 18:12:20 +08:00
|
|
|
|
</script>
|