18 changed files with 247 additions and 108 deletions
After Width: | Height: | Size: 37 KiB |
@ -0,0 +1,81 @@ |
|||
<template> |
|||
<el-button type="primary" @click="data.dialogVisible = true">配置</el-button> |
|||
<el-dialog v-model="data.dialogVisible" title="配置" width="40%"> |
|||
<!-- main --> |
|||
<el-form ref="formRef" :model="form" :rules="rules" label-width="150px" class="forms"> |
|||
<el-form-item label="配置文件:" prop="config"> |
|||
<el-input v-model="form.config" type="textarea" placeholder="请输入配置文件"></el-input> |
|||
</el-form-item> |
|||
<el-form-item> <el-switch v-model="form.debug" class="mr-3"></el-switch> 是否开启debug模式 </el-form-item> |
|||
<el-form-item> |
|||
<el-button type="primary" @click="onSubmit()">发布</el-button> |
|||
<el-button @click="resetForm()">重置</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script setup> |
|||
import { defineProps, reactive, ref } from 'vue'; |
|||
import { ElMessage } from 'element-plus'; |
|||
import { updateConfig } from '@/apis/business'; |
|||
|
|||
const formRef = ref(null); |
|||
|
|||
const props = defineProps({ |
|||
businessPluginId: { default: '', type: String }, |
|||
oldConfig: { default: '', type: String }, |
|||
oldDebug: { default: 0, type: Number }, |
|||
}); |
|||
|
|||
const form = reactive({ |
|||
config: '', |
|||
debug: false, |
|||
}); |
|||
|
|||
const rules = { config: [{ required: true, message: '请输入配置文件', trigger: 'blur' }] }; |
|||
|
|||
const data = reactive({ dialogVisible: false }); |
|||
|
|||
if (props.oldConfig) { |
|||
form.config = props.oldConfig; |
|||
} |
|||
if (props.oldDebug) { |
|||
form.debug = props.oldDebug === 1; |
|||
} |
|||
|
|||
/** |
|||
* 配置修改 |
|||
* @param {object} params |
|||
*/ |
|||
function onSubmit() { |
|||
try { |
|||
formRef.value.validate(async valid => { |
|||
if (valid) { |
|||
const params = { |
|||
param: { |
|||
businessPluginId: props.businessPluginId, |
|||
config: form.config, |
|||
debug: form.debug ? 1 : 0, |
|||
}, |
|||
}; |
|||
await updateConfig(params); |
|||
ElMessage.success('配置修改成功'); |
|||
resetForm(); |
|||
data.dialogVisible = true; |
|||
} else { |
|||
console.log('error submit!!'); |
|||
return false; |
|||
} |
|||
}); |
|||
} catch (error) { |
|||
ElMessage.error(error || '配置修改失败'); |
|||
console.error('error: ', error); |
|||
} |
|||
} |
|||
|
|||
// 重置 |
|||
function resetForm() { |
|||
formRef.value.resetFields(); |
|||
} |
|||
</script> |
Loading…
Reference in new issue