PostMa.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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 src="../js/yz/init.js"></script>
  20. <script>
  21. checkLogin();
  22. </script>
  23. <style type="text/css">
  24. *{
  25. padding: 0;
  26. margin: 0;
  27. box-sizing: border-box;
  28. }
  29. body{
  30. padding: 10px;
  31. background-color: #040d32;
  32. }
  33. .search_ input {
  34. position: relative;
  35. width: 100%;
  36. height: 32px;
  37. line-height: 32px;
  38. border-radius: 4px;
  39. font-size: 14px;
  40. padding: 0 5px 0 25px;
  41. color: #dcdcdc;
  42. background-color: rgba(255, 255, 255, 0.2);
  43. border: 1px solid rgba(232, 232, 232, 0.3);
  44. }
  45. .search_ input::-webkit-input-placeholder {
  46. color: #dcdcdc;
  47. }
  48. .search_ .el-icon-search {
  49. position: absolute;
  50. left: 12px;
  51. top: 16px;
  52. color: #dcdcdc;
  53. }
  54. .elTable{
  55. width: 100%;
  56. border: 1px solid rgba(255, 255, 255, 0.2);
  57. }
  58. .el-table::before{
  59. height: 0;
  60. }
  61. .el-table::after{
  62. width: 0;
  63. }
  64. .el-table,.el-table__expanded-cell {
  65. color: #ddd;
  66. background-color: transparent !important;
  67. }
  68. .el-table tr,
  69. .el-table td {
  70. font-size: 14px;
  71. background-color: transparent !important;
  72. }
  73. .el-table td.el-table__cell,.el-table th.el-table__cell.is-leaf{
  74. border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  75. }
  76. .el-table--border .el-table__cell{
  77. border-right: 1px solid rgba(255, 255, 255, 0.2);
  78. }
  79. .el-dialog__header{
  80. padding: 10px;
  81. }
  82. .el-dialog__title{
  83. font-size: 15px;
  84. }
  85. .el-dialog__headerbtn{
  86. top: 14px;
  87. }
  88. .el-dialog__body{
  89. padding: 10px;
  90. color: #fff;
  91. background-color: #082041;
  92. }
  93. .el-tree{
  94. color: #fff;
  95. background-color: transparent;
  96. }
  97. .br{
  98. border: 1px solid rgba(255, 255, 255, 0.2);
  99. }
  100. ._Form{
  101. flex:1;
  102. flex-direction: column;
  103. border-right: 1px solid rgba(255, 255, 255, 0.2);
  104. }
  105. ._Form>div{
  106. height: 20%;
  107. min-height: 60px;
  108. border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  109. }
  110. ._Form>div>div:first-child{
  111. display: flex;
  112. align-items: center;
  113. justify-content: center;
  114. width: 100px;
  115. height: 100%;
  116. min-height: 60px;
  117. border-right: 1px solid rgba(255, 255, 255, 0.2);
  118. }
  119. ._Form>div>div:last-child{
  120. width: calc(100% - 100px);
  121. padding: 0 10px;
  122. }
  123. .el-input__inner{
  124. height: 34px;
  125. line-height: 34px;
  126. }
  127. .el-input__inner,._Form .el-textarea__inner{
  128. color: #ececec;
  129. border-color: transparent;
  130. background-color: rgba(255, 255, 255, 0.2);
  131. }
  132. .el-input__inner::-webkit-input-placeholder {
  133. color: #b9b9b9;
  134. }
  135. ._Form .el-radio{
  136. color: #fff;
  137. }
  138. ._treeTxt{
  139. display: flex;
  140. align-items: center;
  141. justify-content: center;
  142. width: 120px;
  143. min-height: 360px;
  144. height: 100%;
  145. border-right: 1px solid rgba(255, 255, 255, 0.2);
  146. }
  147. .el-radio__input.is-checked .el-radio__inner,
  148. .el-checkbox__input.is-checked .el-checkbox__inner,
  149. .el-checkbox__input.is-indeterminate .el-checkbox__inner,
  150. .el-button--success{
  151. border-color: #39b54a;
  152. background: #39b54a;
  153. }
  154. .el-radio__input.is-checked+.el-radio__label{
  155. color: #39b54a;
  156. }
  157. .el-tree-node__content:hover,.el-tree-node:focus>.el-tree-node__content {
  158. background-color: transparent;
  159. }
  160. </style>
  161. </head>
  162. <body>
  163. <div id="app">
  164. <div>
  165. <div class="flex align-center margin-bottom-sm">
  166. <div>
  167. <el-input placeholder="请输入关键词" v-model="inpKey" @input="_Search">
  168. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  169. </el-input>
  170. </div>
  171. <div class="tableTool">
  172. <el-button type="primary" size="small" class="margin-left-sm">查询</el-button>
  173. <el-button type="success" size="small" @click="newAdd">新增</el-button>
  174. </div>
  175. </div>
  176. <el-table class="elTable" :data="tableData" border :header-cell-style="{background:'#082041',color:'#fff'}">
  177. <el-table-column align="center" prop="postId" label="岗位编号"> </el-table-column>
  178. <el-table-column align="center" prop="postCode" label="岗位编码"> </el-table-column>
  179. <el-table-column align="center" prop="postName" label="岗位名称"> </el-table-column>
  180. <el-table-column align="center" prop="postSort" label="显示顺序"> </el-table-column>
  181. <el-table-column align="center" prop="status" label="状态">
  182. <template slot-scope="scope">
  183. <el-switch
  184. :value="scope.row.status == 0"
  185. disabled
  186. active-color="#13ce66"
  187. inactive-color="#cecece">
  188. </el-switch>
  189. </template>
  190. </el-table-column>
  191. <el-table-column align="center" prop="createTime" label="创建时间"> </el-table-column>
  192. <el-table-column
  193. align="center"
  194. width="140"
  195. label="操作">
  196. <template slot-scope="scope" v-if="!scope.row.admin">
  197. <el-button type="text" size="small" @click="Edit(scope.row)" class="text-green"><i class="el-icon-edit"></i>编辑</el-button>
  198. <el-button type="text" size="small" @click="Delete(scope.row)" class="text-red"><i class="el-icon-delete"></i>删除</el-button>
  199. </template>
  200. </el-table-column>
  201. </el-table>
  202. </div>
  203. <el-dialog title="岗位信息" :visible.sync="dialogVisible" width="400px">
  204. <div class="flex br" style="text-align: center;">
  205. <div class="_Form">
  206. <div class="flex align-center">
  207. <div><span class="text-red">*</span>岗位名称</div>
  208. <div><el-input v-model="nowForm.postName" placeholder="角色名称"></el-input></div>
  209. </div>
  210. <div class="flex align-center">
  211. <div><span class="text-red">*</span>岗位编码</div>
  212. <div><el-input v-model="nowForm.postCode" placeholder="权限字符"></el-input></div>
  213. </div>
  214. <div class="flex align-center">
  215. <div><span class="text-red">*</span>岗位顺序</div>
  216. <div><el-input type="number" min="0" v-model="nowForm.postSort" placeholder="请输入内容"></el-input></div>
  217. </div>
  218. <div class="flex align-center">
  219. <div>状态</div>
  220. <div class="text-left">
  221. <el-radio v-model="nowForm.status" label="0">正常</el-radio>
  222. <el-radio v-model="nowForm.status" label="1">停用</el-radio>
  223. </div>
  224. </div>
  225. <div class="flex align-center" style="border: none;">
  226. <div>备注</div>
  227. <div><el-input type="textarea" :rows="2" placeholder="请输入备注" v-model="nowForm.remark"></el-input></div>
  228. </div>
  229. </div>
  230. </div>
  231. <div class="padding-sm text-center">
  232. <el-button size="small" @click="dialogVisible = false;">取消</el-button>
  233. <el-button size="small" type="success" @click="conFirm">提交</el-button>
  234. </div>
  235. </el-dialog>
  236. </div>
  237. <script>
  238. var _this, dataObj=[];
  239. new Vue({
  240. el: '#app',
  241. data: function() {
  242. return {
  243. tableData: [],
  244. nowForm:{
  245. postName:"",
  246. postCode:"",
  247. postSort:0,
  248. status:"0",
  249. remark:""
  250. },
  251. dialogVisible:false,
  252. inpKey:""
  253. }
  254. },
  255. created() {
  256. _this = this;
  257. _this.getList();
  258. },
  259. methods: {
  260. getList() {
  261. let data1 = {
  262. pageNum:1,
  263. pageSize:100
  264. };
  265. let _opts = {
  266. url: "/system/post/list",
  267. type:"GET"
  268. };
  269. tokenAjax(_opts, data1)
  270. .then(function(res) {
  271. if (res.code == 200) {
  272. _this.tableData = res.rows;
  273. dataObj = res.rows;
  274. }else{
  275. _this.$message.error(res.msg);
  276. }
  277. })
  278. },
  279. _Search(_key){
  280. let newArr = [],_ovj = dataObj;
  281. if(_key == ""){
  282. newArr = dataObj;
  283. }else{
  284. for(var i=0;i<_ovj.length;i++){
  285. if( JSON.stringify(_ovj[i]).indexOf(_key) != -1){
  286. newArr.push(_ovj[i])
  287. }
  288. }
  289. }
  290. _this.tableData = newArr;
  291. },
  292. newAdd(){
  293. _this.nowForm = {
  294. postName:"",
  295. postCode:"",
  296. postSort:0,
  297. status:"0",
  298. remark:""
  299. };
  300. _this.dialogVisible = true;
  301. },
  302. Edit(_row){
  303. let data1 = {};
  304. let _opts = {
  305. url: "/system/post/" + _row.postId,
  306. type:"GET"
  307. };
  308. tokenAjax(_opts, data1)
  309. .then(function(res) {
  310. if (res.code == 200) {
  311. _this.nowForm = res.data;
  312. _this.dialogVisible = true;
  313. }
  314. })
  315. },
  316. Delete(_row){
  317. _this.$confirm('是否确认删除编号为"'+_row.postId+'"的数据项?', '温馨提示', {
  318. confirmButtonText: '确定',
  319. cancelButtonText: '取消',
  320. type: 'warning'
  321. }).then(() => {
  322. let data1 = {};
  323. let _opts = {
  324. url: "/system/post/"+_row.postId,
  325. type:"DELETE"
  326. };
  327. tokenAjax(_opts, data1)
  328. .then(function(res) {
  329. if(res.code == 200){
  330. _this.$message({
  331. type: 'success',
  332. message: '删除成功!'
  333. });
  334. _this.getList();
  335. }else{
  336. _this.$message.error(res.msg);
  337. }
  338. })
  339. }).catch(() => {
  340. });
  341. },
  342. conFirm(){
  343. if(_this.nowForm.postName == ""){
  344. _this.$message({
  345. type: 'warning',
  346. message: "请输入岗位名称"
  347. });
  348. return;
  349. }
  350. if(_this.nowForm.postCode == ""){
  351. _this.$message({
  352. type: 'warning',
  353. message: "请输入岗位编码"
  354. });
  355. return;
  356. }
  357. let data1 = _this.nowForm;
  358. let _opts = {
  359. url:"/system/post",
  360. type: _this.nowForm.postId == undefined?"POST":"PUT"
  361. };
  362. tokenPostAjax(_opts,data1)
  363. .then(function(res){
  364. if(res.code == 200){
  365. _this.$message({
  366. type: 'success',
  367. message: '操作成功!'
  368. });
  369. _this.getList();
  370. _this.dialogVisible = false;
  371. }else{
  372. _this.$message.error(res.msg);
  373. }
  374. })
  375. }
  376. }
  377. })
  378. </script>
  379. </body>
  380. </html>