tb-port-news-add.html 6.0 KB

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