CardItemThree.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div class="ThreeDetailBox">
  3. <ul>
  4. <li
  5. v-for="(item, index) in signs"
  6. :class="{ active: currentIndex === index }"
  7. :key="index"
  8. @click="clickHandle(item, index)"
  9. >
  10. <span class="circle">{{ item['icon'] }}</span>
  11. <div>
  12. <p class="title">{{ item['title'] }}</p>
  13. <div class="numberBox">
  14. <span class="number">{{ (item['value'] / 10000).toFixed(2) }}</span>
  15. <span class="unit">{{ item['unit'] }}</span>
  16. </div>
  17. </div>
  18. </li>
  19. </ul>
  20. </div>
  21. </template>
  22. <script setup lang="ts">
  23. import request from '@/config/axios'
  24. interface SignInterface {
  25. icon: string
  26. title: string
  27. value: number
  28. unit: string
  29. }
  30. const currentYear = new Date().getFullYear()
  31. const signs = ref<SignInterface[]>([
  32. { icon: '签', title: `${currentYear}年度签约`, value: 0, unit: '万元' },
  33. { icon: '回', title: `${currentYear}年度回款`, value: 0, unit: '万元' },
  34. { icon: '净', title: `${currentYear}年度净合同额`, value: 0, unit: '万元' },
  35. { icon: '拓', title: `${currentYear}年度新开拓`, value: 0, unit: '万元' },
  36. { icon: '分包', title: '待支付', value: 0, unit: '万元' },
  37. { icon: '外包', title: '待支付', value: 0, unit: '万元' }
  38. ])
  39. const currentIndex = ref<number>(0)
  40. const $emit = defineEmits<{
  41. (e: 'init', data: any): void
  42. (e: 'click', v: SignInterface): void
  43. }>()
  44. const clickHandle = (item: SignInterface, index: number): void => {
  45. currentIndex.value = index
  46. $emit('click', item)
  47. }
  48. const queryContractInfo = async (): Promise<void> => {
  49. const urlApi = `/contract/info`
  50. const result = await request.post(
  51. {
  52. url: urlApi,
  53. data: {
  54. year: currentYear
  55. }
  56. },
  57. 'business'
  58. )
  59. signs.value[0].value = result.signAmount ?? 0
  60. signs.value[1].value = result.returnAmount ?? 0
  61. signs.value[2].value = result.netAmount ?? 0
  62. signs.value[3].value = result.newAmount ?? 0
  63. signs.value[4].value = result.subToPay ?? 0
  64. signs.value[5].value = result.outToPay ?? 0
  65. $emit('init', result)
  66. }
  67. queryContractInfo()
  68. </script>
  69. <style lang="scss" scoped>
  70. .ThreeDetailBox {
  71. margin-bottom: 10px;
  72. > ul {
  73. display: grid;
  74. height: 100%;
  75. grid-template-columns: repeat(2, 50%);
  76. place-content: space-between space-between;
  77. > li {
  78. display: flex;
  79. padding: 5px 0;
  80. border: 2px solid transparent;
  81. border-radius: 8px;
  82. align-items: center;
  83. p {
  84. font-size: 14px;
  85. color: #626b70;
  86. white-space: nowrap;
  87. }
  88. > div {
  89. width: 120px;
  90. }
  91. &:nth-child(2n + 1) {
  92. margin-right: 15px;
  93. }
  94. &:nth-child(2n) {
  95. justify-content: end;
  96. }
  97. > .circle {
  98. display: block;
  99. width: 36px;
  100. height: 36px;
  101. margin-right: 10px;
  102. font-size: 16px;
  103. line-height: 36px;
  104. color: #fff;
  105. text-align: center;
  106. background-color: #498bef;
  107. border-radius: 50%;
  108. flex-shrink: 0;
  109. }
  110. &:nth-child(1),
  111. &:nth-child(2) {
  112. // &.active,
  113. // &:hover {
  114. // background: linear-gradient(270deg, #eaf4ff 0%, #f9fcff 100%);
  115. // border-color: #498bef;
  116. // }
  117. }
  118. &:nth-child(3),
  119. &:nth-child(4) {
  120. > .circle {
  121. background-color: #498bef;
  122. }
  123. }
  124. &:nth-child(5),
  125. &:nth-child(6) {
  126. > .circle {
  127. width: 16px;
  128. height: 32px;
  129. padding: 10px 6px;
  130. margin-left: 2px;
  131. line-height: 16px;
  132. background: linear-gradient(180deg, #69d8bd 0%, #12b08a 100%);
  133. border: 2px solid #05ce9e;
  134. border-radius: 8px;
  135. }
  136. .number {
  137. color: #f23c3c;
  138. }
  139. }
  140. }
  141. }
  142. .numberBox {
  143. white-space: nowrap;
  144. > .number {
  145. font-size: 18px;
  146. font-weight: bold;
  147. color: #000000;
  148. }
  149. > .unit {
  150. margin-left: 3px;
  151. font-size: 14px;
  152. font-weight: 500;
  153. color: #626b70;
  154. }
  155. }
  156. }
  157. </style>