workExp.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <view class="content">
  3. <view
  4. v-for="work in data"
  5. :key="work.id"
  6. class="content-item"
  7. >
  8. <view class="content-title">
  9. <view class="name">{{ work.enterpriseName }}</view>
  10. <view class="time">
  11. {{ timesTampChange(work.startTime ,'Y-M') }} - {{ work.endTime ? timesTampChange(work.endTime ,'Y-M') : '至今' }}
  12. </view>
  13. </view>
  14. <view class="content-subTitle">{{ work.positionName }}</view>
  15. <view class="content-main ellipsis-2">
  16. 内容:
  17. <rich-text v-if="work.content" :nodes="cleanedHtml(work.content)"></rich-text>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script setup>
  23. defineProps({ data: Array })
  24. import { timesTampChange } from '@/utils/date'
  25. const cleanedHtml = (text) => {
  26. const cleaned = text.replace(/\n/g, '<br>')
  27. .replace(/\s+/g, ' ')
  28. .replace(/(^|\s+)<\/p>(\s*<p>|$)/g, '</p><p>')
  29. .replace(/<p>\s*(<br>)\s*<\/p>/g, '')
  30. .replace(/<pre([^>]*)>/g, '<div$1>')
  31. .replace(/<\/pre>/g, '</div>')
  32. .replace(/<p>\s*(<\/br>)\s*<\/p>/g, '').trim()
  33. return cleaned
  34. }
  35. </script>
  36. <style scoped lang="scss">
  37. .content {
  38. &-item {
  39. padding: 20rpx 0;
  40. }
  41. &-title {
  42. display: flex;
  43. justify-content: space-between;
  44. .name {
  45. font-size: 30rpx;
  46. color: #333;
  47. }
  48. .time {
  49. color: #999;
  50. font-size: 24rpx;
  51. display: flex;
  52. align-items: center;
  53. .icon {
  54. margin-left: 20rpx;
  55. }
  56. }
  57. }
  58. &-subTitle {
  59. font-size: 24rpx;
  60. margin-top: 6rpx;
  61. color: #999;
  62. }
  63. &-main {
  64. margin-top: 20rpx;
  65. font-size: 24rpx;
  66. color: #999;
  67. }
  68. }
  69. </style>