maintain.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template>
  2. <view class="container">
  3. <common-tabs :list="list" :current="current" @change="change" />
  4. <view class="p-top8">
  5. <template v-if="listData.length > 0">
  6. <view class="mx3 my2 p3 bg-color-white box p-relative" v-for="(item, index) in listData" :key="item.id"
  7. @click="handleDetail(item.id)" @longpress="showMask(item.id, $event)">
  8. <common-mask :item="item" :maskId="maskId" @hide="maskId = 0" @del="handleDel(item.id)" />
  9. <view class="d-flex j-between border-bottom pb-2 a-center">
  10. <view class="text-color-b f-size-26 text-overflow">{{ item.sbNo }} ({{ item.sbName }})</view>
  11. <my-badge :text="statusMap[item.status]" :status="dict[item.status]" />
  12. </view>
  13. <view class="mt-2 d-flex j-between">
  14. <view class="text-color-3 f-size-32 f-weight-bold">{{
  15. item.requirementList ? item.requirementList.map(i => i.stdName).join('、') : ''
  16. }}</view>
  17. </view>
  18. <view class="f-size-26 text-color-6 f-weight-4 mt-2">计划执行日期:{{
  19. item.startTime
  20. }}
  21. </view>
  22. <view class="f-size-26 text-color-6 f-weight-4 mt-2">实际执行日期:{{
  23. item.actualStartTime
  24. }}
  25. </view>
  26. <view class="f-size-26 text-color-6 f-weight-4 mt-2">设备部位:{{
  27. item.partName
  28. }}
  29. </view>
  30. <view class="d-flex j-end edit-box">
  31. <!-- 与 PC 端 CheckJob 保持一致:仅未执行(1)可接收 -->
  32. <view class="text-color-3 f-size-32 edit" v-if="item.status === 1 && !startFlag">
  33. <view @click.stop="handleExecute(item)">开始</view>
  34. </view>
  35. <!-- 与 PC 端 CheckJob 保持一致:仅执行中(2)可执行/完成 -->
  36. <!-- <view class="text-color-3 f-size-32 edit" v-if="item.status === 2 && !startFlag">
  37. <view @click.stop="handleFinish(item)">执行</view>
  38. </view> -->
  39. <view class="text-color-3 f-size-32 edit" v-if="item.status === 2">
  40. <view @click.stop="submit(item)">完成</view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="py3">
  45. <u-loadmore :status="status" />
  46. </view>
  47. </template>
  48. <template v-else>
  49. <view class="empty">
  50. <u-empty text="暂无数据" mode="list"></u-empty>
  51. </view>
  52. </template>
  53. </view>
  54. <!-- <view class="p-fixed d-flex j-around a-center footer">
  55. <view class="main-color-bg text-color-white common" @tap="handleStart">{{ nums }}</view>
  56. </view> -->
  57. </view>
  58. </template>
  59. <script>
  60. import BaseTool from '../../utils/tool'
  61. export default {
  62. data() {
  63. return {
  64. list: [],
  65. current: 1,
  66. sbId: '',
  67. nums: '开始计时',
  68. // 加载更多
  69. status: 'loadmore',
  70. page: 1,
  71. timer: null,
  72. limit: 10,
  73. type: 1,
  74. filter: -1,
  75. searchType: null,
  76. startFlag: false,
  77. loadMore: true,
  78. listData: [],
  79. periodMap: null,
  80. statusMap: null,
  81. sbStatusMap: null,
  82. dict: null,
  83. maskId: 0,
  84. statusList: null,
  85. receiveOvertime: null,
  86. timeFlag: null
  87. }
  88. },
  89. onPullDownRefresh() {
  90. // 请求结束取消刷新
  91. this.page = 1
  92. this.loadMore = true
  93. this.listData = []
  94. this.initData()
  95. uni.stopPullDownRefresh()
  96. },
  97. onReachBottom() {
  98. if (this.loadMore) {
  99. this.page++
  100. this.initData()
  101. }
  102. },
  103. onLoad(options) {
  104. this.sbId = options.sbId
  105. this.filter = options.filter
  106. this.searchType = options.searchType
  107. this.timeFlag = options.timeFlag
  108. this.periodMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
  109. this.statusMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.CHECK_JOB_STATUS)
  110. this.sbStatusMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.CHECK_JOB_SB_STATUS)
  111. this.list = [{ label: '全部', value: '' }].concat(this.$DictCache.getChildrenList(this.$DictCache.TYPE.CHECK_JOB_STATUS))
  112. this.dict = this.$DictCache.COLOR.CHECK_JOB_STATUS
  113. },
  114. onShow() {
  115. this.page = 1
  116. this.loadMore = true
  117. this.listData = []
  118. this.initData()
  119. },
  120. onHide() {
  121. this.maskId = 0
  122. },
  123. methods: {
  124. showMask(id, e) {
  125. this.maskId = id
  126. // #ifdef H5
  127. e.preventDefault()
  128. // #endif
  129. },
  130. handleDel(id) {
  131. const that = this
  132. const params = []
  133. params.push(id)
  134. uni.showModal({
  135. title: '提示',
  136. content: '您确认删除吗?',
  137. success: res => {
  138. if (res.confirm) {
  139. this.$Http.deleteCheckJobs(params).then(res => {
  140. uni.showToast({ title: '删除成功' })
  141. this.page = 1
  142. this.loadMore = true
  143. this.listData = []
  144. this.initData()
  145. })
  146. } else if (res.cancel) {
  147. }
  148. }
  149. })
  150. },
  151. // 详情
  152. handleDetail(id) {
  153. // if (index == 0) {
  154. // uni.navigateTo({
  155. // url: '../maintain-add/maintain-add'
  156. // });
  157. // } else {
  158. // uni.navigateTo({
  159. // url: '../maintain-detail/maintain-detail'
  160. // });
  161. // }
  162. if (this.maskId !== 0) {
  163. return (this.maskId = 0)
  164. }
  165. uni.navigateTo({
  166. url: '/pages/maintain-detail/maintain-detail?detailId=' + id + '&filter=' + this.filter + '&searchType=' + this.searchType
  167. })
  168. },
  169. handleExecute(item) {
  170. this.$Http.execute(item).then(res => {
  171. item.status = this.$DictCache.VALUE.CHECK_JOB_STATUS.EXECUTING
  172. this.current = this.$DictCache.VALUE.CHECK_JOB_STATUS.EXECUTING
  173. this.change(this.current, this.current)
  174. uni.showToast({ title: '已开始,请及时完成任务' })
  175. })
  176. },
  177. handleFinish(item) {
  178. uni.navigateTo({
  179. url: '/pages/maintain-add/maintain-add?detailId=' + item.id + '&filter=' + this.filter + '&searchType=' + this.searchType
  180. })
  181. },
  182. // tab
  183. change(index, value) {
  184. this.current = index
  185. console.log(index)
  186. this.statusList = null
  187. this.receiveOvertime = null
  188. if (index === 0) {
  189. this.type = ''
  190. } else if (value === 4) {
  191. // 已过期与 PC 端逾期页(PollingCheckJobOverTime)一致:receiveOvertime + 不限状态
  192. this.type = null
  193. this.statusList = []
  194. this.receiveOvertime = true
  195. } else {
  196. this.type = value
  197. }
  198. this.page = 1
  199. this.loadMore = true
  200. this.listData = []
  201. this.initData()
  202. },
  203. handleStart() {
  204. clearInterval(this.timer)
  205. uni.showToast({
  206. title: '已开始计时'
  207. })
  208. this.startFlag = true
  209. uni.setStorageSync('check-job-start-' + this.sbId, this.$BaseTool.Date.formatter(new Date(), BaseTool.Date.PICKER_NORM_DATETIME_PATTERN))
  210. var hour, minute, second // 时 分 秒
  211. hour = minute = second = 0 // 初始化
  212. var millisecond = 0 // 毫秒
  213. this.timer = setInterval(() => {
  214. millisecond = millisecond + 50
  215. if (millisecond >= 1000) {
  216. millisecond = 0
  217. second = second + 1
  218. }
  219. if (second >= 60) {
  220. second = 0
  221. minute = minute + 1
  222. }
  223. if (minute >= 60) {
  224. minute = 0
  225. hour = hour + 1
  226. }
  227. // console.log("-------"+hour+'时'+minute+'分'+second+'秒');
  228. this.nums = hour + '时' + minute + '分' + second + '秒'
  229. }, 50)
  230. },
  231. // 提交
  232. submit(item) {
  233. console.log(22)
  234. uni.navigateTo({
  235. url: `/pages/maintain/finish?id=${item.id}&standardId=${item.standardId}`
  236. })
  237. // item.actualStartTime = uni.getStorageSync('check-job-start');
  238. // item.status = 3
  239. // this.$Http.finishJob(item).then((res) => {
  240. // uni.showToast({
  241. // title: '已完成'
  242. // });
  243. // this.initData();
  244. // });
  245. },
  246. initData() {
  247. const that = this
  248. that.status = 'loading'
  249. this.$Http
  250. .getCheckJobPage({
  251. pageNum: this.page,
  252. pageSize: this.limit,
  253. type: 2,
  254. filter: this.filter,
  255. searchType: this.searchType,
  256. sbId: this.sbId,
  257. status: this.type,
  258. receiveOvertime: this.receiveOvertime,
  259. // 与 PC 端 CheckJob 一致:默认只查未执行/执行中/已完成,不含已过期(4)
  260. statusList: this.statusList === null ? [1, 2, 3] : this.statusList,
  261. timeFlag: this.timeFlag,
  262. // 与 PC 端 CheckJob loadData 参数保持一致
  263. mineFlag: false,
  264. record: this.type === 3 ? 1 : null
  265. })
  266. .then(res => {
  267. const data = res.data.rows
  268. if (data && data.length > 0 && data.length < that.limit) {
  269. that.status = 'nomore'
  270. that.loadMore = false
  271. } else if (data.length == that.limit) {
  272. that.status = 'loadmore'
  273. } else {
  274. that.status = 'nomore'
  275. }
  276. that.listData = [...that.listData, ...data]
  277. })
  278. }
  279. }
  280. }
  281. </script>
  282. <style lang="scss">
  283. page {
  284. background-color: #f4f4f4;
  285. }
  286. .box {
  287. padding-right: 0;
  288. border-radius: 20rpx;
  289. }
  290. .edit-box {
  291. padding: 0 30rpx;
  292. margin-top: 40rpx;
  293. .edit {
  294. padding: 8rpx 40rpx;
  295. border: 1px solid #ddd;
  296. border-radius: 20rpx;
  297. font-size: 26rpx;
  298. color: #666;
  299. margin-left: 30rpx;
  300. }
  301. }
  302. .text-overflow {
  303. width: 60%;
  304. overflow: hidden;
  305. text-overflow: ellipsis;
  306. display: -webkit-box;
  307. -webkit-line-clamp: 2;
  308. -webkit-box-orient: vertical;
  309. }
  310. .container {
  311. padding-bottom: 100rpx;
  312. .footer {
  313. bottom: 0;
  314. left: 0;
  315. right: 0;
  316. background-color: #fff;
  317. z-index: 10000;
  318. }
  319. .title {
  320. border-bottom: 1rpx solid #f4f4f4;
  321. }
  322. .img {
  323. width: 100rpx;
  324. height: 100rpx;
  325. }
  326. .p-fixed {
  327. border-top: 1rpx solid #f4f4f4;
  328. height: 100rpx;
  329. .common {
  330. padding: 15rpx 200rpx;
  331. border-radius: 30rpx;
  332. background-color: #0082ff;
  333. color: #fff;
  334. }
  335. }
  336. }
  337. </style>