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

174 lines
5.6 KiB
Vue
Raw Normal View History

<template>
<el-table
id="roleTable"
ref="dataTable"
:data="tableData"
:height="height"
border
@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>
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">
2021-08-03 17:04:23 +08:00
<button class="table-operation-item" @click="showBottomBox('panel', scope.row)"><i class="nz-icon nz-icon-view1"></i></button>
2021-05-19 14:26:09 +08:00
<el-dropdown size="medium" v-has="['panel_chart_edit','panel_chart_delete']" trigger="hover" @command="tableOperation">
<div class="table-operation-item table-operation-item--more">
2021-05-27 13:53:42 +08:00
<i class="nz-icon nz-icon-more3"></i>
</div>
2021-09-26 18:14:47 +08:00
<el-dropdown-menu slot="dropdown" class="right-public-box-select-top right-public-box-dropdown-top">
<el-dropdown-item v-has="'panel_chart_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="'panel_chart_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="'panel_chart_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="'panel_chart_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>
2021-10-22 17:47:42 +08:00
<template v-if="!loading" slot="empty">
<div class="right-no-data">
<svg class="icon" aria-hidden="true">
<use xlink:href="#nz-icon-no-data-list"></use>
</svg>
<div style="font-size: 16px;color: #333333;font-weight: 400;">No results found</div>
</div>
</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'
export default {
name: 'chartTmplTable',
mixins: [table],
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('config.exprTemp.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('config.exprTemp.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('config.exprTemp.varType'),
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
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 ? typeItem.label : '-'
}
}
}
</script>