UserMa.html 19 KB

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