maintain-ignore.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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.requireLogin(() => {
  192. this.$Http.executeJobIgnores(item).then(res => {
  193. item.status = this.$DictCache.VALUE.CHECK_JOB_STATUS.EXECUTING
  194. uni.showToast({ title: '已开始,请及时完成任务' })
  195. })
  196. }, '接收保养任务需要先登录,是否登录?')
  197. },
  198. handleFinish(item) {
  199. this.$Http.requireLogin(() => {
  200. uni.navigateTo({
  201. url: '/pages/maintain-add/maintain-add?detailId=' + item.id
  202. })
  203. }, '完成保养任务需要先登录,是否登录?')
  204. },
  205. // tab
  206. change(index, value) {
  207. this.current = index
  208. if (index === 0) {
  209. this.type = ''
  210. } else {
  211. this.type = value
  212. }
  213. this.page = 1
  214. this.loadMore = true
  215. this.listData = []
  216. this.initData()
  217. },
  218. handleStart() {
  219. clearInterval(this.timer)
  220. uni.showToast({
  221. title: '已开始计时'
  222. })
  223. this.startFlag = true
  224. uni.setStorageSync('check-job-start', this.$BaseTool.Date.formatter(new Date(), BaseTool.Date.PICKER_NORM_DATETIME_PATTERN))
  225. var hour, minute, second // 时 分 秒
  226. hour = minute = second = 0 // 初始化
  227. var millisecond = 0 // 毫秒
  228. this.timer = setInterval(() => {
  229. millisecond = millisecond + 50
  230. if (millisecond >= 1000) {
  231. millisecond = 0
  232. second = second + 1
  233. }
  234. if (second >= 60) {
  235. second = 0
  236. minute = minute + 1
  237. }
  238. if (minute >= 60) {
  239. minute = 0
  240. hour = hour + 1
  241. }
  242. // console.log("-------"+hour+'时'+minute+'分'+second+'秒');
  243. this.nums = hour + '时' + minute + '分' + second + '秒'
  244. }, 50)
  245. },
  246. // 提交
  247. submit(item) {
  248. this.$Http.requireLogin(() => {
  249. item.actualStartTime = uni.getStorageSync('check-job-start')
  250. item.status = 3
  251. this.$Http.finishJobIgnores(item).then(res => {
  252. uni.showToast({
  253. title: '已完成'
  254. })
  255. this.initData()
  256. })
  257. }, '完成保养任务需要先登录,是否登录?')
  258. },
  259. initData() {
  260. const that = this
  261. that.status = 'loading'
  262. this.$Http
  263. .getCheckJobPageIgnores({
  264. pageNum: this.page,
  265. pageSize: this.limit,
  266. type: 2,
  267. searchType: this.searchType,
  268. filter: this.filter,
  269. sbId: this.sbId,
  270. status: this.type
  271. })
  272. .then(res => {
  273. const data = res.data.rows
  274. if (data && data.length > 0 && data.length < that.limit) {
  275. that.status = 'nomore'
  276. that.loadMore = false
  277. } else if (data.length == that.limit) {
  278. that.status = 'loadmore'
  279. } else {
  280. that.status = 'nomore'
  281. }
  282. that.listData = [...that.listData, ...data]
  283. })
  284. }
  285. }
  286. }
  287. </script>
  288. <style lang="scss">
  289. page {
  290. background-color: #f4f4f4;
  291. }
  292. .box {
  293. padding-right: 0;
  294. border-radius: 20rpx;
  295. }
  296. .edit-box {
  297. padding: 0 30rpx;
  298. margin-top: 40rpx;
  299. .edit {
  300. padding: 8rpx 40rpx;
  301. border: 1px solid #ddd;
  302. border-radius: 20rpx;
  303. font-size: 26rpx;
  304. color: #666;
  305. margin-left: 30rpx;
  306. }
  307. }
  308. .text-overflow {
  309. width: 60%;
  310. overflow: hidden;
  311. text-overflow: ellipsis;
  312. display: -webkit-box;
  313. -webkit-line-clamp: 2;
  314. -webkit-box-orient: vertical;
  315. }
  316. .container {
  317. padding-bottom: 100rpx;
  318. .footer {
  319. bottom: 0;
  320. left: 0;
  321. right: 0;
  322. background-color: #fff;
  323. z-index: 10000;
  324. }
  325. .title {
  326. border-bottom: 1rpx solid #f4f4f4;
  327. }
  328. .img {
  329. width: 100rpx;
  330. height: 100rpx;
  331. }
  332. .p-fixed {
  333. border-top: 1rpx solid #f4f4f4;
  334. height: 100rpx;
  335. .common {
  336. padding: 15rpx 200rpx;
  337. border-radius: 30rpx;
  338. background-color: #0082ff;
  339. color: #fff;
  340. }
  341. }
  342. }
  343. </style>