Files
ptools/templates/auto_pt/settings.html

127 lines
4.1 KiB
HTML

{% load static %}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
{% include 'admin/includes/css-part.html' %}
<style>
.el-textarea__inner {
color: #F2F6FC;
background-color: #1f2c39 !important;
font-size: 16px;
font-family: 'Heiti SC';
line-height: 24px;
word-break: break-word;
border: 1px solid #eee;
height: 100%;
width: 100%;
word-spacing: 3px;
letter-spacing: 2px;
}
</style>
</head>
<body>
<div id="app">
<div style="width: 100%">
<el-popconfirm title="确定修改配置文件吗?" @confirm="saveSettings">
<el-button type="primary" slot="reference" size="small">保存</el-button>
</el-popconfirm>
</div>
<div style="width: 100%;margin-top: 5px;">
<el-input v-model="settings" type="textarea" autosize="{minRows: 30}" autocorrect="off"
class="settings"></el-input>
</div>
</div>
{% include 'admin/includes/js-part.html' %}
<script src="{% static 'admin/simpleui-x/js/axios.min.js' %}"></script>
<script>
const vm = new Vue({
el: '#app',
data() {
return {
settings: '',
}
},
beforeMount() {
this.get_config_settings()
},
mounted() {
},
methods: {
get_config_settings() {
axios.get(
"{% url 'get_config_api' %}"
).then(res => {
console.log('获取数据列表成功', res)
{#let data = res.data#}
{#console.log(typeof res.data.data)#}
if (res.data.code === 0) {
this.settings = res.data.data
console.log(this.settings)
//this.$message({
// type: 'success',
// message: res.data.msg
//});
} else {
this.loading = false
this.$message({
type: 'warning',
message: '获取数据列表失败!'
});
}
}).catch(res => {
console.log('获取数据列表失败', res)
this.$message({
type: 'warning',
message: '获取数据列表失败!' + res
});
})
},
saveSettings() {
axios({
method: "post",
headers: {
"content-type": "application/json",
},
url: "{% url 'save_config_api' %}",
data: {
settings: this.settings
}
}).then(res => {
console.log('获取数据列表成功', res)
{#let data = res.data#}
{#console.log(typeof res.data.data)#}
if (res.data.code === 0) {
console.log(res.data.msg)
this.get_config_settings()
this.$message({
type: 'success',
message: res.data.msg
});
} else {
this.loading = false
this.$message({
type: 'warning',
message: '获取数据列表失败!'
});
}
}).catch(res => {
console.log('获取数据列表失败', res)
this.$message({
type: 'warning',
message: '获取数据列表失败!' + res
});
})
}
}
})
</script>
</body>
</html>