grainDeliveryRegistration1.vue 13 KB

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