maintain.vue 10 KB

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