maintain-ignore.vue 9.7 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.requirement
  16. }}</view>
  17. </view>
  18. <!-- 与 PC 端 CheckJob 任务4保持一致:隐藏设备部位,改显示执行人/班组(checkDeptName 优先,其次 checkUserName) -->
  19. <view class="f-size-26 text-color-6 f-weight-4 mt-2">{{
  20. item.startTime
  21. }} ({{ item.period + periodMap[item.periodType] }}) : {{ item.checkDeptName || item.checkUserName || '-' }}
  22. </view>
  23. <view class="d-flex j-end edit-box">
  24. <view class="text-color-3 f-size-32 edit" v-if="(item.status === 1) && !startFlag">
  25. <view @click.stop="handleExecute(item)">接收</view>
  26. </view>
  27. <!-- 与 PC 端 CheckJob 保持一致:仅执行中(2)可完成 -->
  28. <view class="text-color-3 f-size-32 edit" v-if="item.status === 2 && !startFlag">
  29. <view @click.stop="handleFinish(item)">完成</view>
  30. </view>
  31. <!-- <view class="text-color-3 f-size-32 edit" v-if="item.status === 1||
  32. item.status === 2 ||
  33. item.status === 4">
  34. <view @click.stop="submit(item)">完成</view>
  35. </view> -->
  36. </view>
  37. </view>
  38. <view class="py3">
  39. <u-loadmore :status="status" />
  40. </view>
  41. </template>
  42. <template v-else>
  43. <view class="empty">
  44. <u-empty text="暂无数据" mode="list"></u-empty>
  45. </view>
  46. </template>
  47. </view>
  48. <!-- <view class="p-fixed d-flex j-around a-center footer">
  49. <view
  50. class="main-color-bg text-color-white common"
  51. @tap="handleStart"
  52. >{{ nums }}</view
  53. >
  54. </view> -->
  55. </view>
  56. </template>
  57. <script>
  58. import BaseTool from '../../utils/tool'
  59. export default {
  60. data() {
  61. return {
  62. list: [],
  63. current: 1,
  64. sbId: '',
  65. nums: '开始计时',
  66. // 加载更多
  67. status: 'loadmore',
  68. page: 1,
  69. timer: null,
  70. limit: 10,
  71. type: 1,
  72. filter: -1,
  73. startFlag: false,
  74. loadMore: true,
  75. listData: [],
  76. periodMap: null,
  77. statusMap: null,
  78. sbStatusMap: null,
  79. dict: null,
  80. maskId: 0,
  81. searchType: null
  82. }
  83. },
  84. onPullDownRefresh() {
  85. // 请求结束取消刷新
  86. this.page = 1
  87. this.loadMore = true
  88. this.listData = []
  89. this.initData()
  90. uni.stopPullDownRefresh()
  91. },
  92. onReachBottom() {
  93. if (this.loadMore) {
  94. this.page++
  95. this.initData()
  96. }
  97. },
  98. onLoad(options) {
  99. this.sbId = options.sbId
  100. this.filter = options.filter
  101. this.searchType = options.searchType
  102. if (uni.getStorageSync('check-job-start')) {
  103. this.startFlag = true
  104. // 设置计时:
  105. var oldTime = uni.getStorageSync('check-job-start')
  106. // 设置计时:
  107. var hour, minute, second // 时 分 秒
  108. hour = minute = second = 0 // 初始化
  109. var millisecond = 0 // 毫秒
  110. var ms = Math.abs(new Date() - new Date(oldTime))
  111. // 两个日期相减得到毫秒数 1s=1000ms
  112. var s = ms / 1000 // 毫秒转为秒
  113. hour = Math.floor(s / 3600) // 小时
  114. minute = Math.floor((s % 3600) / 60) // 分
  115. second = Math.floor(s % 60) // 秒
  116. this.timer = setInterval(() => {
  117. millisecond = millisecond + 50
  118. if (millisecond >= 1000) {
  119. millisecond = 0
  120. second = second + 1
  121. }
  122. if (second >= 60) {
  123. second = 0
  124. minute = minute + 1
  125. }
  126. if (minute >= 60) {
  127. minute = 0
  128. hour = hour + 1
  129. }
  130. // console.log("-------"+hour+'时'+minute+'分'+second+'秒');
  131. this.nums = hour + '时' + minute + '分' + second + '秒'
  132. }, 50)
  133. }
  134. this.initData()
  135. this.periodMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
  136. this.statusMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.CHECK_JOB_STATUS)
  137. this.sbStatusMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.CHECK_JOB_SB_STATUS)
  138. this.list = [{ label: '全部', value: '' }].concat(this.$DictCache.getChildrenList(this.$DictCache.TYPE.CHECK_JOB_STATUS))
  139. this.dict = this.$DictCache.COLOR.CHECK_JOB_STATUS
  140. },
  141. onHide() {
  142. this.maskId = 0
  143. },
  144. methods: {
  145. showMask(id, e) {
  146. this.maskId = id
  147. // #ifdef H5
  148. e.preventDefault()
  149. // #endif
  150. },
  151. handleDel(id) {
  152. const that = this
  153. const params = []
  154. params.push(id)
  155. uni.showModal({
  156. title: '提示',
  157. content: '您确认删除吗?',
  158. success: res => {
  159. if (res.confirm) {
  160. this.$Http.deleteCheckJobs(params).then(res => {
  161. uni.showToast({ title: '删除成功' })
  162. this.page = 1
  163. this.loadMore = true
  164. this.listData = []
  165. this.initData()
  166. })
  167. } else if (res.cancel) {
  168. }
  169. }
  170. })
  171. },
  172. // 详情
  173. handleDetail(id) {
  174. // if (index == 0) {
  175. // uni.navigateTo({
  176. // url: '../maintain-add/maintain-add'
  177. // });
  178. // } else {
  179. // uni.navigateTo({
  180. // url: '../maintain-detail/maintain-detail'
  181. // });
  182. // }
  183. if (this.maskId !== 0) {
  184. return (this.maskId = 0)
  185. }
  186. uni.navigateTo({
  187. url: '/pages/maintain-detail/maintain-detail-ignore?detailId=' + id
  188. })
  189. },
  190. handleExecute(item) {
  191. this.$Http.executeJobIgnores(item).then(res => {
  192. item.status = this.$DictCache.VALUE.CHECK_JOB_STATUS.EXECUTING
  193. uni.showToast({ title: '已开始,请及时完成任务' })
  194. })
  195. },
  196. handleFinish(item) {
  197. uni.navigateTo({
  198. url: '/pages/maintain-add/maintain-add?detailId=' + item.id
  199. })
  200. },
  201. // tab
  202. change(index, value) {
  203. this.current = index
  204. if (index === 0) {
  205. this.type = ''
  206. } else {
  207. this.type = value
  208. }
  209. this.page = 1
  210. this.loadMore = true
  211. this.listData = []
  212. this.initData()
  213. },
  214. handleStart() {
  215. clearInterval(this.timer)
  216. uni.showToast({
  217. title: '已开始计时'
  218. })
  219. this.startFlag = true
  220. uni.setStorageSync('check-job-start', this.$BaseTool.Date.formatter(new Date(), BaseTool.Date.PICKER_NORM_DATETIME_PATTERN))
  221. var hour, minute, second // 时 分 秒
  222. hour = minute = second = 0 // 初始化
  223. var millisecond = 0 // 毫秒
  224. this.timer = setInterval(() => {
  225. millisecond = millisecond + 50
  226. if (millisecond >= 1000) {
  227. millisecond = 0
  228. second = second + 1
  229. }
  230. if (second >= 60) {
  231. second = 0
  232. minute = minute + 1
  233. }
  234. if (minute >= 60) {
  235. minute = 0
  236. hour = hour + 1
  237. }
  238. // console.log("-------"+hour+'时'+minute+'分'+second+'秒');
  239. this.nums = hour + '时' + minute + '分' + second + '秒'
  240. }, 50)
  241. },
  242. // 提交
  243. submit(item) {
  244. item.actualStartTime = uni.getStorageSync('check-job-start')
  245. item.status = 3
  246. this.$Http.finishJobIgnores(item).then(res => {
  247. uni.showToast({
  248. title: '已完成'
  249. })
  250. this.initData()
  251. })
  252. },
  253. initData() {
  254. const that = this
  255. that.status = 'loading'
  256. this.$Http
  257. .getCheckJobPageIgnores({
  258. pageNum: this.page,
  259. pageSize: this.limit,
  260. type: 2,
  261. searchType: this.searchType,
  262. filter: this.filter,
  263. sbId: this.sbId,
  264. status: this.type
  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>