Ver Fonte

系统配置修改

zhangjie há 2 anos atrás
pai
commit
6496fa33fc

+ 14 - 0
src/assets/styles/pages.scss

@@ -29,6 +29,20 @@
     padding-left: 20px;
   }
 }
+// system-setting
+.system-setting{
+  .form-part{
+    margin-bottom: 30px;
+
+    &-title{
+      font-weight: 600;
+      font-size: 16px;
+      line-height: 1;
+      margin-bottom: 10px;
+    }
+    
+  }
+}
 // organization-manage
 .organization-manage {
   .org-tree-head {

+ 6 - 0
src/constants/adminNavs.js

@@ -17,6 +17,12 @@ const navs = [
     name: "系统角色管理",
     url: "SystemRoleManage"
   },
+  {
+    id: "6",
+    parentId: "1",
+    name: "系统设置",
+    url: "SystemAdminSetting"
+  },
   {
     id: "4",
     parentId: "1",

+ 9 - 0
src/modules/admin/router.js

@@ -2,6 +2,7 @@ import AdminUserManage from "./views/AdminUserManage.vue";
 import PrivilegeManage from "./views/PrivilegeManage.vue";
 import SystemRoleManage from "./views/SystemRoleManage.vue";
 import SchoolMenuManage from "./views/SchoolMenuManage.vue";
+import SystemAdminSetting from "../base/views/SystemSetting.vue";
 import AuthSet from "./views/AuthSet.vue";
 import Admin from "./views/Admin.vue";
 
@@ -34,6 +35,14 @@ export default {
       path: "auth-set",
       name: "AuthSet",
       component: AuthSet
+    },
+    {
+      path: "system-setting",
+      name: "SystemAdminSetting",
+      component: SystemAdminSetting,
+      props: {
+        isSystem: true
+      }
     }
   ]
 };

+ 7 - 1
src/modules/base/api.js

@@ -182,8 +182,14 @@ export const updateArchivesType = datas => {
   return $post("/api/admin/paper/archives_type/save", datas);
 };
 
+// import systemset from "./systemset.json";
 // system-setting
-export const systemSettingQuery = () => {
+export const systemSettingQuery = isSystem => {
+  // console.log(isSystem);
+  // return Promise.resolve(systemset);
+  if (isSystem) {
+    return $postParam("/api/admin/sys/setting_global/get", {});
+  }
   return $postParam("/api/admin/sys/setting/get", {});
 };
 export const updateSystemSetting = datas => {

+ 83 - 0
src/modules/base/systemset.json

@@ -0,0 +1,83 @@
+[
+    {
+        "data": [
+            {
+                "code": "initPassword",
+                "enable": true,
+                "name": "默认初始登录密码",
+                "sort": 1,
+                "value": "123456"
+            },
+            {
+                "code": "verificationCodeLoginEnable",
+                "enable": true,
+                "name": "是否开启验证码登录",
+                "sort": 2,
+                "value": "true"
+            },
+            {
+                "code": "SMSNotificationEnable",
+                "enable": true,
+                "name": "是否开启短信提醒功能",
+                "sort": 3,
+                "value": "true"
+            },
+            {
+                "code": "txtCharset",
+                "enable": true,
+                "name": "异步任务txt日志文件编码",
+                "sort": 4,
+                "value": "gbk"
+            }
+        ],
+        "name": "系统设置",
+        "sort": 1
+    },
+    {
+        "data": [
+            {
+                "code": "openOcr",
+                "enable": true,
+                "name": "是否启用OCR",
+                "sort": 1,
+                "value": "false"
+            },
+            {
+                "code": "ocrAppId",
+                "enable": true,
+                "name": "OCR AppId",
+                "sort": 2,
+                "value": "27869327"
+            },
+            {
+                "code": "ocrAppKey",
+                "enable": true,
+                "name": "OCR AppKey",
+                "sort": 3,
+                "value": "0EatsWDMu4Ts4Q4I9eYZdgV7"
+            },
+            {
+                "code": "ocrAppSecret",
+                "enable": true,
+                "name": "OCR AppSecret",
+                "sort": 4,
+                "value": "rlEolf9jVqS9V0tsi6x4l9Eu4ATKnfYv"
+            }
+        ],
+        "name": "OCR设置",
+        "sort": 2
+    },
+    {
+        "data": [
+            {
+                "code": "openGlobalMatch",
+                "enable": true,
+                "name": "是否开启全局匹配",
+                "sort": 1,
+                "value": "false"
+            }
+        ],
+        "name": "图片检查设置",
+        "sort": 3
+    }
+]

+ 61 - 45
src/modules/base/views/SystemSetting.vue

@@ -5,28 +5,37 @@
         ref="modalFormComp"
         :model="modalForm"
         :rules="rules"
-        label-width="160px"
+        label-width="200px"
       >
-        <el-form-item prop="openOcr" label="是否开启OCR识别:">
-          <el-radio-group v-model="modalForm.openOcr">
-            <el-radio
-              v-for="item in BOOLEAN_STATUS"
-              :key="item.value"
-              :label="item.value"
-              >{{ item.label }}</el-radio
+        <div v-for="(group, gindex) in setList" :key="gindex" class="form-part">
+          <h2 class="form-part-title">{{ group.name }}</h2>
+          <div class="form-part-body">
+            <el-form-item
+              v-for="field in group.data"
+              :key="field.code"
+              :prop="field.code"
+              :label="`${field.name}:`"
             >
-          </el-radio-group>
-        </el-form-item>
-        <el-form-item prop="openGlobalMatch" label="是否开启全局匹配:">
-          <el-radio-group v-model="modalForm.openGlobalMatch">
-            <el-radio
-              v-for="item in BOOLEAN_STATUS"
-              :key="item.value"
-              :label="item.value"
-              >{{ item.label }}</el-radio
-            >
-          </el-radio-group>
-        </el-form-item>
+              <el-radio-group
+                v-if="checkValueIsBoolean(field.value)"
+                v-model="modalForm[field.code]"
+              >
+                <el-radio
+                  v-for="item in BOOLEAN_STATUS"
+                  :key="item.value"
+                  :label="item.value"
+                  >{{ item.label }}</el-radio
+                >
+              </el-radio-group>
+              <el-input
+                v-else
+                v-model="modalForm[field.code]"
+                placeholder="请输入"
+                clearable
+              ></el-input>
+            </el-form-item>
+          </div>
+        </div>
         <el-form-item>
           <el-button type="primary" :disabled="isSubmit" @click="submit"
             >确认</el-button
@@ -39,10 +48,6 @@
 
 <script>
 import { systemSettingQuery, updateSystemSetting } from "../api";
-const initModalForm = {
-  openOcr: false,
-  openGlobalMatch: false
-};
 
 export default {
   name: "system-setting",
@@ -53,38 +58,43 @@ export default {
       BOOLEAN_STATUS: [
         {
           label: "开启",
-          value: true
+          value: "true"
         },
         {
           label: "关闭",
-          value: false
+          value: "false"
         }
       ],
-      rules: {
-        openOcr: [
-          {
-            required: true,
-            message: "请选择",
-            trigger: "change"
-          }
-        ],
-        openGlobalMatch: [
-          {
-            required: true,
-            message: "请选择",
-            trigger: "change"
-          }
-        ]
-      }
+      rules: {},
+      setList: []
     };
   },
   mounted() {
     this.getSysSet();
   },
   methods: {
+    checkValueIsBoolean(val) {
+      return ["true", "false"].includes(val);
+    },
     async getSysSet() {
-      const res = await systemSettingQuery();
-      this.modalForm = this.$objAssign(initModalForm, res || {});
+      const data = await systemSettingQuery(this.$attrs.isSystem);
+      this.setList = data;
+      let modalForm = {},
+        rules = {};
+      data.forEach(item => {
+        item.data.forEach(field => {
+          modalForm[field.code] = field.value;
+          rules[field.code] = [
+            {
+              required: true,
+              message: `请设置${field.name}`,
+              trigger: "change"
+            }
+          ];
+        });
+      });
+      this.modalForm = modalForm;
+      this.rules = rules;
     },
     async submit() {
       const valid = await this.$refs.modalFormComp.validate().catch(() => {});
@@ -92,7 +102,13 @@ export default {
 
       if (this.isSubmit) return;
       this.isSubmit = true;
-      const data = await updateSystemSetting(this.modalForm).catch(() => {});
+      this.setList.forEach(item => {
+        item.data.forEach(field => {
+          field.value = this.modalForm[field.code];
+        });
+      });
+
+      const data = await updateSystemSetting(this.setList).catch(() => {});
       this.isSubmit = false;
 
       if (!data) return;