grainDeliveryRecord.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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.warehouseName}}</view>
  7. <view class="right">{{item.validityDate}}</view>
  8. </view>
  9. <view v-for="(item1,index) in item.shippingInformationList">
  10. <view class="hz-content">
  11. <view class="row1">
  12. <view class="hz-name">
  13. {{item1.shipperName}}
  14. </view>
  15. <view class="car">
  16. ({{item1.carList.length}}车)
  17. </view>
  18. </view>
  19. <view class="car-list">
  20. <view v-for="(item2,index) in item1.carList" class="number">
  21. {{item2}}
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="del-row">
  27. <view>{{item.createDate}}</view>
  28. <view class="del" @click='del(item)'>删除</view>
  29. </view>
  30. </view>
  31. <u-modal v-model="isShowAlert1" :title-style="{fontSize: '18px',fontWeight:'500'}"
  32. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定'
  33. title='提示' :showCancelButton='false' :content="content1" @confirm="alertBtn" @cancel="cancelClick">
  34. </u-modal>
  35. <u-modal v-model="isShowAlert" :title-style="{fontSize: '18px',fontWeight:'500'}"
  36. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定'
  37. title='提示' :showCancelButton='false' :content="content" @confirm="alertBtn" @cancel="cancelClick">
  38. </u-modal>
  39. </view>
  40. </mescroll-body>
  41. </template>
  42. <script>
  43. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  44. import {
  45. mapState
  46. } from 'vuex';
  47. export default {
  48. mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
  49. components: {
  50. },
  51. data() {
  52. return {
  53. downOption: {
  54. auto: false //是否在初始化后,自动执行downCallback; 默认true
  55. },
  56. dataList: [],
  57. validityDate: '',
  58. id: '',
  59. warehouseName: '',
  60. isShowAlert: false,
  61. isShowAlert1: false,
  62. content: '当前登入信息验证失败,是否重新登录?',
  63. content1: '确定删除送粮记录?',
  64. dataList: []
  65. }
  66. },
  67. onLoad() {
  68. },
  69. // #ifndef MP
  70. onNavigationBarButtonTap(e) {
  71. const index = e.index;
  72. if (index === 0) {
  73. this.navTo('/pages/set/set');
  74. } else if (index === 1) {
  75. // #ifdef APP-PLUS
  76. const pages = getCurrentPages();
  77. const page = pages[pages.length - 1];
  78. const currentWebview = page.$getAppWebview();
  79. currentWebview.hideTitleNViewButtonRedDot({
  80. index
  81. });
  82. // #endif
  83. uni.navigateTo({
  84. url: '/pages/notice/notice'
  85. })
  86. }
  87. },
  88. // #endif
  89. computed: {
  90. ...mapState(['hasLogin', 'userInfo']),
  91. },
  92. onShow() {
  93. this.$api.doRequest('get', '/commonUser/api/checkSession').then(res => {
  94. console.log("checkSession", res)
  95. if (res.data.data == "INVALID") {
  96. this.isShowAlert = true;
  97. }
  98. })
  99. console.log("hasLogin", this.hasLogin)
  100. },
  101. methods: {
  102. getData(size, page, type) {
  103. let _obj = {
  104. commonId: uni.getStorageSync("userInfo").id
  105. }
  106. this.$api.doRequest('get', '/grainDeliveryRegistration/selectGrainDeliveryRegistration', _obj)
  107. .then(res => {
  108. if (res.data.code == 200) {
  109. let curPageData = []
  110. for (let i = 0; i < res.data.data.length; i++) {
  111. let _data = res.data.data[i];
  112. //判断是记录是否失效
  113. let _isUserd = function() {
  114. let _startTime = new Date((_data.validityDate + ' 00:00:00')).getTime();
  115. let _endTime = Date.parse(new Date());
  116. if (_endTime - _startTime > 0) {
  117. _data.validityDate = '已失效'
  118. } else {
  119. _data.validityDate = _data.validityDate + ' 0时前有效'
  120. }
  121. }()
  122. let _carNumberList=[]
  123. for (var q = 0; q < _data.shippingInformationList.length; q++) {
  124. console.log(_data.shippingInformationList[q].carNo.split(','))
  125. _data.shippingInformationList[q].carList = _data.shippingInformationList[q].carNo.split(',')
  126. }
  127. let __obj = {
  128. warehouseName: _data.warehouseName,
  129. id: _data.id,
  130. shipperName: _data.shipperName,
  131. shippingInformationList: _data.shippingInformationList,
  132. validityDate: _data.validityDate,
  133. createDate:_data.createDate
  134. }
  135. curPageData.push(__obj)
  136. }
  137. if (type == 'down') {
  138. this.mescroll.endSuccess();
  139. this.dataList = []
  140. } else {
  141. this.mescroll.endBySize(curPageData.length, curPageData.length); //必传参数(当前页的数据个数, 总数据量)
  142. }
  143. console.log(curPageData)
  144. this.dataList = this.dataList.concat(curPageData);
  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>