xiangpei
2024-07-09 0cd01cdd783dd45d20617d5945efe4f9433eb00e
系统配置代码
1个文件已修改
2个文件已添加
91 ■■■■■ 已修改文件
src/api/sysConfig.js 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router.js 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/sys/SysSetting.vue 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/sysConfig.js
New file
@@ -0,0 +1,18 @@
import axios from './request'
// 获取系统配
export const getSysConfig = () => {
  return axios({
    url: '/api/sys-config',
    method: 'GET'
  })
}
// 修改系统配置表
export const editSysConfig = (params) => {
  return axios({
    url: '/api/sys-config/',
    method: 'PUT',
    data: params
  })
}
src/router.js
@@ -313,6 +313,23 @@
      }
    ]
  },
  {
    path: '/config',
    component: Layout,
    children: [
      {
        path: '/setting',
        name: 'SysSetting',
        meta: {
          title: '系统配置',
          icon: 'answer',
          affix: true
        },
        component: () => import('@/views/sys/SysSetting')
      },
    ]
  },
  // {
  //   path: '/message',
  //   component: Layout,
src/views/sys/SysSetting.vue
New file
@@ -0,0 +1,56 @@
<template>
  <div class="app-container">
    <el-form :model="form" status-icon :rules="rules" ref="form" label-width="150px">
      <el-form-item label="密码过期时间(天)" prop="passwordExpireTime">
        <el-input v-model="form.passwordExpireTime" type="number" autocomplete="off" placeholder="比如:30天密码过期"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="edit()">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { getSysConfig, editSysConfig } from '@/api/sysConfig'
export default {
  name: 'SysSetting',
  data () {
    return {
      form: {
        id: null,
        passwordExpireTime: null
      },
      rules: {
        passwordExpireTime: [
          { required: true, message: '请输入密码过期时间', trigger: 'blur' }
        ]
      }
    }
  },
  mounted () {
    this.getConfig()
  },
  methods: {
    getConfig () {
      getSysConfig().then(res => {
        this.form = res.data.data
      })
    },
    edit () {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          editSysConfig(this.form).then(res => {
            this.$message.success('修改成功')
          })
        }
      })
    }
  }
}
</script>
<style scoped>
</style>