spotCheckList.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. <view style="padding-top: 30vh;"><u-empty :text="noDataText" v-if="list.length == 0 && status != 'loading'" mode="list"></u-empty></view>
  21. <view style="padding: 20upx;"><u-loadmore v-if="total > pageSize || status == 'loading'" :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.pageNo = 1;
  57. this.list = [];
  58. this.getList();
  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.pageNo++;
  72. this.getList();
  73. } else {
  74. uni.showToast({
  75. title: '已经到底了',
  76. icon: 'none'
  77. });
  78. this.status = 'nomore';
  79. }
  80. },
  81. methods: {
  82. // 获取列表
  83. getList() {
  84. let _this = this;
  85. let params = {
  86. pageNo: this.pageNo,
  87. pageSize: this.pageSize
  88. };
  89. this.status = 'loading';
  90. getCheckTaskConfigList(params).then(res => {
  91. if (res.status == 200) {
  92. let list = res.data.list;
  93. if (_this.pageNo > 1) {
  94. _this.list = _this.list.concat(list);
  95. } else {
  96. _this.list = list;
  97. }
  98. _this.total = res.data.count;
  99. } else {
  100. uni.showToast({
  101. title: res.message,
  102. icon: 'none'
  103. });
  104. _this.noDataText = res.message;
  105. }
  106. _this.status = 'loadmore';
  107. });
  108. },
  109. // 启用禁用
  110. changeItem(item) {
  111. console.log(item)
  112. let _this = this;
  113. let status = item.status == 1 ? 0 : 1;
  114. enableCheckTaskConfig({ id: item.id, flag: status }).then(res => {
  115. if (res.status == 200) {
  116. let i = _this.list.findIndex(a => a.id == item.id);
  117. _this.list[i].status = status;
  118. _this.list.splice();
  119. }
  120. uni.showToast({
  121. title: res.message,
  122. icon: 'none'
  123. });
  124. });
  125. },
  126. // 查看详情
  127. handetail(item) {
  128. uni.navigateTo({
  129. url: '/pages/spotCheckConfigure/spotCheckDetail/spotCheckDetail?id=' + item.id
  130. });
  131. },
  132. // 编辑
  133. handedit(item) {
  134. uni.navigateTo({
  135. url: '/pages/spotCheckConfigure/addSpotCheck?id=' + item.id
  136. });
  137. },
  138. // 删除
  139. handelete(item) {
  140. const _this = this;
  141. clzConfirm({
  142. title: '提示',
  143. content: '确认删除,删除后数据将无法恢复?',
  144. success: function(res) {
  145. if (res.confirm || res.index == 0) {
  146. delCheckTaskConfig({ id: item.id }).then(ret => {
  147. if (ret.status == 200) {
  148. let i = _this.list.findIndex(a => a.id == item.id);
  149. _this.list.splice(i, 1);
  150. }
  151. uni.showToast({
  152. title: ret.message,
  153. icon: 'none'
  154. });
  155. });
  156. }
  157. }
  158. });
  159. }
  160. }
  161. };
  162. </script>
  163. <style lang="scss">
  164. page {
  165. background: #f8f8f8;
  166. height: auto;
  167. }
  168. .itemInfo {
  169. margin: 20upx;
  170. background-color: #fff;
  171. border-radius: 3px;
  172. box-shadow: 1px 1px 3px #eeeeee;
  173. .itemName {
  174. padding: 25upx;
  175. display: flex;
  176. align-items: center;
  177. .date {
  178. color: #666;
  179. }
  180. > view{
  181. &:first-child{
  182. flex-grow: 1;
  183. }
  184. }
  185. }
  186. .itemName:first-child {
  187. border-bottom: 1px solid #f8f8f8;
  188. padding: 15upx 15upx 15upx 25upx;
  189. }
  190. }
  191. </style>