grainDeliveryRegistration.vue 14 KB

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