edit.blade.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. @extends('layouts.app')
  2. @section('title')编辑-角色@endsection
  3. @section('content')
  4. <div class="container-fluid" id="editPanel">
  5. <div class="card">
  6. <div class="card-body">
  7. @if(Session::has('successTip'))
  8. <div class="alert alert-success h1">{{Session::get('successTip')}}!</div>
  9. @endif
  10. <form method="POST" action='{{url("maintenance/role/{$role->id}")}}'>
  11. @csrf
  12. @method('PUT')
  13. <div class="form-group row">
  14. <label for="name" class="col-2 col-form-label text-right">角色名称</label>
  15. <div class="col-8">
  16. <input type="text" class="form-control @error('name') is-invalid @enderror"
  17. name="name" autocomplete="off" value="@if(old('name')){{old('name')}}@else{{$role->name}}@endif" required>
  18. @error('name')
  19. <span class="invalid-feedback" role="alert">
  20. <strong>{{ $message }}</strong>
  21. </span>
  22. @enderror
  23. </div>
  24. </div>
  25. <div class="form-group row">
  26. <label for="authority" class="col-2 col-form-label text-md-right">允许权限</label>
  27. <div class="col-8">
  28. <input @keydown.enter.prevent="false" type="text" class="form-control tooltipTarget" placeholder="定位权限"
  29. @input="seekAuthority($event)" title="输入关键词快速定位下拉列表"></div>
  30. </div>
  31. <div class="form-group row">
  32. <label class="col-2"></label>
  33. <div class="col-5">
  34. <input name="authority" hidden v-model="authorities" >
  35. <div class="input-group" style="max-height: 245px; overflow-y: scroll;border-radius:5px;opacity:0.5;text-align: center;">
  36. <ul class="list-group" style="width: 100%" onselectstart="return false;">
  37. <li :data-original-title="authority.style ? '双击删除权限' :'双击添加权限'" v-for="authority in authoritiesFilterAll" v-if="authority.permission=='允许'" :id="authority.name" class="list-group-item list-group-item-action pt-0 pb-0"
  38. @dblclick="selectedAuthority(authority)" :class="authority.style ? 'active' :''"><span style="cursor: default;" :id="authority.name"> @{{ authority.name }} </span></li>
  39. </ul>
  40. </div>
  41. @error('authority')
  42. <span class="invalid-feedback">
  43. <strong>{{ $message }}</strong>
  44. </span>
  45. @enderror
  46. </div>
  47. <div class="col-3" v-if="authoritiesList.length>0">
  48. <div class="input-group" style="max-height: 245px; overflow-y: scroll;border-radius:5px;text-align: center;">
  49. <ul class="list-group tooltipTarget" style="width: 100%" onselectstart="return false;">
  50. <li title="双击删除权限" v-for="authority in authoritiesList" v-if="authority.permission=='允许'" class=" list-group-item list-group-item-action pt-0 pb-0"
  51. @dblclick="selectedAuthority(authority)"><span style="cursor: default;"> @{{ authority.name }} </span></li>
  52. </ul>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="form-group row">
  57. <label for="authority" class="col-2 col-form-label text-md-right">禁止权限</label>
  58. <div class="col-8">
  59. <input @keydown.enter.prevent="false" type="text" class="form-control tooltipTarget" placeholder="定位权限"
  60. @input="seekAuthority($event)" title="输入关键词快速定位下拉列表"></div>
  61. </div>
  62. <div class="form-group row">
  63. <label class="col-2"></label>
  64. <div class="col-5">
  65. <input name="authority" hidden v-model="authorities" >
  66. <div class="input-group" style="max-height: 150px; overflow-y: scroll;border-radius:5px;opacity:0.5;text-align: center;">
  67. <ul class="list-group" style="width: 100%" >
  68. <li :data-original-title="authority.style ? '双击删除权限' :'双击添加权限'" v-for="authority in authoritiesAll" v-if="authority.permission=='禁止'" :id="authority.name" class="list-group-item list-group-item-action pt-0 pb-0"
  69. @dblclick="selectedAuthority(authority)" :class="authority.style ? 'active' :''"><span style="cursor: default;" :id="authority.name"> @{{ authority.name }} </span></li>
  70. </ul>
  71. </div>
  72. @error('authority')
  73. <span class="invalid-feedback">
  74. <strong>{{ $message }}</strong>
  75. </span>
  76. @enderror
  77. </div>
  78. <div class="col-3" v-if="authoritiesList.length>0">
  79. <div class="input-group" style="max-height: 150px; overflow-y: scroll;border-radius:5px;text-align: center;">
  80. <ul class="list-group tooltipTarget" style="width: 100%" >
  81. <li title="双击删除权限" v-for="authority in authoritiesList" v-if="authority.permission=='禁止'" class=" list-group-item list-group-item-action pt-0 pb-0"
  82. @dblclick="selectedAuthority(authority)"><span style="cursor: default;"> @{{ authority.name }} </span></li>
  83. </ul>
  84. </div>
  85. </div>
  86. </div>
  87. <div class="form-group row">
  88. <label for="laborCompany" class="col-2 col-form-label text-md-right">劳务所</label>
  89. <div class="col-8">
  90. <input type="text" class="form-control tooltipTarget" placeholder="定位劳务所"
  91. @input="seekLaborCompany($event)" title="输入关键词快速定位"></div>
  92. </div>
  93. <div class="form-group row">
  94. <label class="col-2"></label>
  95. <div class="col-5">
  96. <input name="laborCompany" hidden v-model="laborCompanies" >
  97. <div class="input-group" style="max-height: 190px; overflow-y: scroll;border-radius:5px;opacity:0.5;text-align: center;">
  98. <ul class="list-group tooltipTarget" style="width: 100%" onselectstart="return false;">
  99. <li :data-original-title="laborCompany.style ? '双击删除劳务所' :'双击添加劳务所'" v-for="laborCompany in laborCompaniesFilter" :id="laborCompany.name" class="list-group-item list-group-item-action pt-0 pb-0"
  100. @dblclick="selectedLaborCompany(laborCompany)" :class="laborCompany.style ? 'active' :''"><span style="cursor: default;" :id="laborCompany.name"> @{{ laborCompany.name }} </span></li>
  101. </ul>
  102. </div>
  103. </div>
  104. <div class="col-3">
  105. <div class="input-group" style="max-height: 190px; overflow-y: scroll;border-radius:5px;text-align: center;">
  106. <ul class="list-group" style="width: 100%" onselectstart="return false;">
  107. <li title="双击删除劳务所" v-for="laborCompany in laborCompaniesList" :id="laborCompany.name" class="list-group-item list-group-item-action pt-0 pb-0"
  108. @dblclick="selectedLaborCompany(laborCompany)" ><span style="cursor: default;" > @{{ laborCompany.name }} </span></li>
  109. </ul>
  110. </div>
  111. </div>
  112. </div>
  113. <div class="form-group row">
  114. <div class="col-8 offset-2">
  115. <input type="submit" class="btn btn-outline-dark form-control">
  116. </div>
  117. </div>
  118. </form>
  119. </div>
  120. </div>
  121. </div>
  122. @endsection
  123. @section('lastScript')
  124. <script>
  125. let vueList=new Vue({
  126. el:"#editPanel",
  127. data:{
  128. authoritiesAll:[
  129. @foreach( $authoritiesAll as $authority )
  130. {id:'{{$authority->id}}',name:'{{$authority->alias_name}}',style:false,permission:'{{$authority->permission}}'},
  131. @endforeach
  132. ],
  133. authoritiesFilterAll:[
  134. @foreach( $authoritiesAll as $authority )
  135. {id:'{{$authority->id}}',name:'{{$authority->alias_name}}',style:false,permission:'{{$authority->permission}}'},
  136. @endforeach
  137. ],
  138. authorities:[
  139. @if(old('authority'))
  140. {{ old('authority') }}
  141. @else
  142. @foreach( $authorities as $authority )
  143. {{$authority->id}},
  144. @endforeach
  145. @endif
  146. ],
  147. authoritiesList:[],
  148. laborCompaniesAll: [
  149. @foreach($laborCompanies as $laborCompany)
  150. {
  151. id: '{{$laborCompany->id}}', name: '{{$laborCompany->name}}', style: false
  152. },
  153. @endforeach
  154. ],
  155. laborCompaniesFilter: [
  156. @foreach($laborCompanies as $laborCompany)
  157. {
  158. id: '{{$laborCompany->id}}', name: '{{$laborCompany->name}}', style: false
  159. },
  160. @endforeach
  161. ],
  162. laborCompanies: [
  163. @if(old('laborCompany'))
  164. {{ old('laborCompany') }}
  165. @else
  166. @foreach( $laborCompaniesRole as $laborCompany )
  167. {{$laborCompany->id}},
  168. @endforeach
  169. @endif
  170. ],
  171. laborCompaniesList: [],
  172. },
  173. mounted:function(){
  174. $(".tooltipTarget").tooltip({'trigger':'hover'});
  175. if (this.authorities.length>0){
  176. let authoritiesList=this.authoritiesList;
  177. let authoritiesAll=this.authoritiesAll;
  178. let authorities=this.authorities;
  179. for (let i = 0; i < authorities.length; i++) {
  180. authoritiesAll.every(function (authorityAll) {
  181. if (authorityAll.id == authorities[i]) {
  182. authorityAll.style = true;
  183. authoritiesList.push({'id':authorityAll.id,'name':authorityAll.name,'permission':authorityAll.permission});
  184. return false;
  185. }
  186. return true;
  187. });
  188. }
  189. }
  190. if (this.laborCompanies.length>0){
  191. let laborCompaniesAll=this.laborCompaniesAll;
  192. let laborCompanies=this.laborCompanies;
  193. let laborCompaniesList=this.laborCompaniesList;
  194. for (let i = 0; i < laborCompanies.length; i++) {
  195. laborCompaniesAll.every(function (laborCompanyAll) {
  196. if (laborCompanyAll.id == laborCompanies[i]) {
  197. laborCompanyAll.style = true;
  198. laborCompaniesList.push({'id':laborCompanyAll.id,'name':laborCompanyAll.name});
  199. return false;
  200. }
  201. return true;
  202. });
  203. }
  204. }
  205. },
  206. methods:{
  207. selectedAuthority:function (e) {
  208. let authorities=this.authorities;
  209. let authoritiesAll=this.authoritiesAll;
  210. let authoritiesList=this.authoritiesList;
  211. let isAuthorty=true;
  212. if (authorities) {
  213. for (let i = 0; i < authorities.length; i++) {
  214. if (authorities[i] == e.id) {
  215. authorities.splice(i,1);
  216. authoritiesAll.every(function (authorityAll) {
  217. if (authorityAll.id == e.id) {
  218. authorityAll.style = false;
  219. return false;
  220. }
  221. return true;
  222. });
  223. authoritiesList.every(function (authority,i) {
  224. if (authority.id==e.id){
  225. authoritiesList.splice(i,1);
  226. return false;
  227. }
  228. return true;
  229. });
  230. isAuthorty= false;
  231. break;
  232. }
  233. isAuthorty= true;
  234. }
  235. }
  236. if (isAuthorty || !authorities){
  237. authorities.push(e.id);
  238. authoritiesAll.every(function (authorityAll) {
  239. if (authorityAll.id==e.id){
  240. authorityAll.style=true;
  241. authoritiesList.push({'id':authorityAll.id,'name':authorityAll.name,'permission':authorityAll.permission});
  242. return false;
  243. }
  244. return true;
  245. });
  246. }
  247. setTimeout(function(){
  248. $(".tooltipTarget").tooltip({'trigger':'hover'});
  249. },10)
  250. },
  251. selectedLaborCompany:function (e) {
  252. let laborCompanies=this.laborCompanies;
  253. let laborCompaniesAll=this.laborCompaniesAll;
  254. let laborCompaniesList=this.laborCompaniesList;
  255. let isLaborCompany=true;
  256. if (laborCompanies&&laborCompaniesAll) {
  257. for (let i = 0; i < laborCompanies.length; i++) {
  258. if (laborCompanies[i] == e.id) {
  259. laborCompanies.splice(i,1);
  260. laborCompaniesAll.every(function (laborCompanyAll) {
  261. if (laborCompanyAll.id == e.id) {
  262. laborCompanyAll.style = false;
  263. return false;
  264. }
  265. return true;
  266. });
  267. laborCompaniesList.every(function (laborCompany,i) {
  268. if (laborCompany.id==e.id){
  269. laborCompaniesList.splice(i,1);
  270. return false;
  271. }
  272. return true;
  273. });
  274. isLaborCompany= false;
  275. break;
  276. }
  277. isLaborCompany= true;
  278. }
  279. }
  280. if (isLaborCompany || !laborCompanies){
  281. laborCompanies.push(e.id);
  282. laborCompaniesAll.every(function (laborCompanyAll) {
  283. if (laborCompanyAll.id==e.id){
  284. laborCompanyAll.style=true;
  285. laborCompaniesList.push({'id':laborCompanyAll.id,'name':laborCompanyAll.name});
  286. return false;
  287. }
  288. return true;
  289. });
  290. }
  291. setTimeout(function(){
  292. $(".tooltipTarget").tooltip({'trigger':'hover'});
  293. },10)
  294. },
  295. seekLaborCompany:function (e) {
  296. let $val=e.target.value;
  297. let laborCompaniesAll=this.laborCompaniesAll;
  298. let bool = false;
  299. laborCompaniesAll.every(function (laborCompanyAll) {
  300. let name=laborCompanyAll.name;
  301. if (name.includes($val)){
  302. bool = true;
  303. return false;
  304. }
  305. return true;
  306. });
  307. if($val === '' ){
  308. this.laborCompaniesFilter = this.laborCompaniesAll;
  309. }else if(bool){
  310. this.laborCompaniesFilter = [];
  311. for (let i = 0; i <laborCompaniesAll.length ; i++) {
  312. let laborCompany = laborCompaniesAll[i];
  313. if(laborCompany.name.includes($val)){
  314. this.laborCompaniesFilter.push(laborCompany);
  315. }
  316. }
  317. }
  318. },
  319. seekAuthority:function (e) {
  320. let $val=e.target.value;
  321. let authoritiesAll=this.authoritiesAll;
  322. let authoritiesFilterAll = this.authoritiesFilterAll;
  323. let bool = false;
  324. authoritiesAll.every(function (authorities) {
  325. let name=authorities.name;
  326. if (name.includes($val)){
  327. bool = true;
  328. return false;
  329. }
  330. return true;
  331. });
  332. console.log(bool);
  333. if($val === '' ){
  334. this.authoritiesFilterAll = this.authoritiesAll;
  335. }else if(bool) {
  336. this.authoritiesFilterAll = [];
  337. for (let i = 0; i < authoritiesAll.length; i++) {
  338. let authorities = authoritiesAll[i];
  339. let name = authorities.name;
  340. if (name.includes($val)) {
  341. this.authoritiesFilterAll.push(authorities);
  342. }
  343. }
  344. }
  345. },
  346. },
  347. });
  348. </script>
  349. @endsection