maintain.vue 10.0 KB

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