detail.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <view class="inspect-detail">
  3. <view class="summary" v-if="task">
  4. <view class="head">
  5. <view class="name">{{ task.planName || '巡检报告' }}</view>
  6. <view class="pass" :class="{ good: task.passFlag == 1, bad: task.passFlag == 0 }">{{ passText }}</view>
  7. </view>
  8. <view class="date">巡检日期:{{ formatDate(task.taskDate) }}</view>
  9. <view class="score-row">
  10. <view class="score">
  11. <text class="num">{{ fmtScore(task.totalScore) }}</text>
  12. <text class="max">/{{ fmtScore(task.maxScore) }}</text>
  13. </view>
  14. <view class="inspector" v-if="task.inspectorName">巡检员:{{ task.inspectorName }}</view>
  15. </view>
  16. <view class="rect-link" v-if="task.rectId" @click="goRect(task.rectId)">
  17. 查看关联整改单 <text class="arrow">></text>
  18. </view>
  19. </view>
  20. <view class="items" v-if="items.length">
  21. <view class="section-title">逐项评分</view>
  22. <view class="item" v-for="it in items" :key="it.taskItemId">
  23. <view class="item-head">
  24. <view class="left">
  25. <text class="ind-name">{{ it.indicatorName }}</text>
  26. <text class="type" :class="it.indicatorType == 1 ? 'auto' : 'manual'">{{ it.indicatorType == 1 ? '自动' : '人工' }}</text>
  27. </view>
  28. <view class="right">
  29. <view class="pass" :class="{ good: it.passFlag == 1, bad: it.passFlag == 0 }">{{ it.passFlag == 1 ? '及格' : '不及格' }}</view>
  30. <view class="score"><b>{{ fmtScore(it.score) }}</b>/{{ fmtScore(it.maxScore) }}</view>
  31. </view>
  32. </view>
  33. <view class="deduction" v-if="it.deductionReason"><text class="label">扣分原因:</text>{{ it.deductionReason }}</view><view class="raw" v-if="it.rawValueText">原始数据:{{ it.rawValueText }}</view>
  34. <view class="pics" v-if="picsOf(it).length">
  35. <image v-for="(p, i) in picsOf(it)" :key="i" :src="p" mode="aspectFill" class="pic" @click="preview(it, i)" />
  36. </view>
  37. <view class="rmk" v-if="it.rmk">备注:{{ it.rmk }}</view>
  38. </view>
  39. </view>
  40. <view class="empty" v-if="!task && !loading">
  41. <text>报告不存在</text>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. import { mapState } from 'vuex';
  47. export default {
  48. data() {
  49. return {
  50. apiUrl: '/inspectApi/getMyInspectDetail',
  51. id: '',
  52. task: null,
  53. items: [],
  54. loading: true
  55. }
  56. },
  57. computed: {
  58. ...mapState(['storeInfo']),
  59. passText() {
  60. if (!this.task || this.task.status != 3) return '—'
  61. return this.task.passFlag == 1 ? '及格' : '不及格'
  62. }
  63. },
  64. methods: {
  65. loadData() {
  66. this.loading = true
  67. var dateStr = (new Date()).getTime();
  68. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  69. this.requst({
  70. url: this.apiUrl,
  71. data: {
  72. id: this.id,
  73. timestamp: dateStr,
  74. sign: sign,
  75. storeId: this.storeInfo.storeId,
  76. storeUserId: this.storeInfo.storeUserId
  77. },
  78. success: res => {
  79. if (res.data.rtnBean.rtnCode == 0) {
  80. let obj = res.data.obj || {}
  81. this.task = obj.task || null
  82. this.items = obj.items || []
  83. } else if (res.data.rtnBean.rtnMsg) {
  84. this.$api.msg(res.data.rtnBean.rtnMsg)
  85. }
  86. this.loading = false
  87. },
  88. fail: () => {
  89. this.loading = false
  90. }
  91. })
  92. },
  93. goRect(rectId) {
  94. uni.navigateTo({ url: '/pages/rectification/detail?id=' + rectId })
  95. },
  96. picsOf(it) {
  97. if (!it.pictureUrls) return []
  98. return String(it.pictureUrls).split(',').filter(u => u && u.trim())
  99. },
  100. preview(it, index) {
  101. let urls = this.picsOf(it)
  102. uni.previewImage({ urls: urls, current: urls[index] })
  103. },
  104. formatDate(v) {
  105. if (!v) return ''
  106. let d = new Date(v)
  107. let p = n => (n < 10 ? '0' + n : n)
  108. return d.getFullYear() + '-' + p(d.getMonth() + 1) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes())
  109. },
  110. fmtScore(v) {
  111. return Number(v || 0)
  112. }
  113. },
  114. onLoad(options) {
  115. this.id = options.id || ''
  116. this.loadData()
  117. }
  118. }
  119. </script>
  120. <style lang="scss" scoped>
  121. .inspect-detail {
  122. min-height: 100vh;
  123. background-color: #f5f5f5;
  124. padding-bottom: 40rpx;
  125. }
  126. .summary {
  127. background: #fff;
  128. padding: 30rpx;
  129. border-radius: 0 0 20rpx 20rpx;
  130. .head {
  131. @include between;
  132. margin-bottom: 16rpx;
  133. .name {
  134. font-size: 34rpx;
  135. font-weight: bold;
  136. color: $text-color;
  137. }
  138. .pass {
  139. font-size: $font-sm;
  140. padding: 4rpx 16rpx;
  141. border-radius: 20rpx;
  142. color: #909399;
  143. background: #f4f4f5;
  144. &.good {
  145. color: #67c23a;
  146. background: #f0f9eb;
  147. }
  148. &.bad {
  149. color: #f56c6c;
  150. background: #fef0f0;
  151. }
  152. }
  153. }
  154. .date {
  155. color: $desc-color;
  156. font-size: $font-sm;
  157. margin-bottom: 16rpx;
  158. }
  159. .score-row {
  160. @include between;
  161. .score {
  162. .num {
  163. font-size: 52rpx;
  164. font-weight: bold;
  165. color: $theme-color;
  166. }
  167. .max {
  168. color: $desc-color;
  169. font-size: $font-sm;
  170. }
  171. }
  172. .inspector {
  173. color: $desc-color;
  174. font-size: $font-sm;
  175. }
  176. }
  177. }
  178. .section-title {
  179. font-size: 30rpx;
  180. font-weight: bold;
  181. color: $text-color;
  182. padding: 30rpx 20rpx 10rpx;
  183. }
  184. .items {
  185. padding: 0 20rpx;
  186. .item {
  187. background: #fff;
  188. border-radius: 16rpx;
  189. padding: 24rpx;
  190. margin-bottom: 20rpx;
  191. .item-head {
  192. @include between;
  193. margin-bottom: 12rpx;
  194. .left {
  195. @include flexStart;
  196. .ind-name {
  197. font-size: 30rpx;
  198. font-weight: bold;
  199. color: $text-color;
  200. }
  201. .type {
  202. margin-left: 12rpx;
  203. font-size: $font-sm;
  204. padding: 2rpx 12rpx;
  205. border-radius: 8rpx;
  206. color: #409eff;
  207. background: #ecf5ff;
  208. &.manual {
  209. color: #e6a23c;
  210. background: #fdf6ec;
  211. }
  212. }
  213. }
  214. .right {
  215. text-align: right;
  216. .pass {
  217. font-size: $font-sm;
  218. margin-bottom: 6rpx;
  219. &.good {
  220. color: #67c23a;
  221. }
  222. &.bad {
  223. color: #f56c6c;
  224. }
  225. }
  226. .score {
  227. color: $text-color;
  228. b {
  229. font-size: 34rpx;
  230. color: $theme-color;
  231. }
  232. }
  233. }
  234. }
  235. .raw {
  236. color: $desc-color;
  237. font-size: $font-base;
  238. margin-bottom: 12rpx;
  239. }
  240. .pics {
  241. display: flex;
  242. flex-wrap: wrap;
  243. margin-bottom: 12rpx;
  244. .pic {
  245. width: 160rpx;
  246. height: 160rpx;
  247. border-radius: 10rpx;
  248. margin: 0 12rpx 12rpx 0;
  249. background: #ececec;
  250. }
  251. }
  252. .rmk {
  253. color: $text-color;
  254. font-size: $font-base;
  255. }
  256. }
  257. }
  258. .empty {
  259. display: flex;
  260. flex-direction: column;
  261. align-items: center;
  262. justify-content: center;
  263. padding-top: 200rpx;
  264. color: #cdcdcd;
  265. font-size: $font-lg;
  266. }
  267. </style>