chargeStandard.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <!-- 收费标准 -->
  3. <view class="charge">
  4. <view class="charge-rules-container" v-for="(item, index) in chargeRulesInfo" :key="index">
  5. <view class="charge-rules-list">
  6. <view class="charge-rule-list-header">
  7. <view class="charge-type">
  8. <text v-if="item.feePeriod == 1">节假日规则</text>
  9. <text v-else>非节假日规则</text>
  10. </view>
  11. <view class="charge-time">
  12. <view
  13. >免费时长<text>{{ item.freeTime || 0 }}分钟内</text></view
  14. >
  15. <view v-if="item.topAmt"
  16. >封顶金额<text>{{ item.topAmt || 0 }}元</text></view
  17. >
  18. <view v-else>无封顶金额</view>
  19. </view>
  20. </view>
  21. <view class="charge-rules" v-for="(type, tIndex) in item.list" :key="tIndex">
  22. <view v-if="type.list[0].amt || type.list[1].amt" class="charge-rules-box">
  23. <view v-if="type.vehicleType == 0">小车</view>
  24. <view v-if="type.vehicleType == 1">大车</view>
  25. <view v-if="type.vehicleType == 2">超大型车</view>
  26. <view v-if="type.vehicleType == 3">摩托车</view>
  27. <view v-if="type.vehicleType == 4">非机动车</view>
  28. <view v-if="type.vehicleType == 5">其他</view>
  29. <view class="charge-rules-right">
  30. <view v-for="(time, tIndex) in type.list" :key="tIndex">
  31. <text>{{ time.beginTime.substring(0, 5) }}-{{ time.beginTime > time.endTime ? '次日' : '' }}{{ time.endTime.substring(0, 5) }}</text>
  32. <text>{{ time.amt }}元/小时</text>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="charge-instructions">
  40. <u-parse :html="chargeContent"></u-parse>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. export default {
  46. data() {
  47. return {
  48. roadNo: '',
  49. parkNo: '',
  50. info: {
  51. freeTime: '',
  52. topAmt: ''
  53. },
  54. chargeRulesInfo: [],
  55. // 收费标准说明
  56. chargeContent: ''
  57. };
  58. },
  59. onLoad(page) {
  60. const { roadNo, parkNo } = page;
  61. if (roadNo) {
  62. this.roadNo = roadNo;
  63. this.getSysterms(3);
  64. this.getChargeRulesInfo(roadNo);
  65. } else if (parkNo) {
  66. this.parkNo = parkNo;
  67. this.getSysterms(3);
  68. this.getParkingChargeRulesInfo(parkNo);
  69. } else {
  70. uni.showToast({
  71. title: '参数丢失,返回上一个页面',
  72. duration: 2000,
  73. icon: 'none',
  74. mask: true
  75. });
  76. }
  77. },
  78. onShow() {},
  79. methods: {
  80. /**
  81. * 获取收费标准
  82. * {roadNo} 路段
  83. * */
  84. getChargeRulesInfo(roadNo) {
  85. this.$u.api.roadChargeRule({ roadNo }).then((res) => {
  86. if (res.code === 200) {
  87. // 数据整合后
  88. let chargeRulesArr = [];
  89. for (let i = 0; i < res.data.length; i++) {
  90. let item = res.data[i];
  91. this.info.freeTime = res.data[0].freeTime;
  92. this.info.topAmt = res.data[0].topAmt;
  93. const obj = {
  94. feeName: item.feeName,
  95. feeNo: item.feeNo,
  96. feePeriod: item.feePeriod,
  97. feeStep: item.feeStep,
  98. feeType: item.feeType,
  99. freeTime: item.freeTime,
  100. topAmt: item.topAmt,
  101. id: item.id,
  102. list: [],
  103. repeatList: [] // 用来检验已存在
  104. };
  105. for (let j = 0; j < item.vehicleRules.length; j++) {
  106. let jItem = item.vehicleRules[j];
  107. const obj1 = {
  108. amt: jItem.amt,
  109. beginTime: jItem.beginTime,
  110. endTime: jItem.endTime,
  111. vehicleFeeNo: jItem.vehicleFeeNo,
  112. vehicleType: jItem.vehicleType,
  113. list: []
  114. };
  115. if (obj.repeatList.indexOf(jItem.vehicleType) === -1) {
  116. obj.repeatList.push(jItem.vehicleType);
  117. obj1.list.push(jItem);
  118. } else {
  119. for (let k = 0; k < item.vehicleRules.length; k++) {
  120. if (obj1.vehicleType === item.vehicleRules[k].vehicleType) {
  121. obj1.list.push(item.vehicleRules[k]);
  122. obj.list.push(obj1);
  123. }
  124. }
  125. }
  126. }
  127. // 存在重复,去除重复操作
  128. let obj2 = {};
  129. obj.list = obj.list.reduce((cur, next) => {
  130. obj[next.vehicleType] ? '' : (obj[next.vehicleType] = true && cur.push(next));
  131. return cur;
  132. }, []);
  133. chargeRulesArr.push(obj);
  134. }
  135. this.chargeRulesInfo = chargeRulesArr;
  136. } else {
  137. uni.showToast({
  138. title: `${res.msg}`,
  139. duration: 3000,
  140. icon: 'none',
  141. mask: true
  142. });
  143. }
  144. });
  145. },
  146. /**
  147. * 获取收费标准
  148. * {roadNo} 路段
  149. * */
  150. getParkingChargeRulesInfo(parkNo) {
  151. this.$u.api.parkingLotChargeRule({ parkNo }).then((res) => {
  152. if (res.code === 200) {
  153. // 数据整合后
  154. let chargeRulesArr = [];
  155. for (let i = 0; i < res.data.length; i++) {
  156. let item = res.data[i];
  157. this.info.freeTime = res.data[0].freeTime;
  158. this.info.topAmt = res.data[0].topAmt;
  159. const obj = {
  160. feeName: item.feeName,
  161. feeNo: item.feeNo,
  162. feePeriod: item.feePeriod,
  163. feeStep: item.feeStep,
  164. feeType: item.feeType,
  165. freeTime: item.freeTime,
  166. topAmt: item.topAmt,
  167. id: item.id,
  168. list: [],
  169. repeatList: [] // 用来检验已存在
  170. };
  171. for (let j = 0; j < item.vehicleRules.length; j++) {
  172. let jItem = item.vehicleRules[j];
  173. const obj1 = {
  174. amt: jItem.amt,
  175. beginTime: jItem.beginTime,
  176. endTime: jItem.endTime,
  177. vehicleFeeNo: jItem.vehicleFeeNo,
  178. vehicleType: jItem.vehicleType,
  179. list: []
  180. };
  181. if (obj.repeatList.indexOf(jItem.vehicleType) === -1) {
  182. obj.repeatList.push(jItem.vehicleType);
  183. obj1.list.push(jItem);
  184. } else {
  185. for (let k = 0; k < item.vehicleRules.length; k++) {
  186. if (obj1.vehicleType === item.vehicleRules[k].vehicleType) {
  187. obj1.list.push(item.vehicleRules[k]);
  188. obj.list.push(obj1);
  189. }
  190. }
  191. }
  192. }
  193. // 存在重复,去除重复操作
  194. let obj2 = {};
  195. obj.list = obj.list.reduce((cur, next) => {
  196. obj[next.vehicleType] ? '' : (obj[next.vehicleType] = true && cur.push(next));
  197. return cur;
  198. }, []);
  199. chargeRulesArr.push(obj);
  200. }
  201. this.chargeRulesInfo = chargeRulesArr;
  202. } else {
  203. uni.showToast({
  204. title: `${res.msg}`,
  205. duration: 3000,
  206. icon: 'none',
  207. mask: true
  208. });
  209. }
  210. });
  211. },
  212. /**
  213. * 获取收费标准
  214. * */
  215. getSysterms(termsType) {
  216. this.$u.api
  217. .getSysterms({
  218. termsType: Number(termsType)
  219. })
  220. .then((res) => {
  221. if (res.code === 200) {
  222. this.chargeContent = res.data?.content;
  223. } else {
  224. this.$refs.uToast.show({
  225. title: res.msg,
  226. type: 'error'
  227. });
  228. }
  229. })
  230. .catch((err) => {
  231. this.$refs.uToast.show({
  232. title: '系统错误!',
  233. type: 'error'
  234. });
  235. });
  236. }
  237. }
  238. };
  239. </script>
  240. <style lang="scss" scoped>
  241. @import './chargeStandard.scss';
  242. </style>