NEZ-938 feat:列表页面增加 duplicate按钮

This commit is contained in:
zhangyu
2021-08-26 14:51:38 +08:00
parent 952c563870
commit 7afc73effc
17 changed files with 80 additions and 9 deletions

View File

@@ -138,6 +138,7 @@ const cn = {
assetSubTab: '子级 asset',
moreOption: '更多选项',
copy: '复制',
duplicate: '复制',
silence: '静默',
labels: '标签',
editType: '类型',

View File

@@ -144,6 +144,7 @@ const en = {
labels: 'Label',
moreOption: 'More option',
copy: 'Copy',
duplicate: 'Duplicate',
silence: 'Silence',
editType: 'Type',
searchCondition: 'Search condition',

View File

@@ -147,7 +147,12 @@ export default {
})
},
copy (u) {
this.object = { ...u, name: 'Copy from ' + u.name, id: '' }
this.object = { ...u, name: u.name + '-copy', id: '' }
if (this.object.name.length > 64) {
const length = this.object.name.length - 64
console.log(length, this.object.name.length, u.name.length)
this.object.name = u.name.substring(0, u.name.length - length) + '-copy'
}
this.rightBox.show = true
},
esc () {

View File

@@ -322,7 +322,7 @@ export default {
handler (n, o) {
this.isEdit = true
this.editAlertRule = JSON.parse(JSON.stringify(n))
if (this.editAlertRule.id) {
if (this.editAlertRule.id || this.editAlertRule.name) {
this.expressions = [this.editAlertRule.expr]
this.$nextTick(() => {
this.expressions.forEach((ex, index) => {

View File

@@ -72,6 +72,7 @@
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-has="'alertRule_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="'alertRule_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="'alertRule_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="'alertSilence_add'" :command="['fastSilence', scope.row, 'alertRule']"><i class="nz-icon nz-icon-fast-silence"></i><span class="operation-dropdown-text">{{$t('overall.silenceAlert')}}</span></el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>

View File

@@ -96,6 +96,7 @@
</div>
<el-dropdown-menu slot="dropdown">
<!-- <el-dropdown-item :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="'alertSilence_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="'alertSilence_expire'" :command="['delete', scope.row]"><i class="nz-icon nz-icon-delete"></i><span class="operation-dropdown-text">{{$t('buttons.delete')}}</span></el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>

View File

@@ -58,6 +58,7 @@
<el-dropdown-menu slot="dropdown">
<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>

View File

@@ -178,6 +178,7 @@
<!-- <el-dropdown-item v-if="!endpointTab" :command="['endpointQuery', scope.row]"><i class="nz-icon nz-icon-search"></i><span class="operation-dropdown-text">{{$t('overall.query')}}</span></el-dropdown-item>-->
<el-dropdown-item v-if="!endpointTab" v-has="'monitor_endpoint_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="'monitor_endpoint_delete'" :command="['delete', scope.row, `sys/endpoint?ids=${scope.row.id}`]"><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="'monitor_endpoint_edit'" :command="['copy', scope.row, 'project']"><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="'alertSilence_add'" :command="['fastSilence', scope.row, 'endpoint']"><i class="nz-icon nz-icon-fast-silence"></i><span class="operation-dropdown-text">{{$t('overall.silenceAlert')}}</span></el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>

View File

@@ -50,7 +50,7 @@
<i class="nz-icon nz-icon-more3"></i>
</div>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-has="'expressionTemplate_add'" :command="['copy', scope.row]"><i class="nz-icon nz-icon-override"></i><span class="operation-dropdown-text">{{$t('overall.copy')}}</span></el-dropdown-item>
<el-dropdown-item v-has="'expressionTemplate_add'" :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="'expressionTemplate_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-menu>
</el-dropdown>

View File

@@ -74,6 +74,7 @@
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-has="'monitor_module_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="'monitor_module_delete'" :command="['delete', scope.row, `sys/user?ids=${scope.row.id}`]"><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="'monitor_module_edit'" :command="['copy', scope.row, 'module']"><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-item v-has="'alertSilence_add'" :command="['fastSilence', scope.row, 'module']"><i class="nz-icon nz-icon-fast-silence"></i><span class="operation-dropdown-text">{{$t('overall.silenceAlert')}}</span></el-dropdown-item>
</el-dropdown-menu>

View File

@@ -74,6 +74,7 @@
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="['edit', scope.row]" v-has="'project_edit'"><i class="nz-icon nz-icon-edit"></i><span class="operation-dropdown-text">{{$t('overall.edit')}}</span></el-dropdown-item>
<el-dropdown-item :command="['delete', scope.row, `sys/user?ids=${scope.row.id}`]" v-has="'project_delete'"><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="'project_edit'" :command="['copy', scope.row, 'project']"><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="'alertSilence_add'" :command="['fastSilence', scope.row, 'project']"><i class="nz-icon nz-icon-fast-silence"></i><span class="operation-dropdown-text">{{$t('overall.silenceAlert')}}</span></el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>

View File

@@ -44,6 +44,7 @@
:table-data="tableData"
@del="del"
@edit="edit"
@copy="copy"
@orderBy="tableDataSort"
@queryMessage="queryMessage"
@reload="getTableData"
@@ -178,7 +179,7 @@ export default {
}
})
},
edit (u) {
edit (u, copyFlag) {
this.$get(`${this.url}/${u.id}`).then(response => {
if (response.code === 200) {
this.object = {
@@ -186,9 +187,21 @@ export default {
method: response.data.method ? response.data.method.split(',').map(item => Number(item)) : [],
receiverShow: response.data.receiver ? response.data.receiver.split(',').map(item => Number(item)) : []
}
if (copyFlag) {
this.object.id = ''
this.object.name = this.object.name + '-copy'
if (this.object.name.length > 64) {
const length = this.object.name.length - 64
console.log(length, this.object.name.length, u.name.length)
this.object.name = u.name.substring(0, u.name.length - length) + '-copy'
}
}
this.rightBox.show = true
}
})
},
copy (u) {
this.edit(u, true)
}
},
mounted () {

View File

@@ -26,6 +26,7 @@
:table-data="tableData"
@del="del"
@edit="edit"
@copy="copy"
@orderBy="tableDataSort"
@reload="getTableData"
@selectionChange="selectionChange"
@@ -181,7 +182,7 @@ export default {
this.object = JSON.parse(JSON.stringify(this.blankObject))
this.rightBox.show = true
},
edit (u) {
edit (u, copyFlag) {
this.$get(`${this.url}/${u.id}`).then(response => {
if (response.code === 200) {
this.object = {
@@ -190,10 +191,22 @@ export default {
startAt: bus.UTCTimeToConfigTimezone(response.data.startAt),
endAt: bus.UTCTimeToConfigTimezone(response.data.endAt)
}
if (copyFlag) {
this.object.id = ''
this.object.name = this.object.name + '-copy'
if (this.object.name.length > 64) {
const length = this.object.name.length - 64
console.log(length, this.object.name.length, u.name.length)
this.object.name = u.name.substring(0, u.name.length - length) + '-copy'
}
}
this.rightBox.show = true
}
})
},
copy (u) {
this.edit(u, true)
},
del (row) {
this.$confirm(this.$t('tip.confirmExpired'), {
confirmButtonText: this.$t('tip.yes'),

View File

@@ -74,7 +74,7 @@
:table-data="tableData"
@del="del"
@edit="edit"
@copy="(row) => {copyRow(row, 'exprTmpl')}"
@copy="copy"
@orderBy="tableDataSort"
@reload="getTableData"
@sync="chartBySync"

View File

@@ -60,6 +60,7 @@
:tableId="tableId"
@del="del"
@edit="edit"
@copy="copy"
@orderBy="tableDataSort"
@reload="getTableData"
@addSilence="addSilence"
@@ -317,9 +318,18 @@ export default {
}
},
methods: {
edit (row) {
edit (row, copyFlag) {
this.$get('monitor/endpoint/' + row.id).then(res => {
this.object = JSON.parse(JSON.stringify(res.data))
if (copyFlag) {
this.object.id = ''
this.object.name = this.object.name + '-copy'
if (this.object.name.length > 64) {
const length = this.object.name.length - 64
console.log(length, this.object.name.length, row.name.length)
this.object.name = row.name.substring(0, row.name.length - length) + '-copy'
}
}
this.object.configs.forEach(item => {
item.config = JSON.parse(item.config)
})
@@ -393,12 +403,20 @@ export default {
this.object.paramObj.push({ key: '', value: [] })
}
this.object.assetName = this.object.asset ? this.object.asset.name : ''
this.object.assetId = this.object.asset ? this.object.asset.id + '' : ''
this.object.projectId = this.object.project.id
this.object.moduleId = this.object.module.id
this.object.type = this.object.module.type
if (copyFlag) {
this.rightBox.show = true
} else {
this.rightBox.editShow = true
}
})
},
copy (u) {
this.edit(u, true)
},
closeRightEditBox (refresh) {
this.rightBox.editShow = false
this.rightBox.show = false

View File

@@ -47,6 +47,7 @@
:table-data="tableData"
@del="del"
@edit="edit"
@copy="copy"
@orderBy="tableDataSort"
@reload="getTableData"
@sync="chartBySync"
@@ -200,11 +201,20 @@ export default {
}
},
methods: {
edit (row) {
edit (row, copyFlag) {
this.$get('monitor/module/' + row.id).then(res => {
if (res.code === 200) {
this.object = JSON.parse(JSON.stringify(res.data))
this.object.configs = JSON.parse(this.object.configs)
if (copyFlag) {
this.object.id = ''
this.object.name = this.object.name + '-copy'
if (this.object.name.length > 64) {
const length = this.object.name.length - 64
console.log(length, this.object.name.length, row.name.length)
this.object.name = row.name.substring(0, row.name.length - length) + '-copy'
}
}
// this.object.configs.walk = this.object.configs.walk ? JSON.parse(JSON.stringify(this.object.configs.walk)) : []
// this.object.port = this.object.configs.port ? JSON.parse(JSON.stringify(this.object.configs.port)) : ''
this.object.paramObj = []
@@ -285,6 +295,9 @@ export default {
}
})
},
copy (u) {
this.edit(u, true)
},
getTableData () {
this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo)
this.$set(this.searchLabel, 'pageSize', this.pageObj.pageSize)

View File

@@ -29,6 +29,7 @@
style="padding-right: 0"
@del="del"
@edit="edit"
@copy = 'copy'
@orderBy="tableDataSort"
@reload="getTableData"
@addSilence="addSilence"