<template>
|
<el-dialog
|
:title="title"
|
:width="width"
|
top="50px"
|
:close-on-click-modal="false"
|
:close-on-press-escape="false"
|
:visible.sync="isVisible"
|
>
|
<el-form ref="form" :model="sysConfig" :rules="rules" label-dic="right" label-width="165px">
|
<el-form-item label="参数名称" prop="configName">
|
<el-input v-model="sysConfig.configName" />
|
</el-form-item>
|
<el-form-item label="参数键名" prop="configKey">
|
<el-input v-model="sysConfig.configKey" :readonly="sysConfig.configId === '' ? false : 'readonly'" />
|
</el-form-item>
|
<el-form-item label="参数键值" prop="configValue">
|
<el-input v-model="sysConfig.configValue" />
|
</el-form-item>
|
<el-form-item label="备注" prop="remark">
|
<el-input v-model="sysConfig.remark" />
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="warning" plain :loading="buttonLoading" @click="isVisible = false">
|
{{ $t('common.cancel') }}
|
</el-button>
|
<el-button type="primary" plain :loading="buttonLoading" @click="submitForm">
|
{{ $t('common.confirm') }}
|
</el-button>
|
</div>
|
</el-dialog>
|
</template>
|
<script>
|
export default {
|
name: 'DicEdit',
|
props: {
|
dialogVisible: {
|
type: Boolean,
|
default: false
|
},
|
title: {
|
type: String,
|
default: ''
|
},
|
type: {
|
type: String,
|
default: ''
|
}
|
},
|
data() {
|
return {
|
screenWidth: 0,
|
buttonLoading: false,
|
width: this.initWidth(),
|
sysConfig: this.initSysConfig(),
|
rules: {
|
configName: [
|
{ required: true, message: this.$t('rules.require'), trigger: 'blur' }
|
],
|
configKey: [
|
{ required: true, message: this.$t('rules.require'), trigger: 'blur' }
|
],
|
configValue: [
|
{ required: true, message: this.$t('rules.require'), trigger: 'blur' }
|
],
|
authorizedGrantTypes: { required: true, message: this.$t('rules.require'), trigger: 'blur' }
|
},
|
grantTypes: [
|
{ type: 'refresh_token' },
|
{ type: 'authorization_code' },
|
{ type: 'dic_credentials' },
|
{ type: 'password' },
|
{ type: 'implicit' }
|
]
|
}
|
},
|
computed: {
|
isVisible: {
|
get() {
|
return this.dialogVisible
|
},
|
set() {
|
this.close()
|
this.reset()
|
}
|
}
|
},
|
mounted() {
|
window.onresize = () => {
|
return (() => {
|
this.width = this.initWidth()
|
})()
|
}
|
},
|
methods: {
|
initWidth() {
|
this.screenWidth = document.body.width
|
if (this.screenWidth < 991) {
|
return '90%'
|
} else if (this.screenWidth < 1400) {
|
return '45%'
|
} else {
|
return '800px'
|
}
|
},
|
initSysConfig() {
|
return {
|
configId: '',
|
configName: '',
|
configKey: '',
|
configValue: '',
|
remark: ''
|
}
|
},
|
setSysConfig(val) {
|
this.sysConfig = { ...val }
|
},
|
submitForm() {
|
this.$refs.form.validate((valid) => {
|
if (valid) {
|
this.buttonLoading = true
|
if (this.type === 'add') {
|
// create
|
this.$post('system/sysConfig', { ...this.sysConfig }).then(() => {
|
this.buttonLoading = false
|
this.isVisible = false
|
this.$message({
|
message: this.$t('tips.createSuccess'),
|
type: 'success'
|
})
|
this.$emit('success')
|
})
|
} else {
|
// update
|
this.$put('system/sysConfig', { ...this.sysConfig }).then(() => {
|
debugger
|
this.buttonLoading = false
|
this.isVisible = false
|
this.$message({
|
message: this.$t('tips.updateSuccess'),
|
type: 'success'
|
})
|
this.$emit('success')
|
})
|
}
|
} else {
|
return false
|
}
|
})
|
},
|
close() {
|
this.$emit('close')
|
},
|
reset() {
|
this.$refs.form.clearValidate()
|
this.$refs.form.resetFields()
|
this.sysConfig = this.initSysConfig()
|
}
|
}
|
}
|
</script>
|