grainDeliveryRegistration.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view class="">
  3. <view class="content1">
  4. <view>{{dataList.warehouseName}}</view>
  5. <view class="row2">
  6. <view class='locationwrap'>
  7. <image class='location' src="../../../static/img/liangmai/icon_ditu@2x.png" mode=""></image>
  8. {{warehouseNameAddress}}
  9. </view>
  10. </view>
  11. <view class="row3">
  12. <view>{{startDate}}创建(有效期{{dataList.validityDate}})</view>
  13. </view>
  14. </view>
  15. <view class="content2">
  16. <view class="title">送货信息</view>
  17. <view class="wrap wrap1" v-for="(item,index) in dataList.shippingInformationList" :key='index'>
  18. <view class="row1">
  19. <view class="left">
  20. <view>货主{{index+1}}-{{item.customerName}}</view>
  21. <view @click="reduceBtn(index)">--</view>
  22. </view>
  23. <view class="right" @click='showCustomerName(item)'>
  24. <view>{{item.customerName}}</view>
  25. <u-icon name="arrow-right" color=""></u-icon>
  26. <u-picker @confirm="nameConfirm" range-key='customerName' mode="selector"
  27. v-model="item.showCustomerName" :range="nameList"></u-picker>
  28. </view>
  29. </view>
  30. <view class="row2">
  31. <view class="left">
  32. 供应商(送粮人)
  33. </view>
  34. <view class="right">{{item.supplier}}</view>
  35. </view>
  36. <view class="row2" v-for="(item1,index1) in item.carNumberList" :key='index1'>
  37. <view class="left">
  38. 车牌号-{{index1+1}}
  39. </view>
  40. <u-input v-model="item1.carNo" placeholder="输入7为车牌号" />
  41. <view>
  42. <view @click="addCarNumber(item.carNumberList)">+</view>
  43. <view @click="delCarNumber(item.carNumberList,index1)">-</view>
  44. </view>
  45. </view>
  46. </view>
  47. <u-button @click='addGoodPeople'>增加货主</u-button>
  48. </view>
  49. <u-button @click='submit'>提交</u-button>
  50. <u-modal v-model="isShowAlert" :title-style="{fontSize: '18px',fontWeight:'500'}"
  51. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='登录提示'
  52. showCancelButton='false' :content="content" @confirm="alertBtn" @cancel="cancelClick"></u-modal>
  53. <u-modal v-model="isShowAlert1" :title-style="{fontSize: '18px',fontWeight:'500'}"
  54. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='登录提示'
  55. showCancelButton='false' :content="content1" @confirm="alertBtn" @cancel="cancelClick"></u-modal>
  56. </view>
  57. </template>
  58. <script>
  59. import {
  60. mapState
  61. } from 'vuex';
  62. export default {
  63. components: {
  64. },
  65. data() {
  66. return {
  67. isShowAlert: false,
  68. isShowAlert1: false,
  69. content: '当前登入信息验证失败,是否重新登录?',
  70. content1: '确定提交送粮信息?',
  71. // show: false,
  72. show1: false,
  73. cargoOwner: [{
  74. name: '123'
  75. }],
  76. nameList: [],
  77. warehouseNameAddress: '',
  78. startDate: "",
  79. dataList: {
  80. warehouseName: "",
  81. validityDate: '',
  82. commonId: uni.getStorageSync("userInfo").id,
  83. shippingInformationList: [{
  84. shipperName: '',
  85. supplier: '',
  86. carNo: '',
  87. carNumberList: [{
  88. carNo: ''
  89. }]
  90. }]
  91. }
  92. }
  93. },
  94. onLoad(options) {
  95. debugger
  96. // let _pageToData = JSON.parse(options.itemValue)
  97. // this.dataList.warehouseName = _pageToData.warehouseName
  98. // this.startDate = this.getTime()[0]
  99. // this.dataList.validityDate = this.getTime()[1]
  100. // this.warehouseNameAddress = _pageToData.warehousePrivate + _pageToData.warehouseCity + _pageToData
  101. // .warehouseArea + _pageToData.detailedAddress
  102. },
  103. // #ifndef MP
  104. onNavigationBarButtonTap(e) {
  105. const index = e.index;
  106. if (index === 0) {
  107. this.navTo('/pages/set/set');
  108. } else if (index === 1) {
  109. // #ifdef APP-PLUS
  110. const pages = getCurrentPages();
  111. const page = pages[pages.length - 1];
  112. const currentWebview = page.$getAppWebview();
  113. currentWebview.hideTitleNViewButtonRedDot({
  114. index
  115. });
  116. // #endif
  117. uni.navigateTo({
  118. url: '/pages/notice/notice'
  119. })
  120. }
  121. },
  122. // #endif
  123. computed: {
  124. ...mapState(['hasLogin', 'userInfo']),
  125. },
  126. onShow() {
  127. this.$api.doRequest('get', '/commonUser/api/checkSession').then(res => {
  128. console.log("checkSession", res)
  129. if (res.data.data == "INVALID") {
  130. this.isShowAlert = true;
  131. }
  132. this.getCustomer()
  133. })
  134. console.log("hasLogin", this.hasLogin)
  135. },
  136. methods: {
  137. showCustomerName(value) {debugger
  138. for(let i = 0;i<this.dataList.shippingInformationList.length;i++){
  139. this.dataList.shippingInformationList[i].showCustomerName = false
  140. }
  141. value.showCustomerName = true
  142. },
  143. getCustomer() {
  144. let _data = {
  145. commonId: uni.getStorageSync("userInfo").id,
  146. }
  147. this.$api.doRequest('get', '/identityAuthenticationInfo/identityAuthenticationInfoUser', _data).then(
  148. res => {
  149. if (res.data.code == 200) {
  150. // debugger
  151. this.nameList = res.data.data
  152. // for (let i = 0; i < this.nameList.length; i++) {
  153. // this.nameList[i].showCustomerName = false
  154. // }
  155. this.customerName = res.data.data[0].customerName
  156. }
  157. })
  158. },
  159. getTime() {
  160. let _startTime = new Date().format("yyyy-MM-dd");
  161. var _endTime = new Date();
  162. _endTime.setDate(_endTime.getDate() + 2);
  163. _endTime = _endTime.format("yyyy-MM-dd");
  164. return [_startTime, _endTime]
  165. },
  166. reduceBtn(index) {
  167. if (this.dataList.shippingInformationList.length > 1) {
  168. this.dataList.shippingInformationList.splice(index, 1)
  169. this.$forceUpdate()
  170. }
  171. },
  172. submit() {
  173. this.isShowAlert1 = true
  174. },
  175. nameConfirm() {},
  176. /**
  177. * 统一跳转接口,拦截未登录路由
  178. * navigator标签现在默认没有转场动画,所以用view
  179. */
  180. navTo(url) {
  181. if (!this.hasLogin) {
  182. url = '/pages/public/login';
  183. }
  184. uni.navigateTo({
  185. url
  186. })
  187. },
  188. alertBtn() {
  189. for (let i = 0; i < this.dataList.shippingInformationList.length; i++) {
  190. delete this.dataList.shippingInformationList[i].carNumberList
  191. }
  192. this.$api.doRequest('post', '/grainDeliveryRegistration/api/insertInfo', this.dataList).then(res => {
  193. if (res.data.code == 200) {
  194. }
  195. })
  196. },
  197. cancelClick() {
  198. this.isShowAlert = false
  199. this.isShowAlert1 = false
  200. },
  201. addGoodPeople() {
  202. this.dataList.shippingInformationList.push({
  203. shipperName: '',
  204. supplier: '',
  205. carNo: '',
  206. carNumberList: [{
  207. carNo: ''
  208. }]
  209. })
  210. },
  211. addCarNumber(val) {
  212. val.push({
  213. carNo: ''
  214. })
  215. },
  216. delCarNumber(val, index) {
  217. if (val.length > 1) {
  218. val.splice(index, 1)
  219. this.$forceUpdate()
  220. }
  221. }
  222. }
  223. }
  224. </script>
  225. <style lang='scss' scoped>
  226. page {
  227. background: #F5F6FA;
  228. }
  229. .wrap {
  230. background: #fff;
  231. margin: 10px;
  232. border-radius: 10px;
  233. padding: 10px;
  234. }
  235. .location {
  236. width: 32rpx;
  237. height: 32rpx;
  238. margin-right: 10rpx;
  239. }
  240. .locationwrap {
  241. font-size: 16px;
  242. display: flex;
  243. align-items: center;
  244. }
  245. </style>