dataease/frontend/src/views/panel/enshrine/index.vue

128 lines
2.9 KiB
Vue
Raw Normal View History

2021-04-20 14:19:10 +08:00
<template>
<div>
<el-table
class="de-filter-data-table"
:data="starDatas"
:show-header="false"
:highlight-current-row="true"
style="width: 100%"
>
2021-05-14 18:51:35 +08:00
<el-table-column prop="name" :label="$t('commons.name')">
2021-04-20 14:19:10 +08:00
<template :id="scope.row.storeId" slot-scope="scope">
<div class="start-item">
2022-05-23 16:36:27 +08:00
<div
class="filter-db-row star-item-content"
style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"
@click="showPanel(scope.row)"
>
<svg-icon :icon-class="'panel-'+scope.row.status" class="ds-icon-scene" />
2022-05-23 16:36:27 +08:00
<span :class="scope.row.status"> {{ scope.row.name }}</span>
2021-04-20 14:19:10 +08:00
</div>
<div class="star-item-close">
<i class="el-icon-delete " @click="remove(scope.row)" />
2021-04-20 14:19:10 +08:00
</div>
</div>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
import { deleteEnshrine, enshrineList } from '@/api/panel/enshrine'
import { uuid } from 'vue-uuid'
import { initPanelData } from '@/api/panel/panel'
import bus from '@/utils/bus'
2022-05-23 16:36:27 +08:00
2021-04-20 14:19:10 +08:00
export default {
name: 'Enshrine',
data() {
return {
starDatas: []
}
},
computed: {
panelInfo() {
return this.$store.state.panel.panelInfo
}
},
2021-04-20 14:19:10 +08:00
created() {
bus.$on('panle_start_list_refresh', this.refreshStarts)
2021-04-20 14:19:10 +08:00
this.initData()
},
beforeDestroy() {
bus.$off('panle_start_list_refresh', this.refreshStarts)
},
2021-04-20 14:19:10 +08:00
methods: {
showPanel(row) {
initPanelData(row.panelGroupId, false, function() {
2021-11-10 18:04:20 +08:00
bus.$emit('set-panel-show-type', 0)
2021-04-20 14:19:10 +08:00
})
},
resetID(data) {
if (data) {
2021-05-05 22:14:23 +08:00
data.forEach(item => {
2021-05-20 16:45:27 +08:00
item.type !== 'custom' && (item.id = uuid.v1())
2021-05-05 22:14:23 +08:00
})
}
2021-04-20 14:19:10 +08:00
return data
},
remove(row) {
deleteEnshrine(row.panelGroupId).then(res => {
const msg = this.$t('commons.cancel') + this.$t('panel.store') + this.$t('commons.success')
this.$success(msg)
2021-04-20 14:19:10 +08:00
this.initData()
this.panelInfo && this.panelInfo.id && row.panelGroupId === this.panelInfo.id && this.setMainNull()
2021-04-20 14:19:10 +08:00
})
},
initData() {
enshrineList({}).then(res => {
this.starDatas = res.data
})
},
setMainNull() {
this.$store.dispatch('panel/setPanelInfo', { id: null, name: '', preStyle: null })
},
refreshStarts(isStar) {
this.initData()
!isStar && this.setMainNull()
2021-04-20 14:19:10 +08:00
}
}
}
</script>
<style lang="scss" scoped>
2022-05-23 16:36:27 +08:00
.start-item {
2021-04-20 14:19:10 +08:00
width: 100%;
height: 25px;
margin: 0 0 0 10px;
2022-05-23 16:36:27 +08:00
}
.star-item-content {
2021-04-20 14:19:10 +08:00
width: calc(100% - 60px);
position: absolute;
2022-05-23 16:36:27 +08:00
}
.star-item-close {
2021-04-20 14:19:10 +08:00
width: 25px;
right: 5px;
position: absolute;
display: none;
2022-05-23 16:36:27 +08:00
}
.start-item:hover {
2021-04-20 14:19:10 +08:00
.star-item-close {
2022-05-23 16:36:27 +08:00
display: block;
2021-04-20 14:19:10 +08:00
}
2022-05-23 16:36:27 +08:00
}
.unpublished {
color: #b2b2b2
}
.publish {
}
2021-04-20 14:19:10 +08:00
</style>