confirmUnloading.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. <!-- 确认装车 -->
  2. <template>
  3. <view class="content">
  4. <view class="content2">
  5. <view class="level2-title">基本信息</view>
  6. <view class='row-between'>
  7. <view class="row-left-text">订单编号</view>
  8. <view class="row-right-text">{{detailData.orderNo}}</view>
  9. </view>
  10. <view class='row-between'>
  11. <view class="row-left-text">货主</view>
  12. <view class="row-right-text">{{detailData.cargoOwner}}</view>
  13. </view>
  14. <view class='row-between'>
  15. <view class="row-left-text">货主单位</view>
  16. <view class="row-right-text">{{detailData.compName?detailData.compName:'个人货主'}}</view>
  17. </view>
  18. <view class='row-between'>
  19. <view class="row-left-text">发货地</view>
  20. <view class="row-right-text place">
  21. {{detailData.sendPrivate}}{{detailData.sendCity}}{{detailData.sendArea}}{{detailData.sendDetailedAddress}}
  22. </view>
  23. </view>
  24. <view class='row-between'>
  25. <view class="row-left-text">卸货地</view>
  26. <view class="row-right-text place">
  27. {{detailData.unloadPrivate}}{{detailData.unloadCity}}{{detailData.unloadArea}}{{detailData.unloadDetailedAddress}}
  28. </view>
  29. </view>
  30. <view class='row-between'>
  31. <view class="row-left-text">货名</view>
  32. <view class="row-right-text">{{detailData.goodsName}}</view>
  33. </view>
  34. <view class='row-between'>
  35. <view class="row-left-text">运费</view>
  36. <view class="row-right-text">{{detailData.freight}}{{detailData.billingMethod==0?'元/吨':'元/车'}}</view>
  37. </view>
  38. </view>
  39. <view class="content2">
  40. <view class="level2-title">卸车信息</view>
  41. <view class='row-between'>
  42. <view class="row-left-text">车牌号</view>
  43. <view class="row-right-text">{{detailData.carNumber}}</view>
  44. </view>
  45. <!-- <view class='row-between'>
  46. <view class="row-left-text">卸车日期</view>
  47. <view class="row-right-text">{{detailData.carrierInfo.unloadingDate}}</view>
  48. </view> -->
  49. <view class="row-between">
  50. <view class="left-text">卸车日期</view>
  51. <view class="" @click="selectUnloadingDate">
  52. {{detailData.carrierInfo.unloadingDate?detailData.carrierInfo.unloadingDate:'选择卸车日期'}}
  53. </view>
  54. </view>
  55. <view class='row-between'>
  56. <view class="row-left-text">合计运费(元)</view>
  57. <view style='position:relative;'>
  58. <input :style="{color:this.detailData.freight!=detailData.totalFreight?'red':'#000'}" class="totalFreight-input" placeholder="输入合计运费" v-model="detailData.totalFreight"
  59. type="number" />
  60. <image @click='eliminate' class='close' v-if='detailData.totalFreight.length>0' src="../../static/images/order/guanbi.png" mode=""></image>
  61. </view>
  62. </view>
  63. <view class='row-between'>
  64. <view class="row-left-text">定位</view>
  65. <view class="flex align-center">
  66. {{detailData.carrierInfo.unloadCity}}{{detailData.carrierInfo.unloadArea}}
  67. <view class="sx-style" @click.stop="getLngLat()">刷新</view>
  68. </view>
  69. </view>
  70. <view class='s-flex'>
  71. <view class="row-left-text" style="margin:20rpx 0;">上传卸车照片(1-3张)</view>
  72. <u-upload class="uview-upload" :fileList="fileList1" @afterRead="afterRead($event)" @delete="deletePic"
  73. name="1" multiple :maxCount="3"></u-upload>
  74. </view>
  75. <view class='s-flex'>
  76. <view class="row-left-text" style="margin:20rpx 0;">上传回单照片(磅单)</view>
  77. <u-upload class="uview-upload" :fileList="fileList2" @afterRead="afterRead1($event)" @delete="deletePic1"
  78. name="2" multiple :maxCount="3"></u-upload>
  79. </view>
  80. </view>
  81. <view class="bottom-btn">
  82. <view class="store" @click="submit(1)">暂存</view>
  83. <view class="submit" @click="submit(3)">提交</view>
  84. </view>
  85. <u-modal :show="isShowAlert" :title="alertTitle" :content='alertContent' :closeOnClickOverlay='true'
  86. :showCancelButton='true' confirmColor='#2772FB' @confirm="confirmClick" @close="cancelClick"
  87. @cancel="cancelClick"></u-modal>
  88. <u-picker :show="isShowValidity" ref="uPicker" :columns="validityPeriod" @confirm="confirmValidityPeriod"
  89. :closeOnClickOverlay='true' @close='isShowValidity=false' @cancel='isShowValidity=false'>
  90. </u-picker>
  91. <u-toast ref="uToast"></u-toast>
  92. </view>
  93. </template>
  94. <script>
  95. let that;
  96. import uploadImage from '@/components/ossutil/uploadFile.js';
  97. export default {
  98. data() {
  99. return {
  100. imgList: [],
  101. fileList1: [],
  102. fileList2:[],
  103. isShowValidity: false,
  104. validityPeriod: [],
  105. sourceType: ['camera'],
  106. imgList1:[],
  107. detailData: {
  108. addressUrl: '',
  109. hyCarrierInfo:{},
  110. totalFreight:''
  111. },
  112. action: this.$helper.ossUploadUrl,
  113. maxSize: 50 * 1024 * 1024, //限制文件大小 50M
  114. isAdd: true,
  115. isShowAlert: false,
  116. alertContent: '',
  117. alertTitle: '',
  118. localtion:{},
  119. }
  120. },
  121. onLoad(options) {
  122. this.detailData = JSON.parse(options.obj)
  123. console.log(this.detailData)
  124. this.fileList1=[]
  125. if(this.detailData.hyCarrierInfo.unloadingImg){
  126. this.imgList=this.detailData.hyCarrierInfo.unloadingImg.split(',')
  127. var data=this.detailData.hyCarrierInfo.unloadingImg.split(',')
  128. for (var i = 0; i < data.length; i++) {
  129. if(data[i]!=''){
  130. this.fileList1.push({url:data[i]})
  131. }
  132. }
  133. }
  134. if(this.detailData.hyCarrierInfo.totalFreight){
  135. this.$set(this.detailData,'totalFreight',String(this.detailData.hyCarrierInfo.totalFreight))
  136. // this.detailData.totalFreight=String(this.detailData.hyCarrierInfo.totalFreight)
  137. }else{
  138. this.$set(this.detailData,'totalFreight',String(this.detailData.freight))
  139. // this.detailData.totalFreight=String(this.detailData.freight)
  140. }
  141. this.detailData.carrierInfo = {
  142. // unloadingDate: '',
  143. // estimatedFreight: '',
  144. // unloadingAreaLongitude: '',
  145. // unloadingAreaLatitude: '',
  146. // unloadCity: '',
  147. // unloadArea: '',
  148. // unloadingImg: '',
  149. // totalFreight: '',
  150. unloadingImg:this.detailData.hyCarrierInfo.unloadingImg,
  151. receiptImg:this.detailData.hyCarrierInfo.receiptImg,
  152. id: this.detailData.carrierId,
  153. }
  154. this.validityPeriod = this.$helper.makeValidityPeriod()
  155. // #ifdef APP-PLUS
  156. this.getLngLat();
  157. // #endif
  158. this.getNowTime()
  159. },
  160. methods: {
  161. deletePic(event) {
  162. this[`fileList${event.name}`].splice(event.index, 1)
  163. },
  164. deletePic1(event) {
  165. this[`fileList${event.name}`].splice(event.index, 1)
  166. },
  167. getNowTime() {
  168. let now = new Date();
  169. let year = now.getFullYear(); //得到年份
  170. let month = now.getMonth(); //得到月份
  171. let date = now.getDate(); //得到日期
  172. month = month + 1;
  173. month = month.toString().padStart(2, "0");
  174. date = date.toString().padStart(2, "0");
  175. let defaultDate = `${year}-${month}-${date}`
  176. this.detailData.carrierInfo.unloadingDate = defaultDate
  177. // this.$forceUpdate()
  178. },
  179. eliminate(){
  180. console.log(11111)
  181. this.$set(this.detailData,'totalFreight','')
  182. // t.totalFreight=''
  183. console.log(this.detailData.totalFreight)
  184. console.log(this.detailData.totalFreight.length)
  185. },
  186. selectUnloadingDate() {
  187. this.isShowValidity = true
  188. },
  189. getLngLat() {
  190. let that = this
  191. uni.showLoading({
  192. title: '获取定位中',
  193. mask: true
  194. })
  195. // this.$helper.fUN_AmapLocation.start({
  196. // intervalTime: 1000 * 3,
  197. // isReport: false,
  198. // },
  199. // res => {
  200. // //见下方定位返回示例
  201. // console.log('====fUN_AmapLocation定位====', JSON.stringify(res));
  202. // if (res.latitude) {
  203. // this.detailData.carrierInfo.loadingAreaLongitude = res.longitude;
  204. // this.detailData.carrierInfo.loadingAreaLatitude = res.latitude;
  205. // this.detailData.carrierInfo.sendCity = this.$helper.filterUrban(res.city)
  206. // this.detailData.carrierInfo.sendArea = this.$helper.filterArea(res.district);
  207. // console.log(this.detailData.carrierInfo.sendCity)
  208. // console.log(this.detailData.carrierInfo.sendArea)
  209. // this.$forceUpdate()
  210. // }
  211. // this.$helper.fUN_AmapLocation.stop({}, result => {
  212. // uni.hideLoading()
  213. // console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
  214. // });
  215. // }
  216. // );
  217. uni.getLocation({
  218. type: 'gcj02',
  219. geocode: true,
  220. success: res => {
  221. if (res.latitude) {
  222. // that.detailData.hyCarrierInfo.loadingAreaLongitude = res.longitude;
  223. // that.detailData.hyCarrierInfo.loadingAreaLatitude = res.latitude;
  224. that.detailData.carrierInfo.unloadingAreaLongitude = res.longitude;
  225. that.detailData.carrierInfo.unloadingAreaLatitude = res.latitude;
  226. console.log("1234567890")
  227. that.detailData.carrierInfo.unloadCity = that.$helper.filterUrban(res.address.city)
  228. that.detailData.carrierInfo.unloadArea = that.$helper.filterUrban(res.address.district)
  229. that.localtion.city = that.$helper.filterUrban(res.address.city)
  230. that.localtion.sendArea = that.$helper.filterUrban(res.address.district)
  231. that.detailData.carrierInfo.unloadingCity = that.$helper.filterUrban(res.address.city)
  232. that.detailData.carrierInfo.unloadingArea = that.$helper.filterUrban(res.address.district)
  233. that.detailData.carrierInfo.unloadingLongitude = res.longitude;
  234. that.detailData.carrierInfo.unloadingLatitude = res.latitude;
  235. that.$forceUpdate()
  236. uni.hideLoading()
  237. } else {
  238. if (uni.getSystemInfoSync().platform == 'android') {
  239. var context = plus.android.importClass("android.content.Context");
  240. var locationManager = plus.android.importClass(
  241. "android.location.LocationManager");
  242. var main = plus.android.runtimeMainActivity();
  243. var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  244. that.bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)
  245. }
  246. if (that.bool === false) {
  247. uni.showModal({
  248. title: '提示',
  249. content: '请打开定位服务',
  250. success: ({
  251. confirm,
  252. cancel
  253. }) => {
  254. if (confirm) {
  255. if (uni.getSystemInfoSync().platform == 'android') {
  256. var Intent = plus.android.importClass(
  257. 'android.content.Intent');
  258. var Settings = plus.android.importClass(
  259. 'android.provider.Settings');
  260. var intent = new Intent(Settings
  261. .ACTION_LOCATION_SOURCE_SETTINGS);
  262. var main = plus.android.runtimeMainActivity();
  263. main.startActivity(intent); // 打开系统设置GPS服务页面
  264. }
  265. }
  266. }
  267. });
  268. uni.hideLoading()
  269. }
  270. }
  271. },
  272. fail: res => {
  273. console.log('定位失败')
  274. console.log(res)
  275. uni.hideLoading()
  276. }
  277. });
  278. },
  279. alertBtn() {
  280. // uni.navigateTo({
  281. // url: '/pages/public/login'
  282. // })
  283. },
  284. cancelClick() {
  285. this.isShowAlert = false
  286. },
  287. getImgUrl(res) {
  288. this.detailData.carrierInfo.unloadingImg += res + ','
  289. console.log(res)
  290. console.log('------------res-----------')
  291. },
  292. onError(error) {
  293. alert(error)
  294. console.log('------------error-----------')
  295. console.log(error)
  296. },
  297. onRemove(index) {},
  298. filterFileType(index, lists) {
  299. if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
  300. lists.splice(index, 1);
  301. // 当前文件不支持
  302. uni.showModal({
  303. title: '暂不支持当前图片类型',
  304. showCancel: false
  305. });
  306. } else {
  307. this.isAdd = false;
  308. }
  309. },
  310. // 新增图片
  311. async afterRead(event) {
  312. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  313. let lists = [].concat(event.file)
  314. let fileListLen = this[`fileList${event.name}`].length
  315. lists.map((item) => {
  316. this[`fileList${event.name}`].push({
  317. ...item,
  318. status: 'uploading',
  319. message: '上传中'
  320. })
  321. })
  322. for (let i = 0; i < lists.length; i++) {
  323. const result = await this.uploadFilePromise(lists[i].url)
  324. let item = this[`fileList${event.name}`][fileListLen]
  325. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  326. status: 'success',
  327. message: '',
  328. url: result
  329. }))
  330. fileListLen++
  331. }
  332. },
  333. // 新增图片
  334. async afterRead1(event) {
  335. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  336. let lists = [].concat(event.file)
  337. let fileListLen = this[`fileList${event.name}`].length
  338. lists.map((item) => {
  339. this[`fileList${event.name}`].push({
  340. ...item,
  341. status: 'uploading',
  342. message: '上传中'
  343. })
  344. })
  345. for (let i = 0; i < lists.length; i++) {
  346. const result = await this.uploadFilePromise1(lists[i].url)
  347. let item = this[`fileList${event.name}`][fileListLen]
  348. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  349. status: 'success',
  350. message: '',
  351. url: result
  352. }))
  353. fileListLen++
  354. }
  355. },
  356. uploadFilePromise(url) {
  357. uploadImage('image', url, 'appData/',
  358. result => {
  359. // 上传成功回调函数
  360. console.log('图片地址', result)
  361. this.imgList.push(result)
  362. }
  363. )
  364. },
  365. uploadFilePromise1(url) {
  366. uploadImage('image', url, 'appData/',
  367. result => {
  368. // 上传成功回调函数
  369. console.log('图片地址', result)
  370. this.imgList1.push(result)
  371. }
  372. )
  373. },
  374. onProgress(e) {
  375. console.log(e)
  376. },
  377. submit(type) {
  378. if (type == 1) {
  379. this.alertContent = '确定暂存卸车信息?'
  380. } else {
  381. this.alertContent = '确定提交卸车信息?'
  382. }
  383. if(!this.detailData.totalFreight){
  384. this.$refs.uToast.show({
  385. type: 'error',
  386. message: "请输入合计运费!",
  387. })
  388. return
  389. }
  390. this.isShowAlert = true
  391. this.detailData.statusFlag = type
  392. },
  393. confirmClick() {
  394. var that=this
  395. if (this.detailData.statusFlag == 1) {
  396. delete this.detailData.carrierInfo.unloadingAreaLongitude;
  397. delete this.detailData.carrierInfo.unloadingAreaLatitude;
  398. delete this.detailData.carrierInfo.unloadCity;
  399. delete this.detailData.carrierInfo.unloadArea;
  400. }
  401. this.detailData.carrierInfo.statusFlag = this.detailData.statusFlag
  402. this.detailData.carrierInfo.unloadingImg = this.imgList.toString()
  403. this.detailData.carrierInfo.receiptImg = this.imgList1.toString()
  404. // if (!this.detailData.carrierInfo.totalFreight) {
  405. // uni.showToast({
  406. // title: '运费不能为空!',
  407. // duration: 2000,
  408. // icon: "none",
  409. // });
  410. // return
  411. // }
  412. if (
  413. this.detailData.carrierInfo.totalFreight < 0 || this.detailData.carrierInfo.totalFreight > 100000 || (
  414. String(this.detailData.carrierInfo.totalFreight).indexOf('.') != -1 && String(this.detailData
  415. .carrierInfo.totalFreight).length - (String(this.detailData.carrierInfo.totalFreight).indexOf(
  416. '.') + 1) > 2)
  417. ) {
  418. uni.showToast({
  419. title: '运费输入错误!',
  420. duration: 2000,
  421. icon: "none",
  422. });
  423. return
  424. }
  425. if (!this.detailData.carrierInfo.unloadingImg) {
  426. uni.showToast({
  427. title: '卸车照片不能为空!',
  428. icon: "none",
  429. duration: 2000
  430. });
  431. return
  432. }
  433. this.isShowAlert = false
  434. uni.showLoading({
  435. title:'加载中'
  436. })
  437. let time = new Date() //卸车时间 去当前时间的时分秒
  438. let h = time.getHours();
  439. if (h < 10) {
  440. h = "0" + h
  441. }
  442. let f = time.getMinutes();
  443. if (f < 10) {
  444. f = "0" + f
  445. }
  446. let m = time.getSeconds();
  447. if (m < 10) {
  448. m = "0" + m
  449. }
  450. if(this.detailData.carrierInfo.unloadingDate){//卸车时间 去当前时间的时分秒
  451. this.detailData.carrierInfo.unloadingDate= this.detailData.carrierInfo.unloadingDate.split(" ")[0] + " " + h + ":" + f + ":" + m
  452. }
  453. this.detailData.carrierInfo.totalFreight = this.detailData.totalFreight
  454. this.detailData.carrierInfo.carNo = this.detailData.carNumber
  455. this.$request.baseRequest('post', '/carrierInfo/unLoadingAdd', this.detailData.carrierInfo).then(res => {
  456. if (res.code == 200) {
  457. let _title = ''
  458. if (this.detailData.statusFlag == 1) {
  459. _title = '暂存成功!'
  460. } else {
  461. _title = '提交成功!'
  462. }
  463. uni.hideLoading()
  464. this.$refs.uToast.show({
  465. type: 'success',
  466. message: _title,
  467. complete() {
  468. uni.hideLoading()
  469. uni.switchTab({
  470. url: '/pages/order/index'
  471. })
  472. if(that.$helper.fUN_AmapLocation){
  473. that.$helper.fUN_AmapLocation.stop({}, result => {
  474. console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
  475. });
  476. }
  477. }
  478. })
  479. }
  480. })
  481. .catch(res => {
  482. uni.$u.toast(res.message);
  483. });
  484. },
  485. confirmValidityPeriod(e) {
  486. this.detailData.carrierInfo.unloadingDate = e.value[0] + '-' + e.value[1] + '-' + e.value[2]
  487. this.isShowValidity = false
  488. },
  489. },
  490. }
  491. </script>
  492. <style scoped lang="scss">
  493. .content {
  494. .row-left-text {
  495. color: #333333;
  496. }
  497. }
  498. .level2-title {
  499. margin: 0 0 20rpx 0;
  500. }
  501. .content1,
  502. .content2 {
  503. background: white;
  504. margin: 20rpx;
  505. border-radius: 20rpx;
  506. padding: 20rpx;
  507. .place {
  508. width: 80%;
  509. text-align: right;
  510. }
  511. }
  512. .upload {}
  513. .bottom-btn {
  514. display: flex;
  515. justify-content: space-around;
  516. // margin-bottom: 50rpx;
  517. background: #FFFFFF;
  518. padding: 40rpx 0;
  519. }
  520. .store {
  521. padding: 20rpx 30rpx;
  522. color: #2772FB;
  523. width: 40%;
  524. background: #EEF4FF;
  525. border-radius: 40rpx;
  526. font-size: 36rpx;
  527. text-align: center;
  528. }
  529. .submit {
  530. font-size: 36rpx;
  531. padding: 20rpx 30rpx;
  532. color: white;
  533. width: 40%;
  534. background: #2772FB;
  535. border-radius: 40rpx;
  536. text-align: center;
  537. }
  538. .row-between {
  539. margin: 20rpx 0;
  540. }
  541. .sx-style {
  542. background: #2772FB;
  543. color: white;
  544. padding: 2rpx 16rpx;
  545. box-sizing: border-box;
  546. border-radius: 10rpx;
  547. margin-left: 20rpx;
  548. }
  549. .totalFreight-input {
  550. text-align: right;
  551. padding-right:18px;
  552. }
  553. .close{
  554. position:absolute;
  555. right:0;
  556. width:15px;height:15px;
  557. top:50%;
  558. transform: translateY(-50%);
  559. }
  560. </style>