spotCheckList.vue 4.9 KB

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