grainDeliveryRegistration.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  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', '/qualityInspectionManagement/api/goodsName', {
  155. warehouseId: this.warehouseId
  156. }).then(res => {
  157. if (res.data.code == 200) {
  158. this.goodsName = res.data.data[0]?res.data.data[0].goodsName:''
  159. this.goodsnameList = res.data.data
  160. }
  161. this.$api.doRequest('get', '/commonUser/api/checkSession').then(res => {
  162. console.log("checkSession", res)
  163. if (res.data.data == "INVALID") {
  164. this.isShowAlert = true;
  165. }
  166. this.getCustomer()
  167. })
  168. })
  169. },
  170. methods: {
  171. keyClose(){
  172. this.keyShow = false
  173. },
  174. goodsnameConfirm(e) {
  175. this.goodsName = this.goodsnameList[e[0]].goodsName
  176. this.getCustomer()
  177. },
  178. showgoodsName() {
  179. this.goodsNameshow = true
  180. },
  181. hidden() {
  182. this.carNo = ''
  183. if (this.$refs.keyboard.open) {
  184. this.$refs.keyboard.open(false) //true 键盘显示 false 键盘隐藏
  185. } else {
  186. this.$refs.keyboard[0].open(false)
  187. }
  188. },
  189. handleShowKeyboard(index, index1) {
  190. if (this.dataList.shippingInformationList[index].carNumberList[index1].carNo == '') {
  191. this.carNo = ''
  192. } else {
  193. this.carNo = this.dataList.shippingInformationList[index].carNumberList[index1].carNo
  194. }
  195. if (this.$refs.keyboard.open) {
  196. this.$refs.keyboard.open(false) //true 键盘显示 false 键盘隐藏
  197. } else {
  198. this.$refs.keyboard[0].open(false)
  199. }
  200. this.index = index
  201. this.index1 = index1
  202. if (this.$refs.keyboard.open) {
  203. this.$refs.keyboard.open(true) //true 键盘显示 false 键盘隐藏
  204. } else {
  205. this.$refs.keyboard[0].open(true)
  206. }
  207. },
  208. handleClick(e) {
  209. this.carNo = e.value
  210. this.dataList.shippingInformationList[this.index].carNumberList[this.index1].carNo = e.value //键盘输入值
  211. },
  212. showCustomerName(value, index) {
  213. this.selectObj = value
  214. this.selectObj.index = index
  215. value.showCustomerName = true
  216. },
  217. getCustomer() {
  218. var that = this
  219. let _data = {
  220. commonId: uni.getStorageSync("userInfo").id,
  221. warehouseId: this.warehouseId,
  222. goodsName: this.goodsName
  223. }
  224. this.$api.doRequest('get', '/identityAuthenticationInfo/identityAuthenticationInfoUser', _data).then(
  225. res => {
  226. if (res.data.code == 200) {
  227. this.nameList = res.data.data
  228. if (res.data.data.length > 0) {
  229. that.status = false
  230. this.dataList.shippingInformationList[0].identityId = res.data.data[0].id
  231. this.dataList.shippingInformationList[0].shipperName = res.data.data[0].customerName
  232. this.dataList.shippingInformationList[0].supplier = res.data.data[0].supplier ? res
  233. .data
  234. .data[0].supplier : '无'
  235. } else {
  236. that.status = true
  237. this.$api.msg('当前客户的' + this.goodsName + '送粮量达到上限')
  238. }
  239. }
  240. else if(res.data.code == 11019){
  241. this.$api.msg('未认证粮商身份')
  242. }
  243. else if(res.data.code == 11021){
  244. this.$api.msg('该仓库未设置收购价格或收购价格正在审核中')
  245. }
  246. })
  247. },
  248. getTime() {
  249. let _startTime = new Date().format("yyyy-MM-dd");
  250. var _endTime = new Date();
  251. _endTime.setDate(_endTime.getDate() + 3);
  252. _endTime = _endTime.format("yyyy-MM-dd");
  253. return [_startTime, _endTime]
  254. },
  255. reduceBtn(index) {
  256. if (this.dataList.shippingInformationList.length > 1) {
  257. this.dataList.shippingInformationList.splice(index, 1)
  258. this.$forceUpdate()
  259. } else {
  260. this.$api.msg('至少保留一位货主!')
  261. }
  262. },
  263. submit() {
  264. this.isShowAlert1 = true
  265. },
  266. nameConfirm(e) {
  267. this.dataList.shippingInformationList[this.selectObj["index"]].shipperName = this.nameList[e[0]]
  268. .customerName
  269. this.dataList.shippingInformationList[this.selectObj["index"]].supplier = this.nameList[e[0]].supplier
  270. this.dataList.shippingInformationList[this.selectObj["index"]].identityId = this.nameList[e[0]].id
  271. // 备份货主列表,用于删除货主操作
  272. this.nameListCopy = this.$u.deepClone(this.nameList);
  273. this.nameListCopy.splice(e[0], 1)
  274. },
  275. /**
  276. * 统一跳转接口,拦截未登录路由
  277. * navigator标签现在默认没有转场动画,所以用view
  278. */
  279. navTo(url) {
  280. if (!this.hasLogin) {
  281. url = '/pages/public/login';
  282. }
  283. uni.navigateTo({
  284. url
  285. })
  286. },
  287. alertBtn() {
  288. let _isCanSubmit = this.validate()
  289. if (_isCanSubmit) {
  290. // 处理车牌号数据
  291. for (let i = 0; i < this.dataList.shippingInformationList.length; i++) {
  292. let _data = this.dataList.shippingInformationList[i]
  293. let _index = 0
  294. for (let k = 0; k < _data.carNumberList.length; k++) {
  295. _index++
  296. if (_data.carNumberList.length < 1) {
  297. _data.carNo = _data.carNumberList[k].carNo
  298. } else if (k < _data.carNumberList.length - 1) {
  299. _data.carNo += _data.carNumberList[k].carNo + ','
  300. } else {
  301. _data.carNo += _data.carNumberList[k].carNo
  302. }
  303. }
  304. }
  305. //拷贝dataList用于提交数据
  306. let _dataList = this.$u.deepClone(this.dataList);
  307. for (let i = 0; i < _dataList.shippingInformationList.length; i++) {
  308. let _data = _dataList.shippingInformationList[i]
  309. delete _data.carNumberList
  310. delete _data.index
  311. delete _data.showCustomerName
  312. }
  313. this.$api.doRequest('post', '/grainDeliveryRegistration/api/insertInfo', _dataList).then(res => {
  314. if (res.data.code == 200) {
  315. this.$api.msg('添加成功!')
  316. setTimeout(function() {
  317. uni.navigateBack()
  318. }, 1000)
  319. } else {
  320. this.$api.msg('添加失败!')
  321. }
  322. })
  323. }
  324. },
  325. validate() {
  326. let _val = true
  327. for (let i = 0; i < this.dataList.shippingInformationList.length; i++) {
  328. let _data = this.dataList.shippingInformationList[i]
  329. for (let k = 0; k < _data.carNumberList.length; k++) {
  330. if (!_data.carNumberList[k].carNo) {
  331. this.$api.msg('车牌号不能为空!')
  332. return false
  333. } else if (_data.carNumberList[k].carNo.length != 7) {
  334. this.$api.msg('车牌号输入错误!')
  335. return false
  336. }
  337. }
  338. }
  339. return _val
  340. },
  341. cancelClick() {
  342. this.isShowAlert = false
  343. this.isShowAlert1 = false
  344. },
  345. addGoodPeople() {
  346. if (this.status == true) {
  347. this.$api.msg('当前客户的' + this.goodsName + '送粮量达到上限')
  348. return
  349. }
  350. // 判断是否还有剩余的货主
  351. if (this.nameList.length != this.dataList.shippingInformationList.length) {
  352. this.dataList.shippingInformationList.push({
  353. shipperName: '',
  354. supplier: '无',
  355. carNo: '',
  356. showCustomerName: false,
  357. carNumberList: [{
  358. carNo: ''
  359. }]
  360. })
  361. this.$forceUpdate()
  362. } else {
  363. this.$api.msg('无更多认证货主!')
  364. }
  365. },
  366. addCarNumber(val) {
  367. val.push({
  368. carNo: ''
  369. })
  370. },
  371. delCarNumber(val, index) {
  372. if (val.length > 1) {
  373. val.splice(index, 1)
  374. this.$forceUpdate()
  375. } else {
  376. this.$api.msg('至少保留一个车牌号!')
  377. }
  378. }
  379. }
  380. }
  381. </script>
  382. <style lang='scss' scoped>
  383. page {
  384. background: #F5F6FA;
  385. }
  386. .wrap {
  387. background: #fff;
  388. margin: 10px;
  389. border-radius: 10px;
  390. padding: 10px;
  391. }
  392. .location {
  393. width: 32rpx;
  394. height: 32rpx;
  395. margin-right: 10rpx;
  396. position: absolute;
  397. left: 20rpx
  398. }
  399. .locationwrap {
  400. display: flex;
  401. align-items: center;
  402. position: relative;
  403. }
  404. .position {
  405. font-size: 24rpx;
  406. padding: 6rpx 16rpx 6rpx 60rpx;
  407. border-radius: 30rpx;
  408. background: #F5F6FA;
  409. }
  410. .content1 {
  411. background: white;
  412. margin: 20rpx;
  413. padding: 30rpx 20rpx;
  414. border-radius: 20rpx;
  415. .row1 {
  416. display: flex;
  417. justify-content: space-between;
  418. .title {
  419. font-size: 32rpx;
  420. color: #333;
  421. font-weight: 700;
  422. }
  423. .validityDate {
  424. font-size: 24rpx;
  425. color: #FD714F;
  426. position: relative;
  427. top: -10rpx;
  428. }
  429. }
  430. .row2 {
  431. .start-time {
  432. font-size: 24rpx;
  433. color: #878C9C;
  434. margin: 10rpx 0;
  435. }
  436. }
  437. .row3 {
  438. margin-bottom: 10rpx;
  439. }
  440. }
  441. .content2 {
  442. .row {
  443. padding: 28rpx 0;
  444. border-bottom: 1px solid #EEEEEE;
  445. }
  446. .row1 {
  447. display: flex;
  448. justify-content: space-between;
  449. padding-top: 0rpx;
  450. image {
  451. width: 32rpx;
  452. height: 32rpx;
  453. }
  454. border: none;
  455. .customerName {
  456. font-size: 28rpx;
  457. font-weight: 700;
  458. color: #333333;
  459. }
  460. }
  461. .row2,
  462. .row3,
  463. .row4 {
  464. display: flex;
  465. justify-content: space-between;
  466. .right {
  467. display: flex;
  468. }
  469. }
  470. .row4:last-child {
  471. padding-bottom: 0;
  472. border: none;
  473. }
  474. }
  475. .row4 {
  476. display: flex;
  477. align-items: center;
  478. .right {
  479. .btn {
  480. display: flex;
  481. align-items: center;
  482. }
  483. }
  484. }
  485. .row4-img {
  486. width: 32rpx;
  487. height: 32rpx;
  488. }
  489. .add-good-people {
  490. border-radius: 45rpx;
  491. width: 96%;
  492. margin: 20rpx auto;
  493. text-align: center;
  494. background-color: white;
  495. font-size: 34rpx;
  496. font-weight: 500;
  497. color: #00C265;
  498. padding: 20rpx 0;
  499. display: flex;
  500. justify-content: center;
  501. align-items: center;
  502. .img {
  503. width: 32rpx;
  504. height: 32rpx;
  505. margin-right: 10rpx;
  506. }
  507. }
  508. .submit {
  509. position: fixed;
  510. bottom: 20rpx;
  511. background: #22C572;
  512. border-radius: 46px;
  513. font-size: 34rpx;
  514. font-weight: 500;
  515. color: #FFFFFF;
  516. width: 96%;
  517. margin-left: 2%;
  518. }
  519. .content {
  520. padding-bottom: 200rpx;
  521. }
  522. .car-uumber {
  523. font-size: 28rpx;
  524. }
  525. </style>