confirmUnloading.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  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="$u.throttle(submit(1), 5000)">暂存</view>
  83. <view class="submit" @click="$u.throttle(submit(3), 5000)">提交</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. this.fileList2=[]
  126. if(this.detailData.hyCarrierInfo.unloadingImg){
  127. this.imgList=this.detailData.hyCarrierInfo.unloadingImg.split(',')
  128. var data=this.detailData.hyCarrierInfo.unloadingImg.split(',')
  129. for (var i = 0; i < data.length; i++) {
  130. if(data[i]!=''){
  131. this.fileList1.push({url:data[i]})
  132. }
  133. }
  134. }
  135. if(this.detailData.hyCarrierInfo.receiptImg){
  136. this.imgList1=this.detailData.hyCarrierInfo.receiptImg.split(',')
  137. var data=this.detailData.hyCarrierInfo.receiptImg.split(',')
  138. for (var i = 0; i < data.length; i++) {
  139. if(data[i]!=''){
  140. this.fileList2.push({url:data[i]})
  141. }
  142. }
  143. }
  144. if(this.detailData.hyCarrierInfo.totalFreight){
  145. this.$set(this.detailData,'totalFreight',String(this.detailData.hyCarrierInfo.totalFreight))
  146. // this.detailData.totalFreight=String(this.detailData.hyCarrierInfo.totalFreight)
  147. }else{
  148. this.$set(this.detailData,'totalFreight',String(this.detailData.freight))
  149. // this.detailData.totalFreight=String(this.detailData.freight)
  150. }
  151. this.detailData.carrierInfo = {
  152. // unloadingDate: '',
  153. // estimatedFreight: '',
  154. // unloadingAreaLongitude: '',
  155. // unloadingAreaLatitude: '',
  156. // unloadCity: '',
  157. // unloadArea: '',
  158. // unloadingImg: '',
  159. // totalFreight: '',
  160. unloadingImg:this.detailData.hyCarrierInfo.unloadingImg,
  161. receiptImg:this.detailData.hyCarrierInfo.receiptImg,
  162. id: this.detailData.carrierId?this.detailData.carrierId:this.detailData.hyCarrierInfo.id,
  163. }
  164. this.validityPeriod = this.$helper.makeValidityPeriod()
  165. // #ifdef APP-PLUS
  166. this.getLngLat();
  167. // #endif
  168. this.getNowTime()
  169. },
  170. methods: {
  171. deletePic(event) {
  172. console.log(this[`fileList${event.name}`])
  173. this[`fileList${event.name}`].splice(event.index, 1)
  174. this.imgList.splice(event.index, 1)
  175. },
  176. deletePic1(event) {
  177. this[`fileList${event.name}`].splice(event.index, 1)
  178. this.imgList1.splice(event.index, 1)
  179. },
  180. getNowTime() {
  181. let now = new Date();
  182. let year = now.getFullYear(); //得到年份
  183. let month = now.getMonth(); //得到月份
  184. let date = now.getDate(); //得到日期
  185. month = month + 1;
  186. month = month.toString().padStart(2, "0");
  187. date = date.toString().padStart(2, "0");
  188. let defaultDate = `${year}-${month}-${date}`
  189. this.detailData.carrierInfo.unloadingDate = defaultDate
  190. // this.$forceUpdate()
  191. },
  192. eliminate(){
  193. console.log(11111)
  194. this.$set(this.detailData,'totalFreight','')
  195. // t.totalFreight=''
  196. console.log(this.detailData.totalFreight)
  197. console.log(this.detailData.totalFreight.length)
  198. },
  199. selectUnloadingDate() {
  200. this.isShowValidity = true
  201. },
  202. getLngLat() {
  203. let that = this
  204. uni.showLoading({
  205. title: '获取定位中',
  206. mask: true
  207. })
  208. // this.$helper.fUN_AmapLocation.start({
  209. // intervalTime: 1000 * 3,
  210. // isReport: false,
  211. // },
  212. // res => {
  213. // //见下方定位返回示例
  214. // console.log('====fUN_AmapLocation定位====', JSON.stringify(res));
  215. // if (res.latitude) {
  216. // this.detailData.carrierInfo.loadingAreaLongitude = res.longitude;
  217. // this.detailData.carrierInfo.loadingAreaLatitude = res.latitude;
  218. // this.detailData.carrierInfo.sendCity = this.$helper.filterUrban(res.city)
  219. // this.detailData.carrierInfo.sendArea = this.$helper.filterArea(res.district);
  220. // console.log(this.detailData.carrierInfo.sendCity)
  221. // console.log(this.detailData.carrierInfo.sendArea)
  222. // this.$forceUpdate()
  223. // }
  224. // this.$helper.fUN_AmapLocation.stop({}, result => {
  225. // uni.hideLoading()
  226. // console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
  227. // });
  228. // }
  229. // );
  230. uni.getLocation({
  231. type: 'gcj02',
  232. geocode: true,
  233. success: res => {
  234. if (res.latitude) {
  235. // that.detailData.hyCarrierInfo.loadingAreaLongitude = res.longitude;
  236. // that.detailData.hyCarrierInfo.loadingAreaLatitude = res.latitude;
  237. that.detailData.carrierInfo.unloadingAreaLongitude = res.longitude;
  238. that.detailData.carrierInfo.unloadingAreaLatitude = res.latitude;
  239. console.log("1234567890")
  240. that.detailData.carrierInfo.unloadCity = that.$helper.filterUrban(res.address.city)
  241. that.detailData.carrierInfo.unloadArea = that.$helper.filterUrban(res.address.district)
  242. that.localtion.city = that.$helper.filterUrban(res.address.city)
  243. that.localtion.sendArea = that.$helper.filterUrban(res.address.district)
  244. that.detailData.carrierInfo.unloadingCity = that.$helper.filterUrban(res.address.city)
  245. that.detailData.carrierInfo.unloadingArea = that.$helper.filterUrban(res.address.district)
  246. that.detailData.carrierInfo.unloadingLongitude = res.longitude;
  247. that.detailData.carrierInfo.unloadingLatitude = res.latitude;
  248. that.$forceUpdate()
  249. uni.hideLoading()
  250. } else {
  251. if (uni.getSystemInfoSync().platform == 'android') {
  252. var context = plus.android.importClass("android.content.Context");
  253. var locationManager = plus.android.importClass(
  254. "android.location.LocationManager");
  255. var main = plus.android.runtimeMainActivity();
  256. var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  257. that.bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)
  258. }
  259. if (that.bool === false) {
  260. uni.showModal({
  261. title: '提示',
  262. content: '请打开定位服务',
  263. success: ({
  264. confirm,
  265. cancel
  266. }) => {
  267. if (confirm) {
  268. if (uni.getSystemInfoSync().platform == 'android') {
  269. var Intent = plus.android.importClass(
  270. 'android.content.Intent');
  271. var Settings = plus.android.importClass(
  272. 'android.provider.Settings');
  273. var intent = new Intent(Settings
  274. .ACTION_LOCATION_SOURCE_SETTINGS);
  275. var main = plus.android.runtimeMainActivity();
  276. main.startActivity(intent); // 打开系统设置GPS服务页面
  277. }
  278. }
  279. }
  280. });
  281. uni.hideLoading()
  282. }
  283. }
  284. },
  285. fail: res => {
  286. console.log('定位失败')
  287. console.log(res)
  288. uni.hideLoading()
  289. }
  290. });
  291. },
  292. alertBtn() {
  293. // uni.navigateTo({
  294. // url: '/pages/public/login'
  295. // })
  296. },
  297. cancelClick() {
  298. this.isShowAlert = false
  299. },
  300. getImgUrl(res) {
  301. this.detailData.carrierInfo.unloadingImg += res + ','
  302. console.log(res)
  303. console.log('------------res-----------')
  304. },
  305. onError(error) {
  306. alert(error)
  307. console.log('------------error-----------')
  308. console.log(error)
  309. },
  310. onRemove(index) {},
  311. filterFileType(index, lists) {
  312. if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
  313. lists.splice(index, 1);
  314. // 当前文件不支持
  315. uni.showModal({
  316. title: '暂不支持当前图片类型',
  317. showCancel: false
  318. });
  319. } else {
  320. this.isAdd = false;
  321. }
  322. },
  323. // 新增图片
  324. async afterRead(event) {
  325. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  326. let lists = [].concat(event.file)
  327. let fileListLen = this[`fileList${event.name}`].length
  328. lists.map((item) => {
  329. this[`fileList${event.name}`].push({
  330. ...item,
  331. status: 'uploading',
  332. message: '上传中'
  333. })
  334. })
  335. for (let i = 0; i < lists.length; i++) {
  336. const result = await this.uploadFilePromise(lists[i].url)
  337. let item = this[`fileList${event.name}`][fileListLen]
  338. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  339. status: 'success',
  340. message: '',
  341. url: result
  342. }))
  343. fileListLen++
  344. }
  345. },
  346. // 新增图片
  347. async afterRead1(event) {
  348. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  349. let lists = [].concat(event.file)
  350. let fileListLen = this[`fileList${event.name}`].length
  351. lists.map((item) => {
  352. this[`fileList${event.name}`].push({
  353. ...item,
  354. status: 'uploading',
  355. message: '上传中'
  356. })
  357. })
  358. for (let i = 0; i < lists.length; i++) {
  359. const result = await this.uploadFilePromise1(lists[i].url)
  360. let item = this[`fileList${event.name}`][fileListLen]
  361. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  362. status: 'success',
  363. message: '',
  364. url: result
  365. }))
  366. fileListLen++
  367. }
  368. },
  369. uploadFilePromise(url) {
  370. uploadImage('image', url, 'appData/',
  371. result => {
  372. // 上传成功回调函数
  373. console.log('图片地址', result)
  374. this.imgList.push(result)
  375. }
  376. )
  377. },
  378. uploadFilePromise1(url) {
  379. uploadImage('image', url, 'appData/',
  380. result => {
  381. // 上传成功回调函数
  382. console.log('图片地址', result)
  383. this.imgList1.push(result)
  384. }
  385. )
  386. },
  387. onProgress(e) {
  388. console.log(e)
  389. },
  390. submit(type) {
  391. if (type == 1) {
  392. this.alertContent = '确定暂存卸车信息?'
  393. } else {
  394. this.alertContent = '确定提交卸车信息?'
  395. }
  396. // if(!this.detailData.totalFreight){
  397. // this.$refs.uToast.show({
  398. // type: 'error',
  399. // message: "请输入合计运费!",
  400. // })
  401. // return
  402. // }
  403. this.isShowAlert = true
  404. this.detailData.statusFlag = type
  405. },
  406. confirmClick() {
  407. var that=this
  408. if (this.detailData.statusFlag == 1) {
  409. delete this.detailData.carrierInfo.unloadingAreaLongitude;
  410. delete this.detailData.carrierInfo.unloadingAreaLatitude;
  411. delete this.detailData.carrierInfo.unloadCity;
  412. delete this.detailData.carrierInfo.unloadArea;
  413. }
  414. this.detailData.carrierInfo.statusFlag = this.detailData.statusFlag
  415. this.detailData.carrierInfo.unloadingImg = this.imgList.toString()
  416. this.detailData.carrierInfo.receiptImg = this.imgList1.toString()
  417. // if (!this.detailData.carrierInfo.totalFreight) {
  418. // uni.showToast({
  419. // title: '运费不能为空!',
  420. // duration: 2000,
  421. // icon: "none",
  422. // });
  423. // return
  424. // }
  425. // if (
  426. // this.detailData.carrierInfo.totalFreight < 0 || this.detailData.carrierInfo.totalFreight > 100000 || (
  427. // String(this.detailData.carrierInfo.totalFreight).indexOf('.') != -1 && String(this.detailData
  428. // .carrierInfo.totalFreight).length - (String(this.detailData.carrierInfo.totalFreight).indexOf(
  429. // '.') + 1) > 2)
  430. // ) {
  431. // uni.showToast({
  432. // title: '运费输入错误!',
  433. // duration: 2000,
  434. // icon: "none",
  435. // });
  436. // return
  437. // }
  438. if (!this.detailData.carrierInfo.unloadingImg) {
  439. uni.showToast({
  440. title: '卸车照片不能为空!',
  441. icon: "none",
  442. duration: 2000
  443. });
  444. return
  445. }
  446. if (!this.detailData.carrierInfo.receiptImg) {
  447. uni.showToast({
  448. title: '请上传回单照片!',
  449. icon: "none",
  450. duration: 2000
  451. });
  452. return
  453. }
  454. this.isShowAlert = false
  455. uni.showLoading({
  456. title:'加载中'
  457. })
  458. let time = new Date() //卸车时间 去当前时间的时分秒
  459. let h = time.getHours();
  460. if (h < 10) {
  461. h = "0" + h
  462. }
  463. let f = time.getMinutes();
  464. if (f < 10) {
  465. f = "0" + f
  466. }
  467. let m = time.getSeconds();
  468. if (m < 10) {
  469. m = "0" + m
  470. }
  471. if(this.detailData.carrierInfo.unloadingDate){//卸车时间 去当前时间的时分秒
  472. this.detailData.carrierInfo.unloadingDate= this.detailData.carrierInfo.unloadingDate.split(" ")[0] + " " + h + ":" + f + ":" + m
  473. }
  474. // this.detailData.carrierInfo.totalFreight = this.detailData.totalFreight
  475. this.detailData.carrierInfo.carNo = this.detailData.carNumber
  476. this.$request.baseRequest('post', '/carrierInfo/unLoadingAdd', this.detailData.carrierInfo).then(res => {
  477. if (res.code == 200) {
  478. let _title = ''
  479. if (this.detailData.statusFlag == 1) {
  480. _title = '暂存成功!'
  481. } else {
  482. _title = '提交成功!'
  483. }
  484. uni.hideLoading()
  485. this.$refs.uToast.show({
  486. type: 'success',
  487. message: _title,
  488. complete() {
  489. uni.hideLoading()
  490. uni.switchTab({
  491. url: '/pages/order/index'
  492. })
  493. if(that.$helper.fUN_AmapLocation){
  494. that.$helper.fUN_AmapLocation.stop({}, result => {
  495. console.log('====fUN_AmapLocation定位stop====', JSON.stringify(result));
  496. });
  497. }
  498. }
  499. })
  500. }
  501. })
  502. .catch(res => {
  503. uni.$u.toast(res.message);
  504. });
  505. },
  506. confirmValidityPeriod(e) {
  507. this.detailData.carrierInfo.unloadingDate = e.value[0] + '-' + e.value[1] + '-' + e.value[2]
  508. this.isShowValidity = false
  509. },
  510. },
  511. }
  512. </script>
  513. <style scoped lang="scss">
  514. .content {
  515. .row-left-text {
  516. color: #333333;
  517. }
  518. }
  519. .level2-title {
  520. margin: 0 0 20rpx 0;
  521. }
  522. .content1,
  523. .content2 {
  524. background: white;
  525. margin: 20rpx;
  526. border-radius: 20rpx;
  527. padding: 20rpx;
  528. .place {
  529. width: 80%;
  530. text-align: right;
  531. }
  532. }
  533. .upload {}
  534. .bottom-btn {
  535. display: flex;
  536. justify-content: space-around;
  537. // margin-bottom: 50rpx;
  538. background: #FFFFFF;
  539. padding: 40rpx 0;
  540. }
  541. .store {
  542. padding: 20rpx 30rpx;
  543. color: #2772FB;
  544. width: 40%;
  545. background: #EEF4FF;
  546. border-radius: 40rpx;
  547. font-size: 36rpx;
  548. text-align: center;
  549. }
  550. .submit {
  551. font-size: 36rpx;
  552. padding: 20rpx 30rpx;
  553. color: white;
  554. width: 40%;
  555. background: #2772FB;
  556. border-radius: 40rpx;
  557. text-align: center;
  558. }
  559. .row-between {
  560. margin: 20rpx 0;
  561. }
  562. .sx-style {
  563. background: #2772FB;
  564. color: white;
  565. padding: 2rpx 16rpx;
  566. box-sizing: border-box;
  567. border-radius: 10rpx;
  568. margin-left: 20rpx;
  569. }
  570. .totalFreight-input {
  571. text-align: right;
  572. padding-right:18px;
  573. }
  574. .close{
  575. position:absolute;
  576. right:0;
  577. width:15px;height:15px;
  578. top:50%;
  579. transform: translateY(-50%);
  580. }
  581. </style>