grainDeliveryRegistration.vue 14 KB

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