list.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view class="rect-list">
  3. <view class="filter-tabs">
  4. <view v-for="(t, idx) in tabs" :key="t.label" class="tab" :class="{ active: activeIdx === idx }" @click="switchTab(idx)">
  5. {{ t.label }}
  6. </view>
  7. </view>
  8. <view class="list" v-if="showList.length">
  9. <view class="item" v-for="item in showList" :key="item.rectId" @click="goDetail(item)">
  10. <view class="top">
  11. <view class="left">
  12. <text class="name">{{ item.indicatorName }}</text>
  13. <text class="round" v-if="item.rectRound > 1">第{{ item.rectRound }}轮</text>
  14. </view>
  15. <view class="tag" :style="{ color: statusMeta(item.status).color, background: statusMeta(item.status).bg }">
  16. {{ statusMeta(item.status).text }}
  17. </view>
  18. </view>
  19. <view class="meta">
  20. <text>巡检得分:{{ fmtScore(item.inspectScore) }}(及格 {{ fmtScore(item.passScore) }})</text>
  21. </view>
  22. <view class="meta deadline">截止:{{ formatDate(item.deadlineDate) }}<text class="countdown" v-if="item.status == 1 || item.status == 2"> 剩余{{ remainDays(item.deadlineDate) }}天</text></view>
  23. <view class="actions" v-if="item.status == 1 || item.status == 2">
  24. <button class="btn" v-if="item.status == 1" @tap.stop="doStart(item)">开始整改</button>
  25. <button class="btn primary" v-if="item.status == 2" @tap.stop="goSubmit(item)">提交反馈</button>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="empty" v-else-if="!loading">
  30. <image src="/static/imgs/empty/empty2x.png" class="empty-img" mode="widthFix"></image>
  31. <text>暂无整改记录</text>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import { mapState } from 'vuex';
  37. export default {
  38. data() {
  39. return {
  40. listUrl: '/rectificationApi/getMyRectList',
  41. startUrl: '/rectificationApi/startRect',
  42. records: [],
  43. loading: true,
  44. activeIdx: 0,
  45. // 按 PRD 状态分桶:待整改(1) / 进行中(2整改中,3待复检) / 已完成(4复检通过,5复检不通过,7最终不通过) / 已超期(6)
  46. tabs: [
  47. { label: '待整改', value: [1] },
  48. { label: '进行中', value: [2, 3] },
  49. { label: '已完成', value: [4, 5, 7] },
  50. { label: '已超期', value: [6] }
  51. ]
  52. }
  53. },
  54. computed: {
  55. ...mapState(['storeInfo']),
  56. showList() {
  57. var t = this.tabs[this.activeIdx]
  58. return this.records.filter(r => t.value.indexOf(r.status) > -1)
  59. }
  60. },
  61. methods: {
  62. switchTab(idx) {
  63. this.activeIdx = idx
  64. },
  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.listUrl,
  71. data: {
  72. timestamp: dateStr,
  73. sign: sign,
  74. storeId: this.storeInfo.storeId,
  75. storeUserId: this.storeInfo.storeUserId
  76. },
  77. success: res => {
  78. if (res.data.rtnBean.rtnCode == 0) {
  79. this.records = res.data.list || []
  80. } else if (res.data.rtnBean.rtnMsg) {
  81. this.$api.msg(res.data.rtnBean.rtnMsg)
  82. }
  83. this.loading = false
  84. uni.stopPullDownRefresh()
  85. },
  86. fail: () => {
  87. this.loading = false
  88. uni.stopPullDownRefresh()
  89. }
  90. })
  91. },
  92. doStart(item) {
  93. var dateStr = (new Date()).getTime();
  94. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  95. this.requst({
  96. url: this.startUrl,
  97. data: {
  98. id: item.rectId,
  99. timestamp: dateStr,
  100. sign: sign,
  101. storeId: this.storeInfo.storeId,
  102. storeUserId: this.storeInfo.storeUserId
  103. },
  104. success: res => {
  105. if (res.data.rtnBean.rtnCode == 0) {
  106. this.$api.msg('已开始整改')
  107. this.loadData()
  108. } else if (res.data.rtnBean.rtnMsg) {
  109. this.$api.msg(res.data.rtnBean.rtnMsg)
  110. }
  111. },
  112. fail: () => {}
  113. })
  114. },
  115. goDetail(item) {
  116. uni.navigateTo({ url: '/pages/rectification/detail?id=' + item.rectId })
  117. },
  118. goSubmit(item) {
  119. uni.navigateTo({ url: '/pages/rectification/detail?id=' + item.rectId + '&submit=1' })
  120. },
  121. statusMeta(v) {
  122. var map = {
  123. 1: { text: '待整改', color: '#E6A23C', bg: '#fdf6ec' },
  124. 2: { text: '整改中', color: '#409EFF', bg: '#ecf5ff' },
  125. 3: { text: '待复检', color: '#9c27b0', bg: '#f5eefb' },
  126. 4: { text: '复检通过', color: '#67C23A', bg: '#f0f9eb' },
  127. 5: { text: '复检不通过', color: '#F56C6C', bg: '#fef0f0' },
  128. 6: { text: '已关闭', color: '#909399', bg: '#f4f4f5' },
  129. 7: { text: '最终不通过', color: '#F56C6C', bg: '#fef0f0' }
  130. }
  131. return map[v] || { text: '', color: '#666', bg: '#f4f4f5' }
  132. },
  133. formatDate(v) {
  134. if (!v) return ''
  135. let d = new Date(v)
  136. let p = n => (n < 10 ? '0' + n : n)
  137. return d.getFullYear() + '-' + p(d.getMonth() + 1) + '-' + p(d.getDate())
  138. },
  139. remainDays(deadline) {
  140. if (!deadline) return '?'
  141. let now = new Date()
  142. let end = new Date(deadline)
  143. let diff = Math.ceil((end - now) / (1000 * 60 * 60 * 24))
  144. return diff > 0 ? diff : 0
  145. },
  146. fmtScore(v) {
  147. return Number(v || 0)
  148. }
  149. },
  150. onPullDownRefresh() {
  151. this.loadData()
  152. },
  153. onLoad() {
  154. this.loadData()
  155. }
  156. }
  157. </script>
  158. <style lang="scss" scoped>
  159. .rect-list {
  160. min-height: 100vh;
  161. background-color: #f5f5f5;
  162. }
  163. .filter-tabs {
  164. display: flex;
  165. background-color: #fff;
  166. padding: 20rpx;
  167. .tab {
  168. flex: 1;
  169. text-align: center;
  170. font-size: $font-lg;
  171. color: $text-color;
  172. &.active {
  173. color: $theme-color;
  174. font-weight: bold;
  175. }
  176. }
  177. }
  178. .list {
  179. padding: 20rpx;
  180. .item {
  181. background: #fff;
  182. border-radius: 16rpx;
  183. padding: 24rpx;
  184. margin-bottom: 20rpx;
  185. .top {
  186. @include between;
  187. margin-bottom: 12rpx;
  188. .left {
  189. @include flexStart;
  190. .name {
  191. font-size: 30rpx;
  192. font-weight: bold;
  193. color: $text-color;
  194. }
  195. .round {
  196. margin-left: 12rpx;
  197. font-size: $font-sm;
  198. color: $theme-color;
  199. padding: 2rpx 12rpx;
  200. border: 2rpx solid $theme-color;
  201. border-radius: 20rpx;
  202. }
  203. }
  204. .tag {
  205. font-size: $font-sm;
  206. padding: 4rpx 16rpx;
  207. border-radius: 20rpx;
  208. }
  209. }
  210. .meta {
  211. color: $desc-color;
  212. font-size: $font-base;
  213. margin-bottom: 8rpx;
  214. &.deadline {
  215. color: $icon-color;
  216. }
  217. }
  218. .actions {
  219. display: flex;
  220. justify-content: flex-end;
  221. margin-top: 16rpx;
  222. .btn {
  223. margin: 0 0 0 20rpx;
  224. padding: 0 30rpx;
  225. height: 60rpx;
  226. line-height: 60rpx;
  227. font-size: $font-base;
  228. color: #fff;
  229. background: #909399;
  230. border: none;
  231. border-radius: 30rpx;
  232. &.primary {
  233. background: $theme-color;
  234. }
  235. }
  236. }
  237. }
  238. }
  239. .empty {
  240. display: flex;
  241. flex-direction: column;
  242. align-items: center;
  243. justify-content: center;
  244. padding-top: 200rpx;
  245. color: #cdcdcd;
  246. font-size: $font-lg;
  247. .empty-img {
  248. width: 240rpx;
  249. margin-bottom: 30rpx;
  250. }
  251. }
  252. </style>