tb-item-select.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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" width="300px"></sa-td>
  35. <sa-td name="价格" prop="price"></sa-td>
  36. <sa-td name="单位" prop="unit"></sa-td>
  37. <sa-td name="适合规格(米)">
  38. <template slot-scope="s">
  39. <label>{{s.row.minLength}}—{{s.row.carLength}}</label>
  40. </template>
  41. </sa-td>
  42. <sa-td name="适合载重(吨)">
  43. <template slot-scope="s">
  44. <label>{{s.row.minWeight}}—{{s.row.maxWeight}}</label>
  45. </template>
  46. </sa-td>
  47. <el-table-column label="操作" fixed="right">
  48. <template slot-scope="s">
  49. <el-button class="c-btn" type="primary" @click="selectFn(s.row)">选择
  50. </el-button>
  51. </template>
  52. </el-table-column>
  53. </el-table>
  54. <!-- ------------- 分页 ------------- -->
  55. <el-pagination :page-size="p.pageSize" :current-page="p.pageNo" layout="prev, pager, next"
  56. :total="dataCount" @current-change="pageChange">
  57. </el-pagination>
  58. </div>
  59. </div>
  60. <script>
  61. var app = new Vue({
  62. components: {
  63. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  64. "sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'),
  65. },
  66. el: '.vue-box',
  67. data: {
  68. typeId: sa.p('typeId', ''),
  69. ids: sa.p('ids', ''),
  70. p: { // 查询参数
  71. id: '', // 主键
  72. itemName: '', // 项目名称
  73. pageNo: 1, // 当前页
  74. pageSize: 20, // 页大小
  75. sortType: 0 // 排序方式
  76. },
  77. dataCount: 0,
  78. dataList: [], // 数据集合
  79. selection: []
  80. },
  81. methods: {
  82. // 新增
  83. add: function (data) {
  84. var selection = this.$refs['data-table'].selection;
  85. if (selection.length == 0) {
  86. return sa.msg('至少选择一条数据')
  87. }
  88. selection = selection.concat(this.selection);
  89. let obj = {
  90. typeId: this.typeId,
  91. itemIds: selection.map(obj => obj.id).join(',')
  92. }
  93. sa.ajax('/RelationTypeItem/setBatch', obj, function (resp) {
  94. sa.alert('添加成功');
  95. setTimeout(() => {
  96. sa.closeCurrIframe(); // 关闭本页
  97. parent.app.f5(); // 刷新父页面列表
  98. }, 1000)
  99. }.bind(this))
  100. },
  101. selectFn(data) {
  102. let obj = {
  103. typeId: this.typeId,
  104. itemId: data.id
  105. }
  106. sa.ajax('/RelationTypeItem/setSingle', obj, function (resp) {
  107. this.ids = this.ids + ',' + data.id;
  108. sa.alert('添加成功');
  109. setTimeout(() => {
  110. this.f5();
  111. }, 1000)
  112. }.bind(this))
  113. },
  114. pageChange(p) {
  115. this.selection = this.selection.concat(this.$refs['data-table'].selection);
  116. this.p.pageNo = p;
  117. this.f5();
  118. },
  119. // 刷新
  120. f5: function () {
  121. sa.ajax('/TbItem/getList', sa.removeNull(this.p), function (res) {
  122. let list = res.data;
  123. this.dataList = list; // 数据
  124. this.dataCount = res.dataCount; // 数据总数
  125. let ids = this.ids.split(',');
  126. ids = ids.concat(this.selection);
  127. list.forEach(row => {
  128. if (ids.indexOf(row.id) !== -1) {
  129. this.$nextTick(() => {
  130. this.$refs['data-table'].toggleRowSelection(row,
  131. true)
  132. })
  133. }
  134. })
  135. sa.f5TableHeight(); // 刷新表格高度
  136. }.bind(this));
  137. },
  138. },
  139. created: function () {
  140. this.f5();
  141. sa.onInputEnter();
  142. }
  143. })
  144. </script>
  145. </body>
  146. </html>