tb-discount-list.html 7.6 KB

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