lixuliang
2024-11-22 e26e02fd97880a30b48a6fe086c1b3298903b970
后台管理更新
已修改11个文件
357 ■■■■ 文件已修改
se-ui/.env.development 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
se-ui/public/index.html 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
se-ui/src/api/system/user.js 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
se-ui/src/layout/components/Navbar.vue 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
se-ui/src/permission.js 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
se-ui/src/router/index.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
se-ui/src/store/modules/user.js 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
se-ui/src/utils/jsencrypt.js 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
se-ui/src/utils/request.js 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
se-ui/src/views/login.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
se-ui/src/views/system/user/index.vue 218 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
se-ui/.env.development
@@ -11,4 +11,4 @@
VUE_CLI_BABEL_TRANSPILE_MODULES = true
#项目子路径
VUE_APP_ITEM_PATH = ''
VUE_APP_ITEM_PATH = '/'
se-ui/public/index.html
@@ -1,14 +1,23 @@
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <title><%= webpackConfig.name %></title>
    <!--[if lt IE 11]><script>window.location.href='/html/ie.html';</script><![endif]-->
      <style>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="renderer" content="webkit">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <link rel="icon" href="<%= BASE_URL %>favicon.ico">
  <title>
    <%= webpackConfig.name %>
  </title>
  <!--[if lt IE 11]><script>window.location.href='/html/ie.html';</script><![endif]-->
  <!-- <script src="rsa.min.js"></script> -->
  <!-- <script src="rollups.js"></script> -->
  <script src="<%= BASE_URL %>config/rsa.min.js"></script>
  <script src="<%= BASE_URL %>config/rollups.js"></script>
  <style>
    html,
    body,
    #app {
@@ -16,6 +25,7 @@
      margin: 0px;
      padding: 0px;
    }
    .chromeframe {
      margin: 0.2em 0;
      background: #ccc;
@@ -92,6 +102,7 @@
        -ms-transform: rotate(0deg);
        transform: rotate(0deg);
      }
      100% {
        -webkit-transform: rotate(360deg);
        -ms-transform: rotate(360deg);
@@ -105,6 +116,7 @@
        -ms-transform: rotate(0deg);
        transform: rotate(0deg);
      }
      100% {
        -webkit-transform: rotate(360deg);
        -ms-transform: rotate(360deg);
@@ -194,15 +206,17 @@
      opacity: 0.5;
    }
  </style>
  </head>
  <body>
    <div id="app">
        <div id="loader-wrapper">
            <div id="loader"></div>
            <div class="loader-section section-left"></div>
            <div class="loader-section section-right"></div>
            <div class="load_title">正在加载系统资源,请耐心等待</div>
        </div>
    </div>
  </body>
</html>
</head>
<body>
  <div id="app">
    <div id="loader-wrapper">
      <div id="loader"></div>
      <div class="loader-section section-left"></div>
      <div class="loader-section section-right"></div>
      <div class="load_title">正在加载系统资源,请耐心等待</div>
    </div>
  </div>
</body>
</html>
se-ui/src/api/system/user.js
@@ -1,5 +1,6 @@
import request from '@/utils/request'
import { parseStrEmpty } from "@/utils/se";
import { encr } from "@/utils/jsencrypt";
// 查询用户列表
export function listUser(query) {
@@ -20,19 +21,27 @@
// 新增用户
export function addUser(data) {
  let modifiedObject = {
    ...data,
    password: encr(data.password),
  };
  return request({
    url: '/system/user',
    method: 'post',
    data: data
    data: modifiedObject
  })
}
// 修改用户
export function updateUser(data) {
  let modifiedObject = {
    ...data,
    password: encr(data.password),
  };
  return request({
    url: '/system/user',
    method: 'put',
    data: data
    data: modifiedObject
  })
}
@@ -45,7 +54,8 @@
}
// 用户密码重置
export function resetUserPwd(userId, password) {
export function resetUserPwd(userId, newPassword) {
  let password = encr(newPassword);
  const data = {
    userId,
    password
@@ -88,7 +98,9 @@
}
// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
export function updateUserPwd(OPWD, NPWD) {
  let oldPassword = encr(OPWD);
  let newPassword = encr(NPWD);
  const data = {
    oldPassword,
    newPassword
se-ui/src/layout/components/Navbar.vue
@@ -103,9 +103,10 @@
      })
        .then(() => {
          this.$store.dispatch("LogOut").then(() => {
            if ((process.env.ENV == "development")) {
              console.log(process.env.NODE_ENV);
            if (process.env.NODE_ENV == "development") {
              window.location.href = "http://localhost:8080/login";
            } else if ((process.env.ENV == "production")) {
            } else if (process.env.NODE_ENV == "production") {
              window.location.href = window.location.origin + "/sso/login";
            }
          });
se-ui/src/permission.js
@@ -16,9 +16,9 @@
    to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
    /* has token*/
    if (to.path === '/login') {
      if (process.env.ENV == 'development') {
      if (process.env.NODE_ENV == 'development') {
        window.location.href = 'http://localhost:8080/login'
      } else if (process.env.ENV == 'production') {
      } else if (process.env.NODE_ENV == 'production') {
        window.location.href = window.location.origin + '/sso/login'
      }
      // next({ path: '/' })
@@ -39,9 +39,10 @@
        }).catch(err => {
          store.dispatch('LogOut').then(() => {
            Message.error(err)
            if (process.env.ENV == 'development') {
            console.log(process.env.NODE_ENV);
            if (process.env.NODE_ENV == 'development') {
              window.location.href = 'http://localhost:8080/login'
            } else if (process.env.ENV == 'production') {
            } else if (process.env.NODE_ENV == 'production') {
              window.location.href = window.location.origin + '/sso/login'
            }
            // next({ path: '/' })
@@ -57,9 +58,9 @@
      // 在免登录白名单,直接进入
      next()
    } else {
      if (process.env.ENV == 'development') {
      if (process.env.NODE_ENV == 'development') {
        window.location.href = 'http://localhost:8080/login'
      } else if (process.env.ENV == 'production') {
      } else if (process.env.NODE_ENV == 'production') {
        window.location.href = window.location.origin + '/sso/login'
      }
      NProgress.done()
se-ui/src/router/index.js
@@ -64,8 +64,8 @@
  {
    path: '',
    component: Layout,
    redirect: '/login',
    // redirect: 'system/user',
    // redirect: '/login',
    redirect: 'system/user',
    // children: [
    //   {
    //     path: 'index',
se-ui/src/store/modules/user.js
@@ -1,5 +1,6 @@
import { login, logout, getInfo, refreshToken } from '@/api/login'
import { getToken, setToken, setExpiresIn, removeToken } from '@/utils/auth'
import { encr } from "@/utils/jsencrypt";
const user = {
  state: {
@@ -38,8 +39,11 @@
  actions: {
    // 登录
    Login({ commit }, userInfo) {
      const username = userInfo.username.trim()
      const password = userInfo.password
      let pwd = encr(userInfo.password);
      const password = pwd;
      // const password = userInfo.password
      const code = userInfo.code
      const uuid = userInfo.uuid
      return new Promise((resolve, reject) => {
@@ -79,7 +83,7 @@
    },
    // 刷新token
    RefreshToken({commit, state}) {
    RefreshToken({ commit, state }) {
      return new Promise((resolve, reject) => {
        refreshToken(state.token).then(res => {
          setExpiresIn(res.data)
@@ -90,7 +94,7 @@
        })
      })
    },
    // 退出系统
    LogOut({ commit, state }) {
      return new Promise((resolve, reject) => {
se-ui/src/utils/jsencrypt.js
@@ -28,3 +28,22 @@
  return encryptor.decrypt(txt) // 对数据进行解密
}
// 新加密方式
export function encr(word) {
  return CryptoJS.AES.encrypt(
    CryptoJS.enc.Utf8.parse(word),
    CryptoJS.enc.Utf8.parse(base64Decode('QSNzX3paM3NlUnZlX2sueQ==')),
    { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }
  ).toString();
}
// 新解密方式
export function decr(word) {
  return CryptoJS.enc.Utf8.stringify(
    CryptoJS.AES.decrypt(
      word,
      // CryptoJS.enc.Utf8.parse(base64Decode('QSNzX3paM3NlUnZlX2sueQ==')),
      { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }
    )
  ).toString();
}
se-ui/src/utils/request.js
@@ -88,9 +88,11 @@
      MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => {
        isRelogin.show = false;
        store.dispatch('LogOut').then(() => {
          if ((process.env.ENV == "development")) {
          console.log(process.env.NODE_ENV);
          if (process.env.NODE_ENV == "development") {
            window.location.href = "http://localhost:8080/login";
          } else if ((process.env.ENV == "production")) {
          } else if (process.env.NODE_ENV == "production") {
            window.location.href = window.location.origin + "/sso/login";
          }
        })
se-ui/src/views/login.vue
@@ -93,7 +93,7 @@
    this.getCookie();
  },
  methods: {
    // getCode() {
    getCode() {
    //   getCodeImg().then(res => {
    //     this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled;
    //     if (this.captchaEnabled) {
@@ -101,7 +101,7 @@
    //       this.loginForm.uuid = res.uuid;
    //     }
    //   });
    // },
    },
    getCookie() {
      const username = Cookies.get("username");
      const password = Cookies.get("password");
se-ui/src/views/system/user/index.vue
@@ -29,7 +29,14 @@
      </el-col>
      <!--用户数据-->
      <el-col :span="20" :xs="24">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
        <el-form
          :model="queryParams"
          ref="queryForm"
          size="small"
          :inline="true"
          v-show="showSearch"
          label-width="68px"
        >
          <el-form-item label="用户名称" prop="userName">
            <el-input
              v-model="queryParams.userName"
@@ -138,11 +145,45 @@
        <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column label="用户编号" align="center" key="userId" prop="userId" v-if="columns[0].visible" />
          <el-table-column label="用户名称" align="center" key="userName" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" />
          <el-table-column label="用户昵称" align="center" key="nickName" prop="nickName" v-if="columns[2].visible" :show-overflow-tooltip="true" />
          <el-table-column label="部门" align="center" key="deptName" prop="dept.deptName" v-if="columns[3].visible" :show-overflow-tooltip="true" />
          <el-table-column label="手机号码" align="center" key="phonenumber" prop="phonenumber" v-if="columns[4].visible" width="120" />
          <el-table-column
            label="用户编号"
            align="center"
            key="userId"
            prop="userId"
            v-if="columns[0].visible"
          />
          <el-table-column
            label="用户名称"
            align="center"
            key="userName"
            prop="userName"
            v-if="columns[1].visible"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="用户昵称"
            align="center"
            key="nickName"
            prop="nickName"
            v-if="columns[2].visible"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="部门"
            align="center"
            key="deptName"
            prop="dept.deptName"
            v-if="columns[3].visible"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="手机号码"
            align="center"
            key="phonenumber"
            prop="phonenumber"
            v-if="columns[4].visible"
            width="120"
          />
          <el-table-column label="状态" align="center" key="status" v-if="columns[5].visible">
            <template slot-scope="scope">
              <el-switch
@@ -153,7 +194,13 @@
              ></el-switch>
            </template>
          </el-table-column>
          <el-table-column label="创建时间" align="center" prop="createTime" v-if="columns[6].visible" width="160">
          <el-table-column
            label="创建时间"
            align="center"
            prop="createTime"
            v-if="columns[6].visible"
            width="160"
          >
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime) }}</span>
            </template>
@@ -179,13 +226,23 @@
                @click="handleDelete(scope.row)"
                v-hasPermi="['system:user:remove']"
              >删除</el-button>
              <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['system:user:resetPwd', 'system:user:edit']">
              <el-dropdown
                size="mini"
                @command="(command) => handleCommand(command, scope.row)"
                v-hasPermi="['system:user:resetPwd', 'system:user:edit']"
              >
                <el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item command="handleResetPwd" icon="el-icon-key"
                    v-hasPermi="['system:user:resetPwd']">重置密码</el-dropdown-item>
                  <el-dropdown-item command="handleAuthRole" icon="el-icon-circle-check"
                    v-hasPermi="['system:user:edit']">分配角色</el-dropdown-item>
                  <el-dropdown-item
                    command="handleResetPwd"
                    icon="el-icon-key"
                    v-hasPermi="['system:user:resetPwd']"
                  >重置密码</el-dropdown-item>
                  <el-dropdown-item
                    command="handleAuthRole"
                    icon="el-icon-circle-check"
                    v-hasPermi="['system:user:edit']"
                  >分配角色</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </template>
@@ -213,7 +270,12 @@
          </el-col>
          <el-col :span="12">
            <el-form-item label="归属部门" prop="deptId">
              <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
              <treeselect
                v-model="form.deptId"
                :options="deptOptions"
                :show-count="true"
                placeholder="请选择归属部门"
              />
            </el-form-item>
          </el-col>
        </el-row>
@@ -237,7 +299,13 @@
          </el-col>
          <el-col :span="12">
            <el-form-item v-if="form.userId == undefined" label="用户密码" prop="password">
              <el-input v-model="form.password" placeholder="请输入用户密码" type="password" maxlength="20" show-password/>
              <el-input
                v-model="form.password"
                placeholder="请输入用户密码"
                type="password"
                maxlength="20"
                show-password
              />
            </el-form-item>
          </el-col>
        </el-row>
@@ -323,13 +391,21 @@
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
        <div class="el-upload__text">
          将文件拖到此处,或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip text-center" slot="tip">
          <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
            <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
          </div>
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
          <el-link
            type="primary"
            :underline="false"
            style="font-size:12px;vertical-align: baseline;"
            @click="importTemplate"
          >下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
@@ -341,14 +417,23 @@
</template>
<script>
import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus, deptTreeSelect } from "@/api/system/user";
import {
  listUser,
  getUser,
  delUser,
  addUser,
  updateUser,
  resetUserPwd,
  changeUserStatus,
  deptTreeSelect
} from "@/api/system/user";
import { getToken } from "@/utils/auth";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
  name: "User",
  dicts: ['sys_normal_disable', 'sys_user_sex'],
  dicts: ["sys_normal_disable", "sys_user_sex"],
  components: { Treeselect },
  data() {
    return {
@@ -426,15 +511,29 @@
      rules: {
        userName: [
          { required: true, message: "用户名称不能为空", trigger: "blur" },
          { min: 2, max: 20, message: '用户名称长度必须介于 2 和 20 之间', trigger: 'blur' }
          {
            min: 2,
            max: 20,
            message: "用户名称长度必须介于 2 和 20 之间",
            trigger: "blur"
          }
        ],
        nickName: [
          { required: true, message: "用户昵称不能为空", trigger: "blur" }
        ],
        password: [
          { required: true, message: "用户密码不能为空", trigger: "blur" },
          { min: 5, max: 20, message: '用户密码长度必须介于 5 和 20 之间', trigger: 'blur' },
          { pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }
          {
            min: 5,
            max: 20,
            message: "用户密码长度必须介于 5 和 20 之间",
            trigger: "blur"
          },
          {
            pattern: /^[^<>"'|\\]+$/,
            message: "不能包含非法字符:< > \" ' \\ |",
            trigger: "blur"
          }
        ],
        email: [
          {
@@ -470,7 +569,8 @@
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
        response => {
          this.userList = response.rows;
          this.total = response.total;
          this.loading = false;
@@ -496,13 +596,17 @@
    // 用户状态修改
    handleStatusChange(row) {
      let text = row.status === "0" ? "启用" : "停用";
      this.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function() {
        return changeUserStatus(row.userId, row.status);
      }).then(() => {
        this.$modal.msgSuccess(text + "成功");
      }).catch(function() {
        row.status = row.status === "0" ? "1" : "0";
      });
      this.$modal
        .confirm('确认要"' + text + '""' + row.userName + '"用户吗?')
        .then(function() {
          return changeUserStatus(row.userId, row.status);
        })
        .then(() => {
          this.$modal.msgSuccess(text + "成功");
        })
        .catch(function() {
          row.status = row.status === "0" ? "1" : "0";
        });
    },
    // 取消按钮
    cancel() {
@@ -593,16 +697,18 @@
        closeOnClickModal: false,
        inputPattern: /^.{5,20}$/,
        inputErrorMessage: "用户密码长度必须介于 5 和 20 之间",
        inputValidator: (value) => {
        inputValidator: value => {
          if (/<|>|"|'|\||\\/.test(value)) {
            return "不能包含非法字符:< > \" ' \\\ |"
            return "不能包含非法字符:< > \" ' \\ |";
          }
        },
      }).then(({ value }) => {
        }
      })
        .then(({ value }) => {
          resetUserPwd(row.userId, value).then(response => {
            this.$modal.msgSuccess("修改成功,新密码是:" + value);
          });
        }).catch(() => {});
        })
        .catch(() => {});
    },
    /** 分配角色操作 */
    handleAuthRole: function(row) {
@@ -613,6 +719,7 @@
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.userId != undefined) {
            updateUser(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
@@ -632,18 +739,26 @@
    /** 删除按钮操作 */
    handleDelete(row) {
      const userIds = row.userId || this.ids;
      this.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项?').then(function() {
        return delUser(userIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
      this.$modal
        .confirm('是否确认删除用户编号为"' + userIds + '"的数据项?')
        .then(function() {
          return delUser(userIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/user/export', {
        ...this.queryParams
      }, `user_${new Date().getTime()}.xlsx`)
      this.download(
        "system/user/export",
        {
          ...this.queryParams
        },
        `user_${new Date().getTime()}.xlsx`
      );
    },
    /** 导入按钮操作 */
    handleImport() {
@@ -652,8 +767,11 @@
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('system/user/importTemplate', {
      }, `user_template_${new Date().getTime()}.xlsx`)
      this.download(
        "system/user/importTemplate",
        {},
        `user_template_${new Date().getTime()}.xlsx`
      );
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
@@ -664,7 +782,13 @@
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.$alert(
        "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
          response.msg +
          "</div>",
        "导入结果",
        { dangerouslyUseHTMLString: true }
      );
      this.getList();
    },
    // 提交上传文件