Browse Source

系统配置-基础配置

zhongxiaoyu 1 year ago
parent
commit
9191de530d

+ 1 - 1
public/config.js

@@ -427,7 +427,7 @@ var SERVICE_ID = {
   sysQueryTabId: 5, //系统设置-查询模板-表格-增删改
   sysDataTabId: 9, //系统设置-数据结构-数据项-表格-增删改
   sysServiceAddXyId: 10, //系统设置-服务管理-新增服务-新增数据源-提交
-  securityPolicy: 101000, // 系统配置-基础配置
+  securityPolicy: 111000, // 系统配置-基础配置
 
   /***-----应用管理------***/
   appScId: 12, //应用管理-增删改

+ 3 - 3
src/api/webApi.ts

@@ -89,7 +89,7 @@ export async function dataToChange(
 }
 
 //新增
-function newData(params) {
+export function newData(params) {
   return request({
     url: "/externalApi/openApi/sendData",
     method: "post",
@@ -98,7 +98,7 @@ function newData(params) {
 }
 
 //修改
-function modifyData(params) {
+export function modifyData(params) {
   return request({
     url: "/externalApi/openApi/sendData",
     method: "post",
@@ -107,7 +107,7 @@ function modifyData(params) {
 }
 
 //删除movedata
-function moveData(params) {
+export function moveData(params) {
   return request({
     url: "/externalApi/openApi/sendData",
     method: "post",

+ 3 - 1
src/views/login/Login.vue

@@ -15,7 +15,7 @@
       <el-form-item prop="password" :rules="formRules.isNotNull">
         <el-input size="large" show-password ref="refPassword" autocomplete="on" v-model="formInline.password" type="password" name="password" placeholder="密码" />
       </el-form-item>
-      <div class="rowSS">
+      <div v-if="verificationCodeEnable" class="rowSS">
         <el-form-item prop="verificationCode" :rules="formRules.isNotNull">
           <el-input size="large" @keyup.enter="handleLogin" v-model="formInline.verificationCode" placeholder="请输入验证码" />
         </el-form-item>
@@ -80,6 +80,7 @@ onBeforeMount(() => {
   getToken();
 });
 
+const verificationCodeEnable = ref(false)
 const getToken = async () => {
   const { code, returnData, message } = (await gettoken({
     appid: PLATFROM_CONFIG.appId,
@@ -87,6 +88,7 @@ const getToken = async () => {
   })) as any;
   if (code == 0 && returnData) {
     setCodeToken(returnData.appToken);
+    verificationCodeEnable.value = returnData.verificationCode
     getCheckCode();
     //getSystemSet();
   } else {

+ 176 - 143
src/views/systemSettings/securityPolicy/securityPolicyedit.vue

@@ -1,218 +1,251 @@
 <template>
-  <div class="airportInfo">
-    <el-row :gutter="24">
-      <el-col :span="8">
-        <div class="dos">
-          <Minheader :is-preser="true" :is-statuser="true">
-            <template #header>
-              <div class="status flex-wrap">
-                <div class="manageTitle">验证码策略</div>
-              </div>
-            </template>
-          </Minheader>
-          <el-form :model="tableForm">
+  <div class="security-policy">
+    <el-form
+      ref="form"
+      :model="formData"
+      :rules="formRule"
+      size="default"
+      label-position="left"
+      label-width="95px"
+    >
+      <el-row :gutter="24">
+        <el-col :span="8">
+          <div class="security-policy-box">
+            <Minheader
+              :is-preser="true"
+              :is-statuser="true"
+              @preserForm="submitForm"
+            >
+              <template #header>
+                <div class="status flex-wrap">
+                  <div class="manageTitle">验证码策略</div>
+                </div>
+              </template>
+            </Minheader>
             <el-row :gutter="24">
               <el-col :span="12">
-                <el-form-item label="验证码长度" size="default">
+                <el-form-item
+                  label="验证码长度"
+                  prop="verification_code_length"
+                >
                   <el-input
-                    v-model="tableForm.name"
+                    v-model="formData.verification_code_length"
                     placeholder="请输入验证码长度"
+                    clearable
                   />
                 </el-form-item>
               </el-col>
               <el-col :span="12">
-                <el-form-item label="验证码类型" size="default">
+                <el-form-item label="验证码类型" prop="verification_code_type">
                   <el-select
                     style="width: 100%"
-                    v-model="tableForm.china"
+                    v-model="formData.verification_code_type"
                     class="input-shadow"
                     filterable
                     default-first-option
                     clearable
                     placeholder="请选择"
                   >
-                    <el-option
-                      v-for="item in tableOptionser"
-                      :key="item.v ? item.v : item.planDepartureApt"
-                      :label="item.k ? item.k : item.planDepartureApt"
-                      :value="item.v ? item.v : item.planDepartureApt"
-                    >
-                    </el-option>
+                    <el-option :value="1" label="仅数字" />
+                    <el-option :value="2" label="数字英文" />
                   </el-select>
                 </el-form-item>
               </el-col>
               <el-col :span="12">
-                <el-form-item label="大小写选择" size="default">
+                <el-form-item label="大小写选择" prop="verification_code_Aa">
                   <el-select
                     style="width: 100%"
-                    v-model="tableForm.englin"
+                    v-model="formData.verification_code_Aa"
                     class="input-shadow"
                     filterable
                     default-first-option
                     clearable
                     placeholder="请选择"
                   >
-                    <el-option
-                      v-for="item in tableOptionser"
-                      :key="item.v ? item.v : item.planDepartureApt"
-                      :label="item.k ? item.k : item.planDepartureApt"
-                      :value="item.v ? item.v : item.planDepartureApt"
-                    >
-                    </el-option>
+                    <el-option :value="true" label="英文区分大小写" />
+                    <el-option :value="false" label="英文不区分大小写" />
                   </el-select>
                 </el-form-item>
               </el-col>
               <el-col :span="12">
-                <el-form-item label="是否开启" prop="roleStatus">
-                  <el-radio-group v-model="tableForm.two">
-                    <el-radio label="1">是</el-radio>
-                    <el-radio label="2"> 否</el-radio>
+                <el-form-item label="是否开启" prop="verification_code">
+                  <el-radio-group v-model="formData.verification_code">
+                    <el-radio :label="true">是</el-radio>
+                    <el-radio :label="false">否</el-radio>
                   </el-radio-group>
                 </el-form-item>
               </el-col>
             </el-row>
-          </el-form>
-        </div>
-      </el-col>
-      <el-col :span="8">
-        <div class="dos">
-          <Minheader :is-preser="true" :is-statuser="true">
-            <template #header>
-              <div class="status flex-wrap">
-                <div class="manageTitle">密码策略</div>
-              </div>
-            </template>
-          </Minheader>
-          <el-form :model="tableForm1">
+          </div>
+        </el-col>
+        <el-col :span="8">
+          <div class="security-policy-box">
+            <Minheader
+              :is-preser="true"
+              :is-statuser="true"
+              @preserForm="submitForm"
+            >
+              <template #header>
+                <div class="status flex-wrap">
+                  <div class="manageTitle">密码策略</div>
+                </div>
+              </template>
+            </Minheader>
             <el-row :gutter="24">
-              <el-col :span="12">
-                <el-form-item label="密码长度" size="default">
+              <el-col :span="24">
+                <el-form-item
+                  label="密码规则"
+                  prop="pwd_cons"
+                  label-width="70px"
+                >
                   <el-input
-                    v-model="tableForm1.name"
-                    placeholder="请输入密码长度"
-                  />
-                </el-form-item>
-              </el-col>
-              <el-col :span="12">
-                <el-form-item label="密码类型" size="default">
-                  <el-select
-                    style="width: 100%"
-                    v-model="tableForm1.china"
-                    class="input-shadow"
-                    filterable
-                    default-first-option
-                    clearable
-                    placeholder="请选择"
-                  >
-                    <el-option
-                      v-for="item in tableOptionser"
-                      :key="item.v ? item.v : item.planDepartureApt"
-                      :label="item.k ? item.k : item.planDepartureApt"
-                      :value="item.v ? item.v : item.planDepartureApt"
-                    >
-                    </el-option>
-                  </el-select>
-                </el-form-item> </el-col
-              ><el-col :span="12">
-                <el-form-item label="大小写选择" size="default">
-                  <el-select
-                    style="width: 100%"
-                    v-model="tableForm1.englin"
-                    class="input-shadow"
-                    filterable
-                    default-first-option
+                    v-model="formData.pwd_cons"
+                    placeholder="请输入密码规则(正则表达式)"
                     clearable
-                    placeholder="请选择"
-                  >
-                    <el-option
-                      v-for="item in tableOptionser"
-                      :key="item.v ? item.v : item.planDepartureApt"
-                      :label="item.k ? item.k : item.planDepartureApt"
-                      :value="item.v ? item.v : item.planDepartureApt"
-                    >
-                    </el-option>
-                  </el-select>
+                  />
                 </el-form-item>
               </el-col>
             </el-row>
-          </el-form>
-        </div>
-      </el-col>
-      <el-col :span="8">
-        <div class="dos">
-          <Minheader :is-preser="true" :is-statuser="true">
-            <template #header>
-              <div class="status flex-wrap">
-                <div class="manageTitle">多点登录</div>
-              </div>
-            </template>
-          </Minheader>
-          <el-form :model="tableForm2">
+          </div>
+        </el-col>
+        <el-col :span="8">
+          <div class="security-policy-box">
+            <Minheader
+              :is-preser="true"
+              :is-statuser="true"
+              @preserForm="submitForm"
+            >
+              <template #header>
+                <div class="status flex-wrap">
+                  <div class="manageTitle">多点登录</div>
+                </div>
+              </template>
+            </Minheader>
             <el-row :gutter="24">
               <el-col :span="12">
-                <el-form-item label="是否开启" prop="roleStatus">
-                  <el-radio-group v-model="tableForm2.name">
-                    <el-radio label="1">是</el-radio>
-                    <el-radio label="2"> 否</el-radio>
+                <el-form-item label="是否开启" prop="user_officer_multi">
+                  <el-radio-group v-model="formData.user_officer_multi">
+                    <el-radio :label="true">是</el-radio>
+                    <el-radio :label="false">否</el-radio>
                   </el-radio-group>
                 </el-form-item>
               </el-col>
             </el-row>
-          </el-form>
-        </div>
-      </el-col>
-    </el-row>
+          </div>
+        </el-col>
+      </el-row>
+    </el-form>
   </div>
 </template>
 
 <script setup lang="ts">
-import { Query } from '@/api/webApi'
+import { Query, modifyData } from '@/api/webApi'
 import Minheader from '@/components/minheader/index.vue'
-const tableOptionser = ref<any[]>([]) //弹窗下拉
-const tableForm = reactive({
-  name: '',
-  china: '',
-  englin: '',
-  two: '1',
-  three: '',
-  text: '',
-})
-const tableForm1 = reactive({
-  name: '',
-  china: '',
-  englin: '',
-  two: '',
-  three: '',
-  text: '',
-})
-const tableForm2 = reactive({
-  name: '1',
-  china: '',
-  englin: '',
-  two: '',
-  three: '',
-  text: '',
+import { ElMessage, FormInstance } from 'element-plus'
+
+const form = ref<FormInstance | null>(null)
+const formData = reactive({
+  verification_code_length: null,
+  verification_code_type: null,
+  verification_code_Aa: true,
+  verification_code: null,
+  pwd_cons: null,
+  user_officer_multi: true,
 })
+const verificationCodeEnable = computed(() =>
+  Boolean(formData.verification_code)
+)
+const formRule = {
+  verification_code_length: [
+    {
+      required: verificationCodeEnable,
+      message: '请输入验证码长度',
+      trigger: 'blur',
+    },
+  ],
+  verification_code_type: [
+    {
+      required: verificationCodeEnable,
+      message: '请选择验证码类型',
+      trigger: 'blur',
+    },
+  ],
+  verification_code_Aa: [
+    {
+      required: verificationCodeEnable,
+      message: '请选择验证码大小写',
+      trigger: 'blur',
+    },
+  ],
+  verification_code: [
+    { required: true, message: '请选择是否开启验证码', trigger: 'blur' },
+  ],
+  // pwd_cons: [{ required: true, message: '请输入密码规则(正则表达式)', trigger: 'blur' }],
+  user_officer_multi: [
+    { required: true, message: '请选择是否开启多点登录', trigger: 'blur' },
+  ],
+}
+
+const submitForm = () => {
+  form.value?.validate(valid => {
+    if (valid) {
+      setSecurityPolicy()
+    }
+  })
+}
 
 const getSecurityPolicy = async () => {
   try {
-    Query({
+    const {
+      code,
+      returnData: { listValues },
+      message,
+    } = await Query({
       id: DATACONTENT_ID.securityPolicy,
       dataContent: [],
     })
+    if (String(code) !== '0') {
+      throw new Error(message ?? '失败')
+    }
+    if (!listValues.length) {
+      throw new Error('未查询到策略信息')
+    }
+    const data = listValues[0]
+    Object.assign(formData, data)
   } catch (error) {
     console.error(error)
   }
 }
+
+const setSecurityPolicy = async () => {
+  try {
+    const dataContent = {
+      ...formData,
+      event: 2,
+    }
+    const { code, message } = await modifyData({
+      serviceId: SERVICE_ID.securityPolicy,
+      dataContent,
+    })
+    if (String(code) !== '0') {
+      throw new Error(message ?? '失败')
+    }
+    ElMessage.success('操作成功')
+    getSecurityPolicy()
+  } catch (error) {
+    console.error(error)
+  }
+}
+
 onMounted(() => {
   getSecurityPolicy()
 })
 </script>
 
 <style lang="scss" scoped>
-.airportInfo {
+.security-policy {
   height: 100%;
-  .dos {
+  .security-policy-box {
     width: 100%;
     height: 240px;
     background: #fafcff;