2 Commits 4707aa6b9f ... fe636278cb

Author SHA1 Message Date
  guicheng fe636278cb 部分功能添加 1 month ago
  guicheng 5fe11872e5 打包配置调整 4 months ago

+ 10 - 10
src/api/user.ts

@@ -2,15 +2,15 @@
  * @Author: Gui
  * @Date: 2023-03-01 19:20:44
  * @LastEditors: guicheng 1625811865@qq.com
- * @LastEditTime: 2024-06-20 11:35:34
+ * @LastEditTime: 2024-09-29 10:07:12
  * @Description: kxs files
  * @filePath:
  */
 import { http } from "@/utils/http";
-import { baseUrlApi } from "./utils";
 import encryptByDES from "@/utils/encryptByDES";
+import productionEnvironment from "@/api/utils";
 import { getGroupUrl } from "@/utils/getUrl/getUrl.js";
-const UrlList = await getGroupUrl();
+const UrlList: any = await getGroupUrl();
 
 export type UserResult = {
   status: String;
@@ -49,20 +49,20 @@ export type RefreshTokenResult = {
 /** 登录 */
 export const getLogin = (data?: object) => {
   console.log(data);
-  return http.login(UrlList.SkbSystem.oauth2token.url, data);
+  const url =
+    "https://test-gateway-llb.kexiaoshuang.com/v1/llb/sysServer/oauth2/token";
+  return http.login(url, data);
 };
 /** 获取当前用户树形菜单 */
 export const getUserMenu = () => {
-  return http.Request({
-    url: UrlList.SkbSystem.menugetUserMenu.url,
-    method: UrlList.SkbSystem.menugetUserMenu.method,
-    params: {}
-  });
+  const url =
+    "https://test-gateway-llb.kexiaoshuang.com/v1/llb/sysServer/menu/getUserMenu";
+  return http.get(url, {});
 };
 
 /** 刷新token */
 export const refreshTokenApi = (data?: object) => {
-  return http.request<RefreshTokenResult>("post", "/refreshtoken", {
+  return http.request("post", "/refreshtoken", {
     data: { value: encryptByDES(JSON.stringify(data)) }
   });
 };

+ 3 - 3
src/api/utils.ts

@@ -1,10 +1,10 @@
 /*
  * @Author: Gui
  * @Date: 2023-03-08 11:24:34
- * @LastEditors: Please set LastEditors
- * @LastEditTime: 2024-01-03 14:24:41
+ * @LastEditors: guicheng 1625811865@qq.com
+ * @LastEditTime: 2024-09-29 10:06:26
  * @Description: kxs files
  * @filePath:
  */
 export const baseUrlApi = (url: string) =>
-  `http://test.mpadminap.kexiaoshuang.com${url}`;
+  `https://test-gateway-llb.kexiaoshuang.com${url}`;

+ 5 - 5
src/utils/encryptByDES.ts

@@ -2,14 +2,14 @@
  * @Author: guicheng 1625811865@qq.com
  * @Date: 2023-02-21 15:36:29
  * @LastEditors: guicheng 1625811865@qq.com
- * @LastEditTime: 2024-04-11 11:35:19
+ * @LastEditTime: 2024-09-29 10:08:02
  * @FilePath: /admin/src/utils/encryptByDES.ts
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
 import CryptoJS from "crypto-js";
 const encryptByDES = message => {
-  const keyHex = CryptoJS.enc.Utf8.parse("CBTU1dD4Kd5pyiGWTsI10jRQ3SvKusSV");
-  const ivHex = CryptoJS.enc.Utf8.parse("DYgjCEIMVrj2W9xN");
+  const keyHex = CryptoJS.enc.Utf8.parse("ZwwQCjEnGwaKzKWeuk4XIaHR0zbF8kSk");
+  const ivHex = CryptoJS.enc.Utf8.parse("Jg4FxlLbfn0viypF");
   const encrypted = CryptoJS.AES.encrypt(message, keyHex, {
     iv: ivHex,
     mode: CryptoJS.mode.CBC,
@@ -21,8 +21,8 @@ const encryptByDES = message => {
 const decryptByDES = message => {
   const encryptedHexStr = CryptoJS.enc.Base64.parse(message);
   const str = encryptedHexStr.toString(CryptoJS.enc.Utf8);
-  const keyHex = CryptoJS.enc.Utf8.parse("CBTU1dD4Kd5pyiGWTsI10jRQ3SvKusSV");
-  const ivHex = CryptoJS.enc.Utf8.parse("DYgjCEIMVrj2W9xN");
+  const keyHex = CryptoJS.enc.Utf8.parse("ZwwQCjEnGwaKzKWeuk4XIaHR0zbF8kSk");
+  const ivHex = CryptoJS.enc.Utf8.parse("Jg4FxlLbfn0viypF");
   const decrypt = CryptoJS.AES.decrypt(str, keyHex, {
     iv: ivHex,
     mode: CryptoJS.mode.CBC,

+ 24 - 2
src/utils/importUsed.ts

@@ -2,7 +2,7 @@
  * @Author: guicheng 1625811865@qq.com
  * @Date: 2024-06-21 11:11:08
  * @LastEditors: guicheng 1625811865@qq.com
- * @LastEditTime: 2024-06-21 11:55:32
+ * @LastEditTime: 2024-09-29 10:38:34
  * @FilePath: /admin-skb/src/utils/importUsed.ts
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -21,5 +21,27 @@ import verification, { RegularVerification } from "./rules";
 import { type PaginationProps } from "@pureadmin/table";
 import { hasAuth } from "@/router/utils";
 import { PureTableBar } from "@/components/RePureTableBar";
+import { usePublicHooks } from "@/utils/switchStyle";
 
-export { inject, onMounted, reactive, ref, Uploadfile, UploadImg, Editor, useRenderIcon, ElMessage, ElMessageBox, Upload, Close, http, getGroupUrl, RegularVerification, verification, PaginationProps, hasAuth, PureTableBar }
+export {
+  inject,
+  onMounted,
+  reactive,
+  ref,
+  usePublicHooks,
+  Uploadfile,
+  UploadImg,
+  Editor,
+  useRenderIcon,
+  ElMessage,
+  ElMessageBox,
+  Upload,
+  Close,
+  http,
+  getGroupUrl,
+  RegularVerification,
+  verification,
+  PaginationProps,
+  hasAuth,
+  PureTableBar
+};

+ 39 - 0
src/utils/switchStyle.ts

@@ -0,0 +1,39 @@
+// 抽离可公用的工具函数等用于系统管理页面逻辑
+import { computed } from "vue";
+import { useDark } from "@pureadmin/utils";
+
+export function usePublicHooks() {
+  const { isDark } = useDark();
+
+  const switchStyle = computed(() => {
+    return {
+      "--el-switch-on-color": "#6abe39",
+      "--el-switch-off-color": "#e84749"
+    };
+  });
+
+  const tagStyle = computed(() => {
+    return (status: number) => {
+      return status === 1
+        ? {
+            "--el-tag-text-color": isDark.value ? "#6abe39" : "#389e0d",
+            "--el-tag-bg-color": isDark.value ? "#172412" : "#f6ffed",
+            "--el-tag-border-color": isDark.value ? "#274a17" : "#b7eb8f"
+          }
+        : {
+            "--el-tag-text-color": isDark.value ? "#e84749" : "#cf1322",
+            "--el-tag-bg-color": isDark.value ? "#2b1316" : "#fff1f0",
+            "--el-tag-border-color": isDark.value ? "#58191c" : "#ffa39e"
+          };
+    };
+  });
+
+  return {
+    /** 当前网页是否为`dark`模式 */
+    isDark,
+    /** 表现更鲜明的`el-switch`组件  */
+    switchStyle,
+    /** 表现更鲜明的`el-tag`组件  */
+    tagStyle
+  };
+}

+ 244 - 4
src/views/Template/template/hook.tsx

@@ -1,6 +1,7 @@
-import { reactive, onMounted, ref, ElMessage, ElMessageBox, http, getGroupUrl, RegularVerification, verification, PaginationProps } from "@/utils/importUsed"
+import { reactive, onMounted, ref, usePublicHooks, ElMessage, ElMessageBox, http, getGroupUrl, RegularVerification, verification, PaginationProps, hasAuth } from "@/utils/importUsed"
 // 接口列表实例
 const UserUrl = ref(null)
+const { switchStyle } = usePublicHooks();
 // 获取当前板块接口列表
 onMounted(async () => {
   UserUrl.value = await getGroupUrl(["User"]);
@@ -14,7 +15,27 @@ export function useUser() {
     searchMain: "", // 搜索内容
     select: "", // 选择项
     date: "",
+    sex: "",
   });
+  // 性别映射表
+  const sexMapList = [
+    { id: 1, label: "男", type: "primary", effect: "light" },
+    { id: 2, label: "女", type: "success", effect: "light" },
+    { id: 0, label: "其他", type: "danger", effect: "light" }
+  ]
+  // 职级映射表
+  const userRankMapList = [
+    { id: 0, label: "K0", type: "warning", effect: "light" },
+    { id: 1, label: "K1", type: "warning", effect: "light" },
+    { id: 2, label: "K2", type: "warning", effect: "light" },
+    { id: 3, label: "K3", type: "primary", effect: "light" },
+    { id: 4, label: "K4", type: "primary", effect: "light" },
+    { id: 5, label: "K5", type: "primary", effect: "light" },
+    { id: 6, label: "K6", type: "success", effect: "light" },
+    { id: 7, label: "K7", type: "success", effect: "light" },
+    { id: 8, label: "K8", type: "success", effect: "light" },
+    { id: 9, label: "K9", type: "success", effect: "light" }
+  ]
   // 级联选择器参数
   const optionList = ref([
     {
@@ -37,7 +58,10 @@ export function useUser() {
     }
   ]);
   // 表格数据列表
-  const dataList = ref([{ Id: 1 },{ Id: 2 }]);
+  const dataList = ref([
+    { sort:0, Id: 1, status:false,sex:1, name:'角色名称1', rank:3, dept:"行政部", post:["人事专员", "行政主管"]},
+    { sort:1, Id: 2, status:true,sex:0, name:'角色名称2', rank:9, dept:"运营部", post:["数据分析", "运营专员", "运营主管"] }
+  ]);
   // 页面加载状态
   const loading = ref(false);
   // 表格分页选择器
@@ -66,6 +90,96 @@ export function useUser() {
       prop: "Id",
       minWidth: 130
     },
+    {
+      label: "角色名称",
+      prop: "name",
+      minWidth: 130
+    },
+    {
+      label: "职级",
+      minWidth: 200,
+      cellRenderer: ({ row, props }) => (
+        <el-tag
+          size={props.size}
+          type={userRankMapList.find(item => item.id === row.rank)?.type}
+          effect={userRankMapList.find(item => item.id === row.rank)?.effect}
+        >
+          {userRankMapList.find(item => item.id === row.rank)?.label}
+          </el-tag>
+      )
+    },
+    {
+      label: "锁定状态",
+      minWidth: 200,
+      cellRenderer: (scope) => (
+        <div>
+           <el-switch
+            size={scope.props.size === "small" ? "small" : "default"}
+            loading={switchLoadMap.value[scope.index]?.loading}
+            v-model={scope.row.status}
+            active-value={true}
+            inactive-value={false}
+            active-text="未锁定"
+            inactive-text="已锁定"
+            inline-prompt
+            style={switchStyle.value}
+            onChange={() => onChange(scope as any)}
+          />
+          </div>
+      )
+    },
+    {
+      label: "性别",
+      minWidth: 200,
+      cellRenderer: ({ row, props }) => (
+        <div>
+          
+          <el-select
+            class="!w-[100px]"
+            v-model={row.sex}
+            placeholder="请选择性别"
+            clearable>
+            {sexMapList.map((item: any) => (
+              <el-option label={item.label} value={item.id}/>
+            ))}
+          </el-select>
+        </div>
+      )
+    },
+    {
+      label: "排序",
+      minWidth: 200,
+      cellRenderer: (scope) => (
+        <div>
+          <el-input-number class="!w-[120px]" min="0" v-model={scope.row.sort} onChange={() => changeSort(scope as any) } />
+        </div>
+      )
+    },
+    {
+      label: "部门",
+      minWidth: 130,
+      cellRenderer: ({ row, props }) => (
+        <el-tag
+          size={props.size}
+          effect="plain"
+        >
+          { row.dept }
+          </el-tag>
+      )
+    },
+    {
+      label: "岗位",
+      minWidth: 130,
+      cellRenderer: ({ row, props }) => (
+        <div>
+          {row.post.map((item: any) => (
+            <el-tag size={props.size} type="success" effect="plain" class="mr-2">
+              {item}
+            </el-tag>
+          ))}
+        </div>
+      )
+    },
     {
       label: "操作",
       fixed: "right",
@@ -73,6 +187,131 @@ export function useUser() {
       slot: "operation"
     }
   ];
+  // 调整表单顺序函数
+  const changeSort = ({ row }) => {
+    const params = {
+      id: row.id,
+      sort: row.sort
+    };
+    const { data }: any = http.request(
+      UserUrl.User.userSearch.method,
+      UserUrl.User.userSearch.url,
+      params,
+    );
+    if (data.status != 1) {
+      return
+    } else {
+      onSearch(ruleFormRef);
+    }
+  }
+  // 表格开关
+  const switchLoadMap = ref({});
+  function onChange({ row, index }) {
+    switchLoadMap.value[index] = Object.assign(
+      {},
+      switchLoadMap.value[index],
+      {
+        loading: true
+      }
+    );
+    if (row.status == 0) {
+      handleUnlockUser(row, index)
+    } else {
+      handleLockUser(row, index)
+    }
+  }
+    // 锁定用户
+  function handleLockUser(row, index) {
+    ElMessageBox.confirm(
+      `是否锁定该角色?  角色名称为:${row.name}`,
+      "提示",
+      {
+        confirmButtonText: "锁定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }
+    ).then(async () => {
+      const { status, msg }: any = await http.Request({
+        method: UserUrl.llbMech.llbUserlockUser.method,
+        url: UserUrl.llbMech.llbUserlockUser.url,
+        params: {id: row.id,lockFlag:1}
+      });
+      if (status == 1) {
+        ElMessage({
+          message: "锁定成功",
+          type: "success"
+        });
+        onSearch(ruleFormRef.value);
+      } else {
+        ElMessageBox.alert(msg, "提示", {
+          confirmButtonText: "关闭",
+          type: "warning"
+        });
+      }
+      switchLoadMap.value[index] = Object.assign(
+        {},
+        switchLoadMap.value[index],
+        {
+          loading: false
+        }
+      );
+    }).catch(() => {
+      !row.status ? (row.status = true) : (row.status = false);
+      switchLoadMap.value[index] = Object.assign(
+        {},
+        switchLoadMap.value[index],
+        {
+          loading: false
+        }
+      );
+    })
+  };
+    // 解锁用户
+  function handleUnlockUser(row, index) {
+    ElMessageBox.confirm(
+      `是否解锁该角色?  角色名称为:${row.name}`,
+      "提示",
+      {
+        confirmButtonText: "解锁",
+        cancelButtonText: "取消",
+        type: "warning"
+      }
+    ).then(async () => {
+      const { status, msg }: any = await http.Request({
+        method: UserUrl.llbMech.llbUserlockUser.method,
+        url: UserUrl.llbMech.llbUserlockUser.url,
+        params: {id: row.id,lockFlag:0}
+      });
+      if (status == 1) {
+        ElMessage({
+          message: "解锁成功",
+          type: "success"
+        });
+        onSearch(ruleFormRef.value);
+      } else {
+        ElMessageBox.alert(msg, "提示", {
+          confirmButtonText: "关闭",
+          type: "warning"
+        });
+      }
+      switchLoadMap.value[index] = Object.assign(
+        {},
+        switchLoadMap.value[index],
+        {
+          loading: false
+        }
+      );
+    }).catch(() => {
+      !row.status ? (row.status = true) : (row.status = false);
+      switchLoadMap.value[index] = Object.assign(
+        {},
+        switchLoadMap.value[index],
+        {
+          loading: false
+        }
+      );
+    })
+  };
   // 当前页数量切换
   function handleSizeChange(val: number) {
     if (typeof val === "number") {
@@ -131,7 +370,7 @@ export function useUser() {
   // 删除
   function handleDelete(row) {
     ElMessageBox.confirm(
-      `是否删除该用户?  用户名称为:${row.AdminName}`,
+      `是否删除该用户?  用户名称为:${row.name}`,
       "提示",
       {
         confirmButtonText: "删除",
@@ -225,6 +464,7 @@ export function useUser() {
     editFormData,
     optionList,
     ruleFormRef,
-    rules
+    rules,
+    sexMapList
   };
 }

+ 13 - 2
src/views/Template/template/index.vue

@@ -34,7 +34,8 @@ const {
   editFormData,
   optionList,
   ruleFormRef,
-  rules
+  rules,
+  sexMapList
 } = useUser();
 // 关闭修改弹窗
 const closeEditVisible = () => {
@@ -88,6 +89,14 @@ provide("closeAddVisible", closeAddVisible);
           end-placeholder="结束时间"
           :default-value="[new Date(2010, 9, 1), new Date(2010, 10, 1)]"
         )
+      el-form-item(label="性别", prop="sex")
+        el-select(
+          class="!w-[230px]"
+          v-model="form.sex",
+          placeholder="请选择性别",
+          clearable,
+        )
+          el-option(:label="item.label", :value="item.id" v-for="(item, index) in sexMapList")
       //- 搜索按钮
       el-form-item
         el-button(
@@ -103,6 +112,8 @@ provide("closeAddVisible", closeAddVisible);
         el-button(type="primary" :icon="useRenderIcon(Addicon)" @click="handleAdd") 新增
       template(v-slot="{ size, checkList }")
         pure-table(
+          stripe 
+          border,
           row-key="id"
           ref="tableRef"
           adaptive
@@ -130,7 +141,7 @@ provide("closeAddVisible", closeAddVisible);
             ) 编辑
             el-button.reset-margin(
               link
-              type="primary"
+              type="danger"
               size="small"
               @click="handleDelete(row)"
               :icon="useRenderIcon(Delete)"

+ 21 - 48
src/views/login/index.vue

@@ -76,12 +76,12 @@ const onLogin = async (formEl: FormInstance | undefined) => {
   };
   checked.value
     ? Cookies.set("isRememberPassword", "true") &&
-      Cookies.set("RememberAccount", ShakeDownEncrypt(ruleForm))
+    Cookies.set("RememberAccount", ShakeDownEncrypt(ruleForm))
     : Cookies.set("isRememberPassword", "") &&
-      Cookies.set(
-        "RememberAccount",
-        ShakeDownEncrypt({ username: ruleForm.username })
-      );
+    Cookies.set(
+      "RememberAccount",
+      ShakeDownEncrypt({ username: ruleForm.username })
+    );
   if (!formEl) return;
   await formEl.validate((valid, fields) => {
     if (valid) {
@@ -195,53 +195,31 @@ watch(imgCode, value => {
             </h2>
           </Motion>
 
-          <el-form
-            v-if="currentPage === 0"
-            ref="ruleFormRef"
-            :model="ruleForm"
-            :rules="loginRules"
-            size="large"
-          >
+          <el-form v-if="currentPage === 0" ref="ruleFormRef" :model="ruleForm" :rules="loginRules" size="large">
             <Motion :delay="100">
-              <el-form-item
-                :rules="[
-                  {
-                    required: true,
-                    message: transformI18n($t('login.usernameReg')),
-                    trigger: 'blur'
-                  }
-                ]"
-                prop="username"
-              >
-                <el-input
-                  clearable
-                  v-model="ruleForm.username"
-                  :placeholder="t('login.username')"
-                  :prefix-icon="useRenderIcon(User)"
-                />
+              <el-form-item :rules="[
+          {
+            required: true,
+            message: transformI18n($t('login.usernameReg')),
+            trigger: 'blur'
+          }
+        ]" prop="username">
+                <el-input clearable v-model="ruleForm.username" :placeholder="t('login.username')"
+                  :prefix-icon="useRenderIcon(User)" />
               </el-form-item>
             </Motion>
 
             <Motion :delay="150">
               <el-form-item prop="password">
-                <el-input
-                  clearable
-                  show-password
-                  v-model="ruleForm.password"
-                  :placeholder="t('login.password')"
-                  :prefix-icon="useRenderIcon(Lock)"
-                />
+                <el-input clearable show-password v-model="ruleForm.password" :placeholder="t('login.password')"
+                  :prefix-icon="useRenderIcon(Lock)" />
               </el-form-item>
             </Motion>
 
             <Motion :delay="200">
               <el-form-item prop="verifyCode">
-                <el-input
-                  clearable
-                  v-model="ruleForm.verifyCode"
-                  :placeholder="t('login.verifyCode')"
-                  :prefix-icon="useRenderIcon('ri:shield-keyhole-line')"
-                >
+                <el-input clearable v-model="ruleForm.verifyCode" :placeholder="t('login.verifyCode')"
+                  :prefix-icon="useRenderIcon('ri:shield-keyhole-line')">
                   <template v-slot:append>
                     <ReImageVerify v-model:code="imgCode" />
                   </template>
@@ -263,13 +241,8 @@ watch(imgCode, value => {
                     {{ t("login.forget") }}
                   </el-button> -->
                 </div>
-                <el-button
-                  class="w-full mt-4"
-                  size="default"
-                  type="primary"
-                  :loading="loading"
-                  @click="onLogin(ruleFormRef)"
-                >
+                <el-button class="w-full mt-4" size="default" type="primary" :loading="loading"
+                  @click="onLogin(ruleFormRef)">
                   {{ t("login.login") }}
                 </el-button>
               </el-form-item>

+ 2 - 1
vite.config.ts

@@ -2,7 +2,7 @@
  * @Author: Gui
  * @Date: 2023-03-01 19:20:44
  * @LastEditors: guicheng 1625811865@qq.com
- * @LastEditTime: 2024-04-10 15:54:56
+ * @LastEditTime: 2024-07-12 15:08:30
  * @Description: kxs files
  * @filePath:
  */
@@ -67,6 +67,7 @@ export default ({ command, mode }: ConfigEnv): UserConfigExport => {
       exclude
     },
     build: {
+      target: "esnext",
       sourcemap: false,
       // 消除打包大小超过500kb警告
       chunkSizeWarningLimit: 4000,