2023-05-17 10:51:52 +08:00
|
|
|
<template>
|
|
|
|
|
<el-table
|
|
|
|
|
id="knowledgeBaseTable"
|
|
|
|
|
ref="dataTable"
|
|
|
|
|
:data="tableData"
|
|
|
|
|
:height="height"
|
|
|
|
|
border
|
|
|
|
|
@header-dragend="dragend"
|
|
|
|
|
@sort-change="tableDataSort"
|
|
|
|
|
@selection-change="selectionChange"
|
|
|
|
|
>
|
|
|
|
|
<el-table-column
|
|
|
|
|
:resizable="false"
|
|
|
|
|
align="center"
|
|
|
|
|
type="selection"
|
|
|
|
|
width="55">
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column
|
|
|
|
|
v-for="(item, index) in customTableTitles"
|
|
|
|
|
:key="`col-${index}`"
|
|
|
|
|
:fixed="item.fixed"
|
|
|
|
|
:label="item.label"
|
|
|
|
|
:min-width="`${item.minWidth}`"
|
|
|
|
|
:prop="item.prop"
|
|
|
|
|
:resizable="true"
|
|
|
|
|
:sort-orders="['ascending', 'descending']"
|
|
|
|
|
:sortable="item.sortable"
|
|
|
|
|
:width="`${item.width}`"
|
|
|
|
|
class="data-column"
|
|
|
|
|
>
|
|
|
|
|
<template #header>
|
|
|
|
|
<span class="data-column__span">{{item.label}}</span>
|
|
|
|
|
<div class="col-resize-area"></div>
|
|
|
|
|
</template>
|
|
|
|
|
<template #default="scope" :column="item">
|
2023-05-29 13:00:28 +08:00
|
|
|
<template v-if="item.prop === 'name'" >
|
2023-05-17 10:51:52 +08:00
|
|
|
<template v-if="scope.row.i18n">
|
2023-05-29 13:00:28 +08:00
|
|
|
<span :title="scope.row[item.prop]">{{$t(scope.row.i18n)}}</span>
|
2023-05-17 10:51:52 +08:00
|
|
|
</template>
|
|
|
|
|
<template v-else-if="scope.row.name">
|
2023-05-29 13:00:28 +08:00
|
|
|
<span :title="scope.row[item.prop]">{{scope.row.name}}</span>
|
2023-05-17 10:51:52 +08:00
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<span>-</span>
|
|
|
|
|
</template>
|
|
|
|
|
</template>
|
2023-05-29 13:00:28 +08:00
|
|
|
<template v-else-if="item.prop === 'category'">
|
|
|
|
|
<span >{{tagCategoryText(scope.row[item.prop])}}</span>
|
2023-05-17 10:51:52 +08:00
|
|
|
</template>
|
2023-05-29 13:00:28 +08:00
|
|
|
<template v-else-if="item.prop === 'source'">
|
|
|
|
|
<span class="type-tag">{{tagSourceText(scope.row[item.prop])}}</span>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else-if="item.prop === 'opTime' || item.prop === 'ctime'">
|
2023-05-17 10:51:52 +08:00
|
|
|
<template v-if="scope.row[item.prop]">
|
|
|
|
|
{{dateFormatByAppearance(scope.row[item.prop])}}
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<span>-</span>
|
|
|
|
|
</template>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else-if="item.prop === 'cuser' || item.prop === 'uuser'">
|
|
|
|
|
<template v-if="scope.row[item.prop]">
|
|
|
|
|
{{scope.row[item.prop].username || '-'}}
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<span>-</span>
|
|
|
|
|
</template>
|
|
|
|
|
</template>
|
2023-05-29 13:00:28 +08:00
|
|
|
<template v-else-if="item.prop === 'description'">
|
2023-05-17 10:51:52 +08:00
|
|
|
<span class="list-desc" :title="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
|
|
|
|
|
</template>
|
2023-05-29 13:00:28 +08:00
|
|
|
<template v-else-if="item.prop === 'status'">
|
|
|
|
|
<el-switch class="card-enable"
|
2023-06-02 14:15:00 +08:00
|
|
|
v-model="scope.row.status"
|
2023-05-29 13:00:28 +08:00
|
|
|
active-color="#38ACD2"
|
|
|
|
|
inactive-color="#C0CEDB"
|
2023-06-02 14:15:00 +08:00
|
|
|
:active-value="1"
|
|
|
|
|
:inactive-value="0"
|
2023-06-08 14:35:30 +08:00
|
|
|
:disabled="scope.row.isBuiltIn === 1"
|
2023-05-29 13:00:28 +08:00
|
|
|
@change="changeStatus($event,scope.row.knowledgeId)"
|
|
|
|
|
>
|
|
|
|
|
</el-switch>
|
|
|
|
|
</template>
|
2023-05-17 10:51:52 +08:00
|
|
|
<span v-else>{{scope.row[item.prop] || '-'}}</span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import table from '@/mixins/table'
|
2023-05-29 13:00:28 +08:00
|
|
|
import { knowledgeBaseCategory, knowledgeBaseSource } from '@/utils/constants'
|
2023-05-17 10:51:52 +08:00
|
|
|
export default {
|
|
|
|
|
name: 'KnowledgeBaseTableForRow',
|
|
|
|
|
mixins: [table],
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
tableTitle: [ // 原table列
|
|
|
|
|
{
|
|
|
|
|
label: 'ID',
|
2023-05-29 13:00:28 +08:00
|
|
|
prop: 'knowledgeId',
|
2023-05-17 10:51:52 +08:00
|
|
|
show: true,
|
2023-05-29 13:00:28 +08:00
|
|
|
width: 60,
|
2023-05-17 10:51:52 +08:00
|
|
|
sortable: 'custom'
|
|
|
|
|
}, {
|
|
|
|
|
label: this.$t('config.roles.name'),
|
2023-05-29 13:00:28 +08:00
|
|
|
prop: 'name',
|
|
|
|
|
minWidth: 100,
|
2023-05-17 10:51:52 +08:00
|
|
|
show: true,
|
|
|
|
|
sortable: 'custom'
|
|
|
|
|
}, {
|
2023-05-29 13:00:28 +08:00
|
|
|
label: this.$t('overall.category'),
|
|
|
|
|
prop: 'category',
|
|
|
|
|
width: 100,
|
|
|
|
|
show: true
|
|
|
|
|
}, {
|
|
|
|
|
label: this.$t('overall.source'),
|
|
|
|
|
prop: 'source',
|
|
|
|
|
width: 130,
|
2023-05-17 10:51:52 +08:00
|
|
|
show: true
|
|
|
|
|
}, {
|
|
|
|
|
label: this.$t('overall.remark'),
|
2023-05-29 13:00:28 +08:00
|
|
|
prop: 'description',
|
|
|
|
|
minWidth: 150,
|
2023-05-17 10:51:52 +08:00
|
|
|
show: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: this.$t('overall.createdBy'),
|
2023-05-29 13:00:28 +08:00
|
|
|
prop: 'opUser',
|
|
|
|
|
show: false
|
2023-05-17 10:51:52 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: this.$t('config.user.createTime'),
|
|
|
|
|
prop: 'ctime',
|
|
|
|
|
show: false,
|
|
|
|
|
sortable: 'custom'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: this.$t('overall.updatedBy'),
|
|
|
|
|
prop: 'uuser',
|
|
|
|
|
show: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: this.$t('overall.updateTime'),
|
2023-05-29 13:00:28 +08:00
|
|
|
prop: 'opTime',
|
|
|
|
|
show: true,
|
2023-05-17 10:51:52 +08:00
|
|
|
sortable: 'custom'
|
2023-05-29 13:00:28 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: this.$t('knowledge.status'),
|
|
|
|
|
prop: 'status',
|
|
|
|
|
show: true,
|
|
|
|
|
minWidth: 40
|
2023-05-17 10:51:52 +08:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
2023-05-29 13:00:28 +08:00
|
|
|
tagCategoryText () {
|
|
|
|
|
return function (type) {
|
|
|
|
|
const t = knowledgeBaseCategory.find(t => t.value === type)
|
|
|
|
|
return t ? t.name : ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
tagSourceText () {
|
2023-05-17 10:51:52 +08:00
|
|
|
return function (type) {
|
2023-05-29 13:00:28 +08:00
|
|
|
const t = knowledgeBaseSource.find(t => t.value === type)
|
2023-05-17 10:51:52 +08:00
|
|
|
return t ? t.name : ''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|