grainDeliveryRecord.vue 6.6 KB

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