tb-item.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. <el-form ref="form" :model='p' @submit.native.prevent>
  23. <el-button type="primary" icon="el-icon-search" @click="p.pageNo = 1; f5()">重置</el-button>
  24. <el-button type="primary" icon="el-icon-plus" @click="add()">选择
  25. </el-button>
  26. <br />
  27. </el-form>
  28. <!-- ------------- 数据列表 ------------- -->
  29. <el-table class="data-table" ref="data-table" :data="dataList" style="margin-top: 10px;">
  30. <el-table-column type="index" width="50">
  31. </el-table-column>
  32. <sa-td name="明细名称" prop="itemName"></sa-td>
  33. <sa-td name="价格" prop="price"></sa-td>
  34. <sa-td name="单位" prop="unit"></sa-td>
  35. <sa-td name="适合规格(米)">
  36. <template slot-scope="s">
  37. <label>{{s.row.minLength}}—{{s.row.carLength}}</label>
  38. </template>
  39. </sa-td>
  40. <sa-td name="适合载重(吨)">
  41. <template slot-scope="s">
  42. <label>{{s.row.minWeight}}—{{s.row.maxWeight}}</label>
  43. </template>
  44. </sa-td>
  45. <sa-td name="是否必须" prop="need" type="switch" :jv="{1: '是[#005500]', 0: '否[#ff0000]'}"
  46. @change="s => updateStatus(s.row)"></sa-td>
  47. <el-table-column label="操作" fixed="right">
  48. <template slot-scope="s">
  49. <el-button class="c-btn" type="danger"
  50. @click="del(s.row)">移除
  51. </el-button>
  52. </template>
  53. </el-table-column>
  54. </el-table>
  55. <!-- ------------- 分页 ------------- -->
  56. <sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()">
  57. </sa-item>
  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. p: { // 查询参数
  69. id: '', // 主键
  70. typeId:sa.p('id',''),
  71. pageNo: 1, // 当前页
  72. pageSize: 20, // 页大小
  73. sortType: 0 // 排序方式
  74. },
  75. dataCount: 0,
  76. dataList: [], // 数据集合
  77. },
  78. methods: {
  79. updateStatus: function(data) {
  80. // 声明变量记录是否成功
  81. var isOk = false;
  82. var oldValue = data.need;
  83. var ajax = sa.ajax('/RelationTypeItem/updateStatus', {
  84. itemId: data.id,
  85. typeId:data.typeId,
  86. need: data.need
  87. }, function(res) {
  88. isOk = true;
  89. sa.msg('修改成功');
  90. }.bind(this));
  91. // 如果未能修改成功, 则回滚
  92. $.when(ajax).done(function() {
  93. if (isOk == false) {
  94. data.need = oldValue;
  95. }
  96. })
  97. },
  98. // 新增
  99. add: function(data) {
  100. let ids=this.dataList.map(obj=>obj.id).join(',');
  101. sa.showIframe('选择明细', 'tb-item-select.html?typeId='+this.p.typeId+'&ids='+ids, '900px', '90%');
  102. },
  103. // 删除
  104. del: function(data) {
  105. sa.confirm('是否移除出该收费项?', function() {
  106. sa.ajax('/RelationTypeItem/delete?id=' + data.id, function(res) {
  107. sa.arrayDelete(this.dataList, data);
  108. sa.ok('删除成功');
  109. sa.f5TableHeight(); // 刷新表格高度
  110. }.bind(this))
  111. }.bind(this));
  112. },
  113. // 刷新
  114. f5: function() {
  115. sa.ajax('/TbItem/getTypeItemList', sa.removeNull(this.p), function(res) {
  116. let list = res.data;
  117. this.dataList = list; // 数据
  118. this.dataCount = res.dataCount; // 数据总数
  119. sa.f5TableHeight(); // 刷新表格高度
  120. }.bind(this));
  121. },
  122. },
  123. created: function() {
  124. this.f5();
  125. sa.onInputEnter();
  126. }
  127. })
  128. </script>
  129. </body>
  130. </html>