useAnalysisSelect.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. import { CSelectType } from '@/types/HomeTypes'
  2. import type {
  3. BaseOption,
  4. DateOption,
  5. CSelectInfo,
  6. CSelectRadio,
  7. CSelectDate,
  8. CSelectLegend,
  9. CSelectMutipleTag,
  10. } from '@/types/HomeTypes'
  11. import { reactive } from 'vue'
  12. export function useAnalysisSelect() {
  13. // 总览数据的选择框的信息格式
  14. interface AnalysisSelectInfo extends CSelectInfo {
  15. mediaSelect: CSelectRadio
  16. dateSelect: CSelectDate
  17. customIndicatorSelect: CSelectRadio
  18. }
  19. // 图例信息格式
  20. interface LegendSelectInfo extends CSelectInfo {
  21. leftLegned: CSelectLegend
  22. rightLegned: CSelectLegend
  23. }
  24. // 左侧工具栏选择信息格式
  25. interface LeftToolsSelectInfo extends CSelectInfo {
  26. dataSource: CSelectRadio
  27. }
  28. // 右侧工具栏选择信息格式
  29. interface RightToolsSelectInfo extends CSelectInfo {
  30. dataCategory: CSelectRadio
  31. }
  32. // 媒体选择选项
  33. const mediaSelectOptions = reactive<Array<BaseOption>>([
  34. {
  35. label: '全部媒体',
  36. value: 'all',
  37. },
  38. {
  39. label: '全部媒体',
  40. value: 'all',
  41. },
  42. ])
  43. // 日期选择
  44. const dateSelectOptions = reactive<Array<DateOption>>([
  45. {
  46. label: '今天',
  47. value: new Date(),
  48. },
  49. {
  50. label: '昨天',
  51. value: new Date(),
  52. },
  53. ])
  54. // 项目选择
  55. const projSelectOptions = reactive<Array<BaseOption>>([
  56. {
  57. label: '测试1',
  58. value: 'ce1',
  59. },
  60. {
  61. label: '测试2',
  62. value: 'ce2',
  63. },
  64. {
  65. label: '测试3',
  66. value: 'ce3',
  67. },
  68. {
  69. label: '测试4',
  70. value: 'ce4',
  71. },
  72. {
  73. label: '测试5',
  74. value: 'ce5',
  75. },
  76. {
  77. label: '测试6',
  78. value: 'ce6',
  79. },
  80. ])
  81. // 广告数据选择栏数据
  82. const analysisSelectInfo = reactive<AnalysisSelectInfo>({
  83. mediaSelect: {
  84. type: CSelectType.Radio,
  85. name: 'media',
  86. value: mediaSelectOptions[0].value,
  87. options: mediaSelectOptions,
  88. },
  89. dateSelect: {
  90. type: CSelectType.Radio,
  91. name: 'date',
  92. value: dateSelectOptions[0].value,
  93. options: dateSelectOptions,
  94. },
  95. customIndicatorSelect: {
  96. tagText: '全部项目',
  97. type: CSelectType.Radio,
  98. name: 'project',
  99. value: projSelectOptions[0].value,
  100. options: projSelectOptions,
  101. },
  102. })
  103. // 左边图例的选项
  104. const leftLegnedOptions = reactive<Array<BaseOption>>([
  105. {
  106. label: '消耗',
  107. value: 'cost',
  108. },
  109. {
  110. label: '展示数',
  111. value: 'show_count',
  112. },
  113. ])
  114. // 右边图例选项
  115. const rightLegnedOptions = reactive<Array<BaseOption>>([
  116. {
  117. label: '支付数',
  118. value: 'pay_count',
  119. },
  120. {
  121. label: '转化率',
  122. value: 'convert_rate',
  123. },
  124. ])
  125. // 图例的选择框信息
  126. const legendSelectInfo = reactive<LegendSelectInfo>({
  127. leftLegned: {
  128. type: CSelectType.RadioLegend,
  129. name: 'leftLegned',
  130. value: leftLegnedOptions[0].value,
  131. options: leftLegnedOptions,
  132. color: '#bfdaff',
  133. },
  134. rightLegned: {
  135. type: CSelectType.RadioLegend,
  136. name: 'rightLegned',
  137. value: rightLegnedOptions[1].value,
  138. options: rightLegnedOptions,
  139. color: '#f9b65d',
  140. },
  141. })
  142. // 数据来源选项
  143. const dataSourceOptions = reactive<Array<BaseOption>>([
  144. {
  145. label: '消耗',
  146. value: 'consume',
  147. },
  148. ])
  149. // 左侧工具栏选择框信息
  150. const leftToolsSelectInfo = reactive<LeftToolsSelectInfo>({
  151. dataSource: {
  152. type: CSelectType.Radio,
  153. name: 'dataSource',
  154. value: dataSourceOptions[0].value,
  155. options: dataSourceOptions,
  156. },
  157. })
  158. // 数据分类选项
  159. const categoryOptions = reactive<Array<BaseOption>>([
  160. {
  161. label: '汇总',
  162. value: 'all',
  163. },
  164. {
  165. label: 'Top5产品',
  166. value: 'top5',
  167. },
  168. ])
  169. // 右侧工具栏选择框信息
  170. const rightToolsSelectInfo = reactive<RightToolsSelectInfo>({
  171. dataCategory: {
  172. type: CSelectType.Radio,
  173. name: 'dataCategory',
  174. value: categoryOptions[0].value,
  175. options: categoryOptions,
  176. },
  177. })
  178. return {
  179. analysisSelectInfo,
  180. legendSelectInfo,
  181. leftToolsSelectInfo,
  182. rightToolsSelectInfo,
  183. }
  184. }