grainDeliveryRegistration.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template>
  2. <view class="content">
  3. <view class="content1">
  4. <view class="row1">
  5. <view class="title">{{dataList.warehouseName}}</view>
  6. <view class="validityDate"> {{dataList.validityDate}} 0时前有效期</view>
  7. </view>
  8. <view class="row2">
  9. <view class="start-time">{{startDate}}创建</view>
  10. </view>
  11. <view class="row3">
  12. <view class='locationwrap'>
  13. <image class='location' src="../../../static/img/liangmai/icon_ditu.png" mode=""></image>
  14. <view class="position">{{warehouseNameAddress}}</view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="content2">
  19. <view class="wrap wrap1" v-for="(item,index) in dataList.shippingInformationList" :key='index'>
  20. <view class="row1 row">
  21. <!-- -{{item.customerName}} -->
  22. <view class="customerName">货主-{{index+1}}</view>
  23. <image src="../../../static/img/sign/shanchu@2x.png" @click="reduceBtn(index)"></image>
  24. </view>
  25. <view class="row2 row">
  26. <view class="left">姓名</view>
  27. <view class="right" @click='showCustomerName(item,index)'>
  28. <view>{{item.shipperName}}</view>
  29. <u-picker @confirm="nameConfirm" range-key='customerName' mode="selector"
  30. v-model="item.showCustomerName" :range="nameList"></u-picker>
  31. <u-icon name="arrow-right"></u-icon>
  32. </view>
  33. </view>
  34. <view class="row3 row">
  35. <view class="left">
  36. 供应商(送粮人)
  37. </view>
  38. <view class="right">{{item.supplier}}</view>
  39. </view>
  40. <view class="row4 row" v-for="(item1,index1) in item.carNumberList" :key='index1'>
  41. <view class="left">
  42. 车牌号-{{index1+1}}
  43. </view>
  44. <view class="right">
  45. <u-input v-model="item1.carNo" placeholder="输入7位车牌号" />
  46. <view class="btn">
  47. <view @click="addCarNumber(item.carNumberList)" style="margin-right: 20rpx;">
  48. <image class='row4-img'
  49. src="https://taohaoliang.oss-cn-beijing.aliyuncs.com/app/tmp/jia%402x.png"></image>
  50. </view>
  51. <view @click="delCarNumber(item.carNumberList,index1)">
  52. <image class='row4-img'
  53. src="https://taohaoliang.oss-cn-beijing.aliyuncs.com/app/tmp/jian%402x.png"></image>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <view class='add-good-people' @click='addGoodPeople'>
  60. <image class="img"
  61. src="https://taohaoliang.oss-cn-beijing.aliyuncs.com/app/tmp/ic_join_dialing_norm%402x.png"
  62. @click="reduceBtn(index)"></image>增加货主
  63. </view>
  64. </view>
  65. <u-button class='submit' @click='submit'>提交</u-button>
  66. <u-modal v-model="isShowAlert" :title-style="{fontSize: '18px',fontWeight:'500'}"
  67. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='登录提示'
  68. showCancelButton='false' :content="content" @confirm="alertBtn" @cancel="cancelClick"></u-modal>
  69. <u-modal v-model="isShowAlert1" :title-style="{fontSize: '18px',fontWeight:'500'}"
  70. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='登录提示'
  71. showCancelButton='false' :content="content1" @confirm="alertBtn" @cancel="cancelClick"></u-modal>
  72. </view>
  73. </template>
  74. <script>
  75. import {
  76. mapState
  77. } from 'vuex';
  78. export default {
  79. components: {
  80. },
  81. data() {
  82. return {
  83. isShowAlert: false,
  84. isShowAlert1: false,
  85. content: '当前登入信息验证失败,是否重新登录?',
  86. content1: '确定提交送粮信息?',
  87. // show: false,
  88. show1: false,
  89. cargoOwner: [{
  90. name: '123'
  91. }],
  92. nameList: [],
  93. warehouseNameAddress: '',
  94. startDate: "",
  95. dataList: {
  96. warehouseName: "",
  97. validityDate: '',
  98. commonId: uni.getStorageSync("userInfo").id,
  99. shippingInformationList: [{
  100. identityId: '',
  101. shipperName: '',
  102. supplier: '无',
  103. carNo: '',
  104. showCustomerName: false,
  105. carNumberList: [{
  106. carNo: ''
  107. }]
  108. }]
  109. },
  110. selectObj: {},
  111. nameListCopy: []
  112. }
  113. },
  114. onLoad(options) {
  115. let _pageToData = JSON.parse(options.itemValue)
  116. this.dataList.warehouseName = _pageToData.warehouseName
  117. this.startDate = this.getTime()[0]
  118. this.dataList.validityDate = this.getTime()[1]
  119. this.warehouseNameAddress = _pageToData.warehousePrivate + _pageToData.warehouseCity + _pageToData
  120. .warehouseArea + _pageToData.detailedAddress
  121. },
  122. computed: {
  123. ...mapState(['hasLogin', 'userInfo']),
  124. },
  125. onShow() {
  126. this.$api.doRequest('get', '/commonUser/api/checkSession').then(res => {
  127. console.log("checkSession", res)
  128. if (res.data.data == "INVALID") {
  129. this.isShowAlert = true;
  130. }
  131. this.getCustomer()
  132. })
  133. console.log("hasLogin", this.hasLogin)
  134. },
  135. methods: {
  136. showCustomerName(value, index) {
  137. this.selectObj = value
  138. this.selectObj.index = index
  139. value.showCustomerName = true
  140. },
  141. getCustomer() {
  142. let _data = {
  143. commonId: uni.getStorageSync("userInfo").id,
  144. }
  145. this.$api.doRequest('get', '/identityAuthenticationInfo/identityAuthenticationInfoUser', _data).then(
  146. res => {
  147. if (res.data.code == 200) {
  148. this.nameList = res.data.data
  149. this.dataList.shippingInformationList[0].identityId = res.data.data[0].id
  150. this.dataList.shippingInformationList[0].shipperName = res.data.data[0].customerName
  151. this.dataList.shippingInformationList[0].supplier = res.data.data[0].supplier ? res.data
  152. .data[0].supplier : '无'
  153. }
  154. })
  155. },
  156. getTime() {
  157. let _startTime = new Date().format("yyyy-MM-dd");
  158. var _endTime = new Date();
  159. _endTime.setDate(_endTime.getDate() + 2);
  160. _endTime = _endTime.format("yyyy-MM-dd");
  161. return [_startTime, _endTime]
  162. },
  163. reduceBtn(index) {
  164. if (this.dataList.shippingInformationList.length > 1) {
  165. this.dataList.shippingInformationList.splice(index, 1)
  166. this.$forceUpdate()
  167. } else {
  168. this.$api.msg('至少保留一位货主!')
  169. }
  170. },
  171. submit() {
  172. this.isShowAlert1 = true
  173. },
  174. nameConfirm(e) {
  175. console.log(e)
  176. this.dataList.shippingInformationList[this.selectObj["index"]].shipperName = this.nameList[e[0]]
  177. .customerName
  178. this.dataList.shippingInformationList[this.selectObj["index"]].supplier = this.nameList[e[0]].supplier
  179. this.dataList.shippingInformationList[this.selectObj["index"]].identityId = this.nameList[e[0]].id
  180. // 备份货主列表,用于删除货主操作
  181. this.nameListCopy = this.$u.deepClone(this.nameList);
  182. this.nameListCopy.splice(e[0], 1)
  183. },
  184. /**
  185. * 统一跳转接口,拦截未登录路由
  186. * navigator标签现在默认没有转场动画,所以用view
  187. */
  188. navTo(url) {
  189. if (!this.hasLogin) {
  190. url = '/pages/public/login';
  191. }
  192. uni.navigateTo({
  193. url
  194. })
  195. },
  196. alertBtn() {
  197. let _isCanSubmit = this.validate()
  198. if (_isCanSubmit) {
  199. // 处理车牌号数据
  200. for (let i = 0; i < this.dataList.shippingInformationList.length; i++) {
  201. let _data = this.dataList.shippingInformationList[i]
  202. let _index = 0
  203. for (let k = 0; k < _data.carNumberList.length; k++) {
  204. _index++
  205. if (_data.carNumberList.length < 1) {
  206. _data.carNo = _data.carNumberList[k].carNo
  207. } else if (k < _data.carNumberList.length - 1) {
  208. _data.carNo += _data.carNumberList[k].carNo + ','
  209. } else {
  210. _data.carNo += _data.carNumberList[k].carNo
  211. }
  212. }
  213. }
  214. //拷贝dataList用于提交数据
  215. let _dataList = this.$u.deepClone(this.dataList);
  216. for (let i = 0; i < _dataList.shippingInformationList.length; i++) {
  217. let _data = _dataList.shippingInformationList[i]
  218. delete _data.carNumberList
  219. delete _data.index
  220. delete _data.showCustomerName
  221. }
  222. this.$api.doRequest('post', '/grainDeliveryRegistration/api/insertInfo', _dataList).then(res => {
  223. if (res.data.code == 200) {
  224. debugger
  225. this.$api.msg('添加成功!')
  226. setTimeout(function() {
  227. uni.navigateBack()
  228. }, 1000)
  229. } else {
  230. this.$api.msg('添加失败!')
  231. }
  232. })
  233. }
  234. },
  235. validate() {
  236. let _val = true
  237. for (let i = 0; i < this.dataList.shippingInformationList.length; i++) {
  238. let _data = this.dataList.shippingInformationList[i]
  239. for (let k = 0; k < _data.carNumberList.length; k++) {
  240. if (!_data.carNumberList[k].carNo) {
  241. this.$api.msg('车牌号不能为空!')
  242. return false
  243. } else if (_data.carNumberList[k].carNo.length != 7) {
  244. this.$api.msg('车牌号输入错误!')
  245. return false
  246. }
  247. }
  248. }
  249. return _val
  250. },
  251. cancelClick() {
  252. this.isShowAlert = false
  253. this.isShowAlert1 = false
  254. },
  255. addGoodPeople() {
  256. // 判断是否还有剩余的货主
  257. if (this.nameListCopy.length != 0) {
  258. this.dataList.shippingInformationList.push({
  259. shipperName: '',
  260. supplier: '无',
  261. carNo: '',
  262. showCustomerName: false,
  263. carNumberList: [{
  264. carNo: ''
  265. }]
  266. })
  267. } else {
  268. this.$api.msg('无更多认证货主!')
  269. }
  270. },
  271. addCarNumber(val) {
  272. val.push({
  273. carNo: ''
  274. })
  275. },
  276. delCarNumber(val, index) {
  277. if (val.length > 1) {
  278. val.splice(index, 1)
  279. this.$forceUpdate()
  280. } else {
  281. this.$api.msg('至少保留一个车牌号!')
  282. }
  283. }
  284. }
  285. }
  286. </script>
  287. <style lang='scss' scoped>
  288. page {
  289. background: #F5F6FA;
  290. }
  291. .wrap {
  292. background: #fff;
  293. margin: 10px;
  294. border-radius: 10px;
  295. padding: 10px;
  296. }
  297. .location {
  298. width: 32rpx;
  299. height: 32rpx;
  300. margin-right: 10rpx;
  301. position: absolute;
  302. left: 20rpx
  303. }
  304. .locationwrap {
  305. display: flex;
  306. align-items: center;
  307. position: relative;
  308. }
  309. .position {
  310. font-size: 24rpx;
  311. padding: 6rpx 16rpx 6rpx 60rpx;
  312. border-radius: 30rpx;
  313. background: #F5F6FA;
  314. }
  315. .content1 {
  316. background: white;
  317. margin: 20rpx;
  318. padding: 30rpx 20rpx;
  319. border-radius: 20rpx;
  320. .row1 {
  321. display: flex;
  322. justify-content: space-between;
  323. .title {
  324. font-size: 32rpx;
  325. color: #333;
  326. font-weight: 700;
  327. }
  328. .validityDate {
  329. font-size: 24rpx;
  330. color: #FD714F;
  331. position: relative;
  332. top: -10rpx;
  333. }
  334. }
  335. .row2 {
  336. .start-time {
  337. font-size: 24rpx;
  338. color: #878C9C;
  339. margin: 6rpx 0;
  340. }
  341. }
  342. }
  343. .content2 {
  344. .row {
  345. margin: 20rpx 0;
  346. }
  347. .row1 {
  348. display: flex;
  349. justify-content: space-between;
  350. image {
  351. width: 32rpx;
  352. height: 32rpx;
  353. }
  354. .customerName {
  355. font-size: 28rpx;
  356. font-weight: 700;
  357. color: #333333;
  358. }
  359. }
  360. .row2,
  361. .row3,
  362. .row4 {
  363. display: flex;
  364. justify-content: space-between;
  365. .right {
  366. display: flex;
  367. }
  368. }
  369. }
  370. .row4 {
  371. display: flex;
  372. align-items: center;
  373. .right {
  374. .btn {
  375. display: flex;
  376. align-items: center;
  377. }
  378. }
  379. }
  380. .row4-img {
  381. width: 32rpx;
  382. height: 32rpx;
  383. }
  384. .add-good-people {
  385. border-radius: 45rpx;
  386. width: 96%;
  387. margin: 20rpx auto;
  388. text-align: center;
  389. background-color: white;
  390. font-size: 34rpx;
  391. font-weight: 500;
  392. color: #00C265;
  393. padding: 20rpx 0;
  394. display: flex;
  395. justify-content: center;
  396. align-items: center;
  397. .img {
  398. width: 32rpx;
  399. height: 32rpx;
  400. margin-right: 10rpx;
  401. }
  402. }
  403. .submit {
  404. position: fixed;
  405. bottom: 20rpx;
  406. background: #22C572;
  407. border-radius: 46px;
  408. font-size: 34rpx;
  409. font-weight: 500;
  410. color: #FFFFFF;
  411. width: 96%;
  412. margin-left: 2%;
  413. }
  414. .content {
  415. padding-bottom: 200rpx;
  416. }
  417. </style>