maintain-detail.vue 13 KB

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