tb-item-type-select.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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.name"></sa-item>
  25. <el-button type="primary" icon="el-icon-search" @click="p.pageNo = 1; f5()">查询</el-button>
  26. <sa-item type="fast-btn" show="reset" style="display: inline;"></sa-item>
  27. <el-button type="primary" icon="el-icon-plus" @click="selectBatch()">确定
  28. </el-button>
  29. <br/>
  30. </el-form>
  31. <!-- ------------- 数据列表 ------------- -->
  32. <el-table class="data-table" ref="data-table" :data="dataList">
  33. <sa-td type="selection"></sa-td>
  34. <sa-td name="收费项名称" prop="name"></sa-td>
  35. <!-- <sa-td name="付款步骤" prop="payStep" type="enum" :jv="{1: '下单后', 2: '确认后'}"></sa-td> -->
  36. <sa-td name="排序" prop="sort"></sa-td>
  37. <el-table-column label="操作" fixed="right">
  38. <template slot-scope="s">
  39. <el-button class="c-btn" type="primary" icon="el-icon-edit" @click="selectOne(s.row)">选择
  40. </el-button>
  41. </template>
  42. </el-table-column>
  43. </el-table>
  44. <el-pagination :page-size="p.pageSize" :current-page="p.pageNo"
  45. layout="prev, pager, next" :total="dataCount"
  46. @current-change="pageChange">
  47. </el-pagination>
  48. </div>
  49. </div>
  50. <script>
  51. var app = new Vue({
  52. components: {
  53. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  54. "sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'),
  55. },
  56. el: '.vue-box',
  57. data: {
  58. ids: sa.p('idStr', ''),
  59. goodsId: sa.p('goodsId', ''),
  60. p: { // 查询参数
  61. id: '', // 主键
  62. name: '', // 项目名称
  63. pageNo: 1, // 当前页
  64. pageSize: 15, // 页大小
  65. sortType: 0 // 排序方式
  66. },
  67. dataCount: 0,
  68. dataList: [], // 数据集合
  69. selection: []
  70. },
  71. methods: {
  72. // 新增
  73. selectBatch: function (data) {
  74. var selection = this.$refs['data-table'].selection;
  75. if (selection.length == 0) {
  76. return sa.msg('至少选择一条数据')
  77. }
  78. selection = selection.concat(this.selection);
  79. let obj = {
  80. goodsId: this.goodsId,
  81. typeIds: selection.map(obj => obj.id).join(',')
  82. }
  83. sa.ajax('/RelationGoodsType/saveBatch', obj, function (res) {
  84. sa.alert('添加成功');
  85. setTimeout(() => {
  86. sa.closeCurrIframe(); // 关闭本页
  87. parent.app.f5(); // 刷新父页面列表
  88. }, 1000)
  89. }.bind(this));
  90. },
  91. // 删除
  92. selectOne: function (data) {
  93. let obj = {
  94. goodsId: this.goodsId,
  95. typeId: data.id
  96. }
  97. sa.ajax('/RelationGoodsType/saveSingle', obj, function (res) {
  98. sa.alert('添加成功');
  99. this.ids = this.ids + ',' + data.id;
  100. this.f5();
  101. }.bind(this));
  102. },
  103. pageChange(p) {
  104. this.selection = this.selection.concat(this.$refs['data-table'].selection);
  105. this.p.pageNo = p;
  106. this.f5();
  107. },
  108. // 刷新
  109. f5: function () {
  110. sa.ajax('/TbItemType/getList', sa.removeNull(this.p), function (res) {
  111. let list = res.data;
  112. this.dataList = list; // 数据
  113. this.dataCount = res.dataCount; // 数据总数
  114. let ids = this.ids.split(',');
  115. ids = ids.concat(this.selection);
  116. list.forEach(row => {
  117. if (ids.indexOf(row.id) !== -1) {
  118. this.$nextTick(() => {
  119. this.$refs['data-table'].toggleRowSelection(row,
  120. true)
  121. })
  122. }
  123. })
  124. sa.f5TableHeight(); // 刷新表格高度
  125. }.bind(this));
  126. },
  127. },
  128. created: function () {
  129. this.f5();
  130. sa.onInputEnter();
  131. }
  132. })
  133. </script>
  134. </body>
  135. </html>