server-cfg.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <title>服务器私有配置</title>
  6. <!-- 所有的 css js 资源 -->
  7. <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
  8. <link rel="stylesheet" href="../../static/sa.css">
  9. <script src="../../static/kj/vue.min.js"></script>
  10. <script src="../../static/kj/element-ui/index.js"></script>
  11. <script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
  12. <script src="../../static/kj/layer/layer.js"></script>
  13. <script src="../../static/sa.js"></script>
  14. <script src="../../static/kj/upload-util.js"></script>
  15. <style type="text/css">
  16. html, body, .vue-box {
  17. height: 100%;
  18. overflow: hidden;
  19. }
  20. /* .vue-box{padding: 0px;} */
  21. .c-panel {
  22. height: calc(100% - 4em);
  23. position: relative;
  24. }
  25. .c-panel .c-label {
  26. width: 10em;
  27. }
  28. .c-panel .el-input {
  29. width: 500px;
  30. }
  31. .c-panel .el-textarea {
  32. width: 500px;
  33. }
  34. .logo-img {
  35. width: 35px;
  36. height: 35px;
  37. border-radius: 2px;
  38. vertical-align: middle;
  39. margin-right: 0.5em;
  40. cursor: pointer;
  41. }
  42. .s-tab {
  43. height: 100%;
  44. }
  45. .el-tabs__content {
  46. height: calc(100% - 130px);
  47. overflow: auto;
  48. }
  49. </style>
  50. </head>
  51. <body>
  52. <div class="vue-box" style="display: none;" :style="'display: block;'">
  53. <div class="c-panel" v-if="m != null">
  54. <!-- tab卡片 -->
  55. <el-tabs class="s-tab" v-model="activeTab">
  56. <!-- ---------------------------------- 系统参数 ---------------------------------- -->
  57. <el-tab-pane label="系统参数" name="tab1">
  58. <!-- <div class="c-item br">
  59. <label class="c-label">预留信息:</label>
  60. <el-input v-model="m.reserve_info"></el-input>
  61. </div> -->
  62. <div class="c-item">
  63. <label class="c-label">抛出SQL:</label>
  64. <el-switch v-model="m.throwOutSql" :active-value="1" :inactive-value="2"></el-switch>
  65. <span class="c-remark" v-if="m.throwOutSql==1">开启</span>
  66. <span class="c-remark" v-else>关闭</span>
  67. <span class="c-remark" style="color: red;">( 抛出sql只为方便调试,建议只在开发环境下打开此选项,生产环境请务必关闭 )</span>
  68. </div>
  69. </el-tab-pane>
  70. </el-tabs>
  71. <!-- ---------------------------------- 其它配置 ---------------------------------- -->
  72. <el-tab-pane label="其它配置" name="tab2">
  73. <br>
  74. <span>其它配置</span>
  75. </el-tab-pane>
  76. <!-- 确定按钮 -->
  77. <div style="position: absolute; bottom: 0px; width: calc(100% - 3em); line-height: 80px; background-color: #FFF;">
  78. <hr style="height: 2px;">
  79. <div class="c-item">
  80. <label class="c-label"></label>
  81. <el-button type="primary" icon="el-icon-check" @click="ok">保存修改</el-button>
  82. <el-button type="primary" icon="el-icon-refresh-right" @click="f5">重置</el-button>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. <script type="text/javascript">
  88. // 创建一个默认的配置对象
  89. function create_m() {
  90. return {
  91. reserve_info: '预留信息', // 预留信息
  92. throwOutSql: 2, // 是否隐藏sql,
  93. }
  94. }
  95. </script>
  96. <script>
  97. var app = new Vue({
  98. el: '.vue-box',
  99. data: {
  100. sa: sa, // 超级对象
  101. m: null, //
  102. activeTab: 'tab1'
  103. },
  104. methods: {
  105. // 初始化配置
  106. init: function (str) {
  107. // 获取
  108. var cfg = sa.JSONParse(str, {}); // 用户配置
  109. var default_cfg = create_m(); // 默认配置
  110. // 遍历
  111. for (var key in default_cfg) {
  112. if (cfg[key] !== undefined && cfg[key] !== null) {
  113. default_cfg[key] = cfg[key];
  114. }
  115. }
  116. // 赋值
  117. this.m = default_cfg;
  118. },
  119. // 刷新
  120. f5: function () {
  121. sa.ajax('/SpCfg/getCfg', {
  122. cfgName: 'server_cfg'
  123. }, function (res) {
  124. this.init(res.data);
  125. }.bind(this));
  126. },
  127. // 提交
  128. ok: function () {
  129. sa.ajax('/SpCfg/updateCfg', {
  130. cfgName: 'server_cfg',
  131. cfgValue: JSON.stringify(this.m)
  132. }, function (res) {
  133. sa.ok2('保存成功');
  134. }.bind(this));
  135. }
  136. },
  137. created: function () {
  138. this.f5();
  139. }
  140. })
  141. </script>
  142. </body>
  143. </html>