apply_for_reimbursement.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <template>
  2. <view class="center">
  3. <view>
  4. <view class='wrap'>
  5. <view class="c-row">
  6. <view class="title">车牌号</view>
  7. <view class="con-list">
  8. {{detailData.carNo}}
  9. </view>
  10. </view>
  11. <view class="c-row">
  12. <view class="title">行程轨迹</view>
  13. <view class="con-list">
  14. <view class="flex align-center">
  15. <view class="item1">
  16. <view class="ssx">{{$helper.getProvinceAbbreviation(detailData.originProvince)}}</view>
  17. <view class="level2-title">
  18. {{$helper.filterUrban(detailData.originCity)}}
  19. {{$helper.filterArea(detailData.originArea)}}
  20. </view>
  21. </view>
  22. <image class="jt-icon item2" src="@/static/images/fuel/jt.png" mode='widthFix'>
  23. </image>
  24. <view class="item3">
  25. <view class="ssx">{{$helper.getProvinceAbbreviation(detailData.destinationProvince)}}
  26. </view>
  27. <view class="level2-title">{{$helper.filterUrban(detailData.destinationCity)}}
  28. {{$helper.filterArea(detailData.destinationArea)}}
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class='wrap1' v-for="(item , index) in fillingDetail.fillingDetailInfoList" :Key="index">
  36. <view class="tit">加油-{{index+1}}</view>
  37. <image src="../../static/img/sign/jian@2x.png" class="eliminate1" @click="delApply(index)">
  38. </image>
  39. <image src="../../static/img/sign/jia@2x.png" class="eliminate2" @click="addApply(index)">
  40. </image>
  41. <view class="c-row">
  42. <view class="title">油耗(升)</view>
  43. <view class="con-list">
  44. <input v-model='item.oilConsumption' placeholder="请输入油耗" @input='calculate(index)'></input>
  45. </view>
  46. </view>
  47. <view class="c-row">
  48. <view class="title">当前油价(元/升)</view>
  49. <view class="con-list">
  50. <input type="digit" v-model='item.currentOilPrice' placeholder="请输入当前油价"
  51. @input='calculate(index)'></input>
  52. </view>
  53. </view>
  54. <view class="c-row">
  55. <view class="title">计算金额(元)</view>
  56. <view class="con-list">
  57. <input type="digit" v-model='item.currentConsumption' placeholder="不可编辑,自动计算"
  58. :disabled="true"></input>
  59. </view>
  60. </view>
  61. <view class="c-row">
  62. <view class="title">加油凭证</view>
  63. </view>
  64. <view class="voucher">
  65. <upload class="upload" ref="upload" :action="action" :max-size="maxSize" :max-count="9"
  66. :size-type="['compressed']" @on-success="getImgUrl($event,index)" @on-error="onError"
  67. @on-remove="onRemove($event,index)" @on-uploaded="isAdd = true" :before-upload="filterFileType"
  68. @on-progress="onProgress"></upload>
  69. </view>
  70. </view>
  71. <view class="footer">
  72. <view class="c-row">
  73. <view class="title">总油耗(L)</view>
  74. <view class="con-list">
  75. <input :disabled="true" v-model='tfc' placeholder="不可编辑,自动计算" type="digit"></input>
  76. </view>
  77. </view>
  78. <view class="c-row">
  79. <view class="title">合计金额(元)</view>
  80. <view class="con-list">
  81. <input :disabled="true" v-model='totalCost' placeholder="不可编辑,自动计算" type="digit"></input>
  82. </view>
  83. </view>
  84. <view @click='submitApply' class="button">提交申请</view>
  85. </view>
  86. </view>
  87. </view>
  88. </template>
  89. <script>
  90. import upload from '@/components/upload.vue';
  91. export default {
  92. components: {
  93. upload,
  94. },
  95. data() {
  96. return {
  97. detailData: {
  98. carNo: '',
  99. destinationProvince: "",
  100. destinationCity: "",
  101. destinationArea: "",
  102. carNo: "",
  103. originProvince: "",
  104. originCity: "",
  105. originArea: "",
  106. },
  107. fillingDetail: {
  108. fillingDetailInfoList: [{
  109. oilConsumption: "",
  110. currentOilPrice: "",
  111. currentConsumption: "",
  112. addressUrl: [],
  113. compId: uni.getStorageSync('pcUserInfo').compId,
  114. commonId: uni.getStorageSync('pcUserInfo').userId,
  115. fillingId: "",
  116. }],
  117. tfc: "",
  118. totalCost: ""
  119. },
  120. action: this.$uploadUrl,
  121. maxSize: 50 * 1024 * 1024, //限制文件大小 50M
  122. btnLoading: false, //防止重复点击
  123. isAdd: true,
  124. tfc: "",
  125. totalCost: ""
  126. }
  127. },
  128. onLoad(options) {
  129. this.id = options.id
  130. this.fillingDetail.fillingDetailInfoList[0].fillingId = this.id
  131. },
  132. onShow() {
  133. var that = this
  134. if (this.id) {
  135. this.seeInfo()
  136. }
  137. },
  138. methods: {
  139. seeInfo() {
  140. this.$api.doRequest('get', '/fuelFillingInfo/getFilling', {
  141. id: this.id
  142. }).then(res => {
  143. if (res.data.code == 200) {
  144. this.detailData = res.data.data
  145. }
  146. })
  147. },
  148. getImgUrl(res, index) {
  149. this.fillingDetail.fillingDetailInfoList[index].addressUrl.push(res)
  150. // if(this.fillingDetail.fillingDetailInfoList[index].addressUrl){
  151. // this.fillingDetail.fillingDetailInfoList[index].addressUrl = this.fillingDetail.fillingDetailInfoList[index].addressUrl +","+res
  152. // }else{
  153. // this.fillingDetail.fillingDetailInfoList[index].addressUrl = res
  154. // }
  155. // console.log(res)
  156. // console.log('------------res-----------')
  157. },
  158. onError(error) {
  159. alert(error)
  160. console.log('------------error-----------')
  161. console.log(error)
  162. },
  163. onProgress(e) {
  164. console.log(e)
  165. },
  166. onRemove(index, num) {
  167. this.fillingDetail.fillingDetailInfoList[num].addressUrl.splice(index, 1)
  168. },
  169. filterFileType(index, lists) {
  170. if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
  171. lists.splice(index, 1);
  172. // 当前文件不支持
  173. uni.showModal({
  174. title: '暂不支持当前图片类型',
  175. showCancel: false
  176. });
  177. } else {
  178. this.isAdd = false;
  179. }
  180. },
  181. calculate(index) {
  182. this.fillingDetail.fillingDetailInfoList[index].currentConsumption = (this.fillingDetail
  183. .fillingDetailInfoList[index].oilConsumption * this.fillingDetail.fillingDetailInfoList[index]
  184. .currentOilPrice)
  185. .toFixed(2)
  186. this.tfc = ""
  187. this.totalCost = ""
  188. for (let i = 0; i < this.fillingDetail.fillingDetailInfoList.length; i++) {
  189. this.tfc = (Number(this.tfc) + Number(this.fillingDetail.fillingDetailInfoList[i].oilConsumption))
  190. .toFixed(2)
  191. this.totalCost = (Number(this.totalCost) + Number(this.fillingDetail.fillingDetailInfoList[i]
  192. .currentConsumption)).toFixed(2)
  193. this.$forceUpdate()
  194. }
  195. },
  196. delApply(index) {
  197. this.fillingDetail.fillingDetailInfoList.splice(index, 1)
  198. },
  199. addApply() {
  200. this.fillingDetail.fillingDetailInfoList.push({
  201. oilConsumption: "",
  202. currentOilPrice: "",
  203. currentConsumption: "",
  204. addressUrl: [],
  205. compId: uni.getStorageSync('pcUserInfo').compId,
  206. commonId: uni.getStorageSync('pcUserInfo').userId,
  207. fillingId: this.id
  208. })
  209. },
  210. submitApply() {
  211. var that = this
  212. for (let i = 0; i < that.fillingDetail.fillingDetailInfoList.length; i++) {
  213. let count = i + 1
  214. if (!that.fillingDetail.fillingDetailInfoList[i].oilConsumption) {
  215. uni.showToast({
  216. title: "加油-" + count + " 油耗不能为空!",
  217. icon: "none"
  218. })
  219. return
  220. }
  221. if (!that.fillingDetail.fillingDetailInfoList[i].currentOilPrice) {
  222. uni.showToast({
  223. title: "加油-" + count + " 当前油价不能为空!",
  224. icon: "none"
  225. })
  226. return
  227. }
  228. if (that.fillingDetail.fillingDetailInfoList[i].addressUrl.length == 0) {
  229. uni.showToast({
  230. title: "加油-" + count + " 请上传加油凭证!",
  231. icon: "none"
  232. })
  233. return
  234. }
  235. }
  236. uni.showModal({
  237. content: "确定提交申请信息?",
  238. showCancel: true,
  239. confirmText: '提交',
  240. success: function(res) {
  241. if (res.confirm) {
  242. uni.showLoading({
  243. title: '加载中',
  244. mask: true
  245. });
  246. that.fillingDetail.tfc = that.tfc
  247. that.fillingDetail.totalCost = that.totalCost
  248. for (let i = 0; i < that.fillingDetail.fillingDetailInfoList.length; i++) {
  249. that.fillingDetail.fillingDetailInfoList[i].addressUrl = that.fillingDetail
  250. .fillingDetailInfoList[i].addressUrl.toString()
  251. }
  252. that.$api.doRequest('post', '/fillingDetailInfo/api/addFillingDetail',
  253. that.fillingDetail
  254. )
  255. .then(res => {
  256. uni.hideLoading()
  257. if (res.data.code == 200) {
  258. that.$api.msg('提交成功')
  259. uni.navigateTo({
  260. url: '/pages/fuelfilling/the_fuel_filling'
  261. })
  262. } else {
  263. that.$api.msg('提交失败')
  264. }
  265. })
  266. }
  267. }
  268. })
  269. },
  270. }
  271. }
  272. </script>
  273. <style lang='scss' scoped>
  274. .center {
  275. padding-bottom: 400rpx;
  276. }
  277. page {
  278. background: #F5F6FA;
  279. }
  280. .title_b {
  281. margin: 20rpx 20rpx 0rpx 20rpx;
  282. padding: 20rpx 10rpx 20rpx 10rpx;
  283. font-weight: 550;
  284. }
  285. .c-row {
  286. display: -webkit-box;
  287. display: -webkit-flex;
  288. display: flex;
  289. -webkit-box-align: center;
  290. -webkit-align-items: center;
  291. align-items: center;
  292. padding: 20rpx 30rpx;
  293. position: relative;
  294. }
  295. .level2-title {}
  296. .level2-title {
  297. font-weight: 700;
  298. color: #000000;
  299. }
  300. .jt-icon {
  301. position: relative;
  302. top: 6rpx;
  303. width: 60rpx;
  304. margin: 0 20rpx;
  305. }
  306. .xf-iamge {
  307. width: 74rpx;
  308. height: 43rpx;
  309. position: absolute;
  310. top: -20rpx;
  311. right: 0;
  312. }
  313. .ssx {
  314. width: 20px;
  315. height: 20px;
  316. background: linear-gradient(180deg, #C8D7E5 0%, #AFC1D6 100%);
  317. font-family: PingFangSC-Medium, PingFang SC;
  318. font-weight: 500;
  319. color: #FFFFFF;
  320. border-radius: 50%;
  321. display: flex;
  322. justify-content: center;
  323. align-items: center;
  324. margin-right: 5px;
  325. }
  326. .con-list {
  327. -webkit-box-flex: 1;
  328. -webkit-flex: 1;
  329. flex: 1;
  330. display: -webkit-box;
  331. display: -webkit-flex;
  332. display: flex;
  333. -webkit-box-orient: vertical;
  334. -webkit-box-direction: normal;
  335. -webkit-flex-direction: column;
  336. flex-direction: column;
  337. color: #303133;
  338. line-height: 40rpx;
  339. text-align: right;
  340. .item1,
  341. .item3 {
  342. // width: 40%;
  343. display: flex;
  344. .text {
  345. text-overflow: ellipsis;
  346. overflow: hidden;
  347. white-space: nowrap;
  348. }
  349. }
  350. .item1 .text {
  351. text-align: left;
  352. }
  353. .item3 .text {
  354. text-align: right;
  355. }
  356. }
  357. .align-center {
  358. align-items: center;
  359. justify-content: flex-end;
  360. }
  361. .wrap1 {
  362. background: #fff;
  363. margin: 10px;
  364. border-radius: 15px 10px;
  365. margin-top: 18px;
  366. input {}
  367. .tit {
  368. margin-left: 14px;
  369. width: 47px;
  370. padding-top: 10px;
  371. }
  372. .eliminate1 {
  373. max-width: 50%;
  374. width: 20px;
  375. height: 20px;
  376. font-family: PingFangSC-Medium, PingFang SC;
  377. font-weight: 500;
  378. border-radius: 50%;
  379. display: flex;
  380. justify-content: center;
  381. align-items: center;
  382. margin-right: 5px;
  383. margin-top: -20px;
  384. margin-left: 73px;
  385. }
  386. .eliminate2 {
  387. max-width: 50%;
  388. width: 20px;
  389. height: 20px;
  390. font-family: PingFangSC-Medium, PingFang SC;
  391. font-weight: 500;
  392. border-radius: 50%;
  393. display: flex;
  394. justify-content: center;
  395. align-items: center;
  396. margin-right: 5px;
  397. margin-top: -20px;
  398. margin-left: 100px;
  399. }
  400. .upload {
  401. /* margin-left: 157px; */
  402. }
  403. }
  404. .wrap {
  405. background: #fff;
  406. margin: 10px;
  407. border-radius: 15px 10px;
  408. margin-top: 18px;
  409. input {}
  410. >.title {
  411. padding: 10px 16px;
  412. }
  413. }
  414. .footer {
  415. background: #fff;
  416. position: fixed;
  417. bottom: 0;
  418. width: 100%;
  419. padding: 20px 10px;
  420. z-index: 10;
  421. height: 25%;
  422. .button {
  423. background: #4089ff;
  424. width: 90%;
  425. margin: 250px auto;
  426. padding: 10px;
  427. color: #fff;
  428. text-align: center;
  429. border-radius: 30px;
  430. margin-top: 10px;
  431. }
  432. }
  433. .buns_item {
  434. display: flex;
  435. padding: 80rpx 0 50rpx 0;
  436. justify-content: space-around;
  437. }
  438. .but_css {
  439. background: #22C572;
  440. width: 40%;
  441. padding: 20rpx;
  442. color: #fff;
  443. text-align: center;
  444. border-radius: 20rpx;
  445. }
  446. /deep/.u-radio-group {
  447. flex-direction: row-reverse;
  448. }
  449. .no-boder {
  450. border: 0;
  451. }
  452. .textarea {
  453. background: #F9F9FA;
  454. border: 1px solid #EEEEEE;
  455. }
  456. .voucher{
  457. margin-left: 20rpx;
  458. }
  459. </style>