tb-port-news-add.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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="https://unpkg.com/element-ui@2.13.0/lib/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. <script src="../../static/kj/wangEditor.min.js"></script>
  19. <style type="text/css">
  20. .c-panel .el-form .c-label{width: 7em !important;}
  21. .c-panel .el-form .el-input, .c-panel .el-form .el-textarea__inner{width: 250px;}
  22. .c-item .el-input__inner{width: 45%;}
  23. /* 普通文本和富文本一起变长 */
  24. .c-panel .el-form .el-input, .c-panel .el-form .el-textarea__inner{width: 800px;}
  25. .c-item-mline{width: 800px;}
  26. .editor-box{display: inline-block;}
  27. .c-item .editor-box, .editor-box #editor{width: 800px;}
  28. </style>
  29. </head>
  30. <body>
  31. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  32. <!-- ------- 内容部分 ------- -->
  33. <div class="s-body">
  34. <div class="c-panel">
  35. <div class="c-title" v-if="id == 0">数据添加</div>
  36. <div class="c-title" v-else>数据修改</div>
  37. <el-form v-if="m">
  38. <el-row>
  39. <el-col>
  40. <sa-item type="text" name="标题" v-model="m.title" br></sa-item>
  41. </el-col>
  42. </el-row>
  43. <el-row>
  44. <el-col>
  45. <sa-item type="img" name="封面图片" v-model="m.cover" br></sa-item>
  46. </el-col>
  47. </el-row>
  48. <el-row>
  49. <el-col>
  50. <sa-item type="text" name="链接地址" v-model="m.url" br :need="false"></sa-item>
  51. </el-col>
  52. </el-row>
  53. <el-row>
  54. <el-col>
  55. <sa-item type="text" name="来源" v-model="m.source" br :need="false"></sa-item>
  56. </el-col>
  57. </el-row>
  58. <el-row>
  59. <el-col>
  60. <sa-item type="richtext" name="内容" v-model="m.content" br></sa-item>
  61. </el-col>
  62. </el-row>
  63. </br></br>
  64. </el-form>
  65. </div>
  66. </div>
  67. <!-- ------- 底部按钮 ------- -->
  68. <div class="s-foot">
  69. <el-button type="primary" @click="ok()">确定</el-button>
  70. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  71. </div>
  72. </div>
  73. <script>
  74. var app = new Vue({
  75. components: {
  76. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  77. },
  78. el: '.vue-box',
  79. data: {
  80. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  81. m: null, // 实体对象
  82. },
  83. methods: {
  84. // 创建一个 默认Model
  85. createModel: function() {
  86. return {
  87. title: '', // 标题
  88. cover: '', // 封面图片
  89. url: '', // 链接地址
  90. content: '', // 内容
  91. source: '', // 来源
  92. }
  93. },
  94. // 提交数据
  95. ok: function(){
  96. // 表单校验
  97. let m = this.m;
  98. sa.checkNull(m.title, '请输入 [标题]');
  99. sa.checkNull(m.content, '请输入 [内容]');
  100. // 开始增加或修改
  101. this.m.createTime = undefined; // 不提交属性:创建时间
  102. this.m.updateTime = undefined; // 不提交属性:更新时间
  103. this.m.status=1;
  104. if(this.id <= 0) { // 添加
  105. sa.ajax('/level-one-server/TbPortNews/add', m, function(res){
  106. sa.alert('增加成功', this.clean);
  107. }.bind(this));
  108. } else { // 修改
  109. sa.ajax('/level-one-server/TbPortNews/update', m, function(res){
  110. sa.alert('修改成功', this.clean);
  111. }.bind(this));
  112. }
  113. },
  114. // 添加/修改 完成后的动作
  115. clean: function() {
  116. if(this.id == 0) {
  117. this.m = this.createModel();
  118. } else {
  119. parent.app.f5(); // 刷新父页面列表
  120. sa.closeCurrIframe(); // 关闭本页
  121. }
  122. }
  123. },
  124. mounted: function(){
  125. // 初始化数据
  126. if(this.id <= 0) {
  127. this.m = this.createModel();
  128. } else {
  129. sa.ajax('/level-one-server/TbPortNews/getById?id=' + this.id, function(res) {
  130. this.m = res.data;
  131. if(res.data == null) {
  132. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  133. }
  134. }.bind(this))
  135. }
  136. }
  137. })
  138. </script>
  139. </body>
  140. </html>