lrf 5 months ago
parent
commit
97c269afdf

+ 11 - 0
src/router/modules/system.js

@@ -9,6 +9,17 @@ export const routes = [
       alwaysShow: false
     },
     children: [
+      {
+        path: '/system/config',
+        name: 'system_config',
+        meta: {
+          title: '平台设置',
+          affix: true,
+          keepAlive: true,
+          alwaysShow: false
+        },
+        component: () => import('@/views/system/config/index.vue')
+      },
       {
         path: '/system/menus',
         name: 'system_menus',

+ 17 - 0
src/store/api/system/config.js

@@ -0,0 +1,17 @@
+import { AxiosWrapper } from '@/utils/axios-wrapper'
+import { get } from 'lodash-es'
+const url = '/config'
+const axios = new AxiosWrapper()
+
+export const ConfigStore = defineStore('config', () => {
+  const query = async () => {
+    const res = await axios.$get(url)
+    return res
+  }
+  const update = async (payload) => {
+    const id = get(payload, 'id', get(payload, '_id'))
+    const res = await axios.$post(`${url}/${id}`, payload)
+    return res
+  }
+  return { query, update }
+})

+ 1 - 1
src/views/login/index.vue

@@ -47,7 +47,7 @@ const loginStore = LoginStore()
 const loading = ref(false) // 按钮loading
 const loginFormRef = ref({}) // 登录表单ref
 const loginData = ref({
-  account: 'admin',
+  account: 'sadmin',
   password: '1qaz2wsx',
   type: 'Admin'
 })

+ 33 - 0
src/views/system/config/index.vue

@@ -3,18 +3,51 @@
     <el-row>
       <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
         <el-col :span="24" class="one"> 系统设置 </el-col>
+        <el-form>
+          <el-form-item label="系统名称">
+            <el-input v-model="config.name"></el-input>
+          </el-form-item>
+          <el-form-item label="logo">
+            <custom-upload
+              v-model="config.logo"
+              url="/ts/frame/api/files/test/upload"
+            ></custom-upload>
+          </el-form-item>
+          <el-row>
+            <el-col :span="24" style="text-align: center">
+              <el-button type="primary" @click="toSave">保存</el-button>
+            </el-col>
+          </el-row>
+        </el-form>
       </el-col>
     </el-row>
   </div>
 </template>
 
 <script setup>
+const $checkRes = inject('$checkRes')
+import { get } from 'lodash'
+import { ConfigStore } from '@/store/api/system/config'
+const configStore = ConfigStore()
 // 加载中
 const loading = ref(false)
 // 请求
 onMounted(async () => {
   loading.value = true
   loading.value = false
+  await getConfig()
 })
+const config = ref({})
+const getConfig = async () => {
+  const res = await configStore.query()
+  if ($checkRes(res)) {
+    config.value = get(res, 'data', {})
+  }
+}
+const toSave = async () => {
+  console.log(config)
+  const res = await configStore.update(config.value)
+  $checkRes(res, '操作成功', res.errmsg)
+}
 </script>
 <style scoped lang="scss"></style>

+ 2 - 2
src/views/system/dictData/index.vue

@@ -70,8 +70,8 @@ const search = async (query = { skip: 0, limit }) => {
   const info = { skip: query.skip, limit: query.limit, ...searchForm.value, code: codeInfo.value.code }
   const res = await store.query(info)
   if (res.errcode == '0') {
-    data.value = res.data
-    total.value = res.total
+    data.value = res.data.data
+    total.value = res.data.total
   }
 }
 // 字典数据转换

+ 2 - 3
src/views/system/role/index.vue

@@ -13,7 +13,7 @@
     <el-row justify="end" style="margin-top: 10px; height: 5vh">
       <el-pagination background layout="total, prev, pager, next" :page-size="limit" :total="total" v-model:current-page="currentPage" @current-change="changePage" />
     </el-row>
-    <el-dialog v-model="dialog" :title="$t('pages.role.dialogTitle')" :destroy-on-close="true" @close="toClose">
+    <el-dialog v-model="dialog" title="角色管理" :destroy-on-close="true" @close="toClose">
       <role-form></role-form>
     </el-dialog>
   </div>
@@ -61,7 +61,7 @@ const dialog = ref(false)
 const toEdit = async (data) => {
   let res = await store.fetch(data._id)
   if ($checkRes(res)) {
-    form.value = res.data.data
+    form.value = res.data
     dialog.value = true
   }
 }
@@ -79,7 +79,6 @@ const toDelete = async (data) => {
 }
 const onSubmit = async () => {
   const data = cloneDeep(form.value)
-  console.log(data)
   let res
   if (get(data, '_id')) res = await store.update(data)
   else res = await store.create(data)