confirmUnloading.vue 19 KB

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