instructorManage.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. <template>
  2. <div class="record-warp">
  3. <div class="record-main">
  4. <el-row>
  5. <el-col :span="24">
  6. <div class="search-head" style="padding-bottom: 10px">
  7. <el-input v-model="name" clearable placeholder="请输入姓名"></el-input
  8. >&nbsp;&nbsp;&nbsp;&nbsp;
  9. <el-input
  10. v-model="studentNumber"
  11. clearable
  12. placeholder="请输入编号"
  13. ></el-input
  14. >&nbsp;&nbsp;&nbsp;&nbsp;
  15. <!-- <el-cascader
  16. v-show="userInfo.roleType=='3'"
  17. placeholder="请选择组织架构"
  18. v-model="group"
  19. :options="groupData"
  20. :props="{ checkStrictly: true }"
  21. clearable
  22. ></el-cascader> -->
  23. <!-- :props="{ checkStrictly: true }" -->
  24. <!-- <el-cascader
  25. v-show="userInfo.roleType=='2'"
  26. placeholder="请选择组织架构"
  27. v-model="group"
  28. :options="groupData"
  29. clearable
  30. ></el-cascader>
  31. &nbsp;&nbsp;&nbsp;&nbsp; -->
  32. <!-- <span style="font-size: 16px;">性别:</span>&nbsp;&nbsp; -->
  33. <div style="display: flex; flex-direction: row; align-items: center">
  34. <span
  35. style="
  36. font-size: 16px;
  37. margin-right: 10px;
  38. line-height: 20px;
  39. min-width: 40px;
  40. "
  41. >性别:</span
  42. >
  43. <el-radio v-model="sex" label="1">男</el-radio>
  44. <el-radio v-model="sex" label="0">女</el-radio>
  45. </div>
  46. &nbsp;&nbsp;&nbsp;&nbsp;
  47. <el-button type="primary" round icon="el-icon-search" @click="searchTarget"
  48. >搜索</el-button
  49. >
  50. <el-button type="info" round @click="clearSearch">清空</el-button>
  51. <!-- <el-button type="success" round class="add_class" @click="fileVisible = true"
  52. >批量导入</el-button
  53. > -->
  54. <el-button type="success" class="add_class" round @click="addUser">新增</el-button>
  55. </div>
  56. </el-col>
  57. </el-row>
  58. <!-- <el-row class="add_user_class">
  59. <el-col :span="24">
  60. <div class="search-head"></div>
  61. </el-col>
  62. </el-row> -->
  63. <div class="table-content" style="flex: 1; overflow: auto">
  64. <el-table
  65. :data="tableData"
  66. :row-style="{ height: '0px' }"
  67. :cell-style="{ padding: '5px' }"
  68. :header-cell-style="{ background: '#F8F8F8', color: '#606266' }"
  69. >
  70. <!-- <el-table-column prop="name" label="姓名" align="center" width="" show-overflow-tooltip>
  71. </el-table-column> -->
  72. <el-table-column
  73. show-overflow-tooltip
  74. prop="userName"
  75. label="姓名"
  76. align="center"
  77. width=""
  78. >
  79. </el-table-column>
  80. <el-table-column prop="userNo" label="编号" align="center" width="">
  81. </el-table-column>
  82. <el-table-column
  83. prop="gender"
  84. label="性别"
  85. align="center"
  86. width=""
  87. :formatter="genderFun"
  88. >
  89. </el-table-column>
  90. <el-table-column prop="orgName" label="所属组织架构" align="center" width="">
  91. </el-table-column>
  92. <el-table-column label="操作" width="400px" align="center">
  93. <template slot-scope="scope">
  94. <div class="detail_button_out">
  95. <div class="detail_button" @click="viewUser(scope.row)">
  96. <img src="../../assets/img/table/search.png" />
  97. <span> 查看 </span>
  98. </div>
  99. <div class="detail_button" @click="editUser(scope.row)">
  100. <img src="../../assets/img/table/edit.png" />
  101. <span>编辑</span>
  102. </div>
  103. <!-- 弹出提示框 提示是否确认重置-->
  104. <div class="detail_button" @click="resetUser(false, scope.row)">
  105. <img src="../../assets/img/table/reset.png" />
  106. <span> 重置密码 </span>
  107. </div>
  108. <!-- 弹出提示框 提示是否确认删除-->
  109. <div class="detail_button" @click="resetUser(true, scope.row)">
  110. <img src="../../assets/img/table/delete.png" />
  111. <span> 删除 </span>
  112. </div>
  113. </div>
  114. </template>
  115. </el-table-column>
  116. </el-table>
  117. </div>
  118. <!-- small -->
  119. <el-pagination
  120. class="pag_class"
  121. background
  122. @size-change="handleSizeChange"
  123. @current-change="handleCurrentChange"
  124. :current-page.sync="pageNum"
  125. layout="total, sizes, prev, pager, next"
  126. :page-size="pageSize"
  127. :page-sizes="[10, 20, 50, 100]"
  128. :total="total"
  129. >
  130. </el-pagination>
  131. <!-- <el-pagination small background layout="total prev, pager, next" :total="36">
  132. </el-pagination> -->
  133. </div>
  134. <InstructorRegister ref="register" @search="searchTarget" />
  135. <el-dialog
  136. class="dig_update"
  137. :visible.sync="centerDialogVisible"
  138. width="40%"
  139. center
  140. style="border-radius: 40px"
  141. >
  142. <div slot="title">
  143. <div class="demo-ruleForm">
  144. <p class="dig_title">详情</p>
  145. <div class="user_out">
  146. <div class="user_out_sub">姓名</div>
  147. <div class="user_out_subNext">
  148. {{ view.name }}
  149. </div>
  150. </div>
  151. <div class="user_out">
  152. <div class="user_out_sub">编号</div>
  153. <div class="user_out_subNext">
  154. {{ view.studentNumber }}
  155. </div>
  156. </div>
  157. <div class="user_out">
  158. <div class="user_out_sub">性别</div>
  159. <div class="user_out_subNext">
  160. {{ view.sex }}
  161. </div>
  162. </div>
  163. <div class="user_out">
  164. <div class="user_out_sub">组织架构</div>
  165. <div class="user_out_subNext">
  166. {{ view.orgName }}
  167. </div>
  168. </div>
  169. </div>
  170. </div>
  171. </el-dialog>
  172. <el-dialog
  173. class="dig_update"
  174. :visible.sync="resetVisible"
  175. width="30%"
  176. center
  177. style="border-radius: 40px"
  178. >
  179. <div slot="title">
  180. <div class="demo-ruleForm">
  181. <p v-show="!isDelete" class="dig_title">重置密码</p>
  182. <p v-show="isDelete" class="dig_title">删除用户</p>
  183. <p v-show="!isDelete">重置密码后密码为123456</p>
  184. <p v-show="isDelete">确认将删除{{ userName }}用户?</p>
  185. <div class="dig_button">
  186. <el-button type="info" round @click="cancle()">取消</el-button>
  187. <!-- <el-button type="success" round @click="submitForm('ruleForm')"
  188. >提交</el-button
  189. > -->
  190. <el-button type="success" round @click="submitCom()">确定</el-button>
  191. </div>
  192. </div>
  193. </div>
  194. </el-dialog>
  195. <el-dialog
  196. class="dig_update"
  197. :visible.sync="fileVisible"
  198. width="40%"
  199. center
  200. style="border-radius: 40px"
  201. >
  202. <div slot="title">
  203. <div class="demo-ruleForm">
  204. <p v-show="!isDelete" class="dig_title">批量导入</p>
  205. <!-- 先选择组织架构 -->
  206. <!-- :props="{ checkStrictly: true }" -->
  207. <!-- <el-cascader
  208. placeholder="请选择组织架构"
  209. v-model="groupLead"
  210. :options="groupData"
  211. clearable
  212. ></el-cascader> -->
  213. <el-upload
  214. class="upload-demo"
  215. style="margin-top: 40px"
  216. drag
  217. :before-upload="beforeUploadFun"
  218. :action="basePath + `/user/userImport?orgNo=${userInfo.orgNo}`"
  219. :on-success="fileSuccess"
  220. :on-error="fileError"
  221. >
  222. <i class="el-icon-upload"></i>
  223. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  224. <div class="el-upload__tip" slot="tip">建议文件不超过500kb</div>
  225. </el-upload>
  226. <a
  227. style="
  228. display: flex;
  229. margin-top: 20px;
  230. margin-bottom: 20px;
  231. color: #409eff;
  232. cursor: pointer;
  233. "
  234. :href="basePath + '/user/templateDownload'"
  235. >
  236. 下载模版
  237. </a>
  238. <!-- <div class="dig_button">
  239. <el-button type="info" round @click="cancle()">取消</el-button>
  240. <el-button type="success" round @click="submitCom()">确定</el-button>
  241. </div> -->
  242. </div>
  243. </div>
  244. </el-dialog>
  245. </div>
  246. </template>
  247. <script>
  248. import { oSessionStorage } from "../../utils/utils";
  249. import instructorRegister from "../../components/instructorRegister.vue";
  250. import { basePath } from "../../utils/http";
  251. export default {
  252. name: "userManage",
  253. components: {
  254. InstructorRegister: instructorRegister,
  255. },
  256. data() {
  257. return {
  258. basePath: basePath,
  259. //上传文件的弹出款的标志
  260. fileVisible: false,
  261. //判断点击的是重置密码还是点击删除
  262. isDelete: false,
  263. //重置密码需要调用个userId
  264. userId: "",
  265. //充值密码使用userName
  266. userName: "",
  267. //重置密码弹出框
  268. resetVisible: false,
  269. //根据名称搜索
  270. name: "",
  271. //搜索的用户编号
  272. studentNumber: "",
  273. //搜索的组织架构
  274. // 搜索需要的性别
  275. sex: "",
  276. group: "",
  277. ppData: [],
  278. groupData: [],
  279. //批量上传时的组织架构
  280. groupLead: [],
  281. options: [
  282. {
  283. value: "1",
  284. label: "选项1",
  285. children: [
  286. {
  287. value: "11",
  288. label: "选项11",
  289. children: [{ value: "111", label: "选项111" }],
  290. },
  291. ],
  292. },
  293. ],
  294. centerDialogVisible: false,
  295. editUserFlag: false,
  296. startTime: "",
  297. endTime: "",
  298. value1: null,
  299. total: 0,
  300. pageSize: 10,
  301. pageNum: 1,
  302. keyword: "",
  303. tableData: [],
  304. userInfo: {}, //用户信息
  305. invitationCode: "",
  306. roleType: "0",
  307. type: 0,
  308. view: {
  309. name: "",
  310. studentNumber: "",
  311. sex: "",
  312. orgName: "",
  313. },
  314. channel: "",
  315. channelList: [{ name: "渠道天成", id: "1" }],
  316. };
  317. },
  318. created() {},
  319. mounted() {
  320. this.userInfo = JSON.parse(oSessionStorage.getItem("userInfo"));
  321. this.getChannel();
  322. if (!this.userInfo) {
  323. //如果用户信息不存在跳转登陆页
  324. this.$router.push({ path: "/" });
  325. }
  326. this.searchTarget();
  327. },
  328. methods: {
  329. //文件上传之前
  330. beforeUploadFun(file) {
  331. //查询是否选择了组织架构
  332. if (this.groupLead.length == 0) {
  333. this.$message({
  334. message: "请选择组织架构",
  335. type: "error",
  336. });
  337. return false;
  338. }
  339. },
  340. //文件上传成功
  341. fileSuccess(res) {
  342. if (res.code == 200) {
  343. this.searchTarget();
  344. this.$message({
  345. message: res.msg,
  346. type: "success",
  347. });
  348. } else {
  349. this.$message({
  350. message: res.msg,
  351. type: "error",
  352. });
  353. }
  354. //查询列表
  355. },
  356. //文件上传失败
  357. fileError() {
  358. this.$message({
  359. message: "上传失败",
  360. type: "error",
  361. });
  362. },
  363. cancle() {
  364. this.resetVisible = false;
  365. },
  366. //提交文本
  367. submitCom() {
  368. //判断当前是否是
  369. if (this.isDelete) {
  370. this.deleteUser();
  371. //调用删除方法
  372. } else {
  373. this.resetFun();
  374. // 调用重置密码方法
  375. }
  376. },
  377. //性别---
  378. genderFun(val) {
  379. let sex = val.gender;
  380. if (sex == "1") {
  381. return "男";
  382. } else if (sex == "0") {
  383. return "女";
  384. } else {
  385. return sex;
  386. }
  387. },
  388. //每页多少条
  389. handleSizeChange(val) {
  390. this.pageSize = val;
  391. this.searchTarget();
  392. //将首页重置为1时---且总条数变化
  393. //设置为当前总条数
  394. },
  395. //获取组织架构方法--------------------开始-----------------------
  396. getChannel() {
  397. this.$http.get(
  398. `/org/findAllOrgByPOrgNo?orgNo=${this.userInfo.orgNo}`,
  399. {},
  400. (res) => {
  401. // this.$toast.success({message:'成功'});
  402. if (res && res.code == 200) {
  403. //将值赋值给list
  404. if (res.data.length > 0) {
  405. let resAdd = this.addPro(res.data);
  406. this.ppData = JSON.parse(JSON.stringify(resAdd));
  407. let forRes = this.arrToTree(resAdd);
  408. // console.log('格式化的结构')
  409. // console.log(forRes)
  410. let resultRes = this.deleteChildren(forRes);
  411. this.groupData = resultRes[0].children;
  412. } else {
  413. this.groupData = [];
  414. }
  415. // this.channelList = res.data;
  416. } else {
  417. this.$message.error(res.msg);
  418. }
  419. }
  420. );
  421. },
  422. //z增加
  423. addPro(val) {
  424. let data = JSON.parse(JSON.stringify(val));
  425. for (let i = 0; i < val.length; i++) {
  426. data[i].value = val[i].orgNo;
  427. data[i].label = val[i].orgName;
  428. }
  429. return data;
  430. },
  431. //非递归方式:将平铺数据转换为树形结构数据
  432. arrToTree(arr) {
  433. let data = arr.filter((item) => {
  434. item.children = arr.filter((e) => {
  435. return item.orgNo === e.parentOrgNo;
  436. });
  437. // return !item.parentOrgNo;
  438. return item.orgNo == this.userInfo.orgNo;
  439. });
  440. return data;
  441. },
  442. //去除转换树形结构数据后存在的空children
  443. deleteChildren(arr) {
  444. let childs = arr;
  445. for (let i = childs.length; i--; i > 0) {
  446. if (childs[i].children) {
  447. if (childs[i].children.length) {
  448. this.deleteChildren(childs[i].children);
  449. } else {
  450. delete childs[i].children;
  451. }
  452. }
  453. }
  454. return arr;
  455. },
  456. //获取组织架构方法--------------------结束-----------------------
  457. formatterDelete(row) {
  458. if (row.state == 0) {
  459. return "已删除";
  460. } else {
  461. return "正常";
  462. }
  463. },
  464. resetUser(flag, val) {
  465. this.resetVisible = true;
  466. this.isDelete = flag;
  467. this.userId = val.id;
  468. this.userName = val.userName;
  469. },
  470. editUser(row) {
  471. this.editRegisterUser(row);
  472. },
  473. viewUser(row) {
  474. this.view.name = row.userName;
  475. this.view.studentNumber = row.userNo;
  476. this.view.sex = row.gender == "0" ? "女" : "男";
  477. this.view.orgName = row.orgName;
  478. this.centerDialogVisible = true;
  479. },
  480. addUser() {
  481. this.addRegisterUser(true);
  482. },
  483. clearSearch() {
  484. this.name = "";
  485. //搜索的用户编号
  486. this.studentNumber = "";
  487. //搜索的组织架构
  488. // 搜索需要的性别
  489. this.sex = "";
  490. this.group = "";
  491. this.searchTarget();
  492. },
  493. addRegisterUser(val) {
  494. this.$refs.register.open(val);
  495. },
  496. editRegisterUser(val) {
  497. this.$refs.register.edit(val);
  498. },
  499. resetFun() {
  500. this.$http.get(`/user/resetPassword?userId=${this.userId}`, {}, (res) => {
  501. // this.$toast.success({message:'成功'});
  502. if (res && res.code == 200) {
  503. this.resetVisible = false;
  504. this.$message.success("重置成功");
  505. this.searchTarget();
  506. } else {
  507. this.$message.error(res.msg);
  508. }
  509. });
  510. },
  511. deleteUser() {
  512. this.$http.get(`/user/delete?userId=${this.userId}`, {}, (res) => {
  513. // this.$toast.success({message:'成功'});
  514. if (res && res.code == 200) {
  515. this.$message.success("删除成功");
  516. this.resetVisible = false;
  517. this.searchTarget();
  518. } else {
  519. this.$message.error("删除失败");
  520. }
  521. });
  522. },
  523. handleCurrentChange(val) {
  524. this.pageNum = val;
  525. this.searchList();
  526. },
  527. //根据现有情况进行搜索
  528. searchList() {
  529. let url = `/user/findUserListByPage?pageSize=${this.pageSize}&pageNum=${
  530. this.pageNum
  531. }&roleType=3${this.sex == "" ? "" : `&gender=${this.sex}`}${
  532. this.group.length == 0
  533. ? `&orgNo=${this.userInfo.orgNo}`
  534. : `&orgNo=${this.group[this.group.length - 1]}`
  535. }${this.name == "" ? "" : `&userName=${this.name}`}${
  536. this.studentNumber == "" ? "" : `&userNo=${this.studentNumber}`
  537. }`;
  538. this.$http.get(url, {}, (res) => {
  539. if (res && res.code == 200) {
  540. this.tableData = res.data.content;
  541. this.total = res.data.totalElements;
  542. } else {
  543. // this.$toast.fail(res.msg);
  544. this.$message.error(res.msg);
  545. }
  546. });
  547. },
  548. searchTarget() {
  549. this.pageNum = 1;
  550. this.searchList();
  551. },
  552. //跳转首页
  553. goHome() {
  554. this.$router.push({ path: "/home" });
  555. },
  556. //跳转记录页
  557. goRecord() {
  558. this.$router.push({ path: "/record" });
  559. },
  560. //退出登陆
  561. logout() {
  562. oSessionStorage.removeItem("userInfo");
  563. oSessionStorage.removeItem("token");
  564. this.$router.push({ path: "/" });
  565. },
  566. //点击获取月出勤次数
  567. getTimes(param) {
  568. this.monthTimes = param;
  569. },
  570. },
  571. };
  572. </script>
  573. <style lang="less" scoped>
  574. @import "../../styles/theme.less";
  575. .pag_class {
  576. text-align: end;
  577. }
  578. .pag_class /deep/.el-input__inner {
  579. width: 100% !important;
  580. }
  581. .pag_class /deep/.el-pagination--small span:not([class*="suffix"]) {
  582. height: 22px;
  583. line-height: 28px !important;
  584. }
  585. .record-warp {
  586. width: 100%;
  587. height: 80vh;
  588. //background: url(../../assets/img/index/19.png) no-repeat center;
  589. //background-size: 100% 100%;
  590. position: relative;
  591. .record-main {
  592. width: 100%;
  593. height: 100%;
  594. box-sizing: border-box;
  595. overflow-y: auto;
  596. display: flex;
  597. flex-direction: column;
  598. .search-head {
  599. width: 100%;
  600. display: flex;
  601. flex-direction: row;
  602. justify-content: flex-start;
  603. align-items: center;
  604. .zc-title {
  605. color: #606266;
  606. font-size: 14px;
  607. }
  608. }
  609. .table-content {
  610. margin: 10px 0;
  611. }
  612. }
  613. }
  614. .add_user_class {
  615. margin-top: 10px;
  616. }
  617. .user_out {
  618. display: flex;
  619. width: 100%;
  620. align-items: center;
  621. border: 1px solid #eeeeef;
  622. line-height: 50px;
  623. margin-top: 10px;
  624. }
  625. .user_out_sub {
  626. flex: 1;
  627. background-color: #fafafa;
  628. text-align: center;
  629. // color:#ffffff
  630. }
  631. .user_out_subNext {
  632. padding-left: 10px;
  633. flex: 3;
  634. }
  635. .detail_button_out {
  636. display: flex;
  637. justify-content: flex-start;
  638. .detail_button {
  639. margin-left: 20px;
  640. display: flex;
  641. align-items: center;
  642. cursor: pointer;
  643. letter-spacing: 2px;
  644. img {
  645. width: 15px;
  646. margin-right: 5px;
  647. }
  648. span {
  649. color: #4D6AD5;
  650. // font-weight: 600;
  651. }
  652. }
  653. }
  654. //弹出框样式
  655. .dig_update /deep/.el-cascader {
  656. position: relative;
  657. font-size: 14px;
  658. line-height: 40px;
  659. width: 100%;
  660. }
  661. .dig_update /deep/.el-dialog {
  662. box-shadow: none !important;
  663. background: transparent !important;
  664. }
  665. .demo-ruleForm /deep/ .el-form-item {
  666. margin-right: 10px;
  667. vertical-align: top;
  668. display: flex !important;
  669. flex-direction: column;
  670. }
  671. .demo-ruleForm /deep/.el-dialog__header {
  672. background-color: #ffffff;
  673. padding-left: 140px !important;
  674. }
  675. .demo-ruleForm /deep/.el-form-item__label {
  676. text-align: left;
  677. vertical-align: middle;
  678. float: left;
  679. font-size: 14px;
  680. color: #606266;
  681. line-height: 40px;
  682. padding: 0 12px 0 0;
  683. -webkit-box-sizing: border-box;
  684. box-sizing: border-box;
  685. }
  686. .demo-ruleForm /deep/.el-input {
  687. width: 100% !important;
  688. }
  689. .demo-ruleForm /deep/.el-input__inner {
  690. width: 100% !important;
  691. background-color: #f7f7f7;
  692. border: 0px;
  693. }
  694. .dig_button {
  695. margin-top: 40px;
  696. display: flex;
  697. width: 100%;
  698. justify-content: space-around;
  699. }
  700. .demo-ruleForm {
  701. background-color: #ffffff;
  702. // border-radius: 20px;
  703. margin-right: -10px;
  704. margin-top: -10px;
  705. padding-right: 100px;
  706. padding-left: 100px;
  707. border-radius: 20px;
  708. padding-top: 20px;
  709. padding-bottom: 20px;
  710. .dig_title {
  711. margin-bottom: 30px;
  712. text-align: center;
  713. font-weight: 700;
  714. }
  715. }
  716. </style>