legworkList.vue 3.1 KB

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