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