spotCheckList.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <view class="pageInfo">
  3. <!-- 任务列表 -->
  4. <view v-for="item in list" :key="item.id" class="itemInfo">
  5. <view class="itemName">
  6. <span class="name">{{ item.name }}</span>
  7. <u-switch size="40" @change="changeItem(item)" v-model="item.status == 1"></u-switch>
  8. </view>
  9. <view class="itemName">
  10. <span>{{ item.startDate }} 至 {{ item.endDate }}</span>
  11. <span>
  12. <u-button v-if="item.status == 1" type="success" size="mini" style="margin-right: 15upx;" @click="handetail">查看</u-button>
  13. <u-button v-if="item.status == 0" type="primary" size="mini" style="margin-right: 15upx;" @click="handedit">编辑</u-button>
  14. <u-button v-if="item.status == 0" type="error" size="mini" @click="handelete(item)">删除</u-button>
  15. </span>
  16. </view>
  17. </view>
  18. <u-empty :text="noDataText" v-if="list.length == 0 && status != 'loading'" mode="list"></u-empty>
  19. <view style="padding: 20upx;"><u-loadmore v-if="total > pageSize || status == 'loading'" :status="status" /></view>
  20. </view>
  21. </template>
  22. <script>
  23. import {clzConfirm} from '@/libs/tools.js'
  24. import { getCheckTaskConfigList, delCheckTaskConfig, enableCheckTaskConfig } from '@/api/checkTaskConfig.js';
  25. export default {
  26. data() {
  27. return {
  28. status: 'loadmore',
  29. noDataText: '暂无数据',
  30. list: [],
  31. pageNo: 1,
  32. pageSize: 10,
  33. total: 0
  34. };
  35. },
  36. onLoad() {
  37. this.getList();
  38. },
  39. // 新增
  40. onNavigationBarButtonTap() {
  41. uni.navigateTo({
  42. url: '/pages/spotCheckConfigure/addSpotCheck'
  43. });
  44. },
  45. // 上拉分页
  46. onReachBottom() {
  47. console.log('onReachBottom');
  48. if(this.list.length< this.total){
  49. this.pageNo++
  50. this.getList()
  51. }else {
  52. uni.showToast({
  53. title: '已经到底了',
  54. icon: 'none'
  55. })
  56. this.status = "nomore"
  57. }
  58. },
  59. methods: {
  60. // 获取列表
  61. getList() {
  62. let _this = this;
  63. let params = {
  64. pageNo: this.pageNo,
  65. pageSize: this.pageSize,
  66. };
  67. this.status = 'loading';
  68. getCheckTaskConfigList(params).then(res => {
  69. console.log(res)
  70. if (res.status == 200) {
  71. let list = res.data.list;
  72. _this.list = _this.list.concat(list);
  73. _this.total = res.data.count;
  74. } else {
  75. uni.showToast({
  76. title: res.message,
  77. icon: 'none'
  78. });
  79. _this.noDataText = res.message;
  80. }
  81. _this.status = 'loadmore';
  82. });
  83. },
  84. // 启用禁用
  85. changeItem(item){
  86. let _this = this
  87. enableCheckTaskConfig({id:item.id,flag:item.status}).then(res=>{
  88. if(res.status == 200){
  89. let i = _this.list.findIndex(a=>a.id == item.id)
  90. _this.list[i].status = item.status == 1 ? 0 : 1
  91. _this.list.splice()
  92. }
  93. uni.showToast({
  94. title: res.message,
  95. icon: 'none'
  96. })
  97. })
  98. },
  99. // 查看详情
  100. handetail(item) {
  101. uni.navigateTo({
  102. url: '/pages/spotCheckConfigure/spotCheckDetail/spotCheckDetail?id='+item.id
  103. });
  104. },
  105. // 编辑
  106. handedit(item) {
  107. uni.navigateTo({
  108. url: '/pages/spotCheckConfigure/addSpotCheck?id='+item.id
  109. });
  110. },
  111. // 删除
  112. handelete(item) {
  113. const _this = this;
  114. clzConfirm({
  115. title: '提示',
  116. content: '确认删除,删除后数据将无法恢复?',
  117. success: function(res) {
  118. if (res.confirm || res.index == 0) {
  119. delCheckTaskConfig({id:item.id}).then(ret=>{
  120. if(ret.status == 200){
  121. let i = _this.list.findIndex(a=>a.id == item.id)
  122. _this.list.splice(i,1)
  123. }
  124. uni.showToast({
  125. title: ret.message,
  126. icon: 'none'
  127. })
  128. })
  129. }
  130. }
  131. });
  132. }
  133. }
  134. };
  135. </script>
  136. <style lang="scss">
  137. page {
  138. background: #f8f8f8;
  139. }
  140. .itemInfo {
  141. margin: 20upx;
  142. background-color: #fff;
  143. border-radius: 3px;
  144. .itemName {
  145. padding: 25upx 35upx;
  146. display: flex;
  147. justify-content: space-between;
  148. }
  149. .itemName:first-child {
  150. border-bottom: 1px solid #f8f8f8;
  151. }
  152. }
  153. </style>