zs 2 years ago
parent
commit
eb017a3d9d
4 changed files with 159 additions and 2 deletions
  1. 7 2
      src/layout/site.ts
  2. 4 0
      src/router/index.ts
  3. 52 0
      src/stores/config.ts
  4. 96 0
      src/views/system/config/index.vue

+ 7 - 2
src/layout/site.ts

@@ -48,7 +48,9 @@ export const menuInfo = {
       name: '账号管理',
       index: '5',
       type: '0',
-      children: [{ icon: 'iconshouye', _id: 'admin_4_1', path: '/acccount/updatepd', name: '修改密码' }]
+      children: [
+        { icon: 'iconshouye', _id: 'admin_4_1', path: '/acccount/updatepd', name: '修改密码' }
+      ]
     },
     {
       icon: 'iconshouye',
@@ -56,7 +58,10 @@ export const menuInfo = {
       name: '系统设置',
       index: '6',
       type: '0',
-      children: [{ icon: 'iconshouye', _id: 'admin_5_1', path: '/system/dict', name: '字典管理' }]
+      children: [
+        { icon: 'iconshouye', _id: 'admin_5_2', path: '/system/config', name: '基础设置' },
+        { icon: 'iconshouye', _id: 'admin_5_1', path: '/system/dict', name: '字典管理' }
+      ]
     }
   ]
 };

+ 4 - 0
src/router/index.ts

@@ -98,6 +98,10 @@ const router = createRouter({
           path: '/system/dictData',
           meta: { title: '字典数据管理' },
           component: () => import('@/views/system/dictData/index.vue')
+        },{
+          path: '/system/config',
+          meta: { title: '基础设置' },
+          component: () => import('@/views/system/config/index.vue')
         }
       ]
     }

+ 52 - 0
src/stores/config.ts

@@ -0,0 +1,52 @@
+import { ref, computed } from 'vue';
+import { defineStore } from 'pinia';
+import { AxiosWrapper } from '@/util/axios-wrapper';
+import _ from 'lodash';
+
+import type { IQueryType, IQueryResult, IQueryParams } from '@/util/types.util';
+const axios = new AxiosWrapper();
+const api = {
+  url: `/ball/v1/api/config`
+};
+export const ConfigStore = defineStore('config', () => {
+  const count = ref(0);
+  const doubleCount = computed(() => count.value * 2);
+  function increment() {
+    count.value++;
+  }
+  const query = async ({ skip = 0, limit = undefined, ...info }: IQueryParams = {}): Promise<IQueryResult> => {
+    let cond: IQueryType = {};
+    if (skip) cond.skip = skip;
+    if (limit) cond.limit = limit;
+    cond = { ...cond, ...info };
+    const res = await axios.$get(`${api.url}`, cond);
+    return res;
+  };
+  const fetch = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$get(`${api.url}/${payload}`);
+    return res;
+  };
+  const create = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}`, payload);
+    return res;
+  };
+  const update = async (payload: any): Promise<IQueryResult> => {
+    const id = _.get(payload, 'id', _.get(payload, '_id'));
+    const res = await axios.$post(`${api.url}/${id}`, payload);
+    return res;
+  };
+  const del = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$delete(`${api.url}/${payload}`);
+    return res;
+  };
+  return {
+    count,
+    doubleCount,
+    increment,
+    query,
+    fetch,
+    create,
+    update,
+    del
+  };
+});

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

@@ -0,0 +1,96 @@
+<template>
+  <div id="index">
+    <el-row>
+      <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
+        <el-col :span="24" class="one">
+          <cSearch :is_title="false"></cSearch>
+        </el-col>
+        <el-col :span="24" class="two">
+          <cForm :span="24" :fields="fields" :form="form" :rules="rules" @save="toSave" label-width="auto">
+            <template #logo_url="{ item }">
+              <cUpload
+                :model="item.model"
+                :limit="1"
+                url="/files/ball/config/upload"
+                :list="form[item.model]"
+                listType="picture-card"
+                @change="onUpload"
+              ></cUpload>
+            </template>
+            <template #longlogo_url="{ item }">
+              <cUpload
+                :model="item.model"
+                :limit="1"
+                url="/files/ball/config/upload"
+                :list="form[item.model]"
+                listType="picture-card"
+                @change="onUpload"
+              ></cUpload>
+            </template>
+            <template #admin_url="{ item }">
+              <cUpload
+                :model="item.model"
+                :limit="1"
+                url="/files/ball/config/upload"
+                :list="form[item.model]"
+                listType="picture-card"
+                @change="onUpload"
+              ></cUpload>
+            </template>
+          </cForm>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script setup lang="ts">
+// 基础
+import type { Ref } from 'vue';
+import { ref, reactive, onMounted } from 'vue';
+import { ElMessage } from 'element-plus';
+import type { FormRules } from 'element-plus';
+// 接口
+import { ConfigStore } from '@/stores/config';
+import type { IQueryResult } from '@/util/types.util';
+const configAxios = ConfigStore();
+
+// 加载中
+const loading: Ref<any> = ref(false);
+
+// 表单
+let form: Ref<any> = ref({});
+let fields: Ref<any[]> = ref([
+  { label: 'logo', model: 'logo_url', custom: true },
+  { label: 'logo长图', model: 'longlogo_url', custom: true },
+  { label: '管理员二维码', model: 'admin_url', custom: true }
+]);
+const rules = reactive<FormRules>({});
+
+// 请求
+onMounted(async () => {
+  loading.value = true;
+  await search();
+  loading.value = false;
+});
+const search = async () => {
+  let res: IQueryResult = await configAxios.query();
+  if (res.errcode == '0') {
+    form.value = res.data;
+  }
+};
+const onUpload = (e: { model: string; value: Array<[]> }) => {
+  const { model, value } = e;
+  form.value[model] = value;
+};
+const toSave = async (data) => {
+  let res: IQueryResult;
+  if (data._id) res = await configAxios.update(data);
+  else res = await configAxios.create(data);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `维护信息成功` });
+    search();
+  }
+};
+</script>
+<style scoped lang="scss"></style>