grainDeliveryRecord1.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback">
  3. <view class="content">
  4. <view class="content1" v-for="(item,index) in dataList" :key="index">
  5. <view class="top">
  6. <view class="left">{{item.currectDate}}</view>
  7. </view>
  8. <view v-for="(item1,index) in item.carList">
  9. <view class="flex justify-between">
  10. <view class="hz-name">
  11. {{item1.shipperName}}
  12. </view>
  13. <view class="car">
  14. {{item1.carNo}}
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <u-modal v-model="isShowAlert1" :title-style="{fontSize: '18px',fontWeight:'500'}"
  20. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定'
  21. title='提示' :showCancelButton='false' :content="content1" @confirm="alertBtn" @cancel="cancelClick">
  22. </u-modal>
  23. <u-modal v-model="isShowAlert" :title-style="{fontSize: '18px',fontWeight:'500'}"
  24. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定'
  25. title='提示' :showCancelButton='false' :content="content" @confirm="alertBtn" @cancel="cancelClick">
  26. </u-modal>
  27. </view>
  28. </mescroll-body>
  29. </template>
  30. <script>
  31. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  32. import {
  33. mapState
  34. } from 'vuex';
  35. export default {
  36. mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
  37. components: {
  38. },
  39. data() {
  40. return {
  41. downOption: {
  42. auto: false //是否在初始化后,自动执行downCallback; 默认true
  43. },
  44. dataList: [],
  45. validityDate: '',
  46. id: '',
  47. warehouseName: '',
  48. isShowAlert: false,
  49. isShowAlert1: false,
  50. content: '当前登入信息验证失败,是否重新登录?',
  51. content1: '确定删除送粮记录?',
  52. dataList: []
  53. }
  54. },
  55. onLoad() {
  56. },
  57. // #ifndef MP
  58. onNavigationBarButtonTap(e) {
  59. const index = e.index;
  60. if (index === 0) {
  61. this.navTo('/pages/set/set');
  62. } else if (index === 1) {
  63. // #ifdef APP-PLUS
  64. const pages = getCurrentPages();
  65. const page = pages[pages.length - 1];
  66. const currentWebview = page.$getAppWebview();
  67. currentWebview.hideTitleNViewButtonRedDot({
  68. index
  69. });
  70. // #endif
  71. uni.navigateTo({
  72. url: '/pages/notice/notice'
  73. })
  74. }
  75. },
  76. // #endif
  77. computed: {
  78. ...mapState(['hasLogin', 'userInfo']),
  79. },
  80. onShow() {
  81. this.$api.doRequest('get', '/commonUser/api/checkSession').then(res => {
  82. console.log("checkSession", res)
  83. if (res.data.data == "INVALID") {
  84. this.isShowAlert = true;
  85. }
  86. })
  87. console.log("hasLogin", this.hasLogin)
  88. },
  89. methods: {
  90. getData(size, page, type) {
  91. let _obj = {
  92. commonId: uni.getStorageSync("userInfo").id,
  93. callFlag:2
  94. }
  95. this.$api.doRequest('get', '/grainDeliveryRegistration/selectGrainDeliveryRegistration', _obj)
  96. .then(res => {
  97. if (res.data.code == 200) {
  98. for (let i = 0; i < res.data.data.length; i++) {
  99. let _data = res.data.data[i];
  100. let date = new Date(_data.createDate)
  101. _data.currectDate = date.getFullYear()+'-'+((date.getMonth()+1)>=10?(date.getMonth()+1):'0'+(date.getMonth()+1))+'-'+(date.getDate()>=10?date.getDate():'0'+date.getDate())
  102. for (var q = 0; q < _data.shippingInformationList.length; q++) {
  103. console.log(_data.shippingInformationList[q].carNo.split(','))
  104. var carArr=_data.shippingInformationList[q].carNo.split(',')
  105. _data.shippingInformationList[q].carList = carArr.map(item=>{return {carNo:item,shipperName:_data.shippingInformationList[q].shipperName}})
  106. }
  107. }
  108. let newList = res.data.data.map(item=>{return {currectDate:item.currectDate,carList:[]}})
  109. let hash={};
  110. newList = newList.reduce((item,next)=>{
  111. hash[next.currectDate]?"":hash[next.currectDate]=true && item.push(next)
  112. return item
  113. },[])
  114. // console.log(newList)
  115. res.data.data.forEach((item,index)=>{
  116. for(let i in newList){
  117. if(item.currectDate==newList[i].currectDate){
  118. newList[i].carList.push(...item.shippingInformationList[0].carList)
  119. }
  120. }
  121. })
  122. console.log(newList)
  123. // let _carNumberList=[]
  124. // for (var q = 0; q < _data.shippingInformationList.length; q++) {
  125. // console.log(_data.shippingInformationList[q].carNo.split(','))
  126. // _data.shippingInformationList[q].carList = _data.shippingInformationList[q].carNo.split(',')
  127. // }
  128. // let __obj = {
  129. // warehouseName: _data.warehouseName,
  130. // id: _data.id,
  131. // shipperName: _data.shipperName,
  132. // shippingInformationList: _data.shippingInformationList,
  133. // validityDate: _data.validityDate,
  134. // createDate:_data.createDate
  135. // }
  136. // curPageData.push(__obj)
  137. if (type == 'down') {
  138. this.mescroll.endSuccess();
  139. this.dataList = []
  140. } else {
  141. this.mescroll.endBySize(newList.length, newList.length); //必传参数(当前页的数据个数, 总数据量)
  142. }
  143. console.log(newList)
  144. this.dataList = this.dataList.concat(newList);
  145. }
  146. })
  147. },
  148. /*下拉刷新的回调 */
  149. downCallback() {
  150. this.getData(10, 1, 'down')
  151. },
  152. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  153. upCallback(page) {
  154. //联网加载数据
  155. this.getData(page.size, page.num, 'up')
  156. },
  157. del(row) {
  158. this.isShowAlert1 = true
  159. this.id = row.id
  160. // 删除成功后删除页面当前行
  161. },
  162. navTo(url) {
  163. if (!this.hasLogin) {
  164. url = '/pages/public/login';
  165. }
  166. uni.navigateTo({
  167. url
  168. })
  169. },
  170. alertBtn() {
  171. this.$api.doRequest('post', '/grainDeliveryRegistration/api/deleteInfo', {
  172. id: this.id
  173. }).then(res => {
  174. if (res.data.code == 200) {
  175. for (let i = 0; i < this.dataList.length; i++) {
  176. if (this.id == this.dataList[i].id) {
  177. this.$api.msg('删除成功!')
  178. this.dataList.splice(i, 1)
  179. }
  180. }
  181. } else {
  182. this.$api.msg('删除失败!')
  183. }
  184. })
  185. },
  186. cancelClick() {
  187. this.isShowAlert = false
  188. }
  189. }
  190. }
  191. </script>
  192. <style lang='scss' scoped>
  193. page {
  194. background: #F5F6FA;
  195. }
  196. .content1 {
  197. background: white;
  198. margin: 20rpx;
  199. padding: 20rpx;
  200. border-radius: 20rpx;
  201. .top {
  202. display: flex;
  203. justify-content: space-between;
  204. .left {
  205. font-size: 32rpx;
  206. font-weight: 700;
  207. }
  208. .right {
  209. font-size: 28rpx;
  210. color: #FD714F;
  211. }
  212. }
  213. .hz-content {
  214. background: #F5F6FA;
  215. margin-top: 20rpx;
  216. padding: 20rpx;
  217. .row1 {
  218. display: flex;
  219. align-items: center;
  220. margin-bottom: 30rpx;
  221. .hz-name {
  222. font-size: 36rpx;
  223. font-weight: 700;
  224. margin-right: 4rpx;
  225. }
  226. .car {
  227. font-size: 24rpx;
  228. color: #676E80;
  229. }
  230. }
  231. .car-list {
  232. .number {
  233. display: inline-block;
  234. width: 25%;
  235. background: #FFFFFF;
  236. border-radius: 23px;
  237. font-size: 24rpx;
  238. color: #676E80;
  239. padding: 10rpx 20rpx;
  240. margin: 1%;
  241. text-align: center;
  242. box-sizing: border-box;
  243. }
  244. }
  245. }
  246. .del-row {
  247. display: flex;
  248. justify-content: space-between;
  249. align-items: center;
  250. margin-top: 20rpx;
  251. .del {
  252. background: #FFFFFF;
  253. border-radius: 33px;
  254. border: 1px solid #CDCDCD;
  255. font-size: 28rpx;
  256. color: #333333;
  257. margin: 0;
  258. padding: 10rpx 30rpx;
  259. height: 100%;
  260. }
  261. /deep/.uni-button {}
  262. }
  263. }
  264. </style>