tb-item.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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" width="200"></sa-td>
  33. <sa-td name="价格" prop="price"></sa-td>
  34. <sa-td name="单位" prop="unit"></sa-td>
  35. <sa-td name="税率" prop="taxRate"></sa-td>
  36. <sa-td name="适合规格(米)" width="120">
  37. <template slot-scope="s">
  38. <label>{{s.row.minLength}}—{{s.row.carLength}}</label>
  39. </template>
  40. </sa-td>
  41. <sa-td name="适合载重(kg)" width="120">
  42. <template slot-scope="s">
  43. <label>{{s.row.minWeight}}—{{s.row.maxWeight}}</label>
  44. </template>
  45. </sa-td>
  46. <el-table-column label="操作" fixed="right">
  47. <template slot-scope="s">
  48. <el-button class="c-btn" type="danger" @click="del(s.row)">移除
  49. </el-button>
  50. </template>
  51. </el-table-column>
  52. </el-table>
  53. <!-- ------------- 分页 ------------- -->
  54. <sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()">
  55. </sa-item>
  56. </div>
  57. </div>
  58. <script>
  59. var app = new Vue({
  60. components: {
  61. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  62. "sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'),
  63. },
  64. el: '.vue-box',
  65. data: {
  66. p: { // 查询参数
  67. id: '', // 主键
  68. typeId: sa.p('id', ''),
  69. pageNo: 1, // 当前页
  70. pageSize: 20, // 页大小
  71. sortType: 0 // 排序方式
  72. },
  73. dataCount: 0,
  74. dataList: [], // 数据集合
  75. },
  76. methods: {
  77. updateRemarkNeed: function (data) {
  78. // 声明变量记录是否成功
  79. var isOk = false;
  80. var oldValue = data.need;
  81. var ajax = sa.ajax('/RelationTypeItem/updateRemarkNeed', {
  82. itemId: data.id,
  83. typeId: data.typeId,
  84. needRemark: data.needRemark
  85. }, function (res) {
  86. isOk = true;
  87. sa.msg('修改成功');
  88. }.bind(this));
  89. // 如果未能修改成功, 则回滚
  90. $.when(ajax).done(function () {
  91. if (isOk == false) {
  92. data.needRemark = oldValue;
  93. }
  94. })
  95. },
  96. updateNum: function (data) {
  97. // 声明变量记录是否成功
  98. var isOk = false;
  99. var oldValue = data.inc;
  100. var ajax = sa.ajax('/RelationTypeItem/updateNum', {
  101. itemId: data.id,
  102. typeId: data.typeId,
  103. inc: data.inc
  104. }, function (res) {
  105. isOk = true;
  106. sa.msg('修改成功');
  107. }.bind(this));
  108. // 如果未能修改成功, 则回滚
  109. $.when(ajax).done(function () {
  110. if (isOk == false) {
  111. data.inc = oldValue;
  112. }
  113. })
  114. },
  115. updateRemarkMust: function (data) {
  116. // 声明变量记录是否成功
  117. var isOk = false;
  118. var oldValue = data.need;
  119. var ajax = sa.ajax('/RelationTypeItem/updateRemarkMust', {
  120. itemId: data.id,
  121. typeId: data.typeId,
  122. mustRemark: data.mustRemark
  123. }, function (res) {
  124. isOk = true;
  125. sa.msg('修改成功');
  126. }.bind(this));
  127. // 如果未能修改成功, 则回滚
  128. $.when(ajax).done(function () {
  129. if (isOk == false) {
  130. data.mustMark = oldValue;
  131. }
  132. })
  133. },
  134. updateStatus: function (data) {
  135. // 声明变量记录是否成功
  136. var isOk = false;
  137. var oldValue = data.need;
  138. var ajax = sa.ajax('/RelationTypeItem/updateStatus', {
  139. itemId: data.id,
  140. typeId: data.typeId,
  141. need: data.need
  142. }, function (res) {
  143. isOk = true;
  144. sa.msg('修改成功');
  145. }.bind(this));
  146. // 如果未能修改成功, 则回滚
  147. $.when(ajax).done(function () {
  148. if (isOk == false) {
  149. data.need = oldValue;
  150. }
  151. })
  152. },
  153. // 新增
  154. add: function (data) {
  155. let ids = this.dataList.map(obj => obj.id).join(',');
  156. sa.showIframe('选择明细', 'tb-item-select.html?typeId=' + this.p.typeId + '&ids=' + ids, '900px',
  157. '90%');
  158. },
  159. // 删除
  160. del: function (data) {
  161. sa.confirm('是否移除出该收费项?', function () {
  162. sa.ajax('/RelationTypeItem/delete?id=' + data.id + '&typeId=' + data.typeId, function (res) {
  163. sa.arrayDelete(this.dataList, data);
  164. sa.ok('删除成功');
  165. sa.f5TableHeight(); // 刷新表格高度
  166. }.bind(this))
  167. }.bind(this));
  168. },
  169. // 刷新
  170. f5: function () {
  171. sa.ajax('/TbItem/getTypeItemList', sa.removeNull(this.p), function (res) {
  172. let list = res.data;
  173. this.dataList = list; // 数据
  174. this.dataCount = res.dataCount; // 数据总数
  175. sa.f5TableHeight(); // 刷新表格高度
  176. }.bind(this));
  177. },
  178. },
  179. created: function () {
  180. this.f5();
  181. sa.onInputEnter();
  182. }
  183. })
  184. </script>
  185. </body>
  186. </html>