index.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. <style>
  2. .table-body {
  3. padding: 20px 20px;
  4. background-color: #fff;
  5. }
  6. .table-body .top-input{
  7. margin-top: 34px;
  8. }
  9. .input-item {
  10. width: 200px;
  11. margin-right: 20px;
  12. }
  13. .input-item .el-input__inner {
  14. border-right: 0;
  15. }
  16. .input-item .el-input__inner:hover {
  17. border: 1px solid #dcdfe6;
  18. border-right: 0;
  19. outline: 0;
  20. }
  21. .input-item .el-input__inner:focus {
  22. border: 1px solid #dcdfe6;
  23. border-right: 0;
  24. outline: 0;
  25. }
  26. .input-item .el-input-group__append {
  27. background-color: #fff;
  28. border-left: 0;
  29. width: 10%;
  30. padding: 0;
  31. }
  32. .input-item .el-input-group__append .el-button {
  33. padding: 0;
  34. }
  35. .input-item .el-input-group__append .el-button {
  36. margin: 0;
  37. }
  38. /* #app .table-body .el-table .el-button {
  39. border-radius: 16px;
  40. } */
  41. .create {
  42. height: 36px;
  43. line-height: 36px;
  44. float: right;
  45. color: #BCBCBC;
  46. margin-left: 20px;
  47. }
  48. .name {
  49. cursor: pointer;
  50. color: #49A9FF;
  51. }
  52. .el-input-group__append {
  53. /* background-color: #fff; */
  54. }
  55. /* 卡片 */
  56. .plugin-list {
  57. margin: 0 0 0 -20px;
  58. /* padding-right: 100px; */
  59. display: flex;
  60. flex-wrap:wrap;
  61. }
  62. .plugin-list .plugin-item{
  63. width: 20%;
  64. min-width: 400px;
  65. }
  66. .plugin-item {
  67. border: 1px solid #ebebeb;
  68. background: #FFFFFF;
  69. box-shadow: 3px 5px 15px rgba(80, 80, 80, 0.16);
  70. opacity: 1;
  71. border-radius: 5px;
  72. padding: 20px;
  73. margin: 0 0 20px 20px;
  74. transition: 250ms;
  75. position: relative;
  76. /* min-width: 300px; */
  77. }
  78. .plugin-item .item-status{
  79. position: absolute;
  80. top: 0;
  81. right: 0;
  82. width: 94px;
  83. height: 30px;
  84. background: #E8EAEC;
  85. opacity: 1;
  86. border-radius: 0px 5px 0px 5px;
  87. font-size: 14px;
  88. font-family: Microsoft YaHei;
  89. font-weight: 400;
  90. line-height: 30px;
  91. color: #9398A4;
  92. text-align: center;
  93. }
  94. .item-status-permanent{
  95. width: 94px;
  96. }
  97. .item-status-effective{
  98. width: 164px;
  99. }
  100. .plugin-item .item-info{
  101. display: flex;
  102. align-items: center;
  103. }
  104. /* .plugin-item .item-info .item-right{
  105. min-width: 500px;
  106. } */
  107. .plugin-item .item-btns{
  108. display: flex;
  109. align-items: center;
  110. justify-content:flex-end;
  111. margin-top: 12px;
  112. }
  113. .plugin-item .mall-logo{
  114. width: 70px;
  115. height: 70px;
  116. margin-right: 12px;
  117. }
  118. .plugin-item .mall-logo img{
  119. width: 100%;
  120. height: 100%;
  121. display: block;
  122. border-radius: 50%;
  123. }
  124. .plugin-item .display-name {
  125. font-size: 18pt;
  126. margin-top: 10px;
  127. margin-bottom: 4px;
  128. font-family: Microsoft YaHei;
  129. font-weight: bold;
  130. line-height: 30px;
  131. color: #3F495D;
  132. opacity: 1;
  133. width: 200px;
  134. white-space:nowrap;
  135. overflow:hidden;
  136. text-overflow:ellipsis;
  137. }
  138. .plugin-item .name {
  139. color: #909399;
  140. }
  141. .plugin-item:hover {
  142. cursor: pointer;
  143. border-color: #bfddff;
  144. }
  145. /* .plugin-item:hover .display-name {
  146. color: #409EFF;
  147. } */
  148. .plugin-item .plugin-option-btn {
  149. height: 25px;
  150. width: 25px;
  151. font-size: 12px;
  152. padding: 0;
  153. }
  154. .plugin-item .detail-option.detail-option {
  155. color: #909399;
  156. background: #F2F6FC;
  157. }
  158. .plugin-item .detail-option:hover {
  159. color: #fff;
  160. background: #909399;
  161. }
  162. </style>
  163. <div id="app" v-cloak>
  164. <el-card shadow="never" style="border:0;min-width: 1200px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  165. <div slot="header">
  166. <div>
  167. <span>权限管理</span>
  168. <div style="float: right; margin: -5px 0">
  169. <el-button type="primary" size="small" @click="handleAdds">新增</el-button>
  170. </div>
  171. </div>
  172. </div>
  173. <div class="table-body">
  174. <template>
  175. <template>
  176. <el-tabs v-model="activeName" @tab-click="handleClick">
  177. <el-tab-pane label="平台" name="1"></el-tab-pane>
  178. <el-tab-pane label="商城" name="2"></el-tab-pane>
  179. <el-tab-pane label="应用" name="3"></el-tab-pane>
  180. </el-tabs>
  181. </template>
  182. <div>
  183. <el-table
  184. :data="tableData"
  185. style="width: 100%;margin-bottom: 20px;"
  186. row-key="id"
  187. stripe
  188. lazy
  189. :load="loadData"
  190. :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
  191. <el-table-column
  192. prop="title"
  193. label="标题"
  194. width="400">
  195. <template slot-scope="scope">
  196. <span style="margin-left: 10px">{{ scope.row.title }}
  197. <i class="el-icon-circle-plus" @click="handleAdd(scope.$index, scope.row)"></i>
  198. </span>
  199. </template>
  200. </el-table-column>
  201. <el-table-column
  202. prop="name"
  203. label="别名">
  204. <template slot-scope="scope">
  205. <span style="margin-left: 10px">{{ scope.row.name }}</span>
  206. </template>
  207. </el-table-column>
  208. <el-table-column
  209. prop="sort"
  210. label="序号"
  211. width="150">
  212. <template slot-scope="scope">
  213. <div v-if="sort_id != scope.row.id">
  214. <el-tooltip class="item" effect="dark" content="排序" placement="top">
  215. <span>{{scope.row.sort}}</span>
  216. </el-tooltip>
  217. <el-button class="edit-sort" type="text" @click="edit(scope.row,'sort')">
  218. <img src="resources/img/mall/order/edit.png" alt="">
  219. </el-button>
  220. </div>
  221. <div style="display: flex;align-items: center" v-else>
  222. <el-input style="min-width: 70px" type="number" size="mini" class="change" v-model="sort"></el-input>
  223. <el-button class="change-quit" type="text" style="color: #F56C6C;padding: 0 5px" icon="el-icon-error" circle @click="cancelEdit('sort')"></el-button>
  224. <el-button class="change-success" type="text" style="margin-left: 0;color: #67C23A;padding: 0 5px" icon="el-icon-success" circle @click="changeValue(scope.row)">
  225. </el-button>
  226. </div>
  227. </template>
  228. </el-table-column>
  229. <el-table-column label="操作">
  230. <template slot-scope="scope">
  231. <el-button type="text" size="mini" circle style="margin-left: 10px;margin-top: 10px"
  232. @click="handleEdit(scope.$index, scope.row)">
  233. <el-tooltip class="item" effect="dark" content="编辑" placement="top">
  234. <img src="resources/img/mall/edit.png" alt="">
  235. </el-tooltip>
  236. </el-button>
  237. <el-button style="margin-left: 10px;margin-top: 10px" type="text"
  238. class="set-el-button"
  239. size="mini" circle @click="handleDelete(scope.$index, scope.row)">
  240. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  241. <img src="resources/img/mall/del.png" alt="">
  242. </el-tooltip>
  243. </el-button>
  244. </template>
  245. </el-table-column>
  246. </el-table>
  247. </div>
  248. </template>
  249. </div>
  250. <el-dialog title="新增" :visible.sync="dialogFormVisible_add_0" >
  251. <el-form :model="form0" :rules="rules" ref="form0" @close="handleClose('form')">
  252. <el-form-item label="父级ID" :label-width="formLabelWidth">
  253. <el-select v-model="parent_title" placeholder="请选择" @change="handleChange">
  254. <el-option
  255. v-for="item,k in parent_list"
  256. :key="k"
  257. :label="item"
  258. :value="k">
  259. </el-option>
  260. </el-select>
  261. </el-form-item>
  262. <el-form-item label="别名" :label-width="formLabelWidth" prop="name">
  263. <el-input v-model="form0.name" autocomplete="off"></el-input>
  264. </el-form-item>
  265. <el-form-item label="标题" :label-width="formLabelWidth" prop="title">
  266. <el-input v-model="form0.title" autocomplete="off"></el-input>
  267. </el-form-item>
  268. <el-form-item label="排序" :label-width="formLabelWidth">
  269. <el-input v-model="form0.sort" autocomplete="off"></el-input>
  270. </el-form-item>
  271. </el-form>
  272. <div slot="footer" class="dialog-footer">
  273. <el-button @click="dialogFormVisible_add_0 = false">取 消</el-button>
  274. <el-button type="primary" @click="postAdd0('form0')">确 定</el-button>
  275. </div>
  276. </el-dialog>
  277. <el-dialog title="新增" :visible.sync="dialogFormVisible_add" @close="handleClose('form')">
  278. <el-form :model="form" :rules="rules" ref="form">
  279. <el-form-item label="父级ID" :label-width="formLabelWidth" >
  280. <el-select v-model="parent_title" placeholder="请选择" @change="handleChange">
  281. <el-option
  282. v-for="item,k in parent_list"
  283. :key="k"
  284. :label="item"
  285. :value="k">
  286. </el-option>
  287. </el-select>
  288. </el-form-item>
  289. <el-form-item label="别名" :label-width="formLabelWidth" prop="name">
  290. <el-input v-model="form.name" autocomplete="off"></el-input>
  291. </el-form-item>
  292. <el-form-item label="标题" :label-width="formLabelWidth" prop="title">
  293. <el-input v-model="form.title" autocomplete="off"></el-input>
  294. </el-form-item>
  295. <el-form-item label="排序" :label-width="formLabelWidth">
  296. <el-input v-model="form.sort" autocomplete="off"></el-input>
  297. </el-form-item>
  298. </el-form>
  299. <div slot="footer" class="dialog-footer">
  300. <el-button @click="dialogFormVisible_add = false">取 消</el-button>
  301. <el-button type="primary" @click="postAdd('form')">确 定</el-button>
  302. </div>
  303. </el-dialog>
  304. <el-dialog title="编辑" :visible.sync="dialogFormVisible_edit" @close="handleClose('form')">
  305. <el-form :model="form" :rules="rules" ref="form">
  306. <el-form-item label="父级ID" :label-width="formLabelWidth" >
  307. <el-select v-model="parent_title" placeholder="请选择" @change="handleChange">
  308. <el-option
  309. v-for="item,k in parent_list"
  310. :key="k"
  311. :label="item"
  312. :value="k">
  313. </el-option>
  314. </el-select>
  315. </el-form-item>
  316. <el-form-item label="别名" :label-width="formLabelWidth" prop="name">
  317. <el-input v-model="form.name" autocomplete="off"></el-input>
  318. </el-form-item>
  319. <el-form-item label="标题" :label-width="formLabelWidth" prop="title">
  320. <el-input v-model="form.title" autocomplete="off"></el-input>
  321. </el-form-item>
  322. <el-form-item label="排序" :label-width="formLabelWidth">
  323. <el-input v-model="form.sort" autocomplete="off"></el-input>
  324. </el-form-item>
  325. </el-form>
  326. <div slot="footer" class="dialog-footer">
  327. <el-button @click="dialogFormVisible_edit = false">取 消</el-button>
  328. <el-button type="primary" @click="postEdit('form')">确 定</el-button>
  329. </div>
  330. </el-dialog>
  331. </el-card>
  332. </div>
  333. <script>
  334. new Vue({
  335. el: '#app',
  336. data() {
  337. return {
  338. tableData: [],
  339. dialogFormVisible_edit:false,
  340. dialogFormVisible_add:false,
  341. dialogFormVisible_add_0:false,
  342. parent_list: [],
  343. items: [],
  344. parent_title:'',
  345. form0: {
  346. id:'',
  347. name:'',
  348. cate_id: '1',
  349. pid:0,
  350. title:'',
  351. sort:999,
  352. app_id:"backend",
  353. },
  354. form: {
  355. id:'',
  356. name:'',
  357. cate_id: '1',
  358. pid:0,
  359. title:'',
  360. sort:999,
  361. app_id:"backend",
  362. },
  363. formLabelWidth: '120px',
  364. rules:{
  365. title: [
  366. { required: true, message: '请输入标题', trigger: 'blur' },
  367. { min: 1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur' }
  368. ],
  369. name: [
  370. { required: true, message: '请输入别名', trigger: 'blur' },
  371. { min: 1, max: 200, message: '长度在 1 到 200 个字符', trigger: 'blur' }
  372. ],
  373. },
  374. sort: 0,
  375. sort_id: 0,
  376. cate_id: 1,
  377. activeName: '',
  378. }
  379. },
  380. created() {
  381. this.loadList({});
  382. },
  383. methods: {
  384. loadList(params) {
  385. params['r'] = 'admin/rbac-auth-item/index';
  386. this.$request({
  387. params: params,
  388. }).then(e => {
  389. if(e.data.code==0){
  390. if(e.data.data.list){
  391. let list = e.data.data.list;
  392. for(var i in list) {
  393. if(list[i]['child'].length!=0){
  394. list[i].hasChildren = true;
  395. }
  396. }
  397. }
  398. this.tableData = e.data.data.list;
  399. }
  400. }).catch(e => {
  401. });
  402. },
  403. handleChange(value){;
  404. this.form.pid = value;
  405. this.form0.pid = value;
  406. },
  407. handleEdit(index, row) {
  408. this.form.id = row.id
  409. this.dialogFormVisible_edit = true;
  410. this.$request({
  411. params: {
  412. r:'admin/rbac-auth-item/edit',
  413. id:row.id,
  414. type:'edit'
  415. },
  416. }).then(e => {
  417. if(e.data.code==0){
  418. this.parent_list = e.data.data.list;
  419. this.form = e.data.data.items;
  420. this.parent_title = e.data.data.parent_title;
  421. }
  422. }).catch(e => {
  423. });
  424. },
  425. handleAdd(index, row) {
  426. this.dialogFormVisible_add = true;
  427. this.$request({
  428. params: {
  429. r:'admin/rbac-auth-item/edit',
  430. type:'add',
  431. id:row.id,
  432. },
  433. }).then(e => {
  434. if(e.data.code==0){
  435. this.parent_list = e.data.data.list;
  436. this.form.pid = row.id;
  437. this.parent_title = e.data.data.parent_title;
  438. }
  439. }).catch(e => {
  440. });
  441. },
  442. handleAdds() {
  443. this.dialogFormVisible_add_0 = true;
  444. this.$request({
  445. params: {
  446. r:'admin/rbac-auth-item/edit',
  447. type:'add'
  448. },
  449. }).then(e => {
  450. if(e.data.code==0){
  451. this.parent_list = e.data.data.list;
  452. this.parent_title = e.data.data.parent_title;
  453. }
  454. }).catch(e => {
  455. });
  456. },
  457. postAdd(formName){
  458. this.form.id = 0;
  459. this.$refs[formName].validate((valid) => {
  460. if(valid){
  461. this.$request({
  462. method:"post",
  463. params: {
  464. r:'admin/rbac-auth-item/add',
  465. },
  466. data:this.form
  467. }).then(e => {
  468. if(e.data.code==0){
  469. this.dialogFormVisible_add = false;
  470. this.$message({
  471. message: e.data.msg,
  472. type: 'success'
  473. });
  474. // location.reload();
  475. }else{
  476. this.$message.error(e.data.msg);
  477. }
  478. }).catch(e => {
  479. });
  480. }
  481. });
  482. },
  483. postEdit(formName){
  484. this.$refs[formName].validate((valid) => {
  485. if(valid){
  486. this.$request({
  487. method:"post",
  488. params: {
  489. r:'admin/rbac-auth-item/edit',
  490. },
  491. data:this.form
  492. }).then(e => {
  493. if(e.data.code==0){
  494. if(this.form.id){
  495. this.dialogFormVisible_edit = false;
  496. }else{
  497. this.dialogFormVisible_add = false;
  498. }
  499. this.$message({
  500. message: e.data.msg,
  501. type: 'success'
  502. });
  503. // location.reload();
  504. }else{
  505. this.$message.error(e.data.msg);
  506. }
  507. }).catch(e => {
  508. });
  509. }
  510. });
  511. },
  512. postAdd0(formName){
  513. this.$refs[formName].validate((valid) => {
  514. if (valid) {
  515. this.$request({
  516. method: "post",
  517. params: {
  518. r: 'admin/rbac-auth-item/add',
  519. },
  520. data: this.form0
  521. }).then(e => {
  522. if (e.data.code == 0) {
  523. if (this.form.id) {
  524. this.dialogFormVisible_edit = false;
  525. } else {
  526. this.dialogFormVisible_add = false;
  527. }
  528. this.$message({
  529. message: e.data.msg,
  530. type: 'success'
  531. });
  532. location.reload();
  533. } else {
  534. this.$message.error(e.data.msg);
  535. }
  536. }).catch(e => {
  537. });
  538. }
  539. });
  540. },
  541. handleDelete(index, row) {
  542. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {
  543. this.form.id = row.id
  544. this.$request({
  545. params: {
  546. r: 'admin/rbac-auth-item/del',
  547. id: row.id,
  548. status: -1,
  549. },
  550. }).then(e => {
  551. if (e.data.code == 0) {
  552. this.$message({
  553. message: e.data.msg,
  554. type: 'success'
  555. });
  556. location.reload();
  557. }
  558. }).catch(e => {
  559. });
  560. });
  561. },
  562. changeValue(row){
  563. this.$request({
  564. params: {
  565. r:'admin/rbac-auth-item/update-sort',
  566. id:row.id,
  567. sort:this.sort,
  568. },
  569. }).then(e => {
  570. this.$message({
  571. message: e.data.msg,
  572. type: 'success'
  573. });
  574. row.sort = this.sort;
  575. this.sort_id=0;
  576. }).catch(e => {
  577. });
  578. },
  579. edit(row, type) {
  580. switch (type) {
  581. case 'sort':
  582. this.sort = row.sort;
  583. this.sort_id = row.id;
  584. break;
  585. }
  586. },
  587. cancelEdit(type) {
  588. switch (type) {
  589. case 'sort':
  590. this.sort = 0;
  591. this.sort_id = 0;
  592. break;
  593. }
  594. },
  595. loadData(tree, treeNode, resolve){
  596. this.$request({
  597. params: {
  598. r:'admin/rbac-auth-item/index',
  599. pid:tree.id,
  600. cate_id:this.cate_id,
  601. },
  602. }).then(e => {
  603. if(e.data.code==0){
  604. let list = e.data.data.list;
  605. for(var i in list) {
  606. console.log(list[i]['child'].length);
  607. if(list[i]['child'].length!=0){
  608. list[i].hasChildren = true;
  609. }
  610. }
  611. resolve(list);
  612. }
  613. }).catch(e => {
  614. });
  615. },
  616. handleClose(formName){
  617. this.$refs[formName].resetFields();
  618. },
  619. handleClick(tab, event) {
  620. this.loadList({
  621. cate_id: tab.name
  622. });
  623. this.form.cate_id = tab.name
  624. this.form0.cate_id = tab.name
  625. this.cate_id = tab.name
  626. },
  627. },
  628. });
  629. </script>