apply_for_reimbursement.vue 12 KB

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