maintain-detail.vue 13 KB

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