16a102a584e5d2300c878cc4167c4d1d.php 5.6 KB

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