tb-message-add.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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"
  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. <style type="text/css">
  18. .c-panel .el-form .c-label {
  19. width: 7em !important;
  20. }
  21. .c-panel .el-form .el-input,
  22. .c-panel .el-form .el-textarea__inner {
  23. width: 250px;
  24. }
  25. textarea{
  26. width: 500px!important;
  27. height: 200px!important;
  28. }
  29. </style>
  30. </head>
  31. <body>
  32. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  33. <!-- ------- 内容部分 ------- -->
  34. <div class="s-body">
  35. <div class="c-panel">
  36. <div class="c-title" v-if="id == 0">数据添加</div>
  37. <div class="c-title" v-else>数据修改</div>
  38. <el-form v-if="m">
  39. <sa-item type="textarea" name="消息内容" v-model="m.contents" placeholder="输入消息内容"></sa-item>
  40. <sa-item type="enum" name="状态" v-model="m.enable" :jv="{0: '禁用', 1: '启用'}" jtype="3" br></sa-item>
  41. <sa-item name="" class="s-ok" br>
  42. <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
  43. </sa-item>
  44. </el-form>
  45. </div>
  46. </div>
  47. <!-- ------- 底部按钮 ------- -->
  48. <div class="s-foot">
  49. <el-button type="primary" @click="ok()">确定</el-button>
  50. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  51. </div>
  52. </div>
  53. <script>
  54. var app = new Vue({
  55. components: {
  56. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  57. },
  58. el: '.vue-box',
  59. data: {
  60. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  61. m: null, // 实体对象
  62. },
  63. methods: {
  64. // 创建一个 默认Model
  65. createModel: function() {
  66. return {
  67. id: '', //
  68. types: '', // 消息类型
  69. module: '', // 模块类型
  70. contents: '', // 消息内容
  71. userId: '', // 关联用户
  72. createTime: '', // 创建时间
  73. }
  74. },
  75. // 提交数据
  76. ok: function() {
  77. // 表单校验
  78. let m = this.m;
  79. sa.checkNull(m.contents, '请输入消息内容');
  80. sa.checkNull(m.enable, '请选择状态');
  81. // 开始增加或修改
  82. if (this.id <= 0) { // 添加
  83. sa.ajax('/sp-admin/TbMessage/add', m, function(res) {
  84. sa.alert('增加成功', this.clean);
  85. }.bind(this));
  86. } else { // 修改
  87. sa.ajax('/sp-admin/TbMessage/update', m, function(res) {
  88. sa.alert('修改成功', this.clean);
  89. }.bind(this));
  90. }
  91. },
  92. // 添加/修改 完成后的动作
  93. clean: function() {
  94. if (this.id == 0) {
  95. this.m = this.createModel();
  96. } else {
  97. parent.app.f5(); // 刷新父页面列表
  98. sa.closeCurrIframe(); // 关闭本页
  99. }
  100. }
  101. },
  102. mounted: function() {
  103. // 初始化数据
  104. if (this.id <= 0) {
  105. this.m = this.createModel();
  106. } else {
  107. sa.ajax('/sp-admin/TbMessage/getById?id=' + this.id, function(res) {
  108. this.m = res.data;
  109. if (res.data == null) {
  110. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  111. }
  112. }.bind(this))
  113. }
  114. }
  115. })
  116. </script>
  117. </body>
  118. </html>