tb-item-edit.html 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>作业配置项-添加/修改</title>
  5. <meta http-equiv="Content-Type" content="text/html; 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. <style type="text/css">
  18. .c-panel .el-form .c-label {
  19. width: 7em !important;
  20. }
  21. .c-panel .el-form .el-input,
  22. .c-panel .el-form .el-textarea__inner {
  23. width: 250px;
  24. }
  25. .item-num .el-input__inner {
  26. width: 130px;
  27. display: inline;
  28. }
  29. </style>
  30. </head>
  31. <body>
  32. <div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
  33. <!-- ------- 内容部分 ------- -->
  34. <div class="s-body">
  35. <div class="c-panel">
  36. <div class="c-title" v-if="id == 0">数据添加</div>
  37. <div class="c-title" v-else>数据修改</div>
  38. <el-form v-if="m">
  39. <sa-item type="text" name="车型" v-model="m.itemName" placeholder="请输入业务类型" br></sa-item>
  40. <div class="c-item">
  41. <label class="c-label">通知类型:</label>
  42. <el-select v-model="m.businessType">
  43. <el-option v-for="item in businessTypeList" :key="item.id" :value="item.id"
  44. :label="item.name">
  45. </el-option>
  46. </el-select>
  47. </div>
  48. <div class="c-item">
  49. <label class="c-label">统计类型:</label>
  50. <el-select v-model="m.payType">
  51. <el-option v-for="item in payTypeList" :key="item.id" :value="item.id"
  52. :label="item.name">
  53. </el-option>
  54. </el-select>
  55. </div>
  56. <div class="c-item">
  57. <label class="c-label">空车/载重:</label>
  58. <el-select multiple v-model="itemType" placeholder="请选择">
  59. <el-option :label="item.name" :value="item.name" v-for="(item,index) in carTypeList">
  60. </el-option>
  61. </el-select>
  62. </div>
  63. <sa-item type="text" name="计价单位" v-model="m.unit" placeholder="请输入计量单位" br></sa-item>
  64. <div class="c-item">
  65. <label class="c-label">计费金额(元):</label>
  66. <el-input-number class="item-num" v-model="m.price" :step="10" :min="1" :max="9999">
  67. </el-input-number>
  68. </div>
  69. <div class="c-item">
  70. <label class="c-label">税率(%):</label>
  71. <el-input-number class="item-num" v-model="m.taxRate" :step="0.1" :min="0.01" :max="100">
  72. </el-input-number>
  73. </div>
  74. <div>
  75. <label>适用载重(kg):</label>
  76. <div style="display: inline;margin-left: 20px;">
  77. <el-input-number class="item-num" v-model="m.minWeight" :step="1" :min="1"
  78. :max="999999"></el-input-number>
  79. <el-input-number class="item-num" v-model="m.maxWeight" :step="1" :min="0"
  80. :max="9999999"></el-input-number>
  81. </div>
  82. </div>
  83. <div style="margin-top: 20px;">
  84. <label>适用车长(米):</label>
  85. <div style="display: inline;margin-left: 20px;">
  86. <el-input-number class="item-num" v-model="m.minLength" :step="1" :min="0" :max="99">
  87. </el-input-number>
  88. <el-input-number class="item-num" v-model="m.carLength" :step="1" :min="0" :max="99">
  89. </el-input-number>
  90. </div>
  91. </div>
  92. </el-form>
  93. </div>
  94. </div>
  95. <!-- ------- 底部按钮 ------- -->
  96. <div class="s-foot">
  97. <el-button type="primary" @click="ok()">确定</el-button>
  98. <el-button @click="sa.closeCurrIframe()">取消</el-button>
  99. </div>
  100. </div>
  101. <script>
  102. var app = new Vue({
  103. components: {
  104. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
  105. },
  106. el: '.vue-box',
  107. data: {
  108. id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改)
  109. m: {
  110. id: '', // 主键
  111. itemName: '',
  112. price: '400',
  113. payType: '',
  114. taxRate: 6,
  115. businessType: '',
  116. unit: '元/车',
  117. minLength: '4.2',
  118. carLength: '20', //车长
  119. minWeight: '5',
  120. maxWeight: '10', //最大载重
  121. status: '1', //转态
  122. }, // 实体对象
  123. itemTypeList: [],
  124. payTypeList: [],
  125. businessTypeList: [],
  126. carTypeList: [],
  127. itemType: []
  128. },
  129. methods: {
  130. getItemType() {
  131. sa.ajax('/TbItem/getItemType', function (resp) {
  132. this.carTypeList = resp.data;
  133. }.bind(this))
  134. },
  135. getBusinessTypeList() {
  136. sa.ajax('/TbCostomer/getTypeList', function (resp) {
  137. let list = resp.data;
  138. this.businessTypeList = list
  139. }.bind(this))
  140. },
  141. getPayTypeList() {
  142. sa.ajax('/TbFeeStatistics/getFeeType', function (resp) {
  143. let list = resp.data;
  144. this.payTypeList = list;
  145. }.bind(this))
  146. },
  147. // 提交数据
  148. ok: function () {
  149. // 表单校验
  150. let m = this.m;
  151. // sa.checkNull(m.id, '请输入 [主键]');
  152. sa.checkNull(m.itemName, '请输入 [业务类型]');
  153. sa.checkNull(m.price, '请输入 [计费金额]');
  154. sa.checkNull(m.unit, '请输入 [计价单位]');
  155. let minLength = m.minLength;
  156. let maxLength = m.carLength;
  157. let minWeight = m.minWeight;
  158. let maxWeight = m.maxWeight;
  159. sa.checkNull(minLength, '请输入 [最小车长]');
  160. sa.checkNull(maxLength, '请输入 [最大车长]');
  161. sa.checkNull(minWeight, '请输入 [最小载重]');
  162. sa.checkNull(maxWeight, '请输入 [最大载重]');
  163. if (minLength > maxLength) {
  164. sa.error('最小车长不能大于最大车长')
  165. return;
  166. }
  167. if (minWeight > maxWeight) {
  168. sa.error('最小载重不能大于最大载重')
  169. return;
  170. }
  171. let payTypeList = this.payTypeList;
  172. let payType = payTypeList.filter(obj => obj.id == m.payType).pop();
  173. sa.checkNull(payType, '请选择收费分类');
  174. m.payType = payType.id;
  175. m.payTypeName = payType.name;
  176. let businessTypeList = this.businessTypeList;
  177. let businessType = businessTypeList.filter(obj => obj.id == m.businessType).pop();
  178. m.businessType = businessType.id;
  179. m.businessTypeName = businessType.name;
  180. m.itemType = this.itemType.join(',')
  181. // 开始增加或修改
  182. sa.ajax('/TbItem/update', m, function (res) {
  183. sa.alert('修改成功', this.clean);
  184. }.bind(this));
  185. },
  186. // 添加/修改 完成后的动作
  187. clean: function () {
  188. if (this.id == 0) {
  189. } else {
  190. parent.app.f5(); // 刷新父页面列表
  191. sa.closeCurrIframe(); // 关闭本页
  192. }
  193. },
  194. },
  195. mounted: function () {
  196. sa.ajax('/TbItem/getById?id=' + this.id, function (res) {
  197. this.m = res.data;
  198. this.itemType = this.m.itemType ? this.m.itemType.split(',') : []
  199. }.bind(this))
  200. this.getBusinessTypeList();
  201. this.getPayTypeList();
  202. this.getItemType();
  203. }
  204. })
  205. </script>
  206. </body>
  207. </html>