tb-shop-list.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. <div class="c-item">
  25. <label class="c-label">互市区:</label>
  26. <el-select v-model="p.tradeAreaId" placeholder="请选择" filterable size="mini">
  27. <el-option label="请选择" :value="0" disabled></el-option>
  28. <el-option v-for="(item,index) in tradeAreaList" :key="index" :label="item.name"
  29. :value="item.id"> </el-option>
  30. </el-select>
  31. </div>
  32. <div class="c-item">
  33. <label class="c-label">名称:</label>
  34. <el-input size="mini" v-model="p.name"></el-input>
  35. </div>
  36. <div class="c-item" style="min-width: 0px;">
  37. <el-button size="mini" type="primary" icon="el-icon-search" @click="p.pageNo = 1; f5()">查询
  38. </el-button>
  39. <el-button size="mini" type="primary" icon="el-icon-plus" @click="add()">新增</el-button>
  40. <el-button size="mini" type="danger" icon="el-icon-delete" @click="deleteByIds()">删除</el-button>
  41. <el-button size="mini" type="info" icon="el-icon-refresh" @click="sa.f5()">重置</el-button>
  42. </div>
  43. <br />
  44. </el-form>
  45. <!-- ------------- 快捷按钮 ------------- -->
  46. <div class="fast-btn">
  47. </div>
  48. <!-- ------------- 数据列表 ------------- -->
  49. <el-table class="data-table" ref="data-table" :data="dataList" size="small">
  50. <el-table-column align="center" label="序号" type="index" width="45px"></el-table-column>
  51. <el-table-column align="center" label="名称" prop="name"></el-table-column>
  52. <el-table-column align="center" label="编号" prop="no"></el-table-column>
  53. <el-table-column align="center" prop="tradeAreaName" label="所属互市区"> </el-table-column>
  54. <el-table-column align="center" prop="enterpriseName" label="入驻商家"> </el-table-column>
  55. <!-- <el-table-column align="center" label="是否可用">
  56. <template slot-scope="s">
  57. <el-switch v-model="s.row.status" :active-value="1" :inactive-value="0"
  58. @change="updateStatus(s.row)" inactive-color="#ff4949" style="vertical-align: top;">
  59. </el-switch>
  60. <span style="color: #999;" v-if="s.row.status == 0">否</span>
  61. <span style="color: #999;" v-if="s.row.status == 1">是</span>
  62. </template>
  63. </el-table-column> -->
  64. <el-table-column align="center" label="操作" fixed="right" width="240px">
  65. <template slot-scope="s">
  66. <el-button class="c-btn" type="success" icon="el-icon-view" @click="get(s.row)">查看
  67. </el-button>
  68. <el-button class="c-btn" type="primary" icon="el-icon-edit" @click="update(s.row)">修改
  69. </el-button>
  70. <el-button class="c-btn" type="danger" icon="el-icon-delete" @click="del(s.row)">删除
  71. </el-button>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. <!-- ------------- 分页 ------------- -->
  76. <div class="page-box">
  77. <el-pagination background layout="total, prev, pager, next, sizes, jumper"
  78. :current-page.sync="p.pageNo" :page-size.sync="p.pageSize" :total="dataCount"
  79. :page-sizes="[1, 10, 20, 30, 40, 50, 100, 1000]" @current-change="f5()" @size-change="f5()">
  80. </el-pagination>
  81. </div>
  82. </div>
  83. </div>
  84. <script>
  85. var app = new Vue({
  86. el: '.vue-box',
  87. data: {
  88. p: { // 查询参数
  89. id: '', // 主键
  90. name: '', // 名称
  91. no: '', // 编号
  92. tradeAreaId:'',
  93. area: '', // 区域(A区=A区,B区=B区,C区=C区)
  94. status: '', // 是否可用(0=否,1=是)
  95. remark: '', //
  96. pageNo: 1, // 当前页
  97. pageSize: 10, // 页大小
  98. sortType: 0 // 排序方式
  99. },
  100. dataCount: 0,
  101. tradeAreaList:[],
  102. dataList: [], // 数据集合
  103. },
  104. methods: {
  105. getTradeArea() {
  106. sa.ajax('/level-one-server/TbTradeArea/getList', {
  107. pageSize: 100,
  108. pageNo: 1
  109. }, function(resp) {
  110. this.tradeAreaList = resp.data;
  111. }.bind(this));
  112. },
  113. // 刷新
  114. f5: function() {
  115. sa.ajax('/level-one-server/TbShop/getList', sa.removeNull(this.p), function(res) {
  116. this.dataList = res.data; // 数据
  117. this.dataCount = parseInt(res.dataCount); // 数据总数
  118. sa.f5TableHeight(); // 刷新表格高度
  119. }.bind(this));
  120. },
  121. // 查看
  122. get: function(data) {
  123. sa.showIframe('数据详情', 'tb-shop-info.html?id=' + data.id, '750px', '70%');
  124. },
  125. // 查看 - 根据选中的
  126. getBySelect: function(data) {
  127. var selection = this.$refs['data-table'].selection;
  128. if (selection.length == 0) {
  129. return sa.msg('请选择一条数据')
  130. }
  131. this.get(selection[0]);
  132. },
  133. // 修改
  134. update: function(data) {
  135. sa.showIframe('修改数据', 'tb-shop-add.html?id=' + data.id, '700px', '70%');
  136. },
  137. // 新增
  138. add: function(data) {
  139. sa.showIframe('新增数据', 'tb-shop-add.html?id=-1', '700px', '70%');
  140. },
  141. // 删除
  142. del: function(data) {
  143. sa.confirm('是否删除,此操作不可撤销', function() {
  144. sa.ajax('/level-one-server/TbShop/delete?id=' + data.id, function(res) {
  145. sa.arrayDelete(this.dataList, data);
  146. sa.ok('删除成功');
  147. sa.f5TableHeight(); // 刷新表格高度
  148. }.bind(this))
  149. }.bind(this));
  150. },
  151. // 批量删除
  152. deleteByIds: function() {
  153. // 获取选中元素的id列表
  154. let selection = this.$refs['data-table'].selection;
  155. let ids = sa.getArrayField(selection, 'id');
  156. if (selection.length == 0) {
  157. return sa.msg('请至少选择一条数据')
  158. }
  159. // 提交删除
  160. sa.confirm('是否批量删除选中数据?此操作不可撤销', function() {
  161. sa.ajax('/level-one-server/TbShop/deleteByIds', {
  162. ids: ids.join(',')
  163. }, function(res) {
  164. sa.arrayDelete(this.dataList, selection);
  165. sa.ok('删除成功');
  166. sa.f5TableHeight(); // 刷新表格高度
  167. }.bind(this))
  168. }.bind(this));
  169. },
  170. // 改 - 是否可用(0=否,1=是)
  171. updateStatus: function(data) {
  172. // 声明变量记录是否成功
  173. var isOk = false;
  174. var oldValue = data.status;
  175. var ajax = sa.ajax('/level-one-server/TbShop/updateStatus', {
  176. id: data.id,
  177. value: data.status
  178. }, function(res) {
  179. isOk = true;
  180. sa.msg('修改成功');
  181. }.bind(this));
  182. // 如果未能修改成功, 则回滚
  183. $.when(ajax).done(function() {
  184. if (isOk == false) {
  185. data.status = oldValue;
  186. }
  187. })
  188. },
  189. },
  190. created: function() {
  191. this.f5();
  192. this.getTradeArea();
  193. sa.onInputEnter();
  194. }
  195. })
  196. </script>
  197. </body>
  198. </html>