grainDeliveryRegistration.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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. if(res.data.data.length>0){
  150. this.dataList.shippingInformationList[0].identityId = res.data.data[0].id
  151. this.dataList.shippingInformationList[0].shipperName = res.data.data[0].customerName
  152. this.dataList.shippingInformationList[0].supplier = res.data.data[0].supplier ? res.data
  153. .data[0].supplier : '无'
  154. }
  155. }
  156. })
  157. },
  158. getTime() {
  159. let _startTime = new Date().format("yyyy-MM-dd");
  160. var _endTime = new Date();
  161. _endTime.setDate(_endTime.getDate() + 2);
  162. _endTime = _endTime.format("yyyy-MM-dd");
  163. return [_startTime, _endTime]
  164. },
  165. reduceBtn(index) {
  166. if (this.dataList.shippingInformationList.length > 1) {
  167. this.dataList.shippingInformationList.splice(index, 1)
  168. this.$forceUpdate()
  169. } else {
  170. this.$api.msg('至少保留一位货主!')
  171. }
  172. },
  173. submit() {
  174. this.isShowAlert1 = true
  175. },
  176. nameConfirm(e) {
  177. console.log(e)
  178. this.dataList.shippingInformationList[this.selectObj["index"]].shipperName = this.nameList[e[0]]
  179. .customerName
  180. this.dataList.shippingInformationList[this.selectObj["index"]].supplier = this.nameList[e[0]].supplier
  181. this.dataList.shippingInformationList[this.selectObj["index"]].identityId = this.nameList[e[0]].id
  182. // 备份货主列表,用于删除货主操作
  183. this.nameListCopy = this.$u.deepClone(this.nameList);
  184. this.nameListCopy.splice(e[0], 1)
  185. },
  186. /**
  187. * 统一跳转接口,拦截未登录路由
  188. * navigator标签现在默认没有转场动画,所以用view
  189. */
  190. navTo(url) {
  191. if (!this.hasLogin) {
  192. url = '/pages/public/login';
  193. }
  194. uni.navigateTo({
  195. url
  196. })
  197. },
  198. alertBtn() {
  199. let _isCanSubmit = this.validate()
  200. if (_isCanSubmit) {
  201. // 处理车牌号数据
  202. for (let i = 0; i < this.dataList.shippingInformationList.length; i++) {
  203. let _data = this.dataList.shippingInformationList[i]
  204. let _index = 0
  205. for (let k = 0; k < _data.carNumberList.length; k++) {
  206. _index++
  207. if (_data.carNumberList.length < 1) {
  208. _data.carNo = _data.carNumberList[k].carNo
  209. } else if (k < _data.carNumberList.length - 1) {
  210. _data.carNo += _data.carNumberList[k].carNo + ','
  211. } else {
  212. _data.carNo += _data.carNumberList[k].carNo
  213. }
  214. }
  215. }
  216. //拷贝dataList用于提交数据
  217. let _dataList = this.$u.deepClone(this.dataList);
  218. for (let i = 0; i < _dataList.shippingInformationList.length; i++) {
  219. let _data = _dataList.shippingInformationList[i]
  220. delete _data.carNumberList
  221. delete _data.index
  222. delete _data.showCustomerName
  223. }
  224. this.$api.doRequest('post', '/grainDeliveryRegistration/api/insertInfo', _dataList).then(res => {
  225. if (res.data.code == 200) {
  226. this.$api.msg('添加成功!')
  227. setTimeout(function() {
  228. uni.navigateBack()
  229. }, 1000)
  230. } else {
  231. this.$api.msg('添加失败!')
  232. }
  233. })
  234. }
  235. },
  236. validate() {
  237. let _val = true
  238. for (let i = 0; i < this.dataList.shippingInformationList.length; i++) {
  239. let _data = this.dataList.shippingInformationList[i]
  240. for (let k = 0; k < _data.carNumberList.length; k++) {
  241. if (!_data.carNumberList[k].carNo) {
  242. this.$api.msg('车牌号不能为空!')
  243. return false
  244. } else if (_data.carNumberList[k].carNo.length != 7) {
  245. this.$api.msg('车牌号输入错误!')
  246. return false
  247. }
  248. }
  249. }
  250. return _val
  251. },
  252. cancelClick() {
  253. this.isShowAlert = false
  254. this.isShowAlert1 = false
  255. },
  256. addGoodPeople() {
  257. // 判断是否还有剩余的货主
  258. if (this.nameList.length != this.dataList.shippingInformationList.length) {
  259. this.dataList.shippingInformationList.push({
  260. shipperName: '',
  261. supplier: '无',
  262. carNo: '',
  263. showCustomerName: false,
  264. carNumberList: [{
  265. carNo: ''
  266. }]
  267. })
  268. } else {
  269. this.$api.msg('无更多认证货主!')
  270. }
  271. },
  272. addCarNumber(val) {
  273. val.push({
  274. carNo: ''
  275. })
  276. },
  277. delCarNumber(val, index) {
  278. if (val.length > 1) {
  279. val.splice(index, 1)
  280. this.$forceUpdate()
  281. } else {
  282. this.$api.msg('至少保留一个车牌号!')
  283. }
  284. }
  285. }
  286. }
  287. </script>
  288. <style lang='scss' scoped>
  289. page {
  290. background: #F5F6FA;
  291. }
  292. .wrap {
  293. background: #fff;
  294. margin: 10px;
  295. border-radius: 10px;
  296. padding: 10px;
  297. }
  298. .location {
  299. width: 32rpx;
  300. height: 32rpx;
  301. margin-right: 10rpx;
  302. position: absolute;
  303. left: 20rpx
  304. }
  305. .locationwrap {
  306. display: flex;
  307. align-items: center;
  308. position: relative;
  309. }
  310. .position {
  311. font-size: 24rpx;
  312. padding: 6rpx 16rpx 6rpx 60rpx;
  313. border-radius: 30rpx;
  314. background: #F5F6FA;
  315. }
  316. .content1 {
  317. background: white;
  318. margin: 20rpx;
  319. padding: 30rpx 20rpx;
  320. border-radius: 20rpx;
  321. .row1 {
  322. display: flex;
  323. justify-content: space-between;
  324. .title {
  325. font-size: 32rpx;
  326. color: #333;
  327. font-weight: 700;
  328. }
  329. .validityDate {
  330. font-size: 24rpx;
  331. color: #FD714F;
  332. position: relative;
  333. top: -10rpx;
  334. }
  335. }
  336. .row2 {
  337. .start-time {
  338. font-size: 24rpx;
  339. color: #878C9C;
  340. margin: 6rpx 0;
  341. }
  342. }
  343. }
  344. .content2 {
  345. .row {
  346. margin: 20rpx 0;
  347. }
  348. .row1 {
  349. display: flex;
  350. justify-content: space-between;
  351. image {
  352. width: 32rpx;
  353. height: 32rpx;
  354. }
  355. .customerName {
  356. font-size: 28rpx;
  357. font-weight: 700;
  358. color: #333333;
  359. }
  360. }
  361. .row2,
  362. .row3,
  363. .row4 {
  364. display: flex;
  365. justify-content: space-between;
  366. .right {
  367. display: flex;
  368. }
  369. }
  370. }
  371. .row4 {
  372. display: flex;
  373. align-items: center;
  374. .right {
  375. .btn {
  376. display: flex;
  377. align-items: center;
  378. }
  379. }
  380. }
  381. .row4-img {
  382. width: 32rpx;
  383. height: 32rpx;
  384. }
  385. .add-good-people {
  386. border-radius: 45rpx;
  387. width: 96%;
  388. margin: 20rpx auto;
  389. text-align: center;
  390. background-color: white;
  391. font-size: 34rpx;
  392. font-weight: 500;
  393. color: #00C265;
  394. padding: 20rpx 0;
  395. display: flex;
  396. justify-content: center;
  397. align-items: center;
  398. .img {
  399. width: 32rpx;
  400. height: 32rpx;
  401. margin-right: 10rpx;
  402. }
  403. }
  404. .submit {
  405. position: fixed;
  406. bottom: 20rpx;
  407. background: #22C572;
  408. border-radius: 46px;
  409. font-size: 34rpx;
  410. font-weight: 500;
  411. color: #FFFFFF;
  412. width: 96%;
  413. margin-left: 2%;
  414. }
  415. .content {
  416. padding-bottom: 200rpx;
  417. }
  418. </style>