spotCheckList.vue 4.9 KB

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