index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view class="container uni-container uni-container-bg">
  3. <view class="uni-padding-wrap uni-common-mt">
  4. <uni-segmented-control :current="current" :values="items" style-type="button" active-color="#C3D8F9"
  5. @clickItem="onClickItem" />
  6. </view>
  7. <view class="content">
  8. <view v-if="current === 0">
  9. <!-- <view class=" ">
  10. <uni-card v-for="(item, index) in tableData" :key="index" :title="item.name"
  11. :sub-title="item.code" extra="去完成" @click="onClick(item)">
  12. <view class=" flex flex-direction">
  13. <text class="text-cut">任务介绍:{{item.introduction}}</text>
  14. <text class="text-cut">发布单位:{{item.unit}}</text>
  15. <text class="text-cut">
  16. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  17. <uni-col :span="18" class="text-cut text-grey1">截止时间:{{item.cutofftime}}</uni-col>
  18. <uni-col :span="6" class="justify-end flex ">
  19. <u-button size="small"
  20. :color="item.status==='0'||item.status==='3'?'red':item.status==='1'?'green':'blue'"
  21. style="width: 160rpx;">{{statusListTran(item.status)}}</u-button>
  22. </uni-col>
  23. </uni-row>
  24. </text>
  25. </view>
  26. </uni-card>
  27. </view> -->
  28. <u-list @scrolltolower="scrolltolower">
  29. <u-list-item v-for="(item, index) in tableData" :key="index" @click.native="onClick(item)" link>
  30. <uni-row class="demo-uni-row padding-tb-sm" :gutter="20" width="100%">
  31. <uni-col :span="24">
  32. <text class="text-xl font-weight-700">
  33. {{item.name}}
  34. </text>
  35. </uni-col>
  36. </uni-row>
  37. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  38. <uni-col :span="24" class="text-xl font-weight-700">
  39. <u-line></u-line>
  40. </uni-col>
  41. </uni-row>
  42. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  43. <uni-col :span="24" class="text-cut text-grey1"> 任务介绍:{{item.introduction}}</uni-col>
  44. </uni-row>
  45. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  46. <uni-col :span="24" class="text-cut text-grey1">发布单位:{{item.unit}}</uni-col>
  47. </uni-row>
  48. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  49. <uni-col :span="18" class="text-cut text-grey1">截止时间:{{item.cutofftime}}</uni-col>
  50. <uni-col :span="6" class="justify-end flex ">
  51. <u-button size="small"
  52. :color="item.status==='0'||item.status==='3'?'#D51A52':item.status==='1'?'#00B998':'#2563EB'"
  53. style="width: 160rpx;">{{statusListTran(item.status)}}</u-button>
  54. </uni-col>
  55. </uni-row>
  56. </u-list-item>
  57. </u-list>
  58. </view>
  59. <view v-if="current === 1">
  60. <u-list @scrolltolower="scrolltolower">
  61. <u-list-item v-for="(item, index) in tableData" :key="index" @click.native="onClick(item)" link>
  62. <uni-row class="demo-uni-row padding-tb-sm" :gutter="20" width="100%">
  63. <uni-col :span="24" class="text-xl font-weight-700">
  64. <text class="text-xl font-weight-700">
  65. {{item.name}}
  66. </text>
  67. </uni-col>
  68. </uni-row>
  69. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  70. <uni-col :span="24" class="text-xl font-weight-700">
  71. <u-line></u-line>
  72. </uni-col>
  73. </uni-row>
  74. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  75. <uni-col :span="24" class="text-cut text-grey1"> 任务介绍:{{item.introduction}}</uni-col>
  76. </uni-row>
  77. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  78. <uni-col :span="24" class="text-cut text-grey1">发布单位:{{item.unit}}</uni-col>
  79. </uni-row>
  80. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  81. <uni-col :span="18" class="text-cut text-grey1">截止时间:{{item.cutofftime}}</uni-col>
  82. <uni-col :span="6" class="justify-end flex ">
  83. <u-button size="small" color="#D51A52" style="width: 160rpx;">未完成</u-button>
  84. </uni-col>
  85. </uni-row>
  86. </u-list-item>
  87. </u-list>
  88. </view>
  89. <view v-if="current === 2">
  90. <u-list @scrolltolower="scrolltolower">
  91. <u-list-item v-for="(item, index) in tableData" :key="index" @click.native="onClick(item)" link>
  92. <uni-row class="demo-uni-row padding-tb-sm" :gutter="20" width="100%">
  93. <uni-col :span="24" class="text-xl font-weight-700">
  94. <text class="text-xl font-weight-700">
  95. {{item.name}}
  96. </text>
  97. </uni-col>
  98. </uni-row>
  99. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  100. <uni-col :span="24" class="text-xl font-weight-700">
  101. <u-line></u-line>
  102. </uni-col>
  103. </uni-row>
  104. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  105. <uni-col :span="24" class="text-cut text-grey1"> 任务介绍:{{item.introduction}}</uni-col>
  106. </uni-row>
  107. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  108. <uni-col :span="24" class="text-cut text-grey1">发布单位:{{item.unit}}</uni-col>
  109. </uni-row>
  110. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  111. <uni-col :span="18" class="text-cut text-grey1">截止时间:{{item.cutofftime}}</uni-col>
  112. <uni-col :span="6" class="justify-end flex ">
  113. <u-button size="small" color="#2563EB" style="width: 160rpx;">审核中</u-button>
  114. </uni-col>
  115. </uni-row>
  116. </u-list-item>
  117. </u-list>
  118. </view>
  119. <view v-if="current === 3">
  120. <u-list @scrolltolower="scrolltolower">
  121. <u-list-item v-for="(item, index) in tableData" :key="index" @click.native="onClick(item)" link>
  122. <uni-row class="demo-uni-row padding-tb-sm" :gutter="20" width="100%">
  123. <uni-col :span="24" class="text-xl font-weight-700">
  124. <text class="text-xl font-weight-700">
  125. {{item.name}}
  126. </text>
  127. </uni-col>
  128. </uni-row>
  129. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  130. <uni-col :span="24" class="text-xl font-weight-700">
  131. <u-line></u-line>
  132. </uni-col>
  133. </uni-row>
  134. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  135. <uni-col :span="24" class="text-cut text-grey1"> 任务介绍:{{item.introduction}}</uni-col>
  136. </uni-row>
  137. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  138. <uni-col :span="24" class="text-cut text-grey1">发布单位:{{item.unit}}</uni-col>
  139. </uni-row>
  140. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  141. <uni-col :span="18" class="text-cut text-grey1">截止时间:{{item.cutofftime}}</uni-col>
  142. <uni-col :span="6" class="justify-end flex ">
  143. <u-button size="small" color="#00B998" style="width: 160rpx;">已完成</u-button>
  144. </uni-col>
  145. </uni-row>
  146. </u-list-item>
  147. </u-list>
  148. </view>
  149. </view>
  150. </view>
  151. </template>
  152. <script>
  153. let that = null;
  154. import {
  155. getTask
  156. } from "@/api/task";
  157. export default {
  158. data() {
  159. return {
  160. current: 0,
  161. items: ['全部', '未完成', '审核中', '已完成'],
  162. // 数据
  163. tableData: [],
  164. // 每页数据量
  165. pageSize: 20,
  166. // 当前页
  167. pageNo: 1,
  168. // 数据总量
  169. total: 0,
  170. // tableData数据加载中
  171. loading: false,
  172. statusList: {
  173. 0: "未完成",
  174. 1: "已完成",
  175. 2: "审核中",
  176. 3: "审核未通过"
  177. },
  178. }
  179. },
  180. // 在 vue页面,向起始页通过事件传递数据
  181. onLoad: function(option) {
  182. this.getData(1)
  183. },
  184. methods: {
  185. // =================数据转换==================
  186. statusListTran(val) { //status状态转换
  187. return this.statusList[val]
  188. },
  189. // ================================
  190. // tab头部点击
  191. onClickItem(e) {
  192. if (this.current !== e.currentIndex) {
  193. this.current = e.currentIndex
  194. }
  195. },
  196. // 获取数据
  197. getData(pageNo, value = '') {
  198. this.loading = true
  199. this.pageNo = pageNo
  200. getTask({
  201. pageNo: this.pageNo,
  202. pageSize: this.pageSize,
  203. status: '1',
  204. }).then(response => {
  205. // 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接
  206. this.tableData = [...this.tableData, ...response.data.list]
  207. // this.tableData = response.data.list;
  208. this.total = response.data.total;
  209. this.loading = false;
  210. });
  211. },
  212. onClick(val) {
  213. uni.navigateTo({
  214. url: '/pagesA/fire/check_tasks/tasks_details/tasks_details?id=' + val.id,
  215. // events: {
  216. // // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  217. // acceptDataFromOpenedPage: function(val) {
  218. // },
  219. // },
  220. // success: function(res) {
  221. // // 通过eventChannel向被打开页面传送数据
  222. // res.eventChannel.emit('acceptDataFromOpenerPage', val)
  223. // }
  224. })
  225. },
  226. // 触底的事件
  227. scrolltolower() {
  228. // 判断是否还有下一页数据
  229. if (this.pageNo * this.pageSize >= this.total) return uni.showToast({
  230. title: `数据加载完毕`
  231. })
  232. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  233. if (this.loading) return
  234. this.pageNo += 1
  235. this.getData(this.pageNo)
  236. },
  237. // 触底的事件
  238. // onReachBottom() {
  239. // // 判断是否还有下一页数据
  240. // if (this.pageNo * this.pageSize >= this.total) return uni.showToast({
  241. // title: `数据加载完毕`
  242. // })
  243. // // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  244. // if (this.loading) return
  245. // this.pageNo += 1
  246. // this.getData(this.pageNo)
  247. // }
  248. }
  249. }
  250. </script>
  251. <style>
  252. </style>