tb-port-news-list.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. qzyReal /
  2. market-admin-ui
  3. tb-port-news-list.html 6.9 KB
  4. 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  5. <!DOCTYPE html>
  6. <html>
  7. <head>
  8. <title>口岸资讯-列表</title>
  9. <meta charset="utf-8">
  10. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  11. <!-- 所有的 css & js 资源 -->
  12. <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
  13. <link rel="stylesheet" href="../../static/sa.css">
  14. <script src="../../static/kj/vue.min.js"></script>
  15. <script src="../../static/kj/element-ui/index.js"></script>
  16. <script src="../../static/kj/httpVueLoader.js"></script>
  17. <script src="../../static/kj/jquery.min.js"></script>
  18. <script src="../../static/kj/layer/layer.js"></script>
  19. <script src="../../static/sa.js"></script>
  20. </head>
  21. <body>
  22. <div class="vue-box" style="display: none;" :style="'display: block;'">
  23. <div class="c-panel">
  24. <!-- ------------- 检索参数 ------------- -->
  25. <!-- <div class="c-title">检索参数</div> -->
  26. <el-form ref="form" :model='p' @submit.native.prevent>
  27. <sa-item type="text" name="标题" v-model="p.title"></sa-item>
  28. <el-button type="primary" icon="el-icon-search" @click="p.pageNo = 1; f5()">查询</el-button>
  29. <el-button type="info" icon="el-icon-refresh" @click="sa.f5()">重置</el-button>
  30. </el-form>
  31. <div class="fast-btn">
  32. <el-button v-if="sa.isAuth('tb-port-news-add')" size="mini" type="primary" @click="add()">新增</el-button>
  33. <el-button size="mini" type="success" @click="getBySelect()">查看</el-button>
  34. </div>
  35. <!-- ------------- 数据列表 ------------- -->
  36. <el-table class="data-table" ref="data-table" :data="dataList" >
  37. <sa-td type="selection"></sa-td>
  38. <sa-td name="标题" prop="title" ></sa-td>
  39. <sa-td name="封面图片" prop="cover" type="img"></sa-td>
  40. <sa-td name="链接地址" prop="url" type="link"></sa-td>
  41. <sa-td name="内容" prop="content" type="richtext"></sa-td>
  42. <sa-td name="来源" prop="source" ></sa-td>
  43. <sa-td name="阅读量" prop="readCount" ></sa-td>
  44. <sa-td name="发布状态" prop="isRelease" type="switch" :jv="{0: '未发布', 1: '发布'}" @change="s => updateIsRelease(s.row)"></sa-td>
  45. <sa-td name="发布时间" prop="releaseTime" ></sa-td>
  46. <sa-td name="状态" prop="status" type="switch" :jv="{0: '禁用', 1: '启用'}" @change="s => updateStatus(s.row)"></sa-td>
  47. <el-table-column label="操作" fixed="right" width="240px">
  48. <template slot-scope="s">
  49. <el-button class="c-btn" type="success" icon="el-icon-view" @click="get(s.row)">查看</el-button>
  50. <el-button v-if="sa.isAuth('tb-port-news-edit')" class="c-btn" type="primary" icon="el-icon-edit" @click="update(s.row)">修改</el-button>
  51. <el-button v-if="sa.isAuth('tb-port-news-del')" class="c-btn" type="danger" icon="el-icon-delete" @click="del(s.row)">删除</el-button>
  52. </template>
  53. </el-table-column>
  54. </el-table>
  55. <!-- ------------- 分页 ------------- -->
  56. <sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()"></sa-item>
  57. </div>
  58. </div>
  59. <script>
  60. var app = new Vue({
  61. components: {
  62. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  63. "sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'),
  64. },
  65. el: '.vue-box',
  66. data: {
  67. p: { // 查询参数
  68. title: '', // 标题
  69. url: '', // 链接地址
  70. content: '', // 内容
  71. source: '', // 来源
  72. readCount: '', // 阅读量
  73. isRelease: '', // 发布状态(0=未发布,1=发布)
  74. releaseTime: '', // 发布时间
  75. status: '', // 状态(0=禁用,1=启用)
  76. pageNo: 1, // 当前页
  77. pageSize: 10, // 页大小
  78. sortType: 0 // 排序方式
  79. },
  80. dataCount: 0,
  81. dataList: [], // 数据集合
  82. },
  83. methods: {
  84. // 刷新
  85. f5: function() {
  86. sa.ajax('/level-one-server/TbPortNews/getList', sa.removeNull(this.p), function(res) {
  87. this.dataList = res.data; // 数据
  88. this.dataCount = res.dataCount; // 数据总数
  89. sa.f5TableHeight(); // 刷新表格高度
  90. }.bind(this));
  91. },
  92. // 查看
  93. get: function(data) {
  94. sa.showIframe('数据详情', 'tb-port-news-info.html?id=' + data.id, '1050px', '90%');
  95. },
  96. // 查看 - 根据选中的
  97. getBySelect: function(data) {
  98. var selection = this.$refs['data-table'].selection;
  99. if(selection.length == 0) {
  100. return sa.msg('请选择一条数据')
  101. }
  102. this.get(selection[0]);
  103. },
  104. // 修改
  105. update: function(data) {
  106. sa.showIframe('修改数据', 'tb-port-news-add.html?id=' + data.id, '1000px', '90%');
  107. },
  108. // 新增
  109. add: function(data) {
  110. sa.showIframe('新增数据', 'tb-port-news-add.html?id=-1', '1000px', '90%');
  111. },
  112. // 删除
  113. del: function(data) {
  114. sa.confirm('是否删除,此操作不可撤销', function() {
  115. sa.ajax('/level-one-server/TbPortNews/delete?id=' + data.id, function(res) {
  116. sa.arrayDelete(this.dataList, data);
  117. sa.ok('删除成功');
  118. sa.f5TableHeight(); // 刷新表格高度
  119. }.bind(this))
  120. }.bind(this));
  121. },
  122. // 批量删除
  123. deleteByIds: function() {
  124. // 获取选中元素的id列表
  125. let selection = this.$refs['data-table'].selection;
  126. let ids = sa.getArrayField(selection, 'id');
  127. if(selection.length == 0) {
  128. return sa.msg('请至少选择一条数据')
  129. }
  130. // 提交删除
  131. sa.confirm('是否批量删除选中数据?此操作不可撤销', function() {
  132. sa.ajax('/level-one-server/TbPortNews/deleteByIds', {ids: ids.join(',')}, function(res) {
  133. sa.arrayDelete(this.dataList, selection);
  134. sa.ok('删除成功');
  135. sa.f5TableHeight(); // 刷新表格高度
  136. }.bind(this))
  137. }.bind(this));
  138. },
  139. // 改 - 发布状态(0=未发布,1=发布)
  140. updateIsRelease: function(data) {
  141. // 声明变量记录是否成功
  142. var isOk = false;
  143. var oldValue = data.isRelease;
  144. var ajax = sa.ajax('/level-one-server/TbPortNews/updateIsRelease', {id: data.id, value: data.isRelease}, function(res) {
  145. isOk = true;
  146. sa.msg('修改成功');
  147. }.bind(this));
  148. // 如果未能修改成功, 则回滚
  149. $.when(ajax).done(function() {
  150. if(isOk == false) {
  151. data.status = oldValue;
  152. }
  153. })
  154. },
  155. // 改 - 状态(0=禁用,1=启用)
  156. updateStatus: function(data) {
  157. // 声明变量记录是否成功
  158. var isOk = false;
  159. var oldValue = data.status;
  160. var ajax = sa.ajax('/level-one-server/TbPortNews/updateStatus', {id: data.id, value: data.status}, function(res) {
  161. isOk = true;
  162. sa.msg('修改成功');
  163. }.bind(this));
  164. // 如果未能修改成功, 则回滚
  165. $.when(ajax).done(function() {
  166. if(isOk == false) {
  167. data.status = oldValue;
  168. }
  169. })
  170. },
  171. },
  172. created: function() {
  173. this.f5();
  174. sa.onInputEnter();
  175. }
  176. })
  177. </script>
  178. </body>
  179. </html>