app-menu-add.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>app菜单管理-添加/修改</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  6. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7. <!-- 所有的 css js 资源 -->
  8. <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
  9. <link rel="stylesheet" href="../../static/sa.css">
  10. <script src="../../static/kj/vue.min.js"></script>
  11. <script src="../../static/kj/element-ui/index.js"></script>
  12. <script src="../../static/kj/httpVueLoader.js"></script>
  13. <script src="../../static/kj/jquery.min.js"></script>
  14. <script src="../../static/kj/layer/layer.js"></script>
  15. <script src="../../static/sa.js"></script>
  16. <style type="text/css">
  17. .c-panel .el-form .c-label{width: 7em !important;}
  18. .c-panel .el-form .el-input, .c-panel .el-form .el-textarea__inner{width: 250px;}
  19. </style>
  20. </head>
  21. <body>
  22. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  23. <!-- ------- 内容部分 ------- -->
  24. <div class="s-body">
  25. <div class="c-panel">
  26. <div class="c-title" v-if="id == 0">数据添加</div>
  27. <div class="c-title" v-else>数据修改</div>
  28. <el-form v-if="m">
  29. <el-row :gutter="50">
  30. <el-col :span="12">
  31. <sa-item type="text" name="菜单名称" v-model="m.menuName" br></sa-item>
  32. </el-col>
  33. <el-col :span="12">
  34. <sa-item type="text" name="前端路径" v-model="m.path" br></sa-item>
  35. </el-col>
  36. </el-row>
  37. <el-row :gutter="50">
  38. <el-col :span="12">
  39. <sa-item type="text" name="图标" v-model="m.icon" br></sa-item>
  40. </el-col>
  41. <el-col :span="12">
  42. <sa-item type="text" name="排序" v-model="m.sort" br></sa-item>
  43. </el-col>
  44. </el-row>
  45. <el-row :gutter="50">
  46. <el-col :span="12">
  47. <sa-item type="enum" name="状态" v-model="m.enable" :jv="{0: '禁用', 1: '启用'}" jtype="3" br></sa-item>
  48. </el-col>
  49. <el-col :span="12">
  50. <sa-item type="enum" name="认证后访问" v-model="m.auth" :jv="{0: '否', 1: '是'}" jtype="3" br></sa-item>
  51. </el-col>
  52. </el-row>
  53. <sa-item name="" class="s-ok" br>
  54. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  55. </sa-item>
  56. </el-form>
  57. </div>
  58. </div>
  59. <!-- ------- 底部按钮 ------- -->
  60. <div class="s-foot">
  61. <el-button type="primary" @click="ok()">确定</el-button>
  62. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  63. </div>
  64. </div>
  65. <script>
  66. var app = new Vue({
  67. components: {
  68. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  69. },
  70. el: '.vue-box',
  71. data: {
  72. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  73. m: null, // 实体对象
  74. },
  75. methods: {
  76. // 创建一个 默认Model
  77. createModel: function() {
  78. return {
  79. path: '', // 前端路径
  80. menuName: '', // 菜单名称
  81. icon: '', // 图标
  82. sort: '', // 排序
  83. enable: '', // 状态(0=禁用,1=启用)
  84. auth: '', // 是否认证后访问(0=否,1=是)
  85. }
  86. },
  87. // 提交数据
  88. ok: function(){
  89. // 表单校验
  90. let m = this.m;
  91. sa.checkNull(m.path, '请输入 [前端路径]');
  92. sa.checkNull(m.menuName, '请输入 [菜单名称]');
  93. sa.checkNull(m.icon, '请输入 [图标]');
  94. sa.checkNull(m.sort, '请输入 [排序]');
  95. sa.checkNull(m.enable, '请输入 [状态]');
  96. sa.checkNull(m.auth, '请输入 [是否认证后访问]');
  97. // 开始增加或修改
  98. m.createTime = sa.forDate(m.createTime,2)
  99. m.sort = parseInt(m.sort)
  100. if(this.id <= 0) { // 添加
  101. sa.ajax('/sp-admin/AppMenu/add', m, function(res){
  102. sa.alert('增加成功', this.clean);
  103. }.bind(this));
  104. } else { // 修改
  105. sa.ajax('/sp-admin/AppMenu/update', m, function(res){
  106. sa.alert('修改成功', this.clean);
  107. }.bind(this));
  108. }
  109. },
  110. // 添加/修改 完成后的动作
  111. clean: function() {
  112. if(this.id == 0) {
  113. this.m = this.createModel();
  114. } else {
  115. parent.app.f5(); // 刷新父页面列表
  116. sa.closeCurrIframe(); // 关闭本页
  117. }
  118. }
  119. },
  120. mounted: function(){
  121. // 初始化数据
  122. if(this.id <= 0) {
  123. this.m = this.createModel();
  124. } else {
  125. sa.ajax('/sp-admin/AppMenu/getById?id=' + this.id, function(res) {
  126. this.m = res.data;
  127. if(res.data == null) {
  128. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  129. }
  130. }.bind(this))
  131. }
  132. }
  133. })
  134. </script>
  135. </body>
  136. </html>