index.blade.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. @extends('layouts.base')
  2. @section('title', '角色管理')
  3. @section('content')
  4. <style>
  5. .panel{
  6. margin-bottom:10px!important;
  7. border-radius: 10px;
  8. padding-left: 20px;
  9. }
  10. .panel .active a {
  11. background-color: #29ba9c!important;
  12. border-radius: 18px!important;
  13. color:#fff;
  14. }
  15. .panel a{
  16. border:none!important;
  17. background-color:#fff!important;
  18. }
  19. .content{
  20. background: #eff3f6;
  21. padding: 10px!important;
  22. }
  23. .con{
  24. padding-bottom:20px;
  25. position:relative;
  26. border-radius: 8px;
  27. min-height: 100vh;
  28. background: #fff;
  29. }
  30. .con .setting .block{
  31. padding:10px;
  32. background-color:#fff;
  33. border-radius: 8px;
  34. }
  35. .con .setting .block .title{
  36. font-size:18px;
  37. margin-bottom:15px;
  38. display:flex;
  39. align-items:center;
  40. justify-content:space-between;
  41. }
  42. .add{
  43. width: 154px;
  44. height: 36px;
  45. border-radius: 4px;
  46. border: solid 1px #29ba9c;
  47. color:#29ba9c;
  48. display:flex;
  49. align-items:center;
  50. justify-content:center;
  51. }
  52. .el-table--fit{
  53. margin-top:-10px;
  54. }
  55. b{
  56. font-size:14px;
  57. }
  58. .vue-crumbs a {
  59. color: #333;
  60. }
  61. .vue-crumbs a:hover {
  62. color: #29ba9c;
  63. }
  64. .vue-crumbs {
  65. margin: 0 20px;
  66. font-size: 14px;
  67. color: #333;
  68. font-weight: 400;
  69. padding-bottom: 10px;
  70. line-height: 32px;
  71. }
  72. .el-table--border::after, .el-table--group::after, .el-table::before{
  73. background-color:#fff;
  74. }
  75. </style>
  76. <div id='re_content' >
  77. @include('layouts.newTabs')
  78. <div class="con">
  79. <div class="setting">
  80. <div class="block">
  81. <div class="title"><div style="display:flex;align-items:center;"><span style="width: 4px;height: 18px;background-color: #29ba9c;margin-right:15px;display:inline-block;"></span><b>角色管理</b><span></div></div>
  82. <template>
  83. <el-select v-model="search_form.status" placeholder="请选择">
  84. <el-option
  85. v-for="item in options"
  86. :key="item.value"
  87. :label="item.label"
  88. :value="item.status">
  89. </el-option>
  90. </el-select>
  91. </template>
  92. <el-input v-model="search_form.keyword" style="width:15%;margin-left:16px;margin-right:16px;" placeholder="可搜索角色名称"></el-input><el-button type="primary" @click="search">搜索</el-button>
  93. </div>
  94. <div style="background: #eff3f6;width:100%;height:15px;"></div>
  95. <div class="block">
  96. <div class="title"><div style="display:flex;align-items:center;"><span style="width: 4px;height: 18px;background-color: #29ba9c;margin-right:15px;display:inline-block;"></span><b>角色列表</b><a href="{{ yzWebFullUrl('user.role.store') }}"><el-button type="primary" style="margin-left:30px;" size="mini">添加角色</el-button></a></div></div>
  97. </div>
  98. <template style="margin-top:-10px;">
  99. <el-table
  100. :data="tableData"
  101. style="padding:0 10px"
  102. v-loading="loading"
  103. element-loading-text="加载中"
  104. >
  105. <el-table-column
  106. prop="name"
  107. align="center"
  108. label="角色名称"
  109. >
  110. </el-table-column>
  111. <el-table-column
  112. align="center"
  113. label="操作员数量"
  114. >
  115. <template slot-scope="scope" >
  116. <div>
  117. [[scope.row.role_user.length]]
  118. </div>
  119. </template>
  120. </el-table-column>
  121. <el-table-column
  122. align="center"
  123. label="状态"
  124. >
  125. <template slot-scope="scope" >
  126. <el-switch
  127. @change="changeStatus(scope.row)"
  128. v-model="scope.row.status"
  129. :active-value="2"
  130. :inactive-value="1"
  131. active-color="#54c8b0"
  132. >
  133. </el-switch>
  134. </template>
  135. </el-table-column>
  136. <el-table-column
  137. align="center"
  138. label="操作"
  139. >
  140. <template slot-scope="scope" >
  141. <a :href="'{{ yzWebFullUrl('user.role.update', array('id' => '')) }}'+[[scope.row.id]]" style="color:#999"><i class="iconfont icon-ht_operation_edit" style="font-size:16px;margin-right:35px;"></i></a>
  142. <a style="color:#999"><i class="iconfont icon-ht_operation_delete" style="font-size:16px;" @click="del(scope, tableData)"></i></a>
  143. </template>
  144. </el-table-column>
  145. </el-table>
  146. </template>
  147. <el-row style="background-color:#fff;">
  148. <el-col :span="24" align="center" migra style="padding:15px 5% 15px 0">
  149. <el-pagination background @current-change="currentChange"
  150. :current-page="current_page"
  151. layout="prev, pager, next"
  152. :page-size="Number(page_size)" :current-page="current_page" :total="page_total"></el-pagination>
  153. </el-col>
  154. </el-row>
  155. </div>
  156. </div>
  157. </div>
  158. <script>
  159. var vm = new Vue({
  160. el: "#re_content",
  161. delimiters: ['[[', ']]'],
  162. data() {
  163. return {
  164. loading:false,
  165. search_loading:false,
  166. all_loading:false,
  167. page_total:0,
  168. page_size:0,
  169. current_page:0,
  170. search_form:{
  171. status:''
  172. },
  173. real_search_form:{},
  174. activeName: 'one',
  175. options: [{
  176. status: '2',
  177. label: '启用'
  178. },
  179. {
  180. status: '1',
  181. label: '禁用'
  182. }
  183. ],
  184. tableData: []
  185. }
  186. },
  187. mounted () {
  188. this.getData();
  189. },
  190. methods: {
  191. changeStatus(item){
  192. this.$http.post('{!! yzWebFullUrl('user.role.switchRole') !!}',{id:item.id}).then(function (response){
  193. if (response.data.result) {
  194. this.$message({message:"操作成功!",type:"success"});
  195. this.loading = false;
  196. }else {
  197. this.$message({message: response.data.msg,type: 'error'});
  198. }
  199. },function (response) {
  200. console.log(response);
  201. this.loading = false;
  202. }
  203. );
  204. },
  205. search() {
  206. this.search_loading = true;
  207. let json={
  208. search:this.search_form,
  209. }
  210. this.$http.post('{!! yzWebFullUrl('user.role.index') !!}',json
  211. ).then(function (response) {
  212. if (response.data.result){
  213. let datas = response.data.data.roleList;
  214. this.tableData=datas.data
  215. this.page_total = datas.total;
  216. this.page_size = datas.per_page;
  217. this.current_page = datas.current_page;
  218. this.loading = false;
  219. this.real_search_form=Object.assign({},this.search_form);
  220. }
  221. else {
  222. this.$message({message: response.data.msg,type: 'error'});
  223. }
  224. this.search_loading = false;
  225. },function (response) {
  226. this.search_loading = false;
  227. this.$message({message: response.data.msg,type: 'error'});
  228. }
  229. );
  230. },
  231. currentChange(val) {
  232. this.loading = true;
  233. this.$http.post('{!! yzWebFullUrl('user.role.index') !!}',{page:val,search:this.real_search_form}).then(function (response){
  234. if (response.data.result){
  235. let datas = response.data.data.roleList;
  236. this.tableData=datas.data
  237. this.page_total = datas.total;
  238. this.page_size = datas.per_page;
  239. this.current_page = datas.current_page;
  240. this.loading = false;
  241. } else {
  242. this.$message({message: response.data.msg,type: 'error'});
  243. }
  244. },function (response) {
  245. console.log(response);
  246. this.loading = false;
  247. }
  248. );
  249. },
  250. del(scope,rows){
  251. this.$confirm('是否删除?', '提示', {
  252. confirmButtonText: '确定',
  253. cancelButtonText: '取消',
  254. type: 'warning'
  255. }).then(() => {
  256. rows.splice(scope.$index, 1);
  257. let json={
  258. id:scope.row.id
  259. }
  260. this.$http.post('{!! yzWebFullUrl('user.role.destory') !!}',json).then(function (response){
  261. if (response.data.result) {
  262. this.$message({message:"删除成功!",type:"success"});
  263. this.loading = false;
  264. }else {
  265. this.$message({message: response.data.msg,type: 'error'});
  266. }
  267. },function (response) {
  268. console.log(response);
  269. this.loading = false;
  270. }
  271. );
  272. }).catch(() => {
  273. this.$message({
  274. type: 'info',
  275. message: '已取消删除'
  276. });
  277. });
  278. },
  279. getData(){
  280. this.loading = true
  281. this.$http.post('{!! yzWebFullUrl('user.role.index') !!}').then(function (response){
  282. if (response.data.result) {
  283. let datas = response.data.data.roleList;
  284. this.tableData=datas.data
  285. this.page_total = datas.total;
  286. this.page_size = datas.per_page;
  287. this.current_page = datas.current_page;
  288. this.loading = false;
  289. }else{
  290. this.$message({message: response.data.msg,type: 'error'});
  291. }
  292. },function (response) {
  293. this.$message({message: response.data.msg,type: 'error'});
  294. })
  295. },
  296. },
  297. });
  298. </script>
  299. @endsection