tb-item-select.html 4.5 KB

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