e1627a19ee00103b5ad3bbdca4ffc8ad.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php /*a:3:{s:69:"D:\phpstudy_pro\WWW\CRMEB\app\admin\view\setting\system_role\edit.php";i:1595820902;s:56:"D:\phpstudy_pro\WWW\CRMEB\app\admin\view\public\head.php";i:1595820902;s:57:"D:\phpstudy_pro\WWW\CRMEB\app\admin\view\public\style.php";i:1595820902;}*/ ?>
  2. <!DOCTYPE html>
  3. <!--suppress JSAnnotator -->
  4. <html lang="zh-CN">
  5. <head>
  6. <meta charset="UTF-8">
  7. <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  8. <link rel="stylesheet" href="/system/css/main.css">
  9. <link rel="stylesheet" href="/static/css/animate.css">
  10. <!--<script type="text/javascript" src="/static/plug/basket.js"></script>-->
  11. <script type="text/javascript" src="/static/plug/requirejs/require.js"></script>
  12. <?php /* <script type="text/javascript" src="/static/plug/requirejs/require-basket-load.js"></script> */ ?>
  13. <script>
  14. var hostname = location.hostname;
  15. if(location.port) hostname += ':' + location.port;
  16. requirejs.config({
  17. map: {
  18. '*': {
  19. 'css': '/static/plug/requirejs/require-css.js'
  20. }
  21. },
  22. shim:{
  23. 'iview':{
  24. deps:['css!iviewcss']
  25. },
  26. 'layer':{
  27. deps:['css!layercss']
  28. }
  29. },
  30. baseUrl:'//'+hostname+'/',
  31. paths: {
  32. 'static':'static',
  33. 'system':'system',
  34. 'vue':'static/plug/vue/dist/vue.min',
  35. 'axios':'static/plug/axios.min',
  36. 'iview':'static/plug/iview/dist/iview.min',
  37. 'iviewcss':'static/plug/iview/dist/styles/iview',
  38. 'lodash':'static/plug/lodash',
  39. 'layer':'static/plug/layer/layer',
  40. 'layercss':'static/plug/layer/theme/default/layer',
  41. 'jquery':'static/plug/jquery/jquery.min',
  42. 'moment':'static/plug/moment',
  43. 'sweetalert':'static/plug/sweetalert2/sweetalert2.all.min',
  44. 'formCreate':'/static/plug/form-create/form-create.min',
  45. },
  46. basket: {
  47. excludes:['system/js/index','system/util/mpVueComponent','system/util/mpVuePackage']
  48. // excludes:['system/util/mpFormBuilder','system/js/index','system/util/mpVueComponent','system/util/mpVuePackage']
  49. }
  50. });
  51. </script>
  52. <script type="text/javascript" src="/system/util/mpFrame.js"></script>
  53. <script>
  54. $eb = parent._mpApi;
  55. // if(!$eb) top.location.reload();
  56. </script>
  57. <title></title>
  58. </head>
  59. <body>
  60. <div id="form-add" class="mp-form" v-cloak="">
  61. <i-Form :model="formData" :label-width="80" >
  62. <Form-Item label="身份名称">
  63. <i-input v-model="formData.role_name" placeholder="请输入身份名称"></i-input>
  64. </Form-Item>
  65. <Form-Item label="是否开启">
  66. <Radio-Group v-model="formData.status">
  67. <Radio label="1">开启</Radio>
  68. <Radio label="0">关闭</Radio>
  69. </Radio-Group>
  70. </Form-Item>
  71. <Form-Item label="权限">
  72. <Tree :data="menus" show-checkbox ref="tree"></Tree>
  73. </Form-Item>
  74. <Form-Item :class="'add-submit-item'">
  75. <i-Button :type="'primary'" :html-type="'submit'" :size="'large'" :long="true" :loading="loading" @click.prevent="submit">提交</i-Button>
  76. </Form-Item>
  77. </i-Form>
  78. </div>
  79. <script>
  80. $eb = parent._mpApi;
  81. var role = <?php echo $role; ?> || {};
  82. var menus = <?php echo $menus; ?> || [];
  83. mpFrame.start(function(Vue){
  84. new Vue({
  85. el:'#form-add',
  86. data:{
  87. formData:{
  88. role_name:role.role_name || '',
  89. status:String(role.status) || '1',
  90. checked_menus:role.rules
  91. },
  92. menus:[],
  93. loading:false
  94. },
  95. methods:{
  96. tidyRes:function(){
  97. var data = [];
  98. menus.map((menu)=>{
  99. data.push(this.initMenu(menu));
  100. });
  101. this.$set(this,'menus',data);
  102. },
  103. initMenu:function(menu){
  104. var data = {},checkMenus = ','+this.formData.checked_menus+',';
  105. data.title = menu.menu_name;
  106. data.id = menu.id;
  107. if(menu.child && menu.child.length >0){
  108. data.children = [];
  109. menu.child.map((child)=>{
  110. data.children.push(this.initMenu(child));
  111. })
  112. }else{
  113. data.checked = checkMenus.indexOf(String(','+data.id+',')) !== -1;
  114. data.expand = !data.checked;
  115. }
  116. return data;
  117. },
  118. submit:function(){
  119. this.loading = true;
  120. this.formData.checked_menus = [];
  121. this.$refs.tree.getCheckedNodes().map((node)=>{
  122. this.formData.checked_menus.push(node.id);
  123. });
  124. $eb.axios.post("<?php echo htmlentities($updateUrl); ?>",this.formData).then((res)=>{
  125. if(res.status && res.data.code == 200)
  126. return Promise.resolve(res.data);
  127. else
  128. return Promise.reject(res.data.msg || '添加失败,请稍候再试!');
  129. }).then((res)=>{
  130. $eb.message('success',res.msg || '操作成功!');
  131. $eb.closeModalFrame(window.name);
  132. parent.$(".J_iframe:visible")[0].contentWindow.location.reload();
  133. }).catch((err)=>{
  134. this.loading=false;
  135. $eb.message('error',err);
  136. });
  137. }
  138. },
  139. mounted:function(){
  140. t = this;
  141. this.tidyRes();
  142. }
  143. });
  144. });
  145. </script>
  146. </body>