detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <view class="rect-detail">
  3. <view class="card head-card" v-if="latest">
  4. <view class="head">
  5. <view class="left">
  6. <text class="name">{{ latest.indicatorName }}</text>
  7. <text class="round" v-if="rounds.length > 1">共{{ rounds.length }}轮</text>
  8. </view>
  9. <view class="tag" :style="{ color: statusMeta(latest.status).color, background: statusMeta(latest.status).bg }">
  10. {{ statusMeta(latest.status).text }}
  11. </view>
  12. </view>
  13. <view class="info">
  14. <view class="row"><text class="label">巡检得分</text><text>{{ fmtScore(latest.inspectScore) }}(及格 {{ fmtScore(latest.passScore) }})</text></view>
  15. <view class="row"><text class="label">整改截止</text><text>{{ formatDate(latest.deadlineDate, true) }}</text></view>
  16. </view>
  17. <view class="btn-row">
  18. <button class="btn primary" v-if="latest.status == 1" @click="doStart(latest)">开始整改</button>
  19. </view>
  20. </view>
  21. <!-- 时间轴 -->
  22. <view class="card" v-if="rounds.length">
  23. <view class="title">整改时间轴</view>
  24. <view class="timeline">
  25. <view class="tl-item" v-for="(rd, idx) in rounds" :key="rd.rectId">
  26. <view class="tl-circle" :class="{ current: idx === rounds.length - 1 }"></view>
  27. <view class="tl-body">
  28. <view class="tl-title">
  29. 第{{ rd.rectRound }}轮整改
  30. <text class="tl-tag" :style="{ color: statusMeta(rd.status).color, background: statusMeta(rd.status).bg }">{{ statusMeta(rd.status).text }}</text>
  31. </view>
  32. <view class="tl-line">下发整改通知 {{ formatDate(rd.createDate, true) }}</view>
  33. <view class="tl-line" v-if="rd.noticeContent">通知内容:{{ rd.noticeContent }}</view>
  34. <view class="tl-sub" v-if="rd.feedbackDate">
  35. <text class="sub-icon">门店反馈</text>
  36. <view class="sub-content">{{ rd.feedbackContent }}</view>
  37. <view class="pics" v-if="picsOf(rd.feedbackPictures).length">
  38. <image v-for="(u, i) in picsOf(rd.feedbackPictures)" :key="i" :src="u" mode="aspectFill" class="imgR" @click="preview(picsOf(rd.feedbackPictures), i)" />
  39. </view>
  40. <view class="tl-line">反馈时间:{{ formatDate(rd.feedbackDate, true) }}</view>
  41. </view>
  42. <view class="tl-sub recheck" v-if="rd.recheckDate">
  43. <text class="sub-icon">巡检员复检</text>
  44. <view class="tl-line">复检得分:{{ fmtScore(rd.recheckScore) }}</view>
  45. <view class="tl-line" v-if="rd.recheckRmk">复检备注:{{ rd.recheckRmk }}</view>
  46. <view class="tl-line">复检时间:{{ formatDate(rd.recheckDate, true) }}</view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <!-- 提交整改反馈(仅整改中) -->
  53. <view class="card form" v-if="latest && latest.status == 2">
  54. <view class="title">提交整改反馈</view>
  55. <textarea class="textarea" v-model="content" placeholder="请填写整改说明" :maxlength="500" />
  56. <view class="pics">
  57. <view class="pic" v-for="(p, i) in pics" :key="i">
  58. <image :src="p.local" mode="aspectFill" class="img" @click="preview(pics.map(x => x.local), i)"></image>
  59. <view class="del" @click="delPic(i)">×</view>
  60. </view>
  61. <view class="pic add" v-if="pics.length < 5" @click="choosePic">
  62. <view class="plus">+</view>
  63. <text>{{ pics.length }}/5</text>
  64. </view>
  65. </view>
  66. <button class="btn primary submit" @click="doSubmit">提交反馈</button>
  67. </view>
  68. <view class="empty" v-if="!rounds.length && !loading">记录不存在</view>
  69. </view>
  70. </template>
  71. <script>
  72. import { mapState } from 'vuex';
  73. export default {
  74. data() {
  75. return {
  76. getUrl: '/rectificationApi/getRectDetail',
  77. submitUrl: '/rectificationApi/submitRect',
  78. startUrl: '/rectificationApi/startRect',
  79. uploadUrl: '/rectificationApi/uploadPicture',
  80. id: '',
  81. rounds: [],
  82. loading: true,
  83. content: '',
  84. pics: [] // {local, url}
  85. }
  86. },
  87. computed: {
  88. ...mapState(['storeInfo']),
  89. latest() {
  90. return this.rounds.length ? this.rounds[this.rounds.length - 1] : null
  91. }
  92. },
  93. methods: {
  94. statusMeta(v) {
  95. var map = {
  96. 1: { text: '待整改', color: '#E6A23C', bg: '#fdf6ec' },
  97. 2: { text: '整改中', color: '#409EFF', bg: '#ecf5ff' },
  98. 3: { text: '待复检', color: '#9c27b0', bg: '#f5eefb' },
  99. 4: { text: '复检通过', color: '#67C23A', bg: '#f0f9eb' },
  100. 5: { text: '复检不通过', color: '#F56C6C', bg: '#fef0f0' },
  101. 6: { text: '已超期', color: '#909399', bg: '#f4f4f5' },
  102. 7: { text: '最终不通过', color: '#F56C6C', bg: '#fef0f0' }
  103. }
  104. return map[v] || { text: '未知', color: '#666', bg: '#f4f4f5' }
  105. },
  106. loadData() {
  107. this.loading = true
  108. var dateStr = (new Date()).getTime();
  109. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  110. this.requst({
  111. url: this.getUrl,
  112. data: {
  113. id: this.id,
  114. timestamp: dateStr,
  115. sign: sign,
  116. storeId: this.storeInfo.storeId,
  117. storeUserId: this.storeInfo.storeUserId
  118. },
  119. success: res => {
  120. if (res.data.rtnBean.rtnCode == 0) {
  121. this.rounds = (res.data.obj && res.data.obj.rounds) || []
  122. if (this.latest) this.content = this.latest.feedbackContent || ''
  123. } else if (res.data.rtnBean.rtnMsg) {
  124. this.$api.msg(res.data.rtnBean.rtnMsg)
  125. }
  126. this.loading = false
  127. },
  128. fail: () => {
  129. this.loading = false
  130. }
  131. })
  132. },
  133. doStart(rd) {
  134. var dateStr = (new Date()).getTime();
  135. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  136. this.requst({
  137. url: this.startUrl,
  138. data: {
  139. id: rd.rectId,
  140. timestamp: dateStr,
  141. sign: sign,
  142. storeId: this.storeInfo.storeId,
  143. storeUserId: this.storeInfo.storeUserId
  144. },
  145. success: res => {
  146. if (res.data.rtnBean.rtnCode == 0) {
  147. this.$api.msg('已开始整改')
  148. this.loadData()
  149. } else if (res.data.rtnBean.rtnMsg) {
  150. this.$api.msg(res.data.rtnBean.rtnMsg)
  151. }
  152. }
  153. })
  154. },
  155. choosePic() {
  156. let remain = 5 - this.pics.length
  157. if (remain <= 0) return
  158. uni.chooseImage({
  159. count: remain,
  160. sizeType: ['compressed'],
  161. success: res => {
  162. res.tempFiles.forEach(f => { if (f.size > 5 * 1024 * 1024) { this.$api.msg('图片不能超过5MB'); return } this.uploadPic(f.path) })
  163. }
  164. })
  165. },
  166. uploadPic(filePath) {
  167. uni.showLoading({ title: '上传中' })
  168. var dateStr = (new Date()).getTime();
  169. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  170. var uploadUrl = this.uploadUrl
  171. var baseUrl = getApp().globalData.apiUrl
  172. if (uploadUrl.indexOf('/api/') == -1) {
  173. if (baseUrl.indexOf('127.0.0.1') != -1 || baseUrl.indexOf('localhost') != -1) {
  174. uploadUrl = 'a1' + uploadUrl
  175. } else {
  176. var json = getApp().globalData.storeInfo
  177. if (json) uploadUrl = json.code + uploadUrl
  178. }
  179. }
  180. if (uploadUrl.indexOf('http') != 0) {
  181. if (uploadUrl.charAt(0) == '/') uploadUrl = uploadUrl.substring(1)
  182. uploadUrl = baseUrl + '/' + uploadUrl
  183. }
  184. uni.uploadFile({
  185. url: uploadUrl,
  186. filePath: filePath,
  187. name: 'file',
  188. formData: {
  189. timestamp: dateStr,
  190. sign: sign,
  191. storeId: this.storeInfo.storeId,
  192. storeUserId: this.storeInfo.storeUserId
  193. },
  194. success: res => {
  195. try {
  196. var data = JSON.parse(res.data)
  197. if (data.rtnBean.rtnCode == 0 && data.obj) {
  198. this.pics.push({ local: filePath, url: data.obj })
  199. } else {
  200. this.$api.msg((data.rtnBean && data.rtnBean.rtnMsg) || '上传失败')
  201. }
  202. } catch(e) {
  203. this.$api.msg('上传失败,请检查网络')
  204. }
  205. uni.hideLoading()
  206. },
  207. fail: () => {
  208. uni.hideLoading()
  209. this.$api.msg('上传失败')
  210. }
  211. })
  212. },
  213. delPic(i) {
  214. this.pics.splice(i, 1)
  215. },
  216. picsOf(str) {
  217. if (!str) return []
  218. return String(str).split(',').filter(u => u && u.trim())
  219. },
  220. preview(urls, i) {
  221. uni.previewImage({ urls: urls, current: urls[i] })
  222. },
  223. doSubmit() {
  224. if (this.latest && this.latest.rectRound >= 3 && this.latest.status == 5) {
  225. return this.$api.msg('第3轮复检不通过,无法再次提交')
  226. }
  227. if (!this.latest) return
  228. if (!this.content || !String(this.content).trim()) {
  229. return this.$api.msg('请填写整改说明')
  230. }
  231. var dateStr = (new Date()).getTime();
  232. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  233. let urls = this.pics.map(p => p.url)
  234. this.requst({
  235. url: this.submitUrl,
  236. data: {
  237. id: this.latest.rectId,
  238. timestamp: dateStr,
  239. sign: sign,
  240. storeId: this.storeInfo.storeId,
  241. storeUserId: this.storeInfo.storeUserId,
  242. feedbackContent: String(this.content).trim(),
  243. feedbackPictures: urls.join(',')
  244. },
  245. success: res => {
  246. if (res.data.rtnBean.rtnCode == 0) {
  247. this.$api.msg('已提交,等待复检')
  248. this.pics = []
  249. this.content = ''
  250. this.loadData()
  251. } else if (res.data.rtnBean.rtnMsg) {
  252. this.$api.msg(res.data.rtnBean.rtnMsg)
  253. }
  254. },
  255. fail: () => {}
  256. })
  257. },
  258. formatDate(v, withTime) {
  259. if (!v) return ''
  260. let d = new Date(v)
  261. let p = n => (n < 10 ? '0' + n : n)
  262. let s = d.getFullYear() + '-' + p(d.getMonth() + 1) + '-' + p(d.getDate())
  263. if (withTime) s += ' ' + p(d.getHours()) + ':' + p(d.getMinutes())
  264. return s
  265. },
  266. fmtScore(v) {
  267. return Number(v || 0)
  268. }
  269. },
  270. onLoad(options) {
  271. this.id = options.id || ''
  272. this.loadData()
  273. }
  274. }
  275. </script>
  276. <style lang="scss" scoped>
  277. .rect-detail {
  278. min-height: 100vh;
  279. background-color: #f5f5f5;
  280. padding: 20rpx;
  281. box-sizing: border-box;
  282. }
  283. .card {
  284. background: #fff;
  285. border-radius: 16rpx;
  286. padding: 24rpx;
  287. margin-bottom: 20rpx;
  288. .head {
  289. @include between;
  290. margin-bottom: 16rpx;
  291. .left {
  292. @include flexStart;
  293. .name {
  294. font-size: 32rpx;
  295. font-weight: bold;
  296. color: $text-color;
  297. }
  298. .round {
  299. margin-left: 12rpx;
  300. font-size: $font-sm;
  301. color: $theme-color;
  302. padding: 2rpx 12rpx;
  303. border: 2rpx solid $theme-color;
  304. border-radius: 20rpx;
  305. }
  306. }
  307. .tag {
  308. font-size: $font-sm;
  309. padding: 4rpx 16rpx;
  310. border-radius: 20rpx;
  311. }
  312. }
  313. .title {
  314. font-size: 30rpx;
  315. font-weight: bold;
  316. color: $text-color;
  317. margin-bottom: 16rpx;
  318. }
  319. .row {
  320. @include flexStart;
  321. color: $text-color;
  322. font-size: $font-base;
  323. padding: 8rpx 0;
  324. .label {
  325. min-width: 130rpx;
  326. color: $desc-color;
  327. }
  328. }
  329. .btn {
  330. margin-top: 20rpx;
  331. height: 76rpx;
  332. line-height: 76rpx;
  333. font-size: $font-lg;
  334. color: #fff;
  335. background: $theme-color;
  336. border: none;
  337. border-radius: 38rpx;
  338. }
  339. }
  340. /* 时间轴 */
  341. .timeline {
  342. padding-left: 8rpx;
  343. .tl-item {
  344. position: relative;
  345. padding-left: 40rpx;
  346. padding-bottom: 30rpx;
  347. border-left: 2rpx solid #e5e5e5;
  348. &:last-child {
  349. border-left-color: transparent;
  350. }
  351. .tl-circle {
  352. position: absolute;
  353. left: -12rpx;
  354. top: 4rpx;
  355. width: 22rpx;
  356. height: 22rpx;
  357. border-radius: 50%;
  358. background: #c8c9cc;
  359. &.current {
  360. background: $theme-color;
  361. }
  362. }
  363. .tl-title {
  364. font-size: $font-lg;
  365. font-weight: bold;
  366. color: $text-color;
  367. margin-bottom: 8rpx;
  368. .tl-tag {
  369. margin-left: 12rpx;
  370. font-size: $font-sm;
  371. font-weight: normal;
  372. padding: 2rpx 12rpx;
  373. border-radius: 16rpx;
  374. }
  375. }
  376. .tl-line {
  377. color: $icon-color;
  378. font-size: $font-base;
  379. padding: 2rpx 0;
  380. }
  381. .tl-sub {
  382. background: #f7f7f9;
  383. border-radius: 10rpx;
  384. padding: 16rpx;
  385. margin-top: 10rpx;
  386. .sub-icon {
  387. font-size: $font-sm;
  388. color: $theme-color;
  389. }
  390. .sub-content {
  391. color: $text-color;
  392. font-size: $font-base;
  393. padding: 8rpx 0;
  394. }
  395. &.recheck {
  396. margin-top: 8rpx;
  397. }
  398. }
  399. }
  400. }
  401. /* 图片 */
  402. .pics {
  403. display: flex;
  404. flex-wrap: wrap;
  405. margin-top: 16rpx;
  406. .pic {
  407. position: relative;
  408. width: 160rpx;
  409. height: 160rpx;
  410. border-radius: 10rpx;
  411. margin: 0 14rpx 14rpx 0;
  412. overflow: hidden;
  413. .img {
  414. width: 100%;
  415. height: 100%;
  416. background: #ececec;
  417. }
  418. .del {
  419. position: absolute;
  420. top: 0;
  421. right: 0;
  422. width: 40rpx;
  423. height: 40rpx;
  424. line-height: 36rpx;
  425. text-align: center;
  426. background: rgba(0, 0, 0, 0.5);
  427. color: #fff;
  428. font-size: 30rpx;
  429. }
  430. &.add {
  431. border: 2rpx dashed #ccc;
  432. display: flex;
  433. flex-direction: column;
  434. align-items: center;
  435. justify-content: center;
  436. color: #bbb;
  437. font-size: $font-sm;
  438. .plus {
  439. font-size: 50rpx;
  440. line-height: 50rpx;
  441. }
  442. }
  443. }
  444. .imgR {
  445. width: 160rpx;
  446. height: 160rpx;
  447. border-radius: 10rpx;
  448. margin: 0 14rpx 14rpx 0;
  449. background: #ececec;
  450. }
  451. }
  452. /* 提交表单 */
  453. .form {
  454. .textarea {
  455. width: 100%;
  456. height: 200rpx;
  457. background: #f7f7f7;
  458. border-radius: 10rpx;
  459. padding: 16rpx;
  460. box-sizing: border-box;
  461. font-size: $font-base;
  462. }
  463. }
  464. .empty {
  465. display: flex;
  466. flex-direction: column;
  467. align-items: center;
  468. justify-content: center;
  469. padding-top: 200rpx;
  470. color: #cdcdcd;
  471. font-size: $font-lg;
  472. }
  473. </style>