statisticsDetail.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="uni-app">
  3. <view class="status-bar" />
  4. <view class="main-container">
  5. <wk-nav-bar :title="title" />
  6. <view class="container">
  7. <wk-scroll-view
  8. :status="listStatus"
  9. class="list-scroll"
  10. @refresh="getList(true)"
  11. @loadmore="getList()">
  12. <legwork-item
  13. v-for="(item, index) in listData"
  14. :key="index"
  15. :item-data="item"
  16. @delete="handleToDelete" />
  17. </wk-scroll-view>
  18. </view>
  19. </view>
  20. <uni-popup ref="popup" type="dialog">
  21. <uni-popup-dialog
  22. :content="dialogMsg"
  23. type="warning"
  24. @confirm="handleDialogConfirm" />
  25. </uni-popup>
  26. </view>
  27. </template>
  28. <script>
  29. import { LegworkList, DeleteById } from 'API/oa/legwork'
  30. import LegworkItem from './component/legworkItem'
  31. import mainListMixins from '@/mixins/mainList.js'
  32. import { mapGetters } from 'vuex'
  33. export default {
  34. name: 'LegworkListForUser',
  35. components: {
  36. LegworkItem
  37. },
  38. mixins: [mainListMixins],
  39. data() {
  40. return {
  41. title: '',
  42. loading: false,
  43. userId: null,
  44. dialogMsg: '',
  45. selectedId: null,
  46. }
  47. },
  48. computed: {
  49. ...mapGetters({
  50. userInfo: 'user/userInfo'
  51. })
  52. },
  53. onLoad(options) {
  54. let query = options || {}
  55. this.title = query.title
  56. this.userId = query.userId || null
  57. this.listParams = {
  58. ...this.listParams,
  59. startTime: query.startTime,
  60. endTime: query.endTime
  61. }
  62. this.getList()
  63. },
  64. methods: {
  65. getList(flag = false) {
  66. if (this.loading) return
  67. this.loading = true
  68. if (flag) {
  69. this.listParams.page = 0
  70. }
  71. this.listParams.page++
  72. this.listStatus = 'loading'
  73. LegworkList({
  74. userId: this.userId,
  75. ...this.listParams,
  76. }).then(res => {
  77. this.loading = false
  78. if (this.listParams.page === 1) {
  79. this.listData = []
  80. }
  81. this.listData = this.listData.concat(res.list)
  82. if (res.hasOwnProperty('lastPage')) {
  83. this.listStatus = res.lastPage ? 'noMore' : 'more'
  84. } else {
  85. this.listStatus = res.list.length === 0 ? 'noMore' : 'more'
  86. }
  87. }).catch(() => {
  88. this.loading = false
  89. this.listStatus = 'more'
  90. })
  91. },
  92. handleToDelete(id) {
  93. this.selectedId = id
  94. this.dialogMsg = '您确定要删除这一条外勤记录吗?'
  95. this.$refs.popup.open()
  96. },
  97. handleDialogConfirm(next) {
  98. next()
  99. DeleteById({
  100. activityId: this.selectedId
  101. }).then(() => {
  102. this.$toast('删除成功!')
  103. this.getList(true)
  104. }).catch()
  105. },
  106. }
  107. }
  108. </script>
  109. <style scoped lang="scss">
  110. .main-container {
  111. .container {
  112. width: 100%;
  113. flex: 1;
  114. display: flex;
  115. flex-direction: column;
  116. overflow: hidden;
  117. }
  118. }
  119. </style>