index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div class="card">
  3. <div class="inner flex-row">
  4. <el-image
  5. class="left-img"
  6. :src="images[index % 8]"
  7. fit="cover"
  8. />
  9. <div class="detail">
  10. <div class="line-1 flex-row">
  11. <div class="line-name">
  12. {{ item.name }}
  13. </div>
  14. <el-image
  15. v-if="item.reportVersion === 2"
  16. :src="require('@/assets/images/icon-tag-report.png')"
  17. fit="fill"
  18. />
  19. </div>
  20. <div class="content" v-html="item.description"></div>
  21. <div class="bottom-footer flex-row">
  22. <div class="text-info flex-row">
  23. <div v-if="systemVersion !== 'lan'" class="money">免费</div>
  24. <el-image v-show="item.isComplete && item.isComplete === '9'" class="icon-complete" :src="iconCompleteUrl" fit="fill" />
  25. <div v-if="item.testNum" class="info">{{ item.testNum }}人测试过</div>
  26. </div>
  27. <template v-if="item.isComplete && item.isComplete === '9'" />
  28. <el-button v-else type="success" round @click="geDetailPre(item, index)">去测一测</el-button>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. export default {
  36. name: "MainTableItem",
  37. props: {
  38. index: {
  39. type: [String, Number],
  40. default: 0
  41. },
  42. item: {
  43. type: Object,
  44. default: () => {}
  45. },
  46. goDetailFn: {
  47. type: Function,
  48. default: null
  49. }
  50. },
  51. data() {
  52. const systemVersion = process.env.VUE_APP_VERSION
  53. return {
  54. systemVersion: systemVersion,
  55. images: (function () {
  56. // 导入图片模块
  57. let fileArr = [];
  58. for (let i = 0; i < 9; i++) {
  59. fileArr[i] = require("@/assets/images/icon-item-" + (i % 8) + ".png");
  60. }
  61. return fileArr;
  62. })(),
  63. iconCompleteUrl: require('@/assets/images/icon-complete.png')
  64. }
  65. },
  66. methods: {
  67. geDetailPre(item, index) {
  68. if (this.goDetailFn) {
  69. this.goDetailFn(item.flag, item.name, item.testNum, item.description, item.scaleLimit, item.isComplete, item.type, item.status, index)
  70. } else {
  71. this.goDetail(item, index)
  72. }
  73. },
  74. // 查看详情
  75. goDetail({ flag, status, scaleLimit }, index) {
  76. if (status !== 0 && status !== 2 && status !== 3) {
  77. this.$alert("该量表不可用,请联系管理员", "提示", {
  78. confirmButtonText: "确定",
  79. callback: () => {},
  80. });
  81. return;
  82. }
  83. if (scaleLimit !== "public") {
  84. this.$alert("暂无权限查看该量表", "提示", {
  85. confirmButtonText: "确定",
  86. callback: () => {},
  87. });
  88. return;
  89. }
  90. this.$emit('storeInfo')
  91. this.$router.push(`/welcome/ScaleDetail?id=${flag}&index=${index}`);
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. .card {
  98. width: calc(50% - 40px);
  99. height: calc(25% - 14px);
  100. margin: 0 16px 18px;
  101. .inner {
  102. width: 100%;
  103. height: 100%;
  104. border-radius: 20px;
  105. overflow: hidden;
  106. background-color: white;
  107. justify-content: space-between;
  108. .left-img {
  109. width: 208px;
  110. height: calc(100% - 20px);
  111. margin-left: 12px;
  112. border-radius: 20px;
  113. }
  114. .detail {
  115. flex: 1;
  116. margin: 8px 28px;
  117. height: calc(100% - 16px);
  118. position: relative;
  119. .line-1 {
  120. height: 24px;
  121. justify-content: space-between;
  122. .line-name {
  123. line-height: 30px;
  124. font-size: 20px;
  125. color: #333333;
  126. font-style: italic;
  127. }
  128. .el-image {
  129. width: 84px;
  130. height: 20px;
  131. }
  132. }
  133. .content {
  134. width: 100%;
  135. height: 52px;
  136. line-height: 18px;
  137. font-size: 16px;
  138. color: #999999;
  139. margin-top: 6px;
  140. display: -webkit-box;;
  141. -webkit-box-orient: vertical;
  142. -webkit-line-clamp: 3;
  143. overflow: hidden;
  144. text-overflow: ellipsis;
  145. }
  146. .bottom-footer {
  147. width: 100%;
  148. height: 40px;
  149. position: absolute;
  150. bottom: 0;
  151. left: 0;
  152. justify-content: space-between;
  153. .money {
  154. color: #FF6600;
  155. font-size: 22px;
  156. line-height: 36px;
  157. font-style: italic;
  158. margin-right: 30px;
  159. }
  160. .icon-complete {
  161. width: 100px;
  162. height: 36px;
  163. margin-right: 30px;
  164. }
  165. .info {
  166. color: #26B600;
  167. // #26B600
  168. font-size: 18px;
  169. }
  170. .el-button {
  171. width: 116px;
  172. height: 32px;
  173. line-height: 20px;
  174. font-size: 0.084rem;
  175. padding: 4px 6px;
  176. }
  177. }
  178. }
  179. }
  180. }
  181. </style>