Przeglądaj źródła

优化字典hook、关闭百度统计

wangzhiqiang 5 miesięcy temu
rodzic
commit
47fe4021d6

+ 0 - 6
src/assets/svg/read.md

@@ -1,6 +0,0 @@
-<!--
- * @Date: 2023-05-24 14:25:36
- * @Description: 
- * @LastEditors: luoxi
--->
-请在当前文件夹内放入svg文件,并删除当前文件

+ 1 - 2
src/components/from/index.vue

@@ -30,8 +30,7 @@
           </div>
           <div v-else-if="item.type === 'daterange'">
             <el-date-picker v-model="form[item.prop]" type="daterange" range-separator="至" start-placeholder="开始日期"
-              end-placeholder="结束日期" size="default" :clearable="true" style="width: 230px;"
-              :prefix-icon="CustomDateIcon" />
+              end-placeholder="结束日期" size="default" :clearable="true" style="width: 230px;" />
           </div>
           <div v-else-if="item.type === 'date'">
             <el-date-picker v-model="form[item.prop]" type="date" :placeholder="item.placeholder || '请选择'" :size="default" />

+ 4 - 4
src/components/table/index.vue

@@ -5,13 +5,13 @@
       <el-table-column type="selection" align="center" width="50" v-if="showSelection" />
       <el-table-column label="序号" width="60" align="center" v-if="showIndex">
         <template #default="scope">
-          {{ (page.index - 1) * page.size + scope.$index + 1 }}
+          {{ (page.pageNum - 1) * page.pageSize + scope.$index + 1 }}
         </template>
       </el-table-column>
       <slot></slot>
     </el-table>
-    <el-pagination v-if="showPage" v-model:current-page="page.index" class="system-page" background :layout="pageLayout"
-      :total="page.total" :page-size="page.size" :page-sizes="pageSizes" @current-change="handleCurrentChange"
+    <el-pagination v-if="showPage" v-model:current-page="page.pageNum" class="system-page" background :layout="pageLayout"
+      :total="page.total" :page-size="page.pageSize" :page-sizes="pageSizes" @current-change="handleCurrentChange"
       @size-change="handleSizeChange">
     </el-pagination>
   </div>
@@ -29,7 +29,7 @@
       page: { // 分页参数
         type: Object,
         default: () => {
-          return { index: 1, size: 20, total: 0 }
+          return { pageNum: 1, pageSize: 20, total: 0 }
         }
       },
       pageLayout: { type: String, default: "total, sizes, prev, pager, next, jumper" }, // 分页需要显示的东西,默认全部

+ 0 - 4
src/config/index.js

@@ -1,7 +1,3 @@
-/*
- * @Date: 2022-05-22 20:44:25
- * @Description: 
- */
 const showLogo = true; // 是否显示Logo顶部模块
 const systemTitle = '易推网络' // 系统名称,用于显示在左上角模块,登录模块、以及浏览器标题上使用,使用配置项
 const systemSubTitle = '渠道商营销管理系统' // 系统提示信息,用于登录模块使用

+ 22 - 1
src/hooks/useGetDictList.js

@@ -31,7 +31,7 @@ export function useGetDictList() {
                 dictData.value = res.data || []
                 sessionStorage.setItem(DICT_CACHE_KEY, JSON.stringify(res.data))
             }
-            
+
 
             // 处理数据
             const { uniqueTypes: ut, optionsByType: obt } = processDictData(dictData.value)
@@ -113,6 +113,26 @@ export function useGetDictList() {
             }))
     }
 
+    /**
+     * 获取单个字典匹配下标的名称
+     * @param {string} typeCode - 字典类型代码
+     * @param {string | number} dictionaryCode - 字典下标值
+     * @returns 
+     */
+    function getDictionaryName(typeCode, dictionaryCode) {
+        if (!dictData.value.length) {
+            console.warn('字典数据未加载,请先调用 loadDictData')
+            return []
+        }
+
+        const item = dictData.value.find(
+            entry =>
+                entry.typeCode === typeCode &&
+                entry.dictionaryCode === String(dictionaryCode)
+        );
+        return item ? item.dictionaryName : '123';
+    }
+
     /**
      * 清除字典缓存
      */
@@ -130,5 +150,6 @@ export function useGetDictList() {
         loadDictData, // 加载字典数据
         clearDictCache, // 清除缓存
         getOptions, // 获取指定类型的选项
+        getDictionaryName, //获取单个字典匹配下标的名称
     }
 }

+ 3 - 7
src/main.js

@@ -1,11 +1,7 @@
-/*
- * @Date: 2022-05-22 20:44:25
- * @Description: 
- */
 import { createApp } from 'vue'
 import ElementPlus from 'element-plus'
 import locale from "element-plus/es/locale/lang/zh-cn";
-import { baidu } from './utils/system/statistics'
+// import { baidu } from './utils/system/statistics'
 import 'element-plus/theme-chalk/display.css' // 引入基于断点的隐藏类
 import 'element-plus/dist/index.css'
 import 'normalize.css' // css初始化
@@ -15,9 +11,9 @@ import App from './App.vue'
 import store from './store'
 import router from './router'
 import { getAuthRoutes } from './router/permission'
-if (import.meta.env.MODE !== 'development') { // 非开发环境调用百度统计
+/* if (import.meta.env.MODE !== 'development') { // 非开发环境调用百度统计
   baidu()
-}
+} */
 
 /** 权限路由处理主方法 */
 getAuthRoutes().then(() => {

+ 0 - 8
src/router/index.js

@@ -1,11 +1,3 @@
-/*
- * @Author: luoxi
- * @Date: 2022-01-25 09:51:12
- * @LastEditors: luoxi
- * @LastEditTime: 2022-01-25 12:25:51
- * @FilePath: \vue-admin-box\src\router\index.ts
- * @Description: 
- */
 /**
  * @description 所有人可使用的参数配置列表
  * @params hideMenu: 是否隐藏当前路由结点不在导航中展示

+ 0 - 4
src/router/permission.js

@@ -1,7 +1,3 @@
-/*
- * @Date: 2022-07-24 21:43:47
- * @Description: 
- */
 /** 引入类型 */
 
 /** 引入路由相关的资源 */

+ 0 - 5
src/utils/tab/index.js

@@ -1,8 +1,3 @@
-/*
- * @Date: 2022-09-25 20:05:01
- * @Description: tab面板的操作方法
- */
-
 /** 关闭当前标签 */
 export const closeCurrentTab = (nextPath) => {
   /** 拿到tab组件 */

+ 1 - 11
src/views/main/riskModule/components/configForm.vue

@@ -270,7 +270,7 @@
         return true;
     }
 
-    const { dictData, loadDictData, uniqueTypes, optionsByType, getOptions } = useGetDictList();
+    const { dictData, loadDictData, uniqueTypes, optionsByType, getOptions, getDictionaryName } = useGetDictList();
 
     // 配置数据
     const configFormList = ref({
@@ -386,16 +386,6 @@
         }
     }
 
-    // 获取单个字典匹配下标的名称
-    function getDictionaryName(typeCode, dictionaryCode) {
-        const item = dictData.value.find(
-            entry =>
-                entry.typeCode === typeCode &&
-                entry.dictionaryCode === String(dictionaryCode)
-        );
-        return item ? item.dictionaryName : '';
-    }
-
     // 核心:生成每条文本描述
     const conditionTexts = computed(() => {
         return configFormList.value.configList.map(item => {

+ 18 - 25
src/views/main/riskModule/riskControlConfig.vue

@@ -19,7 +19,21 @@
         <el-table-column prop="appNames" label="关联应用" width="120" />
         <el-table-column prop="appIds" label="关联应用ID" width="150" />
         <el-table-column prop="templateCode" label="配置编码" width="90" />
-        <el-table-column prop="templateContent" label="配置内容" />
+        <el-table-column prop="templateContent" label="配置内容">
+          <template #default="scope">
+            <el-popover
+              class="box-item"
+              :title="`${scope.row.templateName}的配置内容`"
+              :width="400"
+              placement="top-start"
+            >
+              <template #reference>
+                {{ scope.row.templateContent }}
+              </template>
+              <div v-html="scope.row.templateContent.split(',').filter(Boolean).map(item => item.trim()).join('<br/>')"></div>
+          </el-popover>
+          </template>
+        </el-table-column>
         <el-table-column prop="templateId" label="配置模版ID" width="160" />
         <el-table-column prop="templateName" label="配置名称" width="100" />
         <el-table-column prop="createTime" label="创建时间" width="160">
@@ -90,7 +104,7 @@
   import { useStore } from 'vuex'
 
   const store = useStore()
-  const { dictData, loadDictData } = useGetDictList();
+  const { dictData, loadDictData, getOptions, getDictionaryName } = useGetDictList();
   const form = ref(null);
   const tableData = ref([]);
 
@@ -133,7 +147,7 @@
 
   onBeforeMount(async () => {
     await getEnabledListData()
-    // await settingData()
+    await settingData()
     await getList();
     await getRiskOptions()
   });
@@ -149,29 +163,9 @@
           options: appListOptions.value,
         },
       ]
-
-      function getOptions(name) {
-        const options = dictData.value
-          .filter(item => item.typeCode === name) // 只取启用的项
-          .sort((a, b) => a.sort - b.sort)   // 按 sort 排序
-          .map(item => ({
-            label: item.dictionaryName,
-            value: Number(item.dictionaryCode) // 将字符串"1"/"0"转为数字
-          }));
-        return options
-      }
     })
   }
 
-  function getDictionaryName(typeCode, dictionaryCode) {
-    const item = dictData.value.find(
-      entry =>
-        entry.typeCode === typeCode &&
-        entry.dictionaryCode === String(dictionaryCode)
-    );
-    return item ? item.dictionaryName : '';
-  }
-
   const appListData = ref([])
   const appListOptions = ref([])
   const getEnabledListData = async () => {
@@ -378,14 +372,13 @@
         // 提交内容
         riskRelativeApps(formEdit.value).then((res) => {
           ElMessage.success('关联应用成功')
+          layer1.value.show = false;
           getList();
         })
       } else {
         console.log("error submit!", fields);
       }
     })
-
-    layer1.value.show = false;
   }
   // #endregion
 

+ 3 - 23
src/views/main/userModule/relieveLogsList.vue

@@ -92,7 +92,7 @@
   import { useStore } from 'vuex'
 
   const store = useStore()
-  const { dictData, loadDictData, getOptions } = useGetDictList();
+  const { dictData, loadDictData, getOptions, getDictionaryName } = useGetDictList();
   const form = ref(null);
   const tableData = ref([]);
 
@@ -168,29 +168,9 @@
         { label: '解封时间', prop: 'deblockingTime', type: 'daterange' },
         { label: '登录时间', prop: 'loginTime', type: 'daterange' },
       ]
-
-      function getOptions(name) {
-        const options = dictData.value
-          .filter(item => item.typeCode === name) // 只取启用的项
-          .sort((a, b) => a.sort - b.sort)   // 按 sort 排序
-          .map(item => ({
-            label: item.dictionaryName,
-            value: Number(item.dictionaryCode) // 将字符串"1"/"0"转为数字
-          }));
-        return options
-      }
     })
   }
 
-  function getDictionaryName(typeCode, dictionaryCode) {
-    const item = dictData.value.find(
-      entry =>
-        entry.typeCode === typeCode &&
-        entry.dictionaryCode === String(dictionaryCode)
-    );
-    return item ? item.dictionaryName : '';
-  }
-
   // 分页数据
   const getList = async () => {
     let res = await riskDeblockingList({ ...formSearch.value });
@@ -240,8 +220,8 @@
     formSearch.value = {
       appId: null,// 应用ID
       channelId: null,// 渠道ID
-      channelType: 0,//渠道类型
-      channelOrigin: 0,// 渠道来源
+      channelType: null,//渠道类型
+      channelOrigin: null,// 渠道来源
       deblockingReason: null,// 解封原因
       deblockingTimeBegin: null,// 解封时间开始
       deblockingTimeEnd: null,// 解封时间结束

+ 1 - 21
src/views/main/userModule/riskLogsList.vue

@@ -98,7 +98,7 @@
   import { useStore } from 'vuex'
 
   const store = useStore()
-  const { dictData, loadDictData } = useGetDictList();
+  const { dictData, loadDictData, getOptions, getDictionaryName } = useGetDictList();
   const form = ref(null);
   const tableData = ref([]);
 
@@ -166,29 +166,9 @@
         },
         { label: '封禁时间', prop: 'bannedTime', type: 'daterange' },
       ]
-
-      function getOptions(name) {
-        const options = dictData.value
-          .filter(item => item.typeCode === name) // 只取启用的项
-          .sort((a, b) => a.sort - b.sort)   // 按 sort 排序
-          .map(item => ({
-            label: item.dictionaryName,
-            value: Number(item.dictionaryCode) // 将字符串"1"/"0"转为数字
-          }));
-        return options
-      }
     })
   }
 
-  function getDictionaryName(typeCode, dictionaryCode) {
-    const item = dictData.value.find(
-      entry =>
-        entry.typeCode === typeCode &&
-        entry.dictionaryCode === String(dictionaryCode)
-    );
-    return item ? item.dictionaryName : '';
-  }
-
   // 分页数据
   const getList = async () => {
     let res = await riskBannedList({ ...formSearch.value });

+ 4 - 26
src/views/main/userModule/userList.vue

@@ -118,7 +118,7 @@
   import { useStore } from 'vuex'
 
   const store = useStore()
-  const { dictData, loadDictData, getOptions } = useGetDictList();
+  const { dictData, loadDictData, getOptions, getDictionaryName } = useGetDictList();
   const form = ref(null);
   const tableData = ref([]);
 
@@ -181,29 +181,9 @@
         { label: '登录时间', prop: 'lastLoginTime', type: 'date' },
         { label: '注册时间', prop: 'registryTime', type: 'date' },
       ]
-
-      function getOptions(name) {
-        const options = dictData.value
-          .filter(item => item.typeCode === name) // 只取启用的项
-          .sort((a, b) => a.sort - b.sort)   // 按 sort 排序
-          .map(item => ({
-            label: item.dictionaryName,
-            value: Number(item.dictionaryCode) // 将字符串"1"/"0"转为数字
-          }));
-        return options
-      }
     })
   }
 
-  function getDictionaryName(typeCode, dictionaryCode) {
-    const item = dictData.value.find(
-      entry =>
-        entry.typeCode === typeCode &&
-        entry.dictionaryCode === String(dictionaryCode)
-    );
-    return item ? item.dictionaryName : '';
-  }
-
   // 分页数据
   const getList = async () => {
     let res = await getUserList({ ...formSearch.value });
@@ -307,15 +287,13 @@
         // 提交内容
         riskBannedUser({ ...formEdit.value }).then((res) => {
           ElMessage.success('封禁用户成功')
+          layer.value.show = false
           getList();
         })
       } else {
         console.log("error submit!", fields);
       }
-    })
-
-    layer.value.show = false
-
+    })  
   }
 
   // 弹窗2
@@ -370,13 +348,13 @@
         // 提交内容
         riskBannedUser(formEdit.value).then((res) => {
           ElMessage.success('更改用户状态成功')
+          layer1.value.show = false
           getList();
         })
       } else {
         console.log("error submit!", fields);
       }
     })
-    layer1.value.show = false
   }
 
 

+ 2 - 22
vite.config.js

@@ -1,13 +1,4 @@
-/*
- * @Author: luoxi
- * @Date: 2022-01-25 09:51:12
- * @LastEditors: Please set LastEditors
- * @LastEditTime: 2023-02-21 22:57:42
- * @FilePath: \vue-admin-box\vite.config.ts
- * @Description: 
- */
 import vue from '@vitejs/plugin-vue'
-import { viteMockServe } from 'vite-plugin-mock'
 // import {vitePluginSvg} from "@webxrd/vite-plugin-svg"
 import { resolve } from 'path'
 
@@ -31,11 +22,11 @@ export default ({ command }) => {
       alias
     },
     server: {
-      port: 3001,
+      port: 3003,
       host: '0.0.0.0',
       open: true,
       proxy: { // 代理配置
-        '/dev': 'https://www.fastmock.site/mock/48cab8545e64d93ff9ba66a87ad04f6b/'
+        // '/dev': 'https://www.fastmock.site/mock/48cab8545e64d93ff9ba66a87ad04f6b/'
       },
     },
     build: {
@@ -49,17 +40,6 @@ export default ({ command }) => {
     },
     plugins: [
       vue(),
-      viteMockServe({
-        mockPath: 'mock',
-        localEnabled: command === 'serve',
-        prodEnabled: command !== 'serve' && prodMock,
-        watchFiles: true,
-        injectCode: `
-          import { setupProdMockServer } from '../mockProdServer';
-          setupProdMockServer();
-        `,
-        logger: true,
-      }),
       /*  vitePluginSvg({
          // 必要的。必须是绝对路径组成的数组。
          iconDirs: [