This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
cyber-narrator-cn-ui/src/components/table/setting/ProfilesTable.vue

138 lines
3.5 KiB
Vue
Raw Normal View History

2024-11-15 18:45:58 +08:00
<template>
<el-table
id="userTable"
ref="dataTable"
:data="tableData"
tooltip-effect="light"
empty-text=" "
@header-dragend="dragend"
@sort-change="tableDataSort"
@selection-change="selectionChange"
>
<el-table-column
:resizable="false"
align="center"
type="selection"
:selectable="checkSelectable"
width="55">
</el-table-column>
<el-table-column
v-for="(item, index) in customTableTitles"
:key="item.prop+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}`"
>
<template #header>
<span class="data-column__span">{{ item.label }}</span>
<div class="col-resize-area"></div>
</template>
<template #default="scope" :column="item">
<template v-if="item.prop === 'create_time' || item.prop === 'update_time'">
2024-11-15 18:45:58 +08:00
<template v-if="scope.row[item.prop]">
{{ dateFormatByAppearance(scope.row[item.prop]) || '-' }}
</template>
<template v-else><span>-</span></template>
</template>
<template v-if="item.prop === 'entitySource'">
{{ scope.row[item.prop].name || '-' }}
</template>
<template v-if="item.prop === 'entities' || item.prop === 'relations'">
{{ handleListTypes(scope.row[item.prop]) }}
</template>
2024-11-15 18:45:58 +08:00
</template>
</el-table-column>
<template v-slot:empty>
<div class="table-no-data" v-if="isNoData">
<div class="table-no-data__title">{{ $t('npm.noData') }}</div>
</div>
</template>
</el-table>
</template>
<script>
import table from '@/mixins/table'
import { dateFormatByAppearance } from '@/utils/date-util'
export default {
name: 'SourcesTable',
props: {
isNoData: {
type: Boolean,
default: false
}
},
mixins: [table],
data () {
return {
tableTitle: [ // 原始table列
{
label: 'ID',
prop: 'id',
show: true,
minWidth: 50,
sortable: 'custom'
},
{
label: this.$t('setting.source'),
prop: 'entitySource',
2024-11-15 18:45:58 +08:00
show: true,
sortable: 'custom',
minWidth: 200
},
{
label: this.$t('setting.entityTypes'),
prop: 'entities',
2024-11-15 18:45:58 +08:00
show: true,
minWidth: 200
},
{
label: this.$t('setting.relationTypes'),
prop: 'relations',
2024-11-15 18:45:58 +08:00
show: true,
minWidth: 200
},
{
label: this.$t('config.user.createTime'),
prop: 'create_time',
2024-11-15 18:45:58 +08:00
show: true,
minWidth: 200
},
{
label: this.$t('overall.updateTime'),
prop: 'update_time',
2024-11-15 18:45:58 +08:00
show: true
}
]
}
},
methods: {
dateFormatByAppearance,
// 禁止勾选buildIn为1的项即禁止修改、删除admin的账号
checkSelectable (row) {
return row.buildIn !== 1
},
handleListTypes (data) {
let str = ''
if (data && typeof data === 'string') {
data = JSON.parse(data)
data.forEach(item => {
if (!str) {
str = item.type + ','
} else if (str.indexOf(item.type) < 0) {
str += item.type + ','
}
})
str = str.slice(0, -1)
}
return str
2024-11-15 18:45:58 +08:00
}
}
}
</script>