grainDeliveryRegistration.vue 15 KB

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