grainDeliveryRecord.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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. callFlag:1
  106. }
  107. this.$api.doRequest('get', '/grainDeliveryRegistration/selectGrainDeliveryRegistration', _obj)
  108. .then(res => {
  109. if (res.data.code == 200) {
  110. let curPageData = []
  111. for (let i = 0; i < res.data.data.length; i++) {
  112. let _data = res.data.data[i];
  113. //判断是记录是否失效
  114. let _isUserd = function() {
  115. let _startTime = new Date((_data.validityDate + ' 00:00:00')).getTime();
  116. let _endTime = Date.parse(new Date());
  117. if (_endTime - _startTime > 0) {
  118. _data.validityDate = '已失效'
  119. } else {
  120. _data.validityDate = _data.validityDate + ' 0时前有效'
  121. }
  122. }()
  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. }
  138. if (type == 'down') {
  139. this.mescroll.endSuccess();
  140. this.dataList = []
  141. } else {
  142. this.mescroll.endBySize(curPageData.length, curPageData.length); //必传参数(当前页的数据个数, 总数据量)
  143. }
  144. console.log(curPageData)
  145. this.dataList = this.dataList.concat(curPageData);
  146. }
  147. })
  148. },
  149. /*下拉刷新的回调 */
  150. downCallback() {
  151. this.getData(10, 1, 'down')
  152. },
  153. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  154. upCallback(page) {
  155. //联网加载数据
  156. this.getData(page.size, page.num, 'up')
  157. },
  158. del(row) {
  159. this.isShowAlert1 = true
  160. this.id = row.id
  161. // 删除成功后删除页面当前行
  162. },
  163. navTo(url) {
  164. if (!this.hasLogin) {
  165. url = '/pages/public/login';
  166. }
  167. uni.navigateTo({
  168. url
  169. })
  170. },
  171. alertBtn() {
  172. this.$api.doRequest('post', '/grainDeliveryRegistration/api/deleteInfo', {
  173. id: this.id
  174. }).then(res => {
  175. if (res.data.code == 200) {
  176. for (let i = 0; i < this.dataList.length; i++) {
  177. if (this.id == this.dataList[i].id) {
  178. this.$api.msg('删除成功!')
  179. this.dataList.splice(i, 1)
  180. }
  181. }
  182. } else {
  183. this.$api.msg('删除失败!')
  184. }
  185. })
  186. },
  187. cancelClick() {
  188. this.isShowAlert = false
  189. }
  190. }
  191. }
  192. </script>
  193. <style lang='scss' scoped>
  194. page {
  195. background: #F5F6FA;
  196. }
  197. .content1 {
  198. background: white;
  199. margin: 20rpx;
  200. padding: 20rpx;
  201. border-radius: 20rpx;
  202. .top {
  203. display: flex;
  204. justify-content: space-between;
  205. .left {
  206. font-size: 32rpx;
  207. font-weight: 700;
  208. }
  209. .right {
  210. font-size: 28rpx;
  211. color: #FD714F;
  212. }
  213. }
  214. .hz-content {
  215. background: #F5F6FA;
  216. margin-top: 20rpx;
  217. padding: 20rpx;
  218. .row1 {
  219. display: flex;
  220. align-items: center;
  221. margin-bottom: 30rpx;
  222. .hz-name {
  223. font-size: 36rpx;
  224. font-weight: 700;
  225. margin-right: 4rpx;
  226. }
  227. .car {
  228. font-size: 24rpx;
  229. color: #676E80;
  230. }
  231. }
  232. .car-list {
  233. .number {
  234. display: inline-block;
  235. width: 25%;
  236. background: #FFFFFF;
  237. border-radius: 23px;
  238. font-size: 24rpx;
  239. color: #676E80;
  240. padding: 10rpx 20rpx;
  241. margin: 1%;
  242. text-align: center;
  243. box-sizing: border-box;
  244. }
  245. }
  246. }
  247. .del-row {
  248. display: flex;
  249. justify-content: space-between;
  250. align-items: center;
  251. margin-top: 20rpx;
  252. .del {
  253. background: #FFFFFF;
  254. border-radius: 33px;
  255. border: 1px solid #CDCDCD;
  256. font-size: 28rpx;
  257. color: #333333;
  258. margin: 0;
  259. padding: 10rpx 30rpx;
  260. height: 100%;
  261. }
  262. /deep/.uni-button {}
  263. }
  264. }
  265. </style>