dataease-dm/frontend/src/views/panel/list/SaveToTemplate.vue

126 lines
2.9 KiB
Vue
Raw Normal View History

2021-04-19 11:51:22 +08:00
<template>
<el-row>
<el-row>
2021-05-14 18:51:35 +08:00
<el-col :span="4"> {{ $t('panel.template_nale')}}</el-col>
<el-col :span="20">
2021-04-19 18:20:15 +08:00
<el-input v-model="templateInfo.name" clearable size="mini" />
</el-col>
2021-04-19 11:51:22 +08:00
</el-row>
<el-row class="de-tab">
<div class="my_table">
<el-table
ref="table"
:data="data.filter(node => !keyWordSearch || node[fieldName].toLowerCase().includes(keyWordSearch.toLowerCase()))"
style="width: 100%"
:row-style="{height: '35px'}"
highlight-current-row
@current-change="clickChange"
>
<el-table-column :label="columnLabel" :column-key="fieldName" :prop="fieldName" />
<el-table-column align="right">
<template slot-scope="scope">
<el-radio v-model="tableRadio" :label="scope.row"><i /></el-radio>
</template>
</el-table-column>
</el-table>
</div>
</el-row>
<el-row class="root-class">
2021-05-19 10:17:36 +08:00
<el-button @click="cancel()">{{ $t('commons.cancel')}}</el-button>
2021-05-14 18:51:35 +08:00
<el-button type="primary" @click="save()">{{ $t('commons.save')}}</el-button>
2021-04-19 11:51:22 +08:00
</el-row>
</el-row>
</template>
<script>
import { post } from '@/api/panel/panel'
export default {
name: 'SaveToTemplate',
2021-04-19 18:20:15 +08:00
props: {
templateInfo: {
type: Object,
require: true
}
},
2021-04-19 11:51:22 +08:00
data() {
return {
data: [],
fieldName: 'name',
tableRadio: null,
keyWordSearch: '',
2021-05-17 14:19:46 +08:00
columnLabel: this.$t('panel.belong_to_category')
2021-04-19 11:51:22 +08:00
}
},
created() {
this.search()
},
methods: {
search() {
const param = {
2021-04-19 18:20:15 +08:00
templateType: 'self',
2021-04-19 11:51:22 +08:00
level: '0'
}
post('/template/templateList', param).then(response => {
this.data = response.data
})
},
clickChange(item) {
this.tableRadio = item
2021-04-19 18:20:15 +08:00
this.templateInfo.pid = item.id
2021-04-19 11:51:22 +08:00
},
cancel() {
2021-04-19 18:20:15 +08:00
this.$emit('closeSaveDialog')
},
save() {
if (!this.templateInfo.pid) {
2021-05-17 14:19:46 +08:00
this.$warning(this.$t(panel.pls_select_belong_to_category))
2021-04-19 18:20:15 +08:00
return false
}
if (!this.templateInfo.name) {
2021-05-17 14:19:46 +08:00
this.$warning(this.$t('panel.template_name_cannot_be_empty'))
2021-04-19 18:20:15 +08:00
return false
}
post('/template/save', this.templateInfo).then(response => {
this.$message({
2021-05-17 14:19:46 +08:00
message: this.$t('commons.save_success'),
2021-04-19 18:20:15 +08:00
type: 'success',
showClose: true
})
this.$emit('closeSaveDialog')
})
2021-04-19 11:51:22 +08:00
}
}
}
</script>
<style scoped>
.de-tab {
border:1px solid #E6E6E6;
min-height:200px !important;
max-height:300px !important;
overflow:auto;
margin-top: 10px;
}
.my_table >>> .el-table__row>td{
/* 去除表格线 */
border: none;
padding: 0 0;
}
.my_table >>> .el-table th.is-leaf {
/* 去除上边框 */
border: none;
}
.my_table >>> .el-table::before{
/* 去除下边框 */
height: 0;
}
.root-class {
margin: 15px 0px 5px;
text-align: center;
}
</style>