maintain-detail.vue 13 KB

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