tb-item-type-select.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. <!-- ------------- 分页 ------------- -->
  45. <sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()">
  46. </sa-item>
  47. </div>
  48. </div>
  49. <script>
  50. var app = new Vue({
  51. components: {
  52. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  53. "sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'),
  54. },
  55. el: '.vue-box',
  56. data: {
  57. ids:sa.p('idStr',''),
  58. goodsId:sa.p('goodsId',''),
  59. p: { // 查询参数
  60. id: '', // 主键
  61. name: '', // 项目名称
  62. business: 0,
  63. pageNo: 1, // 当前页
  64. pageSize: 20, // 页大小
  65. sortType: 0 // 排序方式
  66. },
  67. dataCount: 0,
  68. dataList: [], // 数据集合
  69. },
  70. methods: {
  71. // 新增
  72. selectBatch: function(data) {
  73. var selection = this.$refs['data-table'].selection;
  74. if (selection.length == 0) {
  75. return sa.msg('至少选择一条数据')
  76. }
  77. let obj={
  78. goodsId:this.goodsId,
  79. typeIds: selection.map(obj => obj.id).join(',')
  80. }
  81. sa.ajax('/RelationGoodsType/saveBatch', obj, function(res) {
  82. sa.alert('添加成功');
  83. setTimeout(() => {
  84. sa.closeCurrIframe(); // 关闭本页
  85. parent.app.f5(); // 刷新父页面列表
  86. }, 1000)
  87. }.bind(this));
  88. },
  89. // 删除
  90. selectOne: function(data) {
  91. let obj={
  92. goodsId:this.goodsId,
  93. typeId: data.id
  94. }
  95. sa.ajax('/RelationGoodsType/saveSingle', obj, function(res) {
  96. sa.alert('添加成功');
  97. this.ids=this.ids+','+data.id;
  98. this.f5();
  99. }.bind(this));
  100. },
  101. // 刷新
  102. f5: function() {
  103. sa.ajax('/TbItemType/getList', sa.removeNull(this.p), function(res) {
  104. let list = res.data;
  105. this.dataList = list; // 数据
  106. this.dataCount = res.dataCount; // 数据总数
  107. let ids = this.ids.split(',');
  108. list.forEach(row => {
  109. console.log(ids.indexOf(row.id) !== -1)
  110. if (ids.indexOf(row.id) !== -1) {
  111. this.$nextTick(() => {
  112. this.$refs['data-table'].toggleRowSelection(row,
  113. true)
  114. })
  115. }
  116. })
  117. sa.f5TableHeight(); // 刷新表格高度
  118. }.bind(this));
  119. },
  120. },
  121. created: function() {
  122. this.f5();
  123. sa.onInputEnter();
  124. }
  125. })
  126. </script>
  127. </body>
  128. </html>