app-menu-add.html 4.7 KB

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