maintain-detail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <view class="container py2">
  3. <!-- 标准信息:与 PC 端 Detail 保持一致 -->
  4. <view class="mx3 p3 bg-color-white" style="border-radius: 16rpx">
  5. <view class="f-size-30 main-color-text pb-2">标准信息</view>
  6. <equipment-line title="设备名称" :content="infoData.sbName" />
  7. <equipment-line title="设备编码" :content="infoData.sbNo" />
  8. <equipment-line title="标准编码" :content="modelStandard.no" />
  9. <equipment-line title="检查类型" :content="getMapText(typeMap, modelStandard.type)" />
  10. <equipment-line title="计划周期"
  11. :content="(modelStandard.period || '') + getMapText(periodTypeMap, modelStandard.periodType)" />
  12. <equipment-line title="维护等级" :content="getMapText(levelMap, modelStandard.level)" />
  13. <equipment-line title="标准工时" :content="modelStandard.standardHours" />
  14. <equipment-line title="动作类型" :content="getMapText(actionTypeMap, modelStandard.actionType)" />
  15. <equipment-line title="部位" :content="modelStandard.partName" />
  16. <equipment-line title="要求" :content="modelStandard.requirement" />
  17. <equipment-line title="备注" :content="modelStandard.remark" />
  18. </view>
  19. <view class="m3 p3 bg-color-white" style="border-radius: 16rpx">
  20. <view class="pb-3 border-bottom">
  21. <view class="f-size-30 main-color-text w200">检查项目</view>
  22. <view class="f-size-26 text-color-3 border-bottom py2" v-for="(item, index) in requirementList" :key="index">
  23. <view class="d-flex text-color-6">
  24. <view class="w180">保养周期:</view>
  25. <view class="text-color-3">{{ item.period }}</view>
  26. </view>
  27. <view class="d-flex text-color-6">
  28. <view class="w180">管理项目:</view>
  29. <view class="text-color-3">{{ item.manageItem }}</view>
  30. </view>
  31. <view class="d-flex text-color-6">
  32. <view class="w180">检查项目:</view>
  33. <view class="text-color-3">{{ item.checkItem }}</view>
  34. </view>
  35. <view class="d-flex text-color-6">
  36. <view class="w160">方法工具:</view>
  37. <view class="text-color-3">{{ item.method }}</view>
  38. </view>
  39. <view class="d-flex text-color-6">
  40. <view class="w160">保养级别:</view>
  41. <view class="text-color-3">{{ item.checkLevel }}</view>
  42. </view>
  43. <view class="d-flex text-color-6">
  44. <view class="w160">标准类型:</view>
  45. <view class="text-color-3">{{ item.sbTypeName }}</view>
  46. </view>
  47. <view class="d-flex text-color-6">
  48. <view class="w160">内容:</view>
  49. <view class="text-color-3">{{ item.remark }}</view>
  50. </view>
  51. <view class="d-flex text-color-6">
  52. <view class="w160">填报信息:</view>
  53. <view class="text-color-3 bold">{{ item.value }}</view>
  54. </view>
  55. <view class="d-flex text-color-6">
  56. <view class="w160">备注:</view>
  57. <view class="text-color-3">{{ item.text }}</view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="m3 p3 bg-color-white" style="border-radius: 16rpx">
  63. <view class="d-flex py3 border-bottom">
  64. <view class="f-size-26 text-color-9 w200">标准图片</view>
  65. <view class="f-size-26 text-color-3 d-flex ">
  66. <block v-for="(item, index) in checkImgList" :key="index">
  67. <u-image width="100" class="mr-2" :src="item" @click="handlePre(index)" mode="widthFix"><u-loading
  68. slot="loading"></u-loading></u-image>
  69. </block>
  70. <view v-if="checkImgList.length === 0">暂无</view>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- 标准文件:仅展示文件名 -->
  75. <view class="m3 p3 bg-color-white" style="border-radius: 16rpx"
  76. v-if="modelStandard.checkFileList && modelStandard.checkFileList.length > 0">
  77. <view class="f-size-30 main-color-text pb-2">标准文件</view>
  78. <view class="f-size-26 text-color-3 py2" v-for="item in modelStandard.checkFileList" :key="item.id">{{ item.name
  79. }}</view>
  80. </view>
  81. <!-- 任务信息:与 PC 端 Detail 保持一致 -->
  82. <view class="m3 p3 bg-color-white" style="border-radius: 16rpx">
  83. <view class="f-size-30 main-color-text pb-2">任务信息</view>
  84. <equipment-line title="执行人" :content="infoData.checkUserName" />
  85. <equipment-line title="实际工时" :content="infoData.realHours" />
  86. <equipment-line title="预计执行日期" :content="infoData.startTime" />
  87. <equipment-line title="预计下次执行" :content="infoData.nextDate" />
  88. <equipment-line title="截至日期" :content="infoData.endTime" />
  89. <equipment-line title="实际开始时间" :content="infoData.actualStartTime" />
  90. <equipment-line title="实际结束时间" :content="infoData.actualEndTime" />
  91. <equipment-line title="任务状态" :content="statusMap[infoData.status]" />
  92. <equipment-line title="是否延期"
  93. :content="(infoData.receiveOvertime === null || infoData.receiveOvertime === 0 || !infoData.receiveOvertime) ? '否' : '是'" />
  94. <equipment-line title="检查结果" :content="infoData.feedback" />
  95. </view>
  96. <!-- 完成图片 -->
  97. <view class="m3 p3 bg-color-white" style="border-radius: 16rpx">
  98. <view class="d-flex py3 border-bottom">
  99. <view class="f-size-26 text-color-9 w200">完成图片</view>
  100. <view class="f-size-26 text-color-3 d-flex ">
  101. <block v-for="(item, index) in imgList" :key="index">
  102. <u-image width="100" class="mr-2" :src="item" @click="handleImgPre(index)" mode="widthFix"><u-loading
  103. slot="loading"></u-loading></u-image>
  104. </block>
  105. <view v-if="imgList.length === 0">暂无</view>
  106. </view>
  107. </view>
  108. </view>
  109. <!-- 完成文件:仅展示文件名 -->
  110. <view class="m3 p3 bg-color-white" style="border-radius: 16rpx" v-if="fileList.length > 0">
  111. <view class="f-size-30 main-color-text pb-2">完成文件</view>
  112. <view class="f-size-26 text-color-3 py2" v-for="item in fileList" :key="item.id">{{ item.name }}</view>
  113. </view>
  114. <view class="p-fixed d-flex j-around a-center footer">
  115. <view v-if="infoData.status ===
  116. 1 ||
  117. infoData.status ===
  118. 4" class="main-color-bg text-color-white common" @tap="handleExecute">接收</view>
  119. <view v-if="infoData.status === 2 && displayTime === 0" class="main-color-bg text-color-white common2"
  120. @tap="handleStart">
  121. <u-icon name="play-circle-fill"></u-icon> 开始计时
  122. </view>
  123. <view v-if="infoData.status === 2 && displayTime > 0" class="main-color-bg text-color-white common2"
  124. @tap="handlePause">
  125. <u-icon name="play-circle-fill" v-if="timerStatus === 2"></u-icon><u-icon name="pause-circle-fill"
  126. v-else></u-icon> {{ time }}
  127. </view>
  128. <view v-if="infoData.status === 2" class="main-color-bg text-color-white common" @tap="handleFinish">完成</view>
  129. <view v-if="infoData.status === 3" class="main-color-bg text-color-white common" @tap="handleRepair">发起报修</view>
  130. </view>
  131. </view>
  132. </template>
  133. <script>
  134. export default {
  135. data() {
  136. return {
  137. infoData: {},
  138. detailId: '',
  139. statusMap: null,
  140. sbStatusMap: null,
  141. filter: 0,
  142. searchType: null,
  143. // 标准信息(来自保养标准接口,与 PC 端 Detail 一致)
  144. modelStandard: {},
  145. typeMap: null,
  146. periodTypeMap: null,
  147. levelMap: null,
  148. actionTypeMap: null,
  149. checkImgList: [],
  150. // 完成图片/文件(任务接口返回)
  151. imgList: [],
  152. fileList: [],
  153. requirementList: [],
  154. displayTime: 0,
  155. timer: null,
  156. timerStatus: 0,
  157. time: '00:00:00'
  158. }
  159. },
  160. onLoad(options) {
  161. this.detailId = options.detailId
  162. this.searchType = options.searchType
  163. this.filter = options.filter
  164. this.statusMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.CHECK_JOB_STATUS)
  165. this.sbStatusMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.SB_INFO_STATUS)
  166. this.typeMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.CHECK_STANDARD_TYPE)
  167. this.periodTypeMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
  168. // 维护等级/动作类型本地字典无取值,走后台字典接口(与 PC 端 levelMap/actionTypeMap 对应)
  169. this.$Http.getDictType({ type: 'CHECK_PLAN_LEVEL' }).then(res => {
  170. const map = {}
  171. ; (res.data || []).forEach(item => {
  172. map[item.value] = item.label
  173. })
  174. this.levelMap = map
  175. })
  176. this.$Http.getDictType({ type: 'CHECK_PLAN_ACTION_TYPE' }).then(res => {
  177. const map = {}
  178. ; (res.data || []).forEach(item => {
  179. map[item.value] = item.label
  180. })
  181. this.actionTypeMap = map
  182. })
  183. },
  184. onShow() {
  185. this.initData()
  186. },
  187. methods: {
  188. // 字典取值展示,防止 map 未加载时报错
  189. getMapText(map, value) {
  190. return map && map[value] != null ? map[value] : ''
  191. },
  192. handlePre(index) {
  193. uni.previewImage({
  194. urls: this.checkImgList,
  195. current: this.checkImgList[index],
  196. success() { }
  197. })
  198. },
  199. handleImgPre(index) {
  200. uni.previewImage({
  201. urls: this.imgList,
  202. current: this.imgList[index],
  203. success() { }
  204. })
  205. },
  206. handleExecute() {
  207. this.$Http.execute(this.infoData).then(res => {
  208. this.initData()
  209. uni.showToast({ title: '已接收,请及时完成任务' })
  210. })
  211. },
  212. handleFinish() {
  213. uni.navigateTo({
  214. url: `/pages/maintain/finish?id=${this.infoData.id}&standardId=${this.infoData.standardId}`
  215. })
  216. },
  217. handleRepair() {
  218. uni.navigateTo({
  219. url: '/pages/repair-add/repair-add?detailId=' + this.infoData.sbId
  220. })
  221. },
  222. initData() {
  223. const that = this
  224. this.$Http
  225. .fetchCheckJob({
  226. id: this.detailId
  227. })
  228. .then(res => {
  229. this.infoData = res.data
  230. // 完成图片/文件:与 PC 端 Detail 一致,取任务接口返回的 imgList/fileList
  231. this.imgList = (res.data.imgList || []).map(item => {
  232. return this.$BaseTool.UserUtil.getFileUrl(item.url)
  233. })
  234. this.fileList = res.data.fileList || []
  235. this.$Http.fetchCheckStandard({ id: res.data.standardId }).then(response => {
  236. this.modelStandard = response.data || {}
  237. if (res.data.conTask) {
  238. console.log(2)
  239. that.requirementList = JSON.parse(res.data.conTask)
  240. } else {
  241. that.requirementList = response.data.requirementList
  242. }
  243. // 标准图片:与 PC 端 Detail 一致,取自保养标准接口
  244. this.checkImgList = ((response.data && response.data.checkImgList) || []).map(item => {
  245. return this.$BaseTool.UserUtil.getFileUrl(item.url)
  246. })
  247. })
  248. this.$Http.timerStatus({ referenceId: this.infoData.id }).then(resp => {
  249. this.timerStatus = resp.data.timerStatus
  250. this.$Http.timerAccumulatedTime({ referenceId: this.infoData.id }).then(res => {
  251. this.displayTime = res.data
  252. this.updateDisplay()
  253. if (resp.data.timerStatus === 1) {
  254. that.startLocalTimer()
  255. }
  256. })
  257. })
  258. })
  259. },
  260. handleStart() {
  261. this.$Http.timerStart({ referenceId: this.infoData.id }).then(res => {
  262. uni.showToast({ title: '已开始计时' })
  263. this.startLocalTimer()
  264. })
  265. },
  266. handlePause() {
  267. if (this.timerStatus === 2) {
  268. this.$Http.timerResume({ referenceId: this.infoData.id }).then(res => {
  269. this.timerStatus = res.data.timerStatus
  270. this.startLocalTimer()
  271. })
  272. return
  273. }
  274. this.$Http.timerPause({ referenceId: this.infoData.id }).then(res => {
  275. this.timerStatus = res.data.timerStatus
  276. clearInterval(this.timer)
  277. })
  278. },
  279. // 本地计时器(用于实时显示)
  280. startLocalTimer() {
  281. this.timer = setInterval(() => {
  282. this.displayTime += 1000
  283. this.updateDisplay()
  284. }, 1000)
  285. },
  286. updateDisplay() {
  287. const minutes = Math.floor(this.displayTime / 60000)
  288. const seconds = Math.floor((this.displayTime % 60000) / 1000)
  289. this.time = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`
  290. }
  291. }
  292. }
  293. </script>
  294. <style lang="less">
  295. page {
  296. background-color: #f4f4f4;
  297. }
  298. .container {
  299. padding-bottom: 100rpx;
  300. .footer {
  301. bottom: 0;
  302. left: 0;
  303. right: 0;
  304. background-color: #fff;
  305. z-index: 10000;
  306. }
  307. .title {
  308. border-bottom: 1rpx solid #f4f4f4;
  309. }
  310. .img {
  311. width: 100rpx;
  312. height: 100rpx;
  313. }
  314. .p-fixed {
  315. border-top: 1rpx solid #f4f4f4;
  316. height: 100rpx;
  317. .common {
  318. padding: 15rpx 100rpx;
  319. border-radius: 30rpx;
  320. background-color: #0082ff;
  321. color: #fff;
  322. }
  323. .common2 {
  324. padding: 15rpx 50rpx;
  325. border-radius: 30rpx;
  326. background-color: #0082ff;
  327. color: #fff;
  328. }
  329. }
  330. }
  331. </style>