UserMa - 副本.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta name="renderer" content="webkit">
  5. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  6. <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  7. <meta http-equiv="pragma" content="no-cache">
  8. <meta http-equiv="cache-control" content="no-cache, must-revalidate">
  9. <meta http-equiv="expires" content="0">
  10. <meta name="viewport"
  11. content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  12. <title>设备管理</title>
  13. <link rel="stylesheet" href="../css/index.css">
  14. <link rel="stylesheet" href="../css/style.css">
  15. <script src="../js/vue.min.js"></script>
  16. <script src="../js/jquery.min.js"></script>
  17. <script src="../js/index.js"></script>
  18. <script src="../js/yz/init.js"></script>
  19. <script>
  20. checkLogin();
  21. </script>
  22. <style type="text/css">
  23. *{
  24. padding: 0;
  25. margin: 0;
  26. box-sizing: border-box;
  27. }
  28. body{
  29. padding: 10px;
  30. background-color: #040d32;
  31. }
  32. .search_ input {
  33. position: relative;
  34. width: 100%;
  35. height: 32px;
  36. line-height: 32px;
  37. border-radius: 4px;
  38. font-size: 14px;
  39. padding: 0 5px 0 25px;
  40. color: #dcdcdc;
  41. background-color: rgba(255, 255, 255, 0.2);
  42. border: 1px solid rgba(232, 232, 232, 0.3);
  43. }
  44. .search_ input::-webkit-input-placeholder {
  45. color: #dcdcdc;
  46. }
  47. .search_ .el-icon-search {
  48. position: absolute;
  49. left: 12px;
  50. top: 16px;
  51. color: #dcdcdc;
  52. }
  53. .elTable{
  54. width: 100%;
  55. border: 1px solid rgba(255, 255, 255, 0.2);
  56. }
  57. .el-table::before{
  58. height: 0;
  59. }
  60. .el-table::after{
  61. width: 0;
  62. }
  63. .el-table,.el-table__expanded-cell {
  64. color: #ddd;
  65. background-color: transparent !important;
  66. }
  67. .el-table tr,
  68. .el-table td {
  69. font-size: 14px;
  70. background-color: transparent !important;
  71. }
  72. .el-table td.el-table__cell,.el-table th.el-table__cell.is-leaf{
  73. border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  74. }
  75. .el-table--border .el-table__cell{
  76. border-right: 1px solid rgba(255, 255, 255, 0.2);
  77. }
  78. .el-dialog__header{
  79. padding: 10px;
  80. }
  81. .el-dialog__title{
  82. font-size: 15px;
  83. }
  84. .el-dialog__headerbtn{
  85. top: 14px;
  86. }
  87. .el-dialog__body{
  88. padding: 10px;
  89. color: #fff;
  90. background-color: #082041;
  91. }
  92. .br{
  93. border: 1px solid rgba(255, 255, 255, 0.2);
  94. }
  95. ._Form{
  96. flex:1;
  97. flex-direction: column;
  98. border-right: 1px solid rgba(255, 255, 255, 0.2);
  99. }
  100. ._Form>div{
  101. height: 20%;
  102. min-height: 60px;
  103. border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  104. }
  105. ._Form>div>div:first-child{
  106. display: flex;
  107. align-items: center;
  108. justify-content: center;
  109. width: 100px;
  110. height: 100%;
  111. min-height: 60px;
  112. border-right: 1px solid rgba(255, 255, 255, 0.2);
  113. }
  114. ._Form>div>div:last-child{
  115. width: calc(100% - 100px);
  116. padding: 0 10px;
  117. }
  118. .el-input__inner{
  119. height: 34px;
  120. line-height: 34px;
  121. }
  122. .el-input__inner,._Form .el-textarea__inner{
  123. color: #ececec;
  124. border-color: transparent;
  125. background-color: rgba(255, 255, 255, 0.2);
  126. }
  127. .el-input__inner::-webkit-input-placeholder {
  128. color: #b9b9b9;
  129. }
  130. ._Form .el-radio{
  131. color: #fff;
  132. }
  133. .el-select-dropdown__item{
  134. height: auto;
  135. }
  136. .el-tree{
  137. color: #fff;
  138. background-color: transparent;
  139. }
  140. .el-select-dropdown__item.hover, .el-select-dropdown__item:hover,
  141. .el-tree-node__content:hover,.el-tree-node:focus>.el-tree-node__content{
  142. background-color: transparent;
  143. }
  144. .el-popper[x-placement^=bottom] .popper__arrow::after{
  145. border-bottom-color: #707070;
  146. }
  147. .el-select-dropdown{
  148. background-color: #707070;
  149. }
  150. .el-radio__input.is-checked .el-radio__inner,
  151. .el-checkbox__input.is-checked .el-checkbox__inner,
  152. .el-checkbox__input.is-indeterminate .el-checkbox__inner,
  153. .el-button--success{
  154. border-color: #39b54a;
  155. background: #39b54a;
  156. }
  157. .el-radio__input.is-checked+.el-radio__label{
  158. color: #39b54a;
  159. }
  160. .el-select-dropdown__item{
  161. color: #fff;
  162. }
  163. </style>
  164. </head>
  165. <body>
  166. <div id="app">
  167. <div>
  168. <div class="flex align-center margin-bottom-sm">
  169. <div>
  170. <el-input placeholder="请输入关键词" v-model="inpKey" @input="_Search">
  171. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  172. </el-input>
  173. </div>
  174. <div class="tableTool">
  175. <el-button type="primary" size="small" class="margin-left-sm">查询</el-button>
  176. <el-button type="success" size="small" @click="newAdd">新增</el-button>
  177. </div>
  178. </div>
  179. <el-table class="elTable" :data="tableData" border :header-cell-style="{background:'#082041',color:'#fff'}">
  180. <el-table-column align="center" prop="userId" label="用户编号"> </el-table-column>
  181. <el-table-column align="center" prop="userName" label="用户账号"> </el-table-column>
  182. <el-table-column align="center" prop="nickName" label="用户昵称"> </el-table-column>
  183. <el-table-column align="center" prop="dept.deptName" label="部门"></el-table-column>
  184. <el-table-column align="center" prop="phonenumber" label="手机号码"> </el-table-column>
  185. <el-table-column align="center" prop="status" label="状态">
  186. <template slot-scope="scope">
  187. <el-switch
  188. :value="scope.row.status == 0"
  189. disabled
  190. active-color="#13ce66"
  191. inactive-color="#ff4949">
  192. </el-switch>
  193. </template>
  194. </el-table-column>
  195. <el-table-column align="center" prop="createTime" label="创建时间"> </el-table-column>
  196. <el-table-column
  197. align="center"
  198. width="180"
  199. label="操作">
  200. <template slot-scope="scope" v-if="!scope.row.admin">
  201. <el-button type="text" size="small" @click="Edit(scope.row)" class="text-green"><i class="el-icon-edit"></i>编辑</el-button>
  202. <el-button type="text" size="small" @click="Delete(scope.row)" class="text-red"><i class="el-icon-delete"></i>删除</el-button>
  203. <el-button type="text" size="small" @click="RePwd(scope.row)" class="text-sray"><i class="el-icon-key"></i>密码</el-button>
  204. </template>
  205. </el-table-column>
  206. </el-table>
  207. </div>
  208. <el-dialog title="用户信息" :visible.sync="dialogVisible" width="60%">
  209. <div class="flex br" style="text-align: center;">
  210. <div class="_Form">
  211. <div class="flex align-center">
  212. <div><span class="text-red">*</span>用户昵称</div>
  213. <div><el-input v-model="nowForm.nickName" placeholder="用户昵称"></el-input></div>
  214. </div>
  215. <div class="flex align-center">
  216. <div>手机号码</div>
  217. <div><el-input v-model="nowForm.phonenumber" placeholder="手机号码"></el-input></div>
  218. </div>
  219. <div class="flex align-center" v-if="nowForm.userId == undefined">
  220. <div><span class="text-red">*</span>用户账号</div>
  221. <div><el-input v-model="nowForm.userName" placeholder="用户账号" :readonly="readonlyInput" @focus="cancelReadOnly()"></el-input></div>
  222. </div>
  223. <div class="flex align-center">
  224. <div>用户性别</div>
  225. <div>
  226. <el-select v-model="nowForm.sex" placeholder="请选择" style="width: 100%;">
  227. <el-option
  228. v-for="item in sexOptions"
  229. :key="item.dictValue"
  230. :label="item.dictLabel"
  231. :value="item.dictValue">
  232. </el-option>
  233. </el-select>
  234. </div>
  235. </div>
  236. <div class="flex align-center" style="border: none;">
  237. <div>岗位</div>
  238. <div>
  239. <el-select v-model="nowForm.postIds[0]"
  240. clearable @clear="clearSel('postIds')"
  241. placeholder="请选择" style="width: 100%;">
  242. <el-option
  243. v-for="item in postOptions"
  244. :key="item.postId"
  245. :label="item.postName"
  246. :value="item.postId">
  247. </el-option>
  248. </el-select>
  249. </div>
  250. </div>
  251. </div>
  252. <div class="_Form" style="border: none;">
  253. <div class="flex align-center">
  254. <div>归属部门</div>
  255. <div>
  256. <el-select v-model="parentName.deptName"
  257. ref="conSelect" style="width: 100%;">
  258. <el-option>
  259. <el-tree
  260. ref="tree"
  261. node-key="id"
  262. :data="deptOptions"
  263. :props="defaultProps"
  264. @node-click="nodeClick"
  265. />
  266. </el-option>
  267. </el-select>
  268. </div>
  269. </div>
  270. <div class="flex align-center">
  271. <div>邮箱</div>
  272. <div><el-input type="text" v-model="nowForm.email" placeholder="邮箱" :readonly="readonlyInput" @focus="cancelReadOnly()"></el-input></div>
  273. </div>
  274. <div class="flex align-center" v-if="nowForm.userId == undefined">
  275. <div><span class="text-red">*</span>用户密码</div>
  276. <div><el-input type="password" v-model="nowForm.password" placeholder="用户密码" :readonly="readonlyInput" @focus="cancelReadOnly()"></el-input></div>
  277. </div>
  278. <div class="flex align-center">
  279. <div>状态</div>
  280. <div class="text-left">
  281. <el-radio v-model="nowForm.status" label="0">正常</el-radio>
  282. <el-radio v-model="nowForm.status" label="1">停用</el-radio>
  283. </div>
  284. </div>
  285. <div class="flex align-center" style="border: none;">
  286. <div>角色</div>
  287. <div>
  288. <el-select v-model="nowForm.roleIds[0]"
  289. clearable @clear="clearSel('roleIds')"
  290. placeholder="请选择" style="width: 100%;">
  291. <el-option
  292. v-for="item in roleOptions"
  293. :key="item.roleId"
  294. :label="item.roleName"
  295. :value="item.roleId">
  296. </el-option>
  297. </el-select>
  298. </div>
  299. </div>
  300. </div>
  301. </div>
  302. <div class="padding-sm text-center">
  303. <el-button size="small" @click="dialogVisible = false;">取消</el-button>
  304. <el-button size="small" type="success" @click="conFirm">提交</el-button>
  305. </div>
  306. </el-dialog>
  307. <el-dialog title="提示" :visible.sync="pwdDialog" width="40%">
  308. <div>
  309. <div>请输入"{{ pwdInfo.pwdName }}"的新密码</div>
  310. <div class="margin-tb-sm"><el-input type="text" v-model="pwdInfo.newPwd" placeholder="用户新密码" :readonly="readonlyInput" @focus="cancelReadOnly()"></el-input></div>
  311. </div>
  312. <div class="text-right">
  313. <el-button size="small" @click="pwdDialog = false">取 消</el-button>
  314. <el-button size="small" type="success" @click="conPwd">确 定</el-button>
  315. </div>
  316. </el-dialog>
  317. </div>
  318. <script>
  319. var _this, dataObj=[];
  320. new Vue({
  321. el: '#app',
  322. data: function() {
  323. return {
  324. parentName: {
  325. deptName: "请选择",
  326. deptId: null
  327. },
  328. defaultProps: {
  329. children: 'children',
  330. label: 'label'
  331. },
  332. tableData: [],
  333. nowForm:{
  334. postIds: [],
  335. roleIds: []
  336. },
  337. dialogVisible:false,
  338. inpKey:"",
  339. sexOptions:[],
  340. postOptions:[],
  341. deptOptions :[],
  342. roleOptions:[],
  343. readonlyInput: true,
  344. pwdDialog:false,
  345. pwdInfo:{
  346. userId:null,
  347. newPwd:"",
  348. pwdName:null
  349. }
  350. }
  351. },
  352. created() {
  353. _this = this;
  354. _this.reSet();
  355. _this.getList();
  356. _this.getSex();
  357. _this.getTree();
  358. },
  359. methods: {
  360. cancelReadOnly() {
  361. _this.readonlyInput= false;
  362. },
  363. getList() {
  364. let data1 = {
  365. pageNum:1,
  366. pageSize:100
  367. };
  368. let _opts = {
  369. url: "/system/user/list",
  370. type:"GET"
  371. };
  372. tokenAjax(_opts, data1)
  373. .then(function(res) {
  374. if (res.code == 200) {
  375. _this.tableData = res.rows;
  376. dataObj = res.rows;
  377. }else{
  378. _this.$message.error(res.msg);
  379. }
  380. })
  381. },
  382. getSex(){
  383. let data1 = {};
  384. let _opts = {
  385. url: "/system/dict/data/type/sys_user_sex",
  386. type:"GET"
  387. };
  388. tokenAjax(_opts, data1)
  389. .then(function(res) {
  390. if (res.code == 200) {
  391. _this.sexOptions = res.data;
  392. }
  393. })
  394. },
  395. getTree(){
  396. let data1 = {};
  397. let _opts = {
  398. url: "/system/dept/treeselect",
  399. type:"GET"
  400. };
  401. tokenAjax(_opts, data1)
  402. .then(function(res) {
  403. if (res.code == 200) {
  404. _this.deptOptions = res.data;
  405. }
  406. })
  407. },
  408. _Search(_key){
  409. let newArr = [],_ovj = dataObj;
  410. if(_key == ""){
  411. newArr = dataObj;
  412. }else{
  413. for(var i=0;i<_ovj.length;i++){
  414. if( JSON.stringify(_ovj[i]).indexOf(_key) != -1){
  415. newArr.push(_ovj[i])
  416. }
  417. }
  418. }
  419. _this.tableData = newArr;
  420. },
  421. reSet() {
  422. _this.nowForm = {
  423. deptId: 0,
  424. userName: "",
  425. nickName: "",
  426. password: "",
  427. phonenumber: "",
  428. email: "",
  429. sex: "2",
  430. status: "0",
  431. remark: "",
  432. postIds: [],
  433. roleIds: []
  434. };
  435. },
  436. newAdd(){
  437. let data1 = {};
  438. let _opts = {
  439. url: "/system/user/",
  440. type:"GET"
  441. };
  442. tokenAjax(_opts, data1)
  443. .then(function(res) {
  444. if (res.code == 200) {
  445. _this.postOptions = res.posts;
  446. _this.roleOptions = res.roles;
  447. _this.parentName = {
  448. deptName: _this.deptOptions[0].label,
  449. deptId: _this.deptOptions[0].id
  450. };
  451. _this.reSet();
  452. _this.dialogVisible = true;
  453. }
  454. })
  455. },
  456. Edit(_row){
  457. let data1 = {};
  458. let _opts = {
  459. url: "/system/user/" + _row.userId,
  460. type:"GET"
  461. };
  462. tokenAjax(_opts, data1)
  463. .then(function(res) {
  464. if (res.code == 200) {
  465. _this.nowForm = res.data;
  466. if(res.data.deptId == null){
  467. _this.parentName = {
  468. deptName: _this.deptOptions[0].label,
  469. deptId: _this.deptOptions[0].id
  470. };
  471. }else{
  472. _this.parentName = res.data.dept;
  473. }
  474. _this.postOptions = res.posts;
  475. _this.roleOptions = res.roles;
  476. _this.nowForm.postIds = res.postIds;
  477. _this.nowForm.roleIds = res.roleIds;
  478. _this.dialogVisible = true;
  479. }
  480. })
  481. },
  482. Delete(_row){
  483. _this.$confirm('是否确认删除编号为"'+_row.userId+'"的数据项?', '温馨提示', {
  484. confirmButtonText: '确定',
  485. cancelButtonText: '取消',
  486. type: 'warning'
  487. }).then(() => {
  488. let data1 = {};
  489. let _opts = {
  490. url: "/system/user/"+_row.userId,
  491. type:"DELETE"
  492. };
  493. tokenAjax(_opts, data1)
  494. .then(function(res) {
  495. if(res.code == 200){
  496. _this.$message({
  497. type: 'success',
  498. message: '删除成功!'
  499. });
  500. _this.getList();
  501. }else{
  502. _this.$message.error(res.msg);
  503. }
  504. })
  505. }).catch(() => {
  506. });
  507. },
  508. RePwd(_row){
  509. if(_row.userId != null&&_row.userId != undefined){
  510. _this.pwdInfo.pwdName = _row.nickName;
  511. _this.pwdInfo.userId = _row.userId;
  512. _this.pwdDialog = true;
  513. }
  514. },
  515. conPwd(){
  516. if(_this.pwdInfo.newPwd == ""){
  517. _this.$message({
  518. type: 'warning',
  519. message: "请输入新密码"
  520. });
  521. return;
  522. }
  523. let data1 = {
  524. password: _this.pwdInfo.newPwd,
  525. userId: _this.pwdInfo.userId
  526. };
  527. let _opts = {
  528. url:"/system/user/resetPwd",
  529. type: "PUT"
  530. };
  531. tokenPostAjax(_opts,data1)
  532. .then(function(res){
  533. if(res.code == 200){
  534. _this.$message({
  535. type: 'success',
  536. message: '操作成功!'
  537. });
  538. _this.pwdDialog = false;
  539. }else{
  540. _this.$message.error(res.msg);
  541. }
  542. })
  543. },
  544. conFirm(){
  545. if(_this.nowForm.nickName == ""){
  546. _this.$message({
  547. type: 'warning',
  548. message: "请输入用户昵称"
  549. });
  550. return;
  551. }
  552. if(_this.nowForm.userName == ""&&_this.nowForm.userId == undefined){
  553. _this.$message({
  554. type: 'warning',
  555. message: "请输入用户账号"
  556. });
  557. return;
  558. }
  559. if(_this.nowForm.password == ""&&_this.nowForm.userId == undefined){
  560. _this.$message({
  561. type: 'warning',
  562. message: "请输入权限字符"
  563. });
  564. return;
  565. }
  566. if(_this.nowForm.phonenumber != ""&&_this.nowForm.phonenumber != null&&(!(/^1[3456789]\d{9}$/.test(_this.nowForm.phonenumber)))){
  567. _this.$message({
  568. type: 'warning',
  569. message: '请输入正确的手机号码',
  570. })
  571. return;
  572. }
  573. if(_this.nowForm.email != ""&&_this.nowForm.email != null&&(!(/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/.test(_this.nowForm.email)))){
  574. _this.$message({
  575. type: 'warning',
  576. message: '请输入正确的邮箱格式',
  577. })
  578. return;
  579. }
  580. _this.nowForm.deptId = _this.parentName.deptId;
  581. _this.nowForm.salt = "413295250,413307240,413385020,413396330,413496020";
  582. let data1 = _this.nowForm;
  583. let _opts = {
  584. url:"/system/user",
  585. type: _this.nowForm.userId == undefined?"POST":"PUT"
  586. };
  587. tokenPostAjax(_opts,data1)
  588. .then(function(res){
  589. if(res.code == 200){
  590. _this.$message({
  591. type: 'success',
  592. message: '操作成功!'
  593. });
  594. _this.getList();
  595. _this.dialogVisible = false;
  596. }else{
  597. _this.$message.error(res.msg);
  598. }
  599. })
  600. },
  601. nodeClick(_e){
  602. _this.parentName = {
  603. deptName: _e.label,
  604. deptId: _e.id
  605. };
  606. this.$refs.conSelect.blur();
  607. },
  608. clearSel(_row){
  609. _this.nowForm[_row] = [];
  610. }
  611. }
  612. })
  613. </script>
  614. </body>
  615. </html>