FormulaCalculate.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <script setup>
  2. import { showToast } from 'vant';
  3. import {ref} from 'vue'
  4. import SelectEDB from './SelectEDB.vue'
  5. const letterOpts = [];//字母数据
  6. function initLetterOpt(){
  7. for(let i=0;i<26;i++){
  8. letterOpts.push(String.fromCharCode(65+i));
  9. }
  10. }
  11. initLetterOpt()
  12. //选择的指标集合
  13. const edbList=ref([
  14. {
  15. tag:letterOpts[0],
  16. target:'',
  17. startDate:'',
  18. endDate:''
  19. },
  20. {
  21. tag:letterOpts[1],
  22. target:'',
  23. startDate:'',
  24. endDate:''
  25. },
  26. {
  27. tag:letterOpts[2],
  28. target:'',
  29. startDate:'',
  30. endDate:''
  31. },
  32. {
  33. tag:letterOpts[3],
  34. target:'',
  35. startDate:'',
  36. endDate:''
  37. }
  38. ])
  39. function handleAddEdbList(){
  40. if(edbList.value.length>=26){
  41. showToast('添加指标个数已达上限')
  42. return
  43. }
  44. let tag = edbList.value[edbList.value.length-1].tag;
  45. let index = letterOpts.findIndex(item => item === tag);
  46. const item = {
  47. tag: letterOpts[index+1],
  48. target: '',
  49. start_date: '',
  50. end_date: ''
  51. };
  52. edbList.value.push(item);
  53. }
  54. function handleDeleteEDBItem(index){
  55. edbList.value.splice(index, 1)
  56. }
  57. // 选择指标
  58. const showSelectEDB=ref(false)
  59. let whichIndex=0
  60. function handleShowSelectEDB(index){
  61. whichIndex=index
  62. showSelectEDB.value=true
  63. }
  64. </script>
  65. <template>
  66. <div class="formula-calculate-wrap">
  67. <section class="section select-edb-box">
  68. <van-swipe-cell v-for="(item,index) in edbList" :key="item.tag" :disabled="index<4">
  69. <van-field
  70. :label="item.tag"
  71. is-link
  72. @click-input="handleShowSelectEDB(index)"
  73. >
  74. <template #left-icon>
  75. <div class="left-icon"></div>
  76. </template>
  77. <template #input>
  78. <div class="edb-info-box">
  79. <div class="edb-info" v-if="true">
  80. <span class="name">指标名称</span>
  81. <span class="time">2019-11-25至2023-08-23</span>
  82. </div>
  83. <span class="placeholder" v-else>请选择指标</span>
  84. </div>
  85. </template>
  86. </van-field>
  87. <template #right>
  88. <van-button square type="danger" text="删除" @click="handleDeleteEDBItem(index)"/>
  89. </template>
  90. </van-swipe-cell>
  91. <div class="add-edb-box" @click="handleAddEdbList">
  92. <img src="@/assets/imgs/icon01.png" alt="">
  93. <span>添加更多参数</span>
  94. </div>
  95. </section>
  96. <section class="section formula-box">
  97. <!-- <van-field
  98. v-model="item.target"
  99. :label="item.tag"
  100. is-link
  101. readonly
  102. input-align="right"
  103. placeholder="请选择指标"
  104. >
  105. <template #left-icon>
  106. <div class="left-icon"></div>
  107. </template>
  108. </van-field> -->
  109. </section>
  110. </div>
  111. <!-- 选择指标 -->
  112. <SelectEDB v-model:show="showSelectEDB"/>
  113. </template>
  114. <style lang="scss" scoped>
  115. .formula-calculate-wrap{
  116. min-height: 80vh;
  117. background-color: $page-bg-grey;
  118. }
  119. .section{
  120. background-color: #fff;
  121. margin-bottom: 32px;
  122. }
  123. .select-edb-box{
  124. .left-icon{
  125. width: 48px;
  126. height: 48px;
  127. }
  128. :deep(.van-cell__right-icon){
  129. align-self: center;
  130. color: #333;
  131. }
  132. .edb-info-box{
  133. width: 100%;
  134. text-align: right;
  135. .placeholder{
  136. color: var(--van-text-color-3);
  137. }
  138. .edb-info{
  139. display: flex;
  140. flex-direction: column;
  141. }
  142. .time{
  143. color: $font-grey_999;
  144. font-size: 24px;
  145. }
  146. }
  147. .add-edb-box{
  148. display: flex;
  149. justify-content: flex-end;
  150. align-items: center;
  151. color: $theme-color;
  152. font-size: 32px;
  153. padding: 32px var(--van-cell-horizontal-padding);
  154. img{
  155. width: 48px;
  156. height: 48px;
  157. }
  158. }
  159. }
  160. </style>