index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view class="container uni-container uni-container-bg">
  3. <u-list @scrolltolower="scrolltolower" v-if="tableData.length>0 && isLoaded">
  4. <view class="top">
  5. <view class="">
  6. <u-search placeholder="请输入任务名称" bgColor="#edf6f9" borderColor="#4cb2b6" v-model="taskname"
  7. :showAction="false"></u-search>
  8. <view class="search-time">
  9. <uni-datetime-picker v-model="kewords" type="daterange" @custom="changeLog" />
  10. </view>
  11. </view>
  12. <view class="search-icon">
  13. <u-icon name="search" color="#4CB2B6" size="42" @click="changeLog"></u-icon>
  14. </view>
  15. </view>
  16. <u-list-item v-for="(item, index) in tableData" :key="index" @click.native="onClick(item)" link>
  17. <uni-row class="demo-uni-row padding-tb-sm" :gutter="20" width="100%">
  18. <uni-col :span="24" class="text-xl font-weight-700" v-if="my==''">{{ item.task_name }}</uni-col>
  19. <!-- <u-badge v-if="item.isdenger==1" :value="1011" numberType="overflow" isDot
  20. customStyle="margin-right:40px" /> -->
  21. <u-icon v-if="item.isdenger==1&&my==''" name="warning-fill" color="#ff5647" size="28"
  22. customStyle="margin-right:20px"></u-icon>
  23. </uni-row>
  24. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  25. <uni-col :span="24" class="text-cut text-grey1">任务介绍:{{ item.insp_name }}</uni-col>
  26. <u-icon v-if="item.isdenger==1&&my!=''" name="warning-fill" color="#ff5647" size="28"
  27. customStyle="margin-right:20px"></u-icon>
  28. </uni-row>
  29. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  30. <uni-col :span="24" class="text-cut text-grey1">详情描述:{{ item.description }}</uni-col>
  31. </uni-row>
  32. <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  33. <uni-col :span="24" class="text-cut text-grey1">提交时间:{{ item.inspect_time}}</uni-col>
  34. <!-- <uni-col :span="16" class="text-cut text-grey1">提交时间:{{ item.cutofftime }}</uni-col>
  35. <uni-col :span="8" class="justify-end flex ">
  36. <u-button class="margin-right-sm" size="small" color="#4CB2B6" style="width: 160rpx; "
  37. > 查看 </u-button>
  38. <u-button size="small" color="red" style="width: 160rpx;">删除</u-button>
  39. </uni-col> -->
  40. </uni-row>
  41. <!-- <uni-row class="demo-uni-row padding-bottom-sm" :gutter="20" width="100%">
  42. <uni-col :span="24" class="text-cut text-grey1">
  43. <u-avatar-group :urls="item.url" size="35" gap="0.4" maxCount='5' @showMore="onClick(item)">
  44. </u-avatar-group>
  45. </uni-col>
  46. </uni-row> -->
  47. </u-list-item>
  48. </u-list>
  49. <view v-else-if="tableData.length==0 && isLoaded" style="text-align: center;">
  50. <view class="text-gray" style="padding-top: 20px;">
  51. <img :src="tan90" alt="暂无数据" />
  52. </view>
  53. </view>
  54. <!-- 加载中 -->
  55. <isLodingModel></isLodingModel>
  56. </view>
  57. </template>
  58. <script>
  59. let that = null;
  60. import {
  61. getInspecthisPage,
  62. getSelfInspecthisPage
  63. } from '@/api/task';
  64. import {
  65. getInsHisImgurl,
  66. } from '@/api/check_record';
  67. import {
  68. shijianc
  69. } from '@/utils/common.js'
  70. import config from '@/config'
  71. const baseUrlImg = config.baseUrlImg
  72. export default {
  73. data() {
  74. return {
  75. isLoaded: false,
  76. tan90: `${baseUrlImg}/tan90.png`,
  77. // 数据
  78. tableData: [],
  79. taskname: '',
  80. // 每页数据量
  81. pageSize: 20,
  82. kewords: [],
  83. // 当前页
  84. pageNo: 1,
  85. // 数据总量
  86. total: 0,
  87. // tableData数据加载中
  88. loading: false,
  89. statusList: {
  90. 0: '未完成',
  91. 1: '已完成',
  92. 2: '审核中',
  93. 3: '审核未通过'
  94. },
  95. urls2: ['https://cdn.uviewui.com/uview/album/1.jpg', 'https://cdn.uviewui.com/uview/album/2.jpg',
  96. 'https://cdn.uviewui.com/uview/album/3.jpg', 'https://cdn.uviewui.com/uview/album/4.jpg',
  97. 'https://cdn.uviewui.com/uview/album/5.jpg', 'https://cdn.uviewui.com/uview/album/6.jpg',
  98. 'https://cdn.uviewui.com/uview/album/7.jpg', 'https://cdn.uviewui.com/uview/album/8.jpg',
  99. 'https://cdn.uviewui.com/uview/album/9.jpg', 'https://cdn.uviewui.com/uview/album/10.jpg',
  100. 'https://cdn.uviewui.com/uview/album/9.jpg', 'https://cdn.uviewui.com/uview/album/10.jpg',
  101. ],
  102. my: '',
  103. title: '暂无数据'
  104. };
  105. },
  106. watch: {
  107. loading: {
  108. handler(newLength, oldLength) {
  109. this.$modal.isLoadingModel(this.loading)
  110. },
  111. immediate: true
  112. }
  113. },
  114. // 在 vue页面,向起始页通过事件传递数据
  115. onLoad: function(option) {
  116. console.log(option,'option');
  117. if (option.my) {
  118. this.my = option.my
  119. }
  120. },
  121. onShow() {
  122. this.tableData = []
  123. this.getData(1);
  124. },
  125. methods: {
  126. changeLog(e) {
  127. this.title = ''
  128. this.isLoaded=false
  129. this.tableData = []
  130. if (this.kewords.length > 0 && this.kewords[0].indexOf(":") === -1) {
  131. this.kewords[0] = this.kewords[0] + ' 00:00:00'
  132. this.kewords[1] = this.kewords[1] + ' 23:59:59'
  133. }
  134. this.getData(1)
  135. console.log(this.kewords, 'ddddddddddd', e);
  136. },
  137. // =================数据转换==================
  138. statusListTran(val) {
  139. //status状态转换
  140. return this.statusList[val];
  141. },
  142. // ================================
  143. // 获取数据
  144. getData(pageNo, value = '') {
  145. this.loading = true;
  146. this.pageNo = pageNo;
  147. let formChuan={
  148. pageNo: this.pageNo,
  149. pageSize: this.pageSize,
  150. userId: this.$store.state.user.id,
  151. inspectTime: this.kewords,
  152. taskName: this.taskname
  153. }
  154. if (this.my == 'onlymy') {
  155. getSelfInspecthisPage(formChuan).then(response => {
  156. console.log('response', response);
  157. // 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接
  158. this.isLoaded = true
  159. this.tableData = [...this.tableData, ...response.data.records];
  160. this.tableData.map(i => {
  161. i.inspect_time = shijianc(i.inspect_time)
  162. })
  163. // this.tableData = response.data.list;
  164. this.total = response.data.total;
  165. this.loading = false;
  166. });
  167. } else{
  168. getInspecthisPage(formChuan).then(response => {
  169. console.log('1111', response);
  170. this.isLoaded = true
  171. // 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接
  172. this.tableData = [...this.tableData, ...response.data.list];
  173. this.tableData.map(i => {
  174. i.inspect_time = shijianc(i.inspect_time)
  175. })
  176. // this.tableData = response.data.list;
  177. this.total = response.data.total;
  178. this.loading = false;
  179. });
  180. }
  181. },
  182. onClick(val) {
  183. console.log(val);
  184. this.isLoaded = false
  185. if (this.my == "myonly") {
  186. uni.navigateTo({
  187. url: `/pagesA/fire/check_record/picture/picture?items=${JSON.stringify(val)}`
  188. });
  189. } else {
  190. uni.navigateTo({
  191. url: `/pagesA/fire/check_record/picture/picture?id=${val.id}`
  192. });
  193. }
  194. },
  195. gotoDetails(val) {
  196. this.isLoaded = false
  197. console.log('val.status', val.status);
  198. var url = '';
  199. if (val.status == 1) {
  200. //主动检查详情
  201. url = '/pagesA/fire/check_active/check_details/check_details?id=' + val.id;
  202. } else if (val.status == 2) {
  203. //每日巡检详情
  204. url = '/pages/s9Unit/daily_inspection/inspection_details/inspection_details?id=' + val.id;
  205. } else if (val.status == 3) {
  206. url = '/pagesA/fire/hidden_trouble/trouble_details/trouble_details?id=' + val.id;
  207. } else if (val.status == 4) {
  208. url = '/pagesA/fire/check_tasks/tasks_details/tasks_details?id=' + val.id;
  209. } else {}
  210. uni.navigateTo({
  211. url: url
  212. });
  213. },
  214. gotoPersonnelDetails(val) {
  215. this.isLoaded = false
  216. uni.navigateTo({
  217. url: '/pagesA/fire/check_record/personnel_record/personnel_record?id=' + val.id
  218. });
  219. },
  220. // 触底的事件
  221. scrolltolower() {
  222. // 判断是否还有下一页数据
  223. if (this.pageNo * this.pageSize >= this.total) return uni.showToast({
  224. title: `数据加载完毕`
  225. });
  226. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  227. if (this.loading) return;
  228. this.pageNo += 1;
  229. this.getData(this.pageNo);
  230. }
  231. // 触底的事件
  232. // onReachBottom() {
  233. // // 判断是否还有下一页数据
  234. // if (this.pageNo * this.pageSize >= this.total) return uni.showToast({
  235. // title: `数据加载完毕`
  236. // })
  237. // // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  238. // if (this.loading) return
  239. // this.pageNo += 1
  240. // this.getData(this.pageNo)
  241. // }
  242. }
  243. };
  244. </script>
  245. <style scoped lang="scss">
  246. .uni-container {
  247. height: 100vh;
  248. }
  249. .top {
  250. display: flex;
  251. align-items: center;
  252. width: 90%;
  253. margin-left: 5%;
  254. justify-content: space-between;
  255. .search-time {
  256. display: flex;
  257. align-items: center;
  258. margin-top: 40rpx;
  259. margin-bottom: 20rpx;
  260. .time-item {
  261. margin-right: 20rpx;
  262. }
  263. }
  264. }
  265. ::v-deep .u-icon__icon {
  266. top: 2px !important;
  267. padding-left: 3px !important;
  268. }
  269. </style>