tb-item-select.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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.itemName"></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" @click="add()">确定
  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="itemName"></sa-td>
  35. <sa-td name="价格" prop="price"></sa-td>
  36. <sa-td name="单位" prop="unit"></sa-td>
  37. <el-table-column label="操作" fixed="right">
  38. <template slot-scope="s">
  39. <el-button class="c-btn" type="primary" @click="selectFn(s.row)">选择
  40. </el-button>
  41. </template>
  42. </el-table-column>
  43. </el-table>
  44. <!-- ------------- 分页 ------------- -->
  45. <el-pagination :page-size="p.pageSize" :current-page="p.pageNo" layout="prev, pager, next"
  46. :total="dataCount" @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. typeId: sa.p('typeId', ''),
  59. ids: sa.p('ids', ''),
  60. p: { // 查询参数
  61. id: '', // 主键
  62. itemName: '', // 项目名称
  63. pageNo: 1, // 当前页
  64. pageSize: 20, // 页大小
  65. sortType: 0 // 排序方式
  66. },
  67. dataCount: 0,
  68. dataList: [], // 数据集合
  69. selection: []
  70. },
  71. methods: {
  72. // 新增
  73. add: 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. typeId: this.typeId,
  81. itemIds: selection.map(obj => obj.id).join(',')
  82. }
  83. sa.ajax('/RelationTypeItem/setBatch', obj, function (resp) {
  84. sa.alert('添加成功');
  85. setTimeout(() => {
  86. sa.closeCurrIframe(); // 关闭本页
  87. parent.app.f5(); // 刷新父页面列表
  88. }, 1000)
  89. }.bind(this))
  90. },
  91. selectFn(data) {
  92. let obj = {
  93. typeId: this.typeId,
  94. itemId: data.id
  95. }
  96. sa.ajax('/RelationTypeItem/setSingle', obj, function (resp) {
  97. this.ids = this.ids + ',' + data.id;
  98. sa.alert('添加成功');
  99. setTimeout(() => {
  100. this.f5();
  101. }, 1000)
  102. }.bind(this))
  103. },
  104. pageChange(p) {
  105. this.selection = this.selection.concat(this.$refs['data-table'].selection);
  106. this.p.pageNo = p;
  107. this.f5();
  108. },
  109. // 刷新
  110. f5: function () {
  111. sa.ajax('/TbItem/getList', sa.removeNull(this.p), function (res) {
  112. let list = res.data;
  113. this.dataList = list; // 数据
  114. this.dataCount = res.dataCount; // 数据总数
  115. let ids = this.ids.split(',');
  116. ids = ids.concat(this.selection);
  117. list.forEach(row => {
  118. if (ids.indexOf(row.id) !== -1) {
  119. this.$nextTick(() => {
  120. this.$refs['data-table'].toggleRowSelection(row,
  121. true)
  122. })
  123. }
  124. })
  125. sa.f5TableHeight(); // 刷新表格高度
  126. }.bind(this));
  127. },
  128. },
  129. created: function () {
  130. this.f5();
  131. sa.onInputEnter();
  132. }
  133. })
  134. </script>
  135. </body>
  136. </html>