tb-discount-list.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>折扣管理-列表</title>
  5. <meta 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. </head>
  18. <body>
  19. <div class="vue-box" style="display: none;" :style="'display: block;'">
  20. <div class="c-panel">
  21. <!-- ------------- 检索参数 ------------- -->
  22. <div class="c-title">检索参数</div>
  23. <el-form ref="form" :model='p' @submit.native.prevent>
  24. <sa-item type="text" name="标题" v-model="p.title"></sa-item>
  25. <el-button type="primary" icon="el-icon-search" @click="p.pageNo = 1; f5()">查询</el-button>
  26. </el-form>
  27. <!-- ------------- 快捷按钮 ------------- -->
  28. <div class="fast-btn">
  29. <el-button v-if="sa.isAuth('tb-discount-add')" size="mini" type="primary" @click="add()">
  30. 新增</el-button>
  31. <el-button size="mini" type="success" @click="getBySelect()">查看</el-button>
  32. <el-button size="mini" type="info" @click="sa.f5()">重置</el-button>
  33. </div>
  34. <!-- ------------- 数据列表 ------------- -->
  35. <el-table class="data-table" ref="data-table" :data="dataList" style="margin-top: 10px;">
  36. <sa-td type="selection"></sa-td>
  37. <sa-td name="标题" prop="title"></sa-td>
  38. <sa-td width="130" name="类型" prop="type" type="enum" :jv="{1: '折扣[#005500]', 2: '满减[#005500]'}">
  39. </sa-td>
  40. <sa-td name="折扣" prop="discount"></sa-td>
  41. <sa-td name="充值金额" prop="money"></sa-td>
  42. <sa-td width=100 name="状态" prop="status" type="switch" :jv="{0: '禁用[#ff0000]', 1: '启用[#005500]'}"
  43. @change="s => updateStatus(s.row)"></sa-td>
  44. <sa-td name="创建时间" prop="createTime"></sa-td>
  45. <el-table-column label="操作" fixed="right" width="240px">
  46. <template slot-scope="s">
  47. <el-button class="c-btn" type="success" icon="el-icon-view" @click="get(s.row)">查看
  48. </el-button>
  49. <el-button v-if="sa.isAuth('tb-discount-ediit')" class="c-btn" type="primary" icon="el-icon-edit" @click="update(s.row)">修改
  50. </el-button>
  51. <el-button v-if="sa.isAuth('tb-discount-del')" class="c-btn" type="danger" icon="el-icon-delete" @click="del(s.row)">删除
  52. </el-button>
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. <!-- ------------- 分页 ------------- -->
  57. <sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()">
  58. </sa-item>
  59. </div>
  60. </div>
  61. <script>
  62. var app = new Vue({
  63. components: {
  64. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  65. "sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'),
  66. },
  67. el: '.vue-box',
  68. data: {
  69. p: { // 查询参数
  70. id: '', // 主键
  71. title: '', // 标题
  72. type: '', // 类型[j]
  73. discount: '', // 折扣
  74. money: '', // 充值金额
  75. status: '', // 状态[j]
  76. createTime: '', // 创建时间
  77. pageNo: 1, // 当前页
  78. pageSize: 10, // 页大小
  79. sortType: 0 // 排序方式
  80. },
  81. dataCount: 0,
  82. dataList: [], // 数据集合
  83. },
  84. methods: {
  85. // 改 - 状态(0=否,1=是)
  86. updateStatus: function(data) {
  87. if(!sa.isAuth('tb-discount-change')){
  88. sa.error('无权限修改')
  89. return;
  90. }
  91. // 声明变量记录是否成功
  92. var isOk = false;
  93. var oldValue = data.status;
  94. var ajax = sa.ajax('/TbDiscount/updateStatus', {
  95. id: data.id,
  96. value: data.status
  97. }, function(res) {
  98. isOk = true;
  99. sa.msg('修改成功');
  100. }.bind(this));
  101. // 如果未能修改成功, 则回滚
  102. $.when(ajax).done(function() {
  103. if (isOk == false) {
  104. data.status = oldValue;
  105. }
  106. })
  107. },
  108. // 刷新
  109. f5: function() {
  110. sa.ajax('/TbDiscount/getList', sa.removeNull(this.p), function(res) {
  111. this.dataList = res.data; // 数据
  112. this.dataCount = res.dataCount; // 数据总数
  113. sa.f5TableHeight(); // 刷新表格高度
  114. }.bind(this));
  115. },
  116. // 查看
  117. get: function(data) {
  118. sa.showIframe('数据详情', 'tb-discount-info.html?id=' + data.id, '600px', '60%');
  119. },
  120. // 查看 - 根据选中的
  121. getBySelect: function(data) {
  122. var selection = this.$refs['data-table'].selection;
  123. if (selection.length == 0) {
  124. return sa.msg('请选择一条数据')
  125. }
  126. this.get(selection[0]);
  127. },
  128. // 修改
  129. update: function(data) {
  130. sa.showIframe('修改数据', 'tb-discount-add.html?id=' + data.id, '600px', '60%');
  131. },
  132. // 新增
  133. add: function(data) {
  134. sa.showIframe('新增数据', 'tb-discount-add.html?id=-1', '600px', '60%');
  135. },
  136. // 删除
  137. del: function(data) {
  138. sa.confirm('是否删除,此操作不可撤销', function() {
  139. sa.ajax('/TbDiscount/delete?id=' + data.id, function(res) {
  140. sa.arrayDelete(this.dataList, data);
  141. sa.ok('删除成功');
  142. sa.f5TableHeight(); // 刷新表格高度
  143. }.bind(this))
  144. }.bind(this));
  145. },
  146. // 批量删除
  147. deleteByIds: function() {
  148. // 获取选中元素的id列表
  149. let selection = this.$refs['data-table'].selection;
  150. let ids = sa.getArrayField(selection, 'id');
  151. if (selection.length == 0) {
  152. return sa.msg('请至少选择一条数据')
  153. }
  154. // 提交删除
  155. sa.confirm('是否批量删除选中数据?此操作不可撤销', function() {
  156. sa.ajax('/TbDiscount/deleteByIds', {
  157. ids: ids.join(',')
  158. }, function(res) {
  159. sa.arrayDelete(this.dataList, selection);
  160. sa.ok('删除成功');
  161. sa.f5TableHeight(); // 刷新表格高度
  162. }.bind(this))
  163. }.bind(this));
  164. },
  165. },
  166. created: function() {
  167. this.f5();
  168. sa.onInputEnter();
  169. }
  170. })
  171. </script>
  172. </body>
  173. </html>