editRelease.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. <template>
  2. <view class="content">
  3. <view class="fixed1"></view>
  4. <view class='title flex'>
  5. <u-icon class="back" name="arrow-left" color="" size="20" @click="back"></u-icon>
  6. <view class="nav-title">发布</view>
  7. <view class="search" @click="goToRecord">
  8. <u-icon class="" name="order" color="" size="28"></u-icon>
  9. <view>
  10. 记录
  11. </view>
  12. </view>
  13. </view>
  14. <view class="content1">
  15. <view class="row" @click="selectCargoOwner" v-if="!dataObj.cargoOwner">
  16. <view class="left select-sf">选择货主身份</view>
  17. <view class="right">></view>
  18. </view>
  19. <view class="row" @click="selectCargoOwner" v-if="dataObj.cargoOwner">
  20. <view class="left">{{dataObj.cargoOwner}}</view>
  21. <view class="right">></view>
  22. </view>
  23. <u-picker :show="show" :columns="columns" :closeOnClickOverlay='true' @close='selectCargoOwnerClose'
  24. @cancel='selectCargoOwnerClose' @confirm='confirmSelectCargoOwner'></u-picker>
  25. </view>
  26. <view class="content2">
  27. <view class="row1">
  28. <view class="left">
  29. <view class="top" @click="selectAddress(0)">
  30. <view class="send">寄</view>
  31. <view class="title">
  32. {{dataObj.sendArea?(dataObj.sendPrivate + dataObj.sendCity+dataObj.sendArea):'选择发货地区'}}
  33. </view>
  34. </view>
  35. <view class="bottom">
  36. <input type="text" value="" placeholder="输入详细地址" v-model="dataObj.sendDetailedAddress" />
  37. </view>
  38. </view>
  39. <view class="right" @click="selectAddress(0)" v-if="!dataObj.sendArea">
  40. <view class="right">{{dataObj.sendArea?'':'>'}}</view>
  41. </view>
  42. </view>
  43. <view class="row2">
  44. <view class="left">
  45. <view class="top" @click="selectAddress(1)">
  46. <view class="collect">收</view>
  47. <view class="title">
  48. {{dataObj.unloadArea?(dataObj.unloadPrivate + dataObj.unloadCity+dataObj.unloadArea):'选择收货地区'}}
  49. </view>
  50. </view>
  51. <view class="bottom">
  52. <input type="text" value="" placeholder="输入详细地址" v-model="dataObj.unloadDetailedAddress" />
  53. </view>
  54. </view>
  55. <view class="right" @click="selectAddress(1)" v-if="!dataObj.unloadArea">
  56. <view class="right">{{dataObj.unloadArea?(dataObj.unloadCity+dataObj.unloadArea):'>'}}</view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="content3">
  61. <view class="row">
  62. <view class="left">距离</view>
  63. <input type="text" value="" class="input" placeholder="自动计算" v-model="dataObj.distance" disabled="" />
  64. </view>
  65. <view class="row">
  66. <view class="left">货名</view>
  67. <view class="right"><input type="text" class="input" value="" placeholder="输入货物名称"
  68. v-model="dataObj.goodsName" /></view>
  69. </view>
  70. <view class="flex row">
  71. <view class="left-text">运费计算方式</view>
  72. <!-- <u-radio-group v-model="dataDetails.driverSex" placement="row"> -->
  73. <u-radio-group placement="row" v-model="dataObj.billingMethod" class="select-type">
  74. <u-radio :customStyle="radioCustomStyle" v-for="(item, index) in radiolist1" :key="index"
  75. :label="item.name" :name="item.name" @change="radioChange">
  76. </u-radio>
  77. </u-radio-group>
  78. </view>
  79. <view class="row">
  80. <view class="left">运费单价</view>
  81. <view class="right"><input type="text" value="" placeholder="输入运费单价" class="input"
  82. v-model="dataObj.freightPrice" /></view>
  83. </view>
  84. <view class="row">
  85. <view class="left">该任务申请运费垫付</view>
  86. <view class="right">
  87. <u-switch v-model="dataObj.freightAdvance" @change="change" size="20"></u-switch>
  88. </view>
  89. </view>
  90. </view>
  91. <view class="content4 flex">
  92. <view class="title">以下为附加信息</view>
  93. <view class="btn-text">选填</view>
  94. </view>
  95. <view class="content5">
  96. <view class="row">
  97. <view class="left">发货联系人</view>
  98. <view class="right flex">
  99. <input type="text" value="" placeholder="输入发货联系人姓名" class="input" v-model="dataObj.sender" />
  100. </view>
  101. </view>
  102. <view class="row">
  103. <view class="left">发货联系人电话</view>
  104. <view class="right flex">
  105. <input type="text" value="" placeholder="输入发货联系人手机号" class="input" v-model="dataObj.senderPhone" />
  106. </view>
  107. </view>
  108. <view class="row">
  109. <view class="left">收货联系人</view>
  110. <view class="right flex">
  111. <input type="text" value="" placeholder="输入收货联系人姓名" class="input" v-model="dataObj.receiver" />
  112. </view>
  113. </view>
  114. <view class="row">
  115. <view class="left">收货联系人电话</view>
  116. <view class="right flex">
  117. <input type="text" value="" placeholder="输入收货联系人手机号" class="input"
  118. v-model="dataObj.receiverPhone" />
  119. </view>
  120. </view>
  121. <view class="row">
  122. <view class="left">重量(吨)</view>
  123. <view class="right flex">
  124. <input type="text" value="" placeholder="输入预计发运重量" class="input" v-model="dataObj.weight" />
  125. </view>
  126. </view>
  127. <view class="flex row" @click="selectValidityPeriod(0)">
  128. <view class="left-text">预计装车日期起</view>
  129. <view :class="!dataObj.loadingDateStart?'select-data':''">
  130. {{dataObj.loadingDateStart?dataObj.loadingDateStart:'选择有效截止日期>'}}
  131. </view>
  132. </view>
  133. <view class="flex row" @click="selectValidityPeriod(1)">
  134. <view class="left-text">预计装车日期止</view>
  135. <view :class="!dataObj.loadingDateEnd?'select-data':''">
  136. {{dataObj.loadingDateEnd?dataObj.loadingDateEnd:'选择有效截止日期>'}}
  137. </view>
  138. </view>
  139. <view class="row">
  140. <view class="left">车长要求(米)</view>
  141. </view>
  142. <view class="row flex-space-between row-bgc">
  143. <view class="car-row">
  144. <input type="text" value="" placeholder="最短不限" class="" v-model="dataObj.carLengthSmall"
  145. class="car-input" />
  146. <view>m</view>
  147. </view>
  148. <view class="car-line">-</view>
  149. <view class="car-row">
  150. <input type="text" value="" placeholder="最长不限" class="" v-model="dataObj.carLength"
  151. class="car-input" />
  152. <view>m</view>
  153. </view>
  154. </view>
  155. <view class="row">
  156. <view class="left">载重要求(吨)</view>
  157. </view>
  158. <view class="row flex-space-between row-bgc">
  159. <view class="car-row">
  160. <input type="text" value="" placeholder="最小不限" class="car-input"
  161. v-model="dataObj.loadWeightSmall" />
  162. <view>吨</view>
  163. </view>
  164. <view class="car-line">-</view>
  165. <view class="car-row">
  166. <input type="text" value="" placeholder="最大不限" class="car-input" v-model="dataObj.loadWeight" />
  167. <view>吨</view>
  168. </view>
  169. </view>
  170. <view class="row">
  171. <view class="left">车型要求</view>
  172. </view>
  173. <view class="row">
  174. <u-checkbox-group v-model="checkboxValue1" placement="row" @change="checkboxChange">
  175. <u-checkbox :customStyle="radioCustomStyle" v-for="(item, index) in checkboxList1" :key="index"
  176. :label="item.name" :name="item.name">
  177. </u-checkbox>
  178. </u-checkbox-group>
  179. </view>
  180. <view class="row">
  181. <view class="left">任务描述</view>
  182. </view>
  183. <view class="row">
  184. <u--textarea v-model="dataObj.taskDescription" placeholder="请输入内容"></u--textarea>
  185. </view>
  186. <view class="flex row noborder">
  187. <view class="left-text">任务有效期</view>
  188. <view :class="dataObj.taskValidity?'':'select-data'" @click="selectValidityPeriodcq">
  189. {{dataObj.taskValidity?dataObj.taskValidity:'选择任务有效期>'}}
  190. </view>
  191. </view>
  192. <u-picker :show="isShowcardValidity" ref="uPicker" :columns="validityPeriodcq"
  193. @confirm="confirmValidityPeriodcq" @change="changeHandler" @close='isShowcardValidity=false'
  194. @cancel='isShowcardValidity=false' :closeOnClickOverlay='true'>
  195. </u-picker>
  196. </view>
  197. <view class="submit" @click="submit">立即发布</view>
  198. <u-picker :show="isShowValidity" ref="uPicker" :columns="validityPeriod" @confirm="confirmValidityPeriod"
  199. :closeOnClickOverlay='true' @close='isShowValidity=false' @cancel='isShowValidity=false'>
  200. </u-picker>
  201. <u-toast ref="uToast"></u-toast>
  202. </view>
  203. </template>
  204. <script>
  205. var _this;
  206. import {
  207. mapState
  208. } from 'vuex';
  209. export default {
  210. data() {
  211. return {
  212. radioCustomStyle: {
  213. margin: '0 0 0 20rpx'
  214. },
  215. show: false,
  216. columns: [
  217. ['个人货主', '黑龙江中天昊元贸易有限公司', '黑龙江利润元贸易有限公司']
  218. ],
  219. dataObj: {
  220. commonId: '',
  221. cargoOwner: '',
  222. sendPrivate: '',
  223. sendCity: '',
  224. sendArea: '',
  225. sendDetailedAddress: '',
  226. unloadPrivate: '',
  227. unloadCity: '',
  228. unloadArea: '',
  229. unloadDetailedAddress: '',
  230. distance: '',
  231. goodsName: '',
  232. billingMethod: '元/吨',
  233. freightPrice: '',
  234. freightAdvance: true,
  235. sender: '',
  236. senderPhone: '',
  237. receiver: '',
  238. receiverPhone: '',
  239. weight: '',
  240. loadingDateStart: '',
  241. loadingDateEnd: '',
  242. carLengthSmall: '',
  243. carLength: '',
  244. loadWeightSmall: '',
  245. loadWeight: '',
  246. carModel: '',
  247. taskDescription: '',
  248. taskValidity: '',
  249. sendLongitude: '',
  250. sendLatitude: '',
  251. unsendLongitude: '',
  252. unsendLatitude: '',
  253. },
  254. checkboxValue1: [],
  255. checkboxList1: [{
  256. name: '不限',
  257. disabled: false
  258. },
  259. {
  260. name: '高栏',
  261. disabled: false
  262. },
  263. {
  264. name: '集装箱',
  265. disabled: false
  266. },
  267. {
  268. name: '自卸车',
  269. disabled: false
  270. }
  271. ],
  272. value: true,
  273. isShowcardValidity: false,
  274. ValidityPeriodType: '',
  275. validityPeriod: [],
  276. validityPeriodcq: [],
  277. isShowValidity: false,
  278. radiolist1: [{
  279. name: '元/吨',
  280. disabled: false
  281. },
  282. {
  283. name: '元/车',
  284. disabled: false
  285. },
  286. ],
  287. }
  288. },
  289. onShow() {
  290. // //获取默认收货、发货地
  291. // let _faddress = uni.getStorageSync('storage_faddress');
  292. // let _saddress = uni.getStorageSync('storage_saddress');
  293. // if (_faddress) {
  294. // this.dataObj.sendCity = _faddress.city
  295. // this.dataObj.sendArea = _faddress.area
  296. // this.dataObj.sendPrivate = _faddress.province
  297. // this.dataObj.sendDetailedAddress = _faddress.detailedAddress
  298. // this.dataObj.sendLongitude = _faddress.longitude
  299. // this.dataObj.sendLatitude = _faddress.latitude
  300. // }
  301. // if (_saddress) {
  302. // this.dataObj.unloadDetailedAddress = _saddress.detailedAddress
  303. // this.dataObj.unloadCity = _saddress.city
  304. // this.dataObj.unloadArea = _saddress.area
  305. // this.dataObj.unloadPrivate = _saddress.province
  306. // this.dataObj.unsendLongitude = _saddress.longitude
  307. // this.dataObj.unsendLatitude = _saddress.latitude
  308. // }
  309. },
  310. onLoad(options) {
  311. _this = this;
  312. this.dataObj = options
  313. if (this.dataObj.billingMethod == 1) {
  314. this.dataObj.billingMethod = '元/车'
  315. } else {
  316. this.dataObj.billingMethod = '元/吨'
  317. }
  318. for (let i = 0; i < this.dataObj.carModel.length; i++) {
  319. if (this.dataObj.carModel[i] == '1') {
  320. this.checkboxValue1.push('不限')
  321. } else if (this.dataObj.carModel[i] == '2') {
  322. this.checkboxValue1.push('高栏')
  323. } else if (this.dataObj.carModel[i] == '3') {
  324. this.checkboxValue1.push('集装箱')
  325. } else if (this.dataObj.carModel[i] == '4') {
  326. this.checkboxValue1.push('自卸车')
  327. }
  328. }
  329. if (this.dataObj.freightAdvance) {
  330. this.dataObj.freightAdvance = true
  331. } else {
  332. this.dataObj.freightAdvance = false
  333. }
  334. console.log(this.dataObj)
  335. this.validityPeriod = this.$helper.makeValidityPeriod(0, '随时')
  336. this.validityPeriodcq = this.$helper.makeValidityPeriod(0, '随时')
  337. },
  338. computed: {
  339. ...mapState(['hasLogin', 'userInfo']),
  340. },
  341. methods: {
  342. changeHandler(e) {
  343. const {
  344. columnIndex,
  345. value,
  346. values,
  347. index,
  348. picker = this.$refs.uPicker
  349. } = e
  350. // if (columnIndex === 0) {
  351. //
  352. // if (e.index != 0) {
  353. // picker.setColumnValues(1, this.validityPeriod[1].shift())
  354. // }
  355. // } else if (columnIndex === 1) {
  356. // if (e.index != 0) {
  357. // picker.setColumnValues(2, this.validityPeriod[2].shift())
  358. // }
  359. // }
  360. },
  361. selectCargoOwnerClose() {
  362. this.show = false
  363. },
  364. confirmSelectCargoOwner(e) {
  365. this.dataObj.cargoOwner = e.value[0]
  366. this.show = false
  367. },
  368. selectCargoOwner() {
  369. this.show = true
  370. },
  371. selectAddress(type) {
  372. uni.$u.route('/pages/release/selectAddress', {
  373. type: type,
  374. });
  375. },
  376. checkboxChange(n) {
  377. console.log('change', n);
  378. },
  379. selectValidityPeriodcq() {
  380. this.isShowcardValidity = true
  381. },
  382. confirmValidityPeriod(e) {
  383. console.log('confirm', e)
  384. if (!e.value[1] || !e.value[2]) {
  385. this.$refs.uToast.show({
  386. type: 'error',
  387. message: "日期格式错误,请重新选择!",
  388. })
  389. return
  390. }
  391. switch (this.ValidityPeriodType) {
  392. case 0:
  393. this.dataObj.loadingDateStart = e.value[0] + '-' + e.value[1] + '-' + e.value[2]
  394. break
  395. case 1:
  396. this.dataObj.loadingDateEnd = e.value[0] + '-' + e.value[1] + '-' + e.value[2]
  397. break
  398. }
  399. this.isShowValidity = false
  400. },
  401. confirmValidityPeriodcq(e) {
  402. console.log('confirm', e)
  403. this.dataObj.taskValidity = e.value[0] + '-' + e.value[1] + '-' + e.value[2]
  404. this.isShowcardValidity = false
  405. },
  406. selectValidityPeriod(type) {
  407. this.ValidityPeriodType = type
  408. this.isShowValidity = true
  409. },
  410. change(e) {
  411. console.log('change', e);
  412. },
  413. back() {
  414. uni.navigateBack()
  415. },
  416. goToRecord() {
  417. uni.$u.route('/pages/release/record');
  418. },
  419. radioChange(n) {
  420. console.log('radioChange', n);
  421. this.dataDetails.type = n
  422. },
  423. submit() {
  424. uni.showLoading({
  425. mask: true,
  426. title: '加载中...'
  427. })
  428. // 校验没写
  429. if (this.dataObj.billingMethod == '元/吨') {
  430. this.dataObj.billingMethod = 0
  431. } else {
  432. this.dataObj.billingMethod = 1
  433. }
  434. if (this.dataObj.freightAdvance) {
  435. this.dataObj.freightAdvance = 1
  436. } else {
  437. this.dataObj.freightAdvance = 0
  438. }
  439. let _list = []
  440. for (let i = 0; i < this.checkboxValue1.length; i++) {
  441. if (this.checkboxValue1 == '不限') {
  442. _list.push(1)
  443. } else if (this.checkboxValue1 == '高栏') {
  444. _list.push(2)
  445. } else if (this.checkboxValue1 == '集装箱') {
  446. _list.push(3)
  447. } else if (this.checkboxValue1 == '自卸车') {
  448. _list.push(4)
  449. }
  450. }
  451. this.dataObj.carModel = _list.toString()
  452. this.dataObj.commonId = this.userInfo.id
  453. this.$request.baseRequest('post', '/publishTaskInfo/api/editTask', this.dataObj).then(res => {
  454. uni.hideLoading()
  455. this.$refs.uToast.show({
  456. type: 'success',
  457. message: "发布成功",
  458. complete() {
  459. this.dataObj = {}
  460. uni.$u.route('/pages/release/record');
  461. }
  462. })
  463. })
  464. .catch(res => {
  465. uni.showToast({
  466. title: res.message,
  467. icon: 'none',
  468. duration: 2000
  469. })
  470. });
  471. },
  472. }
  473. }
  474. </script>
  475. <style scoped lang="scss">
  476. .input {
  477. text-align: right;
  478. }
  479. .title {
  480. padding: 0 20rpx;
  481. display: flex;
  482. justify-content: center;
  483. position: relative;
  484. .nav-title {
  485. font-size: 32rpx;
  486. }
  487. .back {
  488. position: absolute;
  489. left: 20rpx;
  490. }
  491. .search {
  492. display: flex;
  493. align-items: center;
  494. position: absolute;
  495. right: 20rpx;
  496. }
  497. }
  498. .fixed1 {
  499. height: var(--status-bar-height);
  500. }
  501. .row {
  502. display: flex;
  503. justify-content: space-between;
  504. }
  505. .content1 {
  506. background: white;
  507. margin: var(--status-bar-height) 20rpx 0 20rpx;
  508. border-radius: 20rpx;
  509. padding: 40rpx;
  510. .select-sf {
  511. color: #999999;
  512. }
  513. .right {
  514. color: #CBCBCB
  515. }
  516. }
  517. .content2,
  518. .content3,
  519. .content5 {
  520. box-sizing: border-box;
  521. background: white;
  522. border-radius: 20rpx;
  523. padding: 20rpx;
  524. margin: 20rpx;
  525. .row {
  526. margin: 30rpx;
  527. }
  528. .row1,
  529. .row2 {
  530. display: flex;
  531. justify-content: space-between;
  532. align-items: center;
  533. .left .top {
  534. display: flex;
  535. }
  536. }
  537. }
  538. .select-type {
  539. display: flex;
  540. justify-content: flex-end;
  541. }
  542. .content2 {
  543. padding: 40rpx;
  544. .row1,
  545. .row2 {
  546. .left {
  547. width: 100%;
  548. }
  549. .right {
  550. color: #CBCBCB
  551. }
  552. }
  553. .row2 {
  554. margin-top: 40rpx;
  555. }
  556. .top {
  557. display: flex;
  558. align-items: center;
  559. }
  560. .bottom {
  561. margin-top: 10rpx;
  562. padding-left: 72rpx;
  563. }
  564. .title {
  565. font-size: 36rpx;
  566. font-weight: 700;
  567. color: #171717;
  568. }
  569. .collect {
  570. width: 40rpx;
  571. height: 40rpx;
  572. line-height: 40rpx;
  573. background: #2772FB;
  574. color: white;
  575. padding: 6rpx;
  576. border-radius: 50%;
  577. text-align: center;
  578. }
  579. .send {
  580. width: 40rpx;
  581. height: 40rpx;
  582. line-height: 40rpx;
  583. background: #101010;
  584. color: white;
  585. padding: 6rpx;
  586. border-radius: 50%;
  587. text-align: center;
  588. }
  589. }
  590. .content3 {}
  591. .content4 {
  592. margin: 20rpx;
  593. padding-left: 20rpx;
  594. .title {
  595. color: #999999;
  596. }
  597. .btn-text {
  598. color: #2772FB;
  599. border: 1px solid #2772FB;
  600. border-radius: 40rpx;
  601. padding: 0rpx 10rpx;
  602. box-sizing: border-box;
  603. }
  604. }
  605. .submit {
  606. width: 90%;
  607. margin: 100rpx auto;
  608. font-size: 36rpx;
  609. font-weight: 500;
  610. color: #FFFFFF;
  611. background: #2772FB;
  612. text-align: center;
  613. padding: 20rpx 0;
  614. border-radius: 50rpx;
  615. }
  616. .select-data {
  617. color: #999999;
  618. }
  619. .row-bgc {
  620. background: #F7F8FA;
  621. padding: 20rpx 30rpx;
  622. box-sizing: border-box;
  623. border-radius: 10rpx;
  624. }
  625. .car-input {
  626. // padding:20rpx;
  627. // box-sizing: border-box;
  628. // border-radius: 10px;
  629. }
  630. .car-line {
  631. margin: 0 20rpx;
  632. }
  633. .car-row {
  634. display: flex;
  635. background: white;
  636. padding: 20rpx;
  637. box-sizing: border-box;
  638. border-radius: 10rpx;
  639. }
  640. </style>