role-add.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>角色-添加/修改</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/jquery.min.js"></script>
  13. <script src="../../static/kj/layer/layer.js"></script>
  14. <script src="../../static/sa.js"></script>
  15. <style type="text/css">
  16. .c-panel .el-form .c-label{width: 6em !important;}
  17. .c-panel .el-form .el-input{width: 250px;}
  18. </style>
  19. </head>
  20. <body>
  21. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  22. <!-- ------- 内容部分 ------- -->
  23. <div class="s-body">
  24. <div class="c-panel">
  25. <div class="c-title">数据添加</div>
  26. <el-form v-if="m">
  27. <!-- no字段: m.id - id -->
  28. <sa-item type="text" name="角色昵称" v-model="m.name" br></sa-item>
  29. <sa-item type="text" name="责任描述" v-model="m.info" br></sa-item>
  30. <sa-item name="" class="s-ok" br>
  31. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  32. </sa-item>
  33. </el-form>
  34. </div>
  35. </div>
  36. <!-- ------- 底部按钮 ------- -->
  37. <div class="s-foot">
  38. <el-button type="primary" @click="ok()">确定</el-button>
  39. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  40. </div>
  41. </div>
  42. <script>
  43. var app = new Vue({
  44. components: {
  45. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  46. },
  47. el: '.vue-box',
  48. data: {
  49. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  50. m: null, // 实体对象
  51. },
  52. methods: {
  53. // 创建一个 默认Model
  54. createModel: function() {
  55. return {
  56. id: '',
  57. name: '',
  58. info: '',
  59. isLock: 2,
  60. // createTime: new Date(),
  61. is_update: false,
  62. }
  63. },
  64. // 提交数据
  65. ok: function(){
  66. // 验证
  67. let m = this.m; // 获取 m对象
  68. sa.checkNull(m.name, '请输入角色名字');
  69. sa.checkNull(m.info, '请输入责任描述');
  70. // 开始增加
  71. sa.ajax('/role/add', this.m, function(res){
  72. sa.alert('增加成功', function() {
  73. if(parent.app) {
  74. parent.app.f5(); // 刷新父页面列表
  75. sa.closeCurrIframe(); // 关闭本页
  76. } else {
  77. app.m = this.createModel();
  78. }
  79. }.bind(this));
  80. }.bind(this));
  81. },
  82. // 添加/修改 完成后的动作
  83. clean: function() {
  84. if(this.id == 0) {
  85. this.m = this.createModel();
  86. } else {
  87. parent.app.f5(); // 刷新父页面列表
  88. sa.closeCurrIframe(); // 关闭本页
  89. }
  90. }
  91. },
  92. mounted: function(){
  93. this.m = this.createModel();
  94. }
  95. })
  96. </script>
  97. </body>
  98. </html>