zouzs преди 2 седмици
родител
ревизия
f2af67ba4f

+ 30 - 31
src/api/system/user.ts

@@ -1,58 +1,57 @@
 import { http } from "@/utils/http";
-import { baseUrlApi } from "../utils";
+import { interfaceUrlApi } from "../utils";
 
 export interface BasicResponseModel<T = any> {
   code: number;
   msg: string;
-  rows: T;
+  list: T;
   data: T;
   total: number;
 }
 
 /**
- * 获取户列表
+ * 获取户列表
  * @param query
  */
-export const getSystemUserList = (query?: object) => {
-  return http.post<BasicResponseModel, any>(baseUrlApi("system/user/list"), {
-    data: query
+export const getIpAccountList = (query?: object) => {
+  return http.get<BasicResponseModel, any>(interfaceUrlApi("ipAccount/list"), {
+    params: query
   });
 };
 
 /**
- * 根据ID获取用户详细信息
- * @param id
- */
-export const getUserInfoById = (id?: string) => {
-  return http.get<BasicResponseModel, any>(baseUrlApi(`system/user/${id}`));
-};
-
-/**
- * 修改用户
+ * 新增账户
  * @param data
  */
-export const editUser = (data?: object) => {
-  return http.post<BasicResponseModel, any>(baseUrlApi("system/user/edit"), {
-    data
-  });
+export const addOrEditIpAccount = (data?: object) => {
+  return http.post<BasicResponseModel, any>(
+    interfaceUrlApi(`ipAccount/saveOrUpdate`),
+    {
+      data
+    }
+  );
 };
 
 /**
- * 添加用
- * @param data
+ * 删除账
+ * @param id
  */
-export const addUser = (data?: object) => {
-  return http.post<BasicResponseModel, any>(baseUrlApi("system/user/add"), {
-    data
-  });
+export const deleteIpAccount = (id: number) => {
+  return http.request<BasicResponseModel>(
+    "delete",
+    interfaceUrlApi(`ipAccount/delete/${id}`)
+  );
 };
 
 /**
- * 删除用户
- * @param id
+ * 切换账户状态
+ * @param data
  */
-export const deleteUser = (id?: string) => {
-  return http.post<BasicResponseModel, any>(baseUrlApi("system/user/delete"), {
-    data: [id]
-  });
+export const switchIpAccountStatus = (data?: object) => {
+  return http.post<BasicResponseModel, any>(
+    interfaceUrlApi(`ipAccount/switchStatus`),
+    {
+      data
+    }
+  );
 };

+ 5 - 0
src/api/utils.ts

@@ -2,3 +2,8 @@ export const baseUrlApi = (url: string) =>
   process.env.NODE_ENV === "development"
     ? `/api/${url}`
     : `http://127.0.0.1:3000/${url}`;
+
+export const interfaceUrlApi = (url: string) =>
+  process.env.NODE_ENV === "development"
+    ? `/api/inPlatfrom/${url}`
+    : `http://127.0.0.1:3000/${url}`;

+ 0 - 19
src/router/modules/system.ts

@@ -1,19 +0,0 @@
-// 最简代码,也就是这些字段必须有
-export default {
-  path: "/system1",
-  meta: {
-    title: "系统管理",
-    showLink: false
-  },
-  children: [
-    {
-      path: "/system/dict-data/index",
-      name: "DictData",
-      component: () => import("@/views/system/dict/dictData.vue"),
-      meta: {
-        title: "字典数据",
-        showParent: true
-      }
-    }
-  ]
-} as RouteConfigsTable;

+ 0 - 19
src/router/modules/testFingerPrints.ts

@@ -1,19 +0,0 @@
-// 最简代码,也就是这些字段必须有
-export default {
-  path: "/testFingerPrints",
-  meta: {
-    title: "测试信息获取",
-    showLink: false
-  },
-  children: [
-    {
-      path: "/testFingerPrints/information",
-      name: "Information",
-      component: () => import("@/views/testFingerPrints/information/index.vue"),
-      meta: {
-        title: "fingerprints,浏览器指纹",
-        showParent: true
-      }
-    }
-  ]
-} as RouteConfigsTable;

+ 0 - 28
src/router/modules/testStorage.ts

@@ -1,28 +0,0 @@
-// 最简代码,也就是这些字段必须有
-export default {
-  path: "/testStorage",
-  meta: {
-    title: "测试存储",
-    showLink: false
-  },
-  children: [
-    {
-      path: "/testStorage/local",
-      name: "Local",
-      component: () => import("@/views/testStorage/local/index.vue"),
-      meta: {
-        title: "本地存储",
-        showParent: true
-      }
-    },
-    {
-      path: "/testStorage/cookie",
-      name: "Cookie",
-      component: () => import("@/views/testStorage/cookie/index.vue"),
-      meta: {
-        title: "cookie存储",
-        showParent: true
-      }
-    }
-  ]
-} as RouteConfigsTable;

+ 0 - 28
src/router/modules/testTable.ts

@@ -1,28 +0,0 @@
-// 最简代码,也就是这些字段必须有
-export default {
-  path: "/testTable",
-  meta: {
-    title: "封装表格",
-    showLink: false
-  },
-  children: [
-    {
-      path: "/testTable/splitTable",
-      name: "SplitTable",
-      component: () => import("@/views/testTable/splitTable/index.vue"),
-      meta: {
-        title: "封装表格",
-        showParent: true
-      }
-    },
-    {
-      path: "/testTable/PageTable",
-      name: "PageTable",
-      component: () => import("@/views/testTable/pageTable/index.vue"),
-      meta: {
-        title: "整体封装",
-        showParent: true
-      }
-    }
-  ]
-} as RouteConfigsTable;

+ 0 - 28
src/router/modules/testUpload.ts

@@ -1,28 +0,0 @@
-// 最简代码,也就是这些字段必须有
-export default {
-  path: "/testUpload",
-  meta: {
-    title: "上传文件",
-    showLink: false
-  },
-  children: [
-    {
-      path: "/testUpload/upload",
-      name: "Upload",
-      component: () => import("@/views/testUpload/upload/index.vue"),
-      meta: {
-        title: "测试上传",
-        showParent: true
-      }
-    },
-    {
-      path: "/testUpload/upload-oss",
-      name: "UploadOss",
-      component: () => import("@/views/testUpload/upload-oss/index.vue"),
-      meta: {
-        title: "上传到oss",
-        showParent: true
-      }
-    }
-  ]
-} as RouteConfigsTable;

+ 79 - 207
src/views/user/index.vue

@@ -11,9 +11,10 @@
       }"
       :table="{
         actionBar: { buttons, type: 'link', width: 140 },
-        adaptive: { offsetBottom: 50 }
+        adaptive: { offsetBottom: 50 },
+        onFormChange: handleTableChange
       }"
-      :pagination="false"
+      :pageInfoMap="{ page: 'pageNum', pageSize: 'pageSize' }"
     >
       <template #table-title>
         <el-row class="button-row">
@@ -32,11 +33,9 @@
         columns,
         labelPosition: 'right',
         labelWidth: 100,
-        rules,
-        rowProps: { gutter: 20 },
-        colProps: { span: 12 }
+        rules
       }"
-      :dialog="{ title: dialogTitle + '菜单', width: 800, confirmLoading }"
+      :dialog="{ title: dialogTitle + '菜单', width: 600, confirmLoading }"
       @confirm="handleSubmit"
       @close="handleClose"
     />
@@ -44,45 +43,34 @@
 </template>
 
 <script lang="ts" setup>
-import { computed, onMounted, reactive, ref, toRefs, type Ref } from "vue";
+import { computed, reactive, ref, toRefs } from "vue";
 import type { FormRules } from "element-plus";
-import { ElMessage } from "element-plus";
+import { ElMessage, ElMessageBox } from "element-plus";
 import {
   type FieldValues,
   type PlusColumn,
-  type OptionsRow,
   PlusDialogForm,
   PlusPage,
   PlusPageInstance,
   useTable
 } from "plus-pro-components";
 import {
-  addUser,
-  deleteUser,
-  editUser,
-  getSystemUserList,
-  getUserInfoById
+  addOrEditIpAccount,
+  deleteIpAccount,
+  getIpAccountList,
+  switchIpAccountStatus
 } from "@/api/system/user";
-import {
-  getSystemRoleDeptTree,
-  getSystemRoleOptionselect
-} from "@/api/system/role";
 
 defineOptions({
   name: "User"
 });
 
-onMounted(async () => {
-  await getDeptList();
-  await getRoleOptions();
-});
-
 const plusPageInstance = ref<PlusPageInstance | null>(null);
 
 const getList = async (query: Record<string, any>) => {
-  let res = await getSystemUserList(query);
+  let res = await getIpAccountList(query);
   return {
-    data: res.rows,
+    data: res.list,
     total: res.total
   };
 };
@@ -92,69 +80,66 @@ const refresh = () => {
   plusPageInstance.value?.getList();
 };
 
-const dialogTitle = computed(() => (state.isCreate ? "新增" : "编辑"));
+const handleTableChange = (values: FieldValues) => {
+  console.log(values);
+  ElMessageBox.confirm("确定修改此数据吗?", "提示", {
+    confirmButtonText: "确定",
+    cancelButtonText: "取消",
+    type: "warning"
+  })
+    .then(async () => {
+      try {
+        let data = {
+          id: values.row.id,
+          status: values.row.status
+        };
+        let res = await switchIpAccountStatus(data);
+        if (res.code === 200) {
+          ElMessage.success("修改成功");
+        } else {
+          ElMessage.error(res.msg);
+        }
+      } catch (e) {
+        ElMessage.error("修改失败");
+      }
+    })
+    .finally(() => {
+      refresh();
+    });
+};
 
-const { buttons } = useTable();
+const dialogTitle = computed(() => (state.isCreate ? "新增" : "编辑"));
 
 // 表格数据
 const tableConfig: PlusColumn[] = [
   {
-    label: "用户姓名",
-    prop: "nickName",
-    width: 180,
-    fieldProps: {
-      clearable: true
-    }
+    label: "账户号",
+    prop: "accNo"
   },
   {
-    label: "登录账号",
-    prop: "userName",
-    width: 180,
+    label: "状态",
+    prop: "status",
+    valueType: "switch",
     fieldProps: {
-      clearable: true
-    }
-  },
-  {
-    label: "角色",
-    prop: "roleName",
-    hideInSearch: true
-  },
-  {
-    label: "所属部门",
-    prop: "deptName",
-    hideInSearch: true
-  },
-  {
-    label: "岗位",
-    prop: "postName",
+      activeValue: "normal",
+      inactiveValue: "disable"
+    },
+    editable: true,
     hideInSearch: true
   },
-  /*{
-    label: "用户类型",
-    prop: "menuName",
-    hideInSearch: true
-  },*/
   {
-    label: "状态",
-    prop: "status",
-    hideInSearch: true,
-    valueType: "select",
-    options: [
-      { label: "启用", value: "0" },
-      { label: "停用", value: "1" }
-    ],
-    fieldProps: {
-      clearable: true
-    }
+    label: "备注",
+    prop: "remark"
   },
   {
-    label: "最近IP",
-    prop: "loginIp",
+    label: "创建时间",
+    prop: "addTime",
+    valueType: "time-picker",
     hideInSearch: true
   },
   {
-    label: "最近登录时间",
-    prop: "loginDate",
+    label: "创建人",
+    prop: "addUserName",
     hideInSearch: true
   }
 ];
@@ -181,143 +166,31 @@ const state = reactive<State>({
   selectedIds: [],
   isCreate: false,
   form: {},
-  rules: {
-    userName: [
-      { required: true, message: "登录账号不能为空", trigger: "blur" }
-    ],
-    password2: [
-      { required: true, message: "二次密码不能为空", trigger: "blur" },
-      {
-        validator: (rule, value, callback) => {
-          if (value !== state.form["password"]) {
-            callback(new Error("两次输入的密码不一致"));
-          } else {
-            callback();
-          }
-        },
-        trigger: "blur"
-      }
-    ],
-    phonenumber: [
-      {
-        pattern: /^1[3-9]\d{9}$/,
-        message: "请输入正确的手机号",
-        trigger: "blur"
-      }
-    ]
-  }
+  rules: {}
 });
 
-const deptList = ref([]);
-const roleList: Ref<OptionsRow[]> = ref([]);
-
-const getDeptList = async () => {
-  let res = await getSystemRoleDeptTree("2");
-  if (res.code === 200) {
-    deptList.value = res.depts;
-  }
-};
-
-const getRoleOptions = async () => {
-  let res = await getSystemRoleOptionselect();
-  if (res.code === 200) {
-    roleList.value = res.data;
-  }
-};
-
 const columns: PlusColumn[] = [
   {
-    label: "所属部门",
-    prop: "deptId",
-    valueType: "tree-select",
-    fieldProps: {
-      placeholder: "请选择所属部门",
-      clearable: true,
-      props: {
-        label: "label",
-        value: "id",
-        children: "children"
-      },
-      data: deptList
-    }
-  },
-  {
-    label: "登录账号",
-    prop: "userName",
-    valueType: "input",
-    fieldProps: {
-      clearable: true
-    }
-  },
-  {
-    label: "登录密码",
-    prop: "password",
-    valueType: "input",
-    fieldProps: {
-      clearable: true,
-      type: "password",
-      showPassword: false
-    }
-  },
-  {
-    label: "二次密码",
-    prop: "password2",
-    valueType: "input",
-    fieldProps: {
-      clearable: true,
-      type: "password",
-      showPassword: false
-    }
-  },
-  {
-    label: "用户姓名",
-    prop: "nickName",
-    valueType: "input",
-    fieldProps: {
-      clearable: true
-    }
-  },
-  {
-    label: "手机号",
-    prop: "phonenumber",
-    valueType: "input",
-    fieldProps: {
-      clearable: true
-    }
+    label: "账户号",
+    prop: "accNo",
+    valueType: "input"
   },
   {
-    label: "角色",
-    prop: "roleId",
-    valueType: "select",
-    options: computed(() => roleList.value),
-    optionsMap: {
-      value: "roleId",
-      label: "roleName"
-    },
+    label: "状态",
+    prop: "status",
+    valueType: "switch",
     fieldProps: {
-      placeholder: "请选择角色",
-      clearable: true
+      activeValue: "normal",
+      inactiveValue: "disable"
     }
   },
   {
-    label: "岗位",
-    prop: "postName",
+    label: "备注",
+    prop: "remark",
     valueType: "input",
     fieldProps: {
-      clearable: true
-    }
-  },
-  {
-    label: "状态",
-    prop: "status",
-    valueType: "radio",
-    fieldProps: {
-      placeholder: "请选择状态",
-      clearable: true,
-      options: [
-        { label: "启用", value: "0" },
-        { label: "停用", value: "1" }
-      ]
+      type: "textarea",
+      rows: 3
     }
   }
 ];
@@ -325,7 +198,7 @@ const columns: PlusColumn[] = [
 // 创建
 const handleCreate = (): void => {
   form.value = {
-    status: "0"
+    status: "normal"
   };
   state.isCreate = true;
   state.dialogVisible = true;
@@ -337,7 +210,7 @@ const handleSubmit = async (values: FieldValues) => {
   if (state.isCreate) {
     try {
       let params = form.value;
-      let res = await addUser(params);
+      let res = await addOrEditIpAccount(params);
       if (res.code === 200) {
         ElMessage.success("新增成功");
         confirmLoading.value = false;
@@ -353,7 +226,7 @@ const handleSubmit = async (values: FieldValues) => {
     // 编辑
     try {
       let params = form.value;
-      let res = await editUser(params);
+      let res = await addOrEditIpAccount(params);
       if (res.code === 200) {
         ElMessage.success("修改成功");
         confirmLoading.value = false;
@@ -372,6 +245,8 @@ const handleClose = () => {
   console.log(dialogForm.value.formInstance);
 };
 
+const { buttons } = useTable();
+
 buttons.value = [
   {
     // 修改
@@ -382,12 +257,9 @@ buttons.value = [
       type: "primary"
     },
     onClick(params) {
-      getUserInfoById(params.row.userId).then(res => {
-        form.value = res.data;
-        form.value.password2 = res.data.password;
-        state.isCreate = false;
-        state.dialogVisible = true;
-      });
+      form.value = params.row;
+      state.isCreate = false;
+      state.dialogVisible = true;
     }
   },
   {
@@ -404,7 +276,7 @@ buttons.value = [
     },
     onConfirm: async params => {
       try {
-        let res = await deleteUser(params.row.userId);
+        let res = await deleteIpAccount(params.row.id);
         if (res.code === 200) {
           ElMessage.success("删除成功");
           refresh();

+ 5 - 2
vite.config.ts

@@ -27,9 +27,12 @@ export default ({ mode }: ConfigEnv): UserConfigExport => {
       proxy: {
         "/api": {
           // 这里填写后端地址
-          target: "http://192.168.1.168/api",
+          target: "http://192.168.1.168:20000",
           changeOrigin: true,
-          rewrite: path => path.replace(/^\/api/, "")
+          rewrite: path => {
+            console.log(path);
+            return path.replace(/^\/api/, "");
+          }
         }
       },
       // 预热文件以提前转换和缓存结果,降低启动期间的初始页面加载时长并防止转换瀑布