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/knowledgeBaseTableForCard.vue

153 lines
4.4 KiB
Vue
Raw Normal View History

<template>
2023-05-10 11:20:31 +08:00
<el-checkbox-group v-model="checkList">
<div @click="isSelectedStatus && clickCard(data,$event)" @mouseenter="mouseenter(data)" @mouseleave="mouseleave(data)" v-for="data in tableData" :key="data.id" class="card-item" :class="data.isSelected ? 'card-selected' : ''">
2023-04-26 23:46:23 +08:00
<div class="card-content">
<div class="card-title">
<div class="card-title-name" :title="data.tagName">{{data.tagName}}</div>
2023-04-26 23:46:23 +08:00
<div class="card-title-more">
<span v-show="!isSelectedStatus && data.showMore"><i class="cn-icon cn-icon-more-dark" @mouseenter="mouseenterMore(data)" test-id="mouseenter-dark"></i></span>
<div class="card-operate" v-show="!isSelectedStatus && data.moreOptions" @mouseleave="mouseleaveMore(data)">
<div class="card-title-more-edit" @click="edit(data.id)" >{{$t('overall.edit')}}</div>
<div class="card-title-more-delete" @click="del(data)" >{{$t('overall.delete')}}</div>
</div>
<el-checkbox @click.stop="" @change="(val) => {checkboxStatusChange(val,data)}" style="position: absolute;right: -12px;" v-if="isSelectedStatus" :key="data.id" :label="data"><br></el-checkbox>
2023-04-26 23:46:23 +08:00
</div>
</div>
<div class="card-id">ID:{{data.id}}</div>
<div class="card-desc" :title="data.remark">{{data.remark?data.remark:'—'}}</div>
2023-04-26 23:46:23 +08:00
</div>
<div class="card-operate__footer">
<div class="card-type">{{data.tagType}}</div>
<el-switch class="card-enable"
disabled
v-model="data.status"
active-color="#38ACD2"
inactive-color="#C0CEDB"
>
</el-switch>
</div>
</div>
</el-checkbox-group>
</template>
<script>
import table from '@/mixins/table'
import { knowledgeBaseType } from '@/utils/constants'
export default {
name: 'knowledgeBaseTableForCard',
mixins: [table],
2023-04-26 23:46:23 +08:00
props: {
isSelectedStatus: {
type: Boolean
}
},
data () {
return {
2023-04-26 23:46:23 +08:00
tableTitle: [],
checkList: []
}
},
2023-04-26 23:46:23 +08:00
watch: {
tableData: {
handler (n) {
if (this.tableData && this.tableData.length > 0) {
this.tableData.forEach(item => {
item.status = true
})
}
}
}
2023-04-26 23:46:23 +08:00
},
methods: {
clickCard (data, event) {
if (data.isSelected) { // 原来为选中,当前点击后未选中
const index = this.checkList.indexOf(data)
if (index > -1) {
this.checkList.splice(index, 1)
}
} else {
const index = this.checkList.indexOf(data)
if (index === -1) {
this.checkList.push(data)
}
}
const val = !data.isSelected
data.isSelected = val
this.$emit('checkboxStatusChange', val, data)
},
2023-04-26 23:46:23 +08:00
checkboxStatusChange (val, data) {
data.isSelected = val
2023-04-26 23:46:23 +08:00
this.$emit('checkboxStatusChange', val, data)
},
showSelect () {
// this.isSelectedStatus = true
},
hideSelect () {
// this.isSelectedStatus = false
},
clearSelect () {
this.$nextTick(() => {
this.checkList = []
if (this.tableData && this.tableData.length > 0) {
this.tableData.forEach(data => {
data.isSelected = false
})
}
})
},
2023-04-26 23:46:23 +08:00
mouseenterMore (card) {
this.tableData.forEach(t => {
if (t.id === card.id) {
t.moreOptions = true
}
})
},
mouseleaveMore (card) {
this.tableData.forEach(t => {
if (t.id === card.id) {
t.moreOptions = false
}
})
},
mouseenter (card) {
this.tableData.forEach(t => {
if (t.id === card.id) {
t.showMore = true
}
})
},
mouseleave (card) {
this.tableData.forEach(t => {
if (t.id === card.id) {
t.showMore = false
t.moreOptions = false
}
})
},
del (data) {
this.$emit('delete', data)
},
edit (id) {
const pageNo = this.$router.currentRoute.value.query.pageNo
2023-04-26 23:46:23 +08:00
this.$router.push({
path: '/knowledgeBase/edit',
query: {
t: +new Date(),
pageNoForTable: pageNo || 1,
2023-04-26 23:46:23 +08:00
id: id
}
})
}
},
mounted () {
this.tableData.forEach(item => {
item.showMore = false
item.moreOptions = false
item.status = true
})
},
computed: {}
}
</script>