123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 |
- <template>
- <div class="record-warp">
- <div class="record-main">
- <el-row>
- <el-col :span="24">
- <div class="search-head" style="padding-bottom: 10px">
- <el-input v-model="name" clearable placeholder="请输入姓名"></el-input
- >
- <el-input
- v-model="studentNumber"
- clearable
- placeholder="请输入学号"
- ></el-input
- >
- <el-cascader
- v-show="userInfo.roleType == '3'"
- placeholder="请选择组织架构"
- v-model="group"
- :options="groupData"
- :props="{ checkStrictly: true }"
- clearable
- ></el-cascader>
- <!-- :props="{ checkStrictly: true }" -->
- <el-cascader
- placeholder="请选择组织架构"
- v-model="group"
- :options="groupData"
- clearable
- ></el-cascader>
-
- <!-- <span style="font-size: 16px;">性别:</span> -->
- <div style="display: flex; flex-direction: row; align-items: center">
- <span
- style="
- font-size: 16px;
- margin-right: 10px;
- line-height: 20px;
- min-width: 40px;
- "
- >性别:</span
- >
- <el-radio v-model="sex" label="1">男</el-radio>
- <el-radio v-model="sex" label="0">女</el-radio>
- </div>
-
- <el-button type="primary" round icon="el-icon-search" @click="searchTarget"
- >搜索</el-button
- >
- <el-button type="info" round @click="clearSearch">清空</el-button>
- <el-button type="success" round class="add_class" @click="fileVisible = true"
- >批量导入</el-button
- >
- <el-button type="info" round @click="addUser">单独注册</el-button>
- </div>
- </el-col>
- </el-row>
- <!-- <el-row class="add_user_class">
- <el-col :span="24">
- <div class="search-head"></div>
- </el-col>
- </el-row> -->
- <div class="table-content" style="flex: 1; overflow: auto">
- <el-table
- :data="tableData"
- :row-style="{ height: '0px' }"
- :cell-style="{ padding: '5px' }"
- :header-cell-style="{ background: '#F8F8F8', color: '#606266' }"
- >
- <!-- <el-table-column prop="name" label="姓名" align="center" width="" show-overflow-tooltip>
- </el-table-column> -->
- <el-table-column
- show-overflow-tooltip
- prop="userName"
- label="姓名"
- align="center"
- width=""
- >
- </el-table-column>
- <el-table-column prop="userNo" label="学号" align="center" width="">
- </el-table-column>
- <el-table-column
- prop="gender"
- label="性别"
- align="center"
- width=""
- :formatter="genderFun"
- >
- </el-table-column>
- <el-table-column prop="grade" label="届数" align="center" width="" :formatter="gradeFormatter">
- </el-table-column>
- <el-table-column prop="orgName" label="所属组织架构" align="center" width="">
- </el-table-column>
- <el-table-column label="操作" width="510px" align="center">
- <template slot-scope="scope">
- <div class="detail_button_out">
- <div class="detail_button" @click="viewUser(scope.row)">
- <img src="../../assets/img/table/search.png" />
- <span> 查看个人详情 </span>
- </div>
- <div class="detail_button" @click="editUser(scope.row)">
- <img src="../../assets/img/table/edit.png" />
- <span>编辑个人详情</span>
- </div>
- <!-- 弹出提示框 提示是否确认重置-->
- <div class="detail_button" @click="resetUser(false, scope.row)">
- <img src="../../assets/img/table/reset.png" />
- <span> 重置密码 </span>
- </div>
- <!-- 弹出提示框 提示是否确认删除-->
- <div class="detail_button" @click="resetUser(true, scope.row)">
- <img src="../../assets/img/table/delete.png" />
- <span> 删除 </span>
- </div>
- </div>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!-- small -->
- <el-pagination
- class="pag_class"
- background
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page.sync="pageNum"
- layout="total, sizes, prev, pager, next"
- :page-size="pageSize"
- :page-sizes="[10, 20, 50, 100]"
- :total="total"
- >
- </el-pagination>
- <!-- <el-pagination small background layout="total prev, pager, next" :total="36">
- </el-pagination> -->
- </div>
- <Register ref="register" @search="searchTarget" />
- <el-dialog
- class="dig_update"
- :visible.sync="centerDialogVisible"
- width="40%"
- center
- style="border-radius: 40px"
- >
- <div slot="title">
- <div class="demo-ruleForm">
- <p class="dig_title">详情</p>
- <div class="user_out">
- <div class="user_out_sub">姓名</div>
- <div class="user_out_subNext">
- {{ view.name }}
- </div>
- </div>
- <div class="user_out">
- <div class="user_out_sub">学号</div>
- <div class="user_out_subNext">
- {{ view.studentNumber }}
- </div>
- </div>
- <div class="user_out">
- <div class="user_out_sub">届数</div>
- <div class="user_out_subNext">
- {{ view.grade }}
- </div>
- </div>
- <div class="user_out">
- <div class="user_out_sub">性别</div>
- <div class="user_out_subNext">
- {{ view.sex }}
- </div>
- </div>
- <div class="user_out">
- <div class="user_out_sub">组织架构</div>
- <div class="user_out_subNext">
- {{ view.orgName }}
- </div>
- </div>
- </div>
- </div>
- </el-dialog>
- <el-dialog
- class="dig_update"
- :visible.sync="resetVisible"
- width="30%"
- center
- style="border-radius: 40px"
- >
- <div slot="title">
- <div class="demo-ruleForm">
- <p v-show="!isDelete" class="dig_title">重置密码</p>
- <p v-show="isDelete" class="dig_title">删除用户</p>
- <p v-show="!isDelete">重置密码后密码为123456</p>
- <p v-show="isDelete">确认将删除{{ userName }}用户?</p>
- <div class="dig_button">
- <el-button type="info" round @click="cancle()">取消</el-button>
- <!-- <el-button type="success" round @click="submitForm('ruleForm')"
- >提交</el-button
- > -->
- <el-button type="success" round @click="submitCom()">确定</el-button>
- </div>
- </div>
- </div>
- </el-dialog>
- <el-dialog
- class="dig_update"
- :visible.sync="fileVisible"
- width="40%"
- center
- style="border-radius: 40px"
- >
- <div slot="title">
- <div class="demo-ruleForm">
- <p v-show="!isDelete" class="dig_title">批量导入</p>
- <!-- 先选择组织架构 -->
- <!-- :props="{ checkStrictly: true }" -->
- <el-cascader
- placeholder="请选择组织架构"
- v-model="groupLead"
- :options="groupData"
- clearable
- ></el-cascader>
- <el-select
- v-model="grade"
- clearable
- placeholder="请选择所属届"
- style="width: 100%; margin-top: 20px"
- >
- <el-option
- v-for="item in gradeOption"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- <el-upload
- class="upload-demo"
- style="margin-top: 20px"
- drag
- :before-upload="beforeUploadFun"
- :action="
- basePath +
- `/user/userImport?orgNo=${groupLead[groupLead.length - 1]}&roleType=1&grade=${grade}`
- "
- :headers="headers"
- :on-success="fileSuccess"
- :on-error="fileError"
- >
- <i class="el-icon-upload"></i>
- <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
- <div class="el-upload__tip" slot="tip">建议文件不超过500kb</div>
- </el-upload>
- <a
- style="
- display: flex;
- margin-top: 20px;
- margin-bottom: 20px;
- color: #409eff;
- cursor: pointer;
- "
- :href="basePath + '/user/templateDownload?roleType=1'"
- >
- 下载模版
- </a>
- <!-- <div class="dig_button">
- <el-button type="info" round @click="cancle()">取消</el-button>
-
- <el-button type="success" round @click="submitCom()">确定</el-button>
- </div> -->
- </div>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { oSessionStorage } from "../../utils/utils";
- import register from "../../components/Register.vue";
- import { basePath } from "../../utils/http";
- export default {
- name: "userManage",
- components: {
- Register: register,
- },
- data() {
- return {
- basePath: basePath,
- //上传文件的弹出款的标志
- fileVisible: false,
- //判断点击的是重置密码还是点击删除
- isDelete: false,
- //重置密码需要调用个userId
- userId: "",
- //充值密码使用userName
- userName: "",
- //重置密码弹出框
- resetVisible: false,
- //根据名称搜索
- name: "",
- //搜索的用户编号
- studentNumber: "",
- //搜索的组织架构
- // 搜索需要的性别
- sex: "",
- group: "",
- ppData: [],
- groupData: [],
- //批量上传时的组织架构
- groupLead: [],
- options: [
- {
- value: "1",
- label: "选项1",
- children: [
- {
- value: "11",
- label: "选项11",
- children: [{ value: "111", label: "选项111" }],
- },
- ],
- },
- ],
- centerDialogVisible: false,
- editUserFlag: false,
- startTime: "",
- endTime: "",
- value1: null,
- total: 0,
- pageSize: 10,
- pageNum: 1,
- keyword: "",
- tableData: [],
- userInfo: {}, //用户信息
- invitationCode: "",
- roleType: "0",
- type: 0,
- view: {
- name: "",
- studentNumber: "",
- sex: "",
- orgName: "",
- //当前学生的届数
- grade:''
- },
- channel: "",
- channelList: [{ name: "渠道天成", id: "1" }],
- headers: {},
- grade: "",
- gradeOption: [],
- };
- },
- created() {},
- mounted() {
- this.userInfo = JSON.parse(oSessionStorage.getItem("userInfo"));
- this.headers = {
- Authorization: oSessionStorage.getItem("token")
- ? `Bearer ${oSessionStorage.getItem("token")}`
- : "",
- };
- this.getGradeFun();
- console.log("this.userInfo");
- console.log(this.userInfo);
- this.getChannel();
- if (!this.userInfo) {
- //如果用户信息不存在跳转登陆页
- this.$router.push({ path: "/" });
- }
- this.searchTarget();
- },
- methods: {
- gradeFormatter(row){
- //格式化当前届数
- return row.grade+'届'
- },
- //获取当前届数
- getGradeFun() {
- this.gradeOption = [];
- //获取当前届数
- //获取当前年份
- let date = new Date();
- let currentYear = date.getFullYear();
- let preYear = currentYear - 12;
- let list = [];
- for (let i = preYear; i < currentYear + 1; i++) {
- //
- let obj = {
- value: i,
- label: i + "届",
- };
- list.push(obj);
- }
- this.gradeOption = list.reverse();
- },
- //文件上传之前
- beforeUploadFun(file) {
- //查询是否选择了组织架构
- if (this.groupLead.length == 0) {
- this.$message({
- message: "请选择组织架构",
- type: "error",
- });
- return false;
- }
- if (this.grade == "") {
- this.$message({
- message: "请选择所属届",
- type: "error",
- });
- return false;
- }
- },
- //文件上传成功
- fileSuccess(res) {
- if (res.code == 200) {
- this.searchTarget();
- this.$message({
- message: res.msg,
- type: "success",
- });
- } else {
- this.$message({
- message: res.msg,
- type: "error",
- });
- }
- //查询列表
- },
- //文件上传失败
- fileError() {
- this.$message({
- message: "上传失败",
- type: "error",
- });
- },
- cancle() {
- this.resetVisible = false;
- },
- //提交文本
- submitCom() {
- //判断当前是否是
- if (this.isDelete) {
- this.deleteUser();
- //调用删除方法
- } else {
- this.resetFun();
- // 调用重置密码方法
- }
- },
- //性别---
- genderFun(val) {
- let sex = val.gender;
- if (sex == "1") {
- return "男";
- } else if (sex == "0") {
- return "女";
- } else {
- return sex;
- }
- },
- //每页多少条
- handleSizeChange(val) {
- this.pageSize = val;
- this.searchTarget();
- //将首页重置为1时---且总条数变化
- //设置为当前总条数
- },
- //获取组织架构方法--------------------开始-----------------------
- getChannel() {
- this.$http.get(
- `/org/findAllOrgByPOrgNo?orgNo=${this.userInfo.orgNo}`,
- {},
- (res) => {
- // this.$toast.success({message:'成功'});
- if (res && res.code == 200) {
- //将值赋值给list
- if (res.data.length > 0) {
- let resAdd = this.addPro(res.data);
- this.ppData = JSON.parse(JSON.stringify(resAdd));
- let forRes = this.arrToTree(resAdd);
- // console.log('格式化的结构')
- // console.log(forRes)
- let resultRes = this.deleteChildren(forRes);
- console.log("格式化的结构且去掉children");
- this.groupData = resultRes[0].children;
- } else {
- this.groupData = [];
- }
- // this.channelList = res.data;
- } else {
- this.$message.error(res.msg);
- }
- }
- );
- },
- //z增加
- addPro(val) {
- let data = JSON.parse(JSON.stringify(val));
- for (let i = 0; i < val.length; i++) {
- data[i].value = val[i].orgNo;
- data[i].label = val[i].orgName;
- }
- return data;
- },
- //非递归方式:将平铺数据转换为树形结构数据
- arrToTree(arr) {
- let data = arr.filter((item) => {
- item.children = arr.filter((e) => {
- return item.orgNo === e.parentOrgNo;
- });
- // return !item.parentOrgNo;
- return item.orgNo == this.userInfo.orgNo;
- });
- return data;
- },
- //去除转换树形结构数据后存在的空children
- deleteChildren(arr) {
- let childs = arr;
- for (let i = childs.length; i--; i > 0) {
- if (childs[i].children) {
- if (childs[i].children.length) {
- this.deleteChildren(childs[i].children);
- } else {
- delete childs[i].children;
- }
- }
- }
- return arr;
- },
- //获取组织架构方法--------------------结束-----------------------
- formatterDelete(row) {
- if (row.state == 0) {
- return "已删除";
- } else {
- return "正常";
- }
- },
- resetUser(flag, val) {
- this.resetVisible = true;
- this.isDelete = flag;
- this.userId = val.id;
- this.userName = val.userName;
- },
- editUser(row) {
- this.editRegisterUser(row);
- },
- viewUser(row) {
- this.view.name = row.userName;
- this.view.studentNumber = row.userNo;
- this.view.sex = row.gender == "0" ? "女" : "男";
- this.view.orgName = row.orgName;
- this.view.grade=row.grade+'届'
- this.centerDialogVisible = true;
- },
- addUser() {
- this.addRegisterUser(true);
- },
- clearSearch() {
- this.name = "";
- //搜索的用户编号
- this.studentNumber = "";
- //搜索的组织架构
- // 搜索需要的性别
- this.sex = "";
- this.group = "";
- this.searchTarget();
- },
- addRegisterUser(val) {
- this.$refs.register.open(val);
- },
- editRegisterUser(val) {
- this.$refs.register.edit(val);
- },
- resetFun() {
- this.$http.get(`/user/resetPassword?userId=${this.userId}`, {}, (res) => {
- // this.$toast.success({message:'成功'});
- if (res && res.code == 200) {
- this.resetVisible = false;
- this.$message.success("重置成功");
- this.searchTarget();
- } else {
- this.$message.error(res.msg);
- }
- });
- },
- deleteUser() {
- this.$http.get(`/user/delete?userId=${this.userId}`, {}, (res) => {
- // this.$toast.success({message:'成功'});
- if (res && res.code == 200) {
- this.$message.success("删除成功");
- this.resetVisible = false;
- this.searchTarget();
- } else {
- this.$message.error("删除失败");
- }
- });
- },
- handleCurrentChange(val) {
- this.pageNum = val;
- this.searchList();
- },
- //根据现有情况进行搜索
- searchList() {
- let url = `/user/findUserListByPage?pageSize=${this.pageSize}&pageNum=${
- this.pageNum
- }&roleType=1${this.sex == "" ? "" : `&gender=${this.sex}`}${
- this.group.length == 0
- ? `&orgNo=${this.userInfo.orgNo}`
- : `&orgNo=${this.group[this.group.length - 1]}`
- }${this.name == "" ? "" : `&userName=${this.name}`}${
- this.studentNumber == "" ? "" : `&userNo=${this.studentNumber}`
- }`;
- this.$http.get(url, {}, (res) => {
- console.log(res);
- if (res && res.code == 200) {
- this.tableData = res.data.content;
- this.total = res.data.totalElements;
- } else {
- // this.$toast.fail(res.msg);
- this.$message.error(res.msg);
- }
- });
- },
- searchTarget() {
- this.pageNum = 1;
- this.searchList();
- },
- //跳转首页
- goHome() {
- this.$router.push({ path: "/home" });
- },
- //跳转记录页
- goRecord() {
- this.$router.push({ path: "/record" });
- },
- //退出登陆
- logout() {
- oSessionStorage.removeItem("userInfo");
- oSessionStorage.removeItem("token");
- this.$router.push({ path: "/" });
- },
- //点击获取月出勤次数
- getTimes(param) {
- this.monthTimes = param;
- },
- },
- };
- </script>
- <style lang="less" scoped>
- @import "../../styles/theme.less";
- .pag_class {
- text-align: end;
- }
- .pag_class /deep/.el-input__inner {
- width: 100% !important;
- }
- .pag_class /deep/.el-pagination--small span:not([class*="suffix"]) {
- height: 22px;
- line-height: 28px !important;
- }
- .record-warp {
- width: 100%;
- height: 80vh;
- //background: url(../../assets/img/index/19.png) no-repeat center;
- //background-size: 100% 100%;
- position: relative;
- .record-main {
- width: 100%;
- height: 100%;
- box-sizing: border-box;
- overflow-y: auto;
- display: flex;
- flex-direction: column;
- .search-head {
- width: 100%;
- display: flex;
- flex-direction: row;
- justify-content: flex-start;
- align-items: center;
- .zc-title {
- color: #606266;
- font-size: 14px;
- }
- }
- .table-content {
- margin: 10px 0;
- }
- }
- }
- .add_user_class {
- margin-top: 10px;
- }
- .user_out {
- display: flex;
- width: 100%;
- align-items: center;
- border: 1px solid #eeeeef;
- line-height: 50px;
- margin-top: 10px;
- }
- .user_out_sub {
- flex: 1;
- background-color: #fafafa;
- text-align: center;
- // color:#ffffff
- }
- .user_out_subNext {
- padding-left: 10px;
- flex: 3;
- }
- .detail_button_out {
- display: flex;
- justify-content: space-around;
- .detail_button {
- display: flex;
- align-items: center;
- cursor: pointer;
- letter-spacing: 2px;
- img {
- width: 15px;
- margin-right: 5px;
- }
- span {
- color: #00bf78;
- // font-weight: 600;
- }
- }
- }
- //弹出框样式
- .dig_update /deep/.el-cascader {
- position: relative;
- font-size: 14px;
- line-height: 40px;
- width: 100%;
- }
- .dig_update /deep/.el-dialog {
- box-shadow: none !important;
- background: transparent !important;
- }
- .demo-ruleForm /deep/ .el-form-item {
- margin-right: 10px;
- vertical-align: top;
- display: flex !important;
- flex-direction: column;
- }
- .demo-ruleForm /deep/.el-dialog__header {
- background-color: #ffffff;
- padding-left: 140px !important;
- }
- .demo-ruleForm /deep/.el-form-item__label {
- text-align: left;
- vertical-align: middle;
- float: left;
- font-size: 14px;
- color: #606266;
- line-height: 40px;
- padding: 0 12px 0 0;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- }
- .demo-ruleForm /deep/.el-input {
- width: 100% !important;
- }
- .demo-ruleForm /deep/.el-input__inner {
- width: 100% !important;
- background-color: #f7f7f7;
- border: 0px;
- }
- .dig_button {
- margin-top: 40px;
- display: flex;
- width: 100%;
- justify-content: space-around;
- }
- .demo-ruleForm {
- background-color: #ffffff;
- // border-radius: 20px;
- margin-right: -10px;
- margin-top: -10px;
- padding-right: 100px;
- padding-left: 100px;
- border-radius: 20px;
- padding-top: 20px;
- padding-bottom: 20px;
- .dig_title {
- margin-bottom: 30px;
- text-align: center;
- font-weight: 700;
- }
- }
- </style>
|