maintain-ignore.vue 9.5 KB

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