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