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
nezha-nezha-fronted/nezha-fronted/src/components/common/table/settings/chartTmplTable.vue

204 lines
6.9 KiB
Vue
Raw Normal View History

<template>
<el-table
id="roleTable"
ref="dataTable"
:data="tableData"
:height="height"
border
:default-sort="orderBy"
@header-dragend="dragend"
@sort-change="tableDataSort"
@selection-change="selectionChange"
2021-05-25 15:37:33 +08:00
@row-dblclick="(row)=>{showBottomBox('panel', row)}"
>
<el-table-column
:resizable="false"
align="center"
type="selection"
width="55">
</el-table-column>
<el-table-column
v-for="(item, index) in customTableTitle"
v-if="item.show"
: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 slot="header">
<span class="data-column__span">{{item.label}}</span>
<div class="col-resize-area"></div>
</template>
<template slot-scope="scope" :column="item">
<span v-if="item.prop==='varType'">{{scope.row[item.prop] === 1 ? 'Asset' : 'Endpoint'}}</span>
2021-04-27 11:25:24 +08:00
<span v-else-if="item.prop==='type'">
<i :class="typeIcon(scope.row)"/>
2021-05-27 14:09:02 +08:00
{{findTypeLabel(scope.row)}}
</span>
<template v-else-if="item.prop === 'name'">
2022-10-20 17:08:16 +08:00
<copy :copyData='scope.row[item.prop]' :showInfo='scope.row[item.prop]'>
<template slot="copy-text">
{{scope.row[item.prop]?scope.row[item.prop]:'-'}}
</template>
</copy>
</template>
2021-04-23 18:10:25 +08:00
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop] || '-'}}</span>
<template v-else>-</template>
</template>
</el-table-column>
<el-table-column
:resizable="false"
:width="operationWidth"
fixed="right">
<div slot="header" class="table-operation-title">{{$t('overall.option')}}</div>
<div slot-scope="scope" class="table-operation-items">
<button class="table-operation-item" @click="showBottomBox('panel', scope.row)" :title="$t('overall.view')"><i class="nz-icon nz-icon-view1"></i></button>
2022-01-11 17:05:21 +08:00
<el-dropdown size="medium" v-has="['chartTemplate_edit','chartTemplate_delete']" trigger="click" @command="tableOperation">
<div class="table-operation-item table-operation-item--more" :title="$t('overall.moreOperations')">
2021-05-27 13:53:42 +08:00
<i class="nz-icon nz-icon-more3"></i>
</div>
<el-dropdown-menu slot="dropdown" class="right-box-select-top right-public-box-dropdown-top">
2022-01-11 17:05:21 +08:00
<el-dropdown-item v-has="'chartTemplate_edit'" :command="['edit', scope.row]"><i class="nz-icon nz-icon-edit"></i><span class="operation-dropdown-text">{{$t('overall.edit')}}</span></el-dropdown-item>
<!-- <el-dropdown-item v-has="'chartTemplate_delete'" :command="['delete', scope.row]"><i class="nz-icon nz-icon-delete"></i><span class="operation-dropdown-text">{{$t('overall.delete')}}</span></el-dropdown-item> -->
<el-dropdown-item v-has="'chartTemplate_delete'" :command="['delete', scope.row]">
<delete-button
ref="deleteButton"
:from="'chartTemp'"
:forceDeleteShow="false"
:type="'link'"
:title="$t('overall.delete')"
id="alert-msg-delete"
v-has="'expressionTemplate_delete'"
:api="api"
:single="true"
:delete-objs="singleDelete"
@before="delFlag=true"
></delete-button>
</el-dropdown-item>
2022-01-11 17:05:21 +08:00
<el-dropdown-item v-has="'chartTemplate_edit'" :command="['copy', scope.row]"><i class="nz-icon nz-icon-override"></i><span class="operation-dropdown-text">{{$t('overall.duplicate')}}</span></el-dropdown-item>
<el-dropdown-item v-has="'chartTemplate_edit'" :command="['sync', scope.row]"><i class="nz-icon nz-icon-sync"></i><span class="operation-dropdown-text">{{$t('overall.syncChart')}}</span></el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</el-table-column>
<template slot="empty">
2021-10-25 14:45:28 +08:00
<div v-if="!loading" class="table-no-data">
2021-10-22 17:47:42 +08:00
<svg class="icon" aria-hidden="true">
<use xlink:href="#nz-icon-no-data-list"></use>
</svg>
2021-10-28 17:53:27 +08:00
<div class="table-no-data__title">No results found</div>
2021-10-22 17:47:42 +08:00
</div>
<div v-else>&nbsp;</div>
2021-10-22 17:47:42 +08:00
</template>
</el-table>
</template>
<script>
import table from '@/components/common/mixin/table'
2021-05-10 15:59:39 +08:00
import { chart as chartConstant } from '@/components/common/js/constants'
import deleteButton from '@/components/common/deleteButton'
2022-10-20 17:08:16 +08:00
import copy from '@/components/common/copy'
export default {
name: 'chartTmplTable',
mixins: [table],
2022-10-20 17:08:16 +08:00
components: { deleteButton, copy },
2021-10-22 17:47:42 +08:00
props: {
loading: Boolean
},
data () {
return {
2021-05-10 15:59:39 +08:00
chartTypeList: chartConstant.type,
tableTitle: [
{
label: 'ID',
prop: 'id',
show: true,
width: 80,
2021-05-10 16:27:27 +08:00
sortable: 'custom'
}, {
label: this.$t('overall.name'),
prop: 'name',
show: true,
2021-07-22 10:00:29 +08:00
minWidth: 200,
2021-05-10 16:27:27 +08:00
sortable: 'custom'
}, {
label: this.$t('overall.type'),
prop: 'type',
show: true,
2021-07-22 10:00:29 +08:00
minWidth: 200,
2021-05-10 16:27:27 +08:00
sortable: 'custom'
2021-04-23 18:10:25 +08:00
}, {
label: this.$t('dashboard.panel.chartForm.varType'),
2021-04-23 18:10:25 +08:00
prop: 'varType',
show: true,
2021-07-22 10:00:29 +08:00
minWidth: 200,
2021-05-10 16:27:27 +08:00
sortable: 'custom'
}, {
2021-06-08 09:44:32 +08:00
label: this.$t('overall.remark'),
prop: 'remark',
2021-07-22 10:00:29 +08:00
show: true,
minWidth: 200
}
2021-05-10 16:27:27 +08:00
]
}
},
methods: {
typeIcon (row) {
2021-04-27 11:25:24 +08:00
let str = 'nz-icon '
switch (row.type) {
case 'line':
str += 'nz-icon-link-chart'
2021-04-27 11:25:24 +08:00
break
case 'bar':
str += 'nz-icon-bar-chart'
2021-04-27 11:25:24 +08:00
break
case 'stackArea':
str += 'nz-icon-stack-area'
2021-04-27 11:25:24 +08:00
break
case 'singleStat':
str += 'nz-icon-single-value'
2021-04-27 11:25:24 +08:00
break
case 'pie':
str += 'nz-icon-pie-chart'
2021-04-27 11:25:24 +08:00
break
case 'table':
str += 'nz-icon-table1'
2021-04-27 11:25:24 +08:00
break
case 'alertList':
str += 'nz-icon-alert-list'
2021-04-27 11:25:24 +08:00
break
case 'text':
str += 'nz-icon-text1'
2021-04-27 11:25:24 +08:00
break
case 'url':
str += 'nz-icon-url'
2021-04-27 11:25:24 +08:00
break
case 'group':
str += 'nz-icon-group'
break
case 'logs':
str += 'nz-icon-logs'
break
case 'bubble':
str += 'nz-icon-bubble'
break
default :
str += 'nz-icon-table1'
break
}
return str
2021-05-27 14:09:02 +08:00
},
findTypeLabel (row) {
const typeItem = this.chartTypeList.find(title => title.value === row.type)
return typeItem ? this.$t(typeItem.label) : '-'
}
}
}
</script>