spotCheckList.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="pageInfo">
  3. <!-- 任务列表 -->
  4. <view v-for="item in list" :key="item.id" class="itemInfo">
  5. <view class="itemName">
  6. <view class="name">{{ item.name }}</view>
  7. <view>
  8. <switch style="transform:scale(0.9)" v-if="$hasPermissions('B_spotConfig_enable_mobile')" :checked="item.status == 1" @change="changeItem(item)" />
  9. </view>
  10. </view>
  11. <view class="itemName">
  12. <view class="date">{{ item.startDate }} 至 {{ item.endDate }}</view>
  13. <view>
  14. <u-button v-if="$hasPermissions('B_spotConfig_view_mobile')" type="success" size="mini" @click="handetail(item)">查看</u-button>
  15. <u-button v-if="item.status == 0 && item.taskGenerateFlag == 0 && $hasPermissions('B_spotConfig_edit_mobile')" type="primary" size="mini" style="margin-left: 15upx;" @click="handedit(item)">编辑</u-button>
  16. <u-button v-if="item.status == 0 && item.taskGenerateFlag == 0 && $hasPermissions('B_spotConfig_del_mobile')" type="error" size="mini" style="margin-left: 15upx;" @click="handelete(item)">删除</u-button>
  17. </view>
  18. </view>
  19. </view>
  20. <u-empty style="padding-top: 10vh;" :text="noDataText" v-if="list.length == 0 && status != 'loading'" mode="list"></u-empty>
  21. <view class="list-nomore" v-if="status == 'nomore'">已经到底了</view>
  22. <view style="padding: 20upx;" v-if="total > pageSize || status == 'loading'"><u-loadmore :status="status" /></view>
  23. </view>
  24. </template>
  25. <script>
  26. import { clzConfirm } from '@/libs/tools.js';
  27. import { getCheckTaskConfigList, delCheckTaskConfig, enableCheckTaskConfig } from '@/api/checkTaskConfig.js';
  28. export default {
  29. data() {
  30. return {
  31. status: 'loadmore',
  32. noDataText: '暂无数据',
  33. list: [],
  34. pageNo: 1,
  35. pageSize: 10,
  36. total: 0
  37. };
  38. },
  39. onLoad() {
  40. if(this.$hasPermissions("B_spotConfig_new_mobile")){
  41. // #ifdef APP-PLUS
  42. // 设置标题栏按钮
  43. let currentWebview = this.$scope.$getAppWebview();
  44. currentWebview.setTitleNViewButtonStyle(0, {
  45. text: '\ue610 新增',
  46. fontSize: 16,
  47. color: '#eee',
  48. width: '80px',
  49. fontSrc: '/static/iconfont/iconfont.ttf'
  50. });
  51. // #endif
  52. }
  53. // 首次加载列表
  54. this.getList();
  55. // 刷新列表
  56. uni.$on('updateCheckTaskConfigList', () => {
  57. this.getList(1);
  58. });
  59. },
  60. // 新增
  61. onNavigationBarButtonTap() {
  62. uni.navigateTo({
  63. url: '/pages/spotCheckConfigure/addSpotCheck'
  64. });
  65. },
  66. // 上拉分页
  67. onReachBottom() {
  68. console.log('onReachBottom');
  69. if (this.list.length < this.total) {
  70. this.getList();
  71. } else {
  72. uni.showToast({
  73. title: '已经到底了',
  74. icon: 'none'
  75. });
  76. this.status = 'nomore';
  77. }
  78. },
  79. methods: {
  80. // 获取列表
  81. getList(pageNo) {
  82. let _this = this;
  83. if(pageNo==1){
  84. this.pageNo = 1
  85. this.list = []
  86. }
  87. let params = {
  88. pageNo: this.pageNo,
  89. pageSize: this.pageSize
  90. };
  91. this.status = 'loading';
  92. getCheckTaskConfigList(params).then(res => {
  93. console.log(res)
  94. if (res.status == 200) {
  95. let list = res.data.list;
  96. if (_this.pageNo > 1) {
  97. _this.list = _this.list.concat(list);
  98. } else {
  99. _this.list = list;
  100. }
  101. _this.total = res.data.count;
  102. _this.pageNo++;
  103. } else {
  104. uni.showToast({
  105. title: res.message,
  106. icon: 'none'
  107. });
  108. _this.noDataText = res.message;
  109. }
  110. _this.status = 'loadmore';
  111. });
  112. },
  113. // 启用禁用
  114. changeItem(item) {
  115. console.log(item)
  116. let _this = this;
  117. let status = item.status == 1 ? 0 : 1;
  118. enableCheckTaskConfig({ id: item.id, flag: status }).then(res => {
  119. if (res.status == 200) {
  120. let i = _this.list.findIndex(a => a.id == item.id);
  121. _this.list[i].status = status;
  122. _this.list.splice();
  123. }
  124. uni.showToast({
  125. title: res.message,
  126. icon: 'none'
  127. });
  128. });
  129. },
  130. // 查看详情
  131. handetail(item) {
  132. uni.navigateTo({
  133. url: '/pages/spotCheckConfigure/spotCheckDetail/spotCheckDetail?id=' + item.id
  134. });
  135. },
  136. // 编辑
  137. handedit(item) {
  138. uni.navigateTo({
  139. url: '/pages/spotCheckConfigure/addSpotCheck?id=' + item.id
  140. });
  141. },
  142. // 删除
  143. handelete(item) {
  144. const _this = this;
  145. clzConfirm({
  146. title: '提示',
  147. content: '确认删除,删除后数据将无法恢复?',
  148. success: function(res) {
  149. if (res.confirm || res.index == 0) {
  150. delCheckTaskConfig({ id: item.id }).then(ret => {
  151. if (ret.status == 200) {
  152. let i = _this.list.findIndex(a => a.id == item.id);
  153. _this.list.splice(i, 1);
  154. }
  155. uni.showToast({
  156. title: ret.message,
  157. icon: 'none'
  158. });
  159. });
  160. }
  161. }
  162. });
  163. }
  164. }
  165. };
  166. </script>
  167. <style lang="scss">
  168. page {
  169. background: #f8f8f8;
  170. height: auto;
  171. }
  172. .itemInfo {
  173. margin: 20upx;
  174. background-color: #fff;
  175. border-radius: 3px;
  176. box-shadow: 1px 1px 3px #eeeeee;
  177. .itemName {
  178. padding: 25upx;
  179. display: flex;
  180. align-items: center;
  181. .date {
  182. color: #666;
  183. }
  184. > view{
  185. &:first-child{
  186. flex-grow: 1;
  187. }
  188. }
  189. }
  190. .itemName:first-child {
  191. border-bottom: 1px solid #f8f8f8;
  192. padding: 15upx 15upx 15upx 25upx;
  193. }
  194. }
  195. </style>