grainDeliveryRegistration1.vue 14 KB

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