index.vue 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <div class="subPage">
  3. <div class="selectCase">
  4. <el-select v-model="postData.caseid" placeholder="请选择">
  5. <el-option
  6. v-for="item in cases"
  7. :key="item.CaseId"
  8. :label="item.CaseName"
  9. :value="item.CaseId">
  10. </el-option>
  11. </el-select>
  12. </div>
  13. <div class="flex-h" v-for="(item,index) in pageData" :key="index">
  14. <div class="flex-item" v-for="(subItem,subIndex) in item" :key="subIndex">
  15. <div v-if="subItem.type === 'dashboardList'">
  16. <dashboardList :data="subItem" :index="index + '-' + subIndex"></dashboardList>
  17. </div>
  18. <!-- <div v-if="subItem.type === 'histogram' && subItem.value.length">
  19. <histogram :data="subItem.value" :index="index + '-' + subIndex"></histogram>
  20. </div>
  21. <div v-if="subItem.type === 'pieDiagram' && subItem.value.length">
  22. <pieDiagram :data="subItem.value" :index="index + '-' + subIndex"></pieDiagram>
  23. </div>
  24. <div v-if="subItem.type === 'brokenLineGraph' && subItem.value.length">
  25. <brokenLineGraph :data="subItem.value" :index="index + '-' + subIndex"></brokenLineGraph>
  26. </div>
  27. <div v-if="subItem.type === 'ringChart' && subItem.value.length">
  28. <ringChart :data="subItem.value" :index="index + '-' + subIndex"></ringChart>
  29. </div>
  30. <div v-if="subItem.type === 'dashboard' && subItem.value.length">
  31. <dashboard :data="subItem.value" :index="index + '-' + subIndex"></dashboard>
  32. </div>
  33. <div v-if="subItem.type === 'brokenLineGraphGroup' && subItem.value.length">
  34. <brokenLineGraphGroup :data="subItem.value" :index="index + '-' + subIndex"></brokenLineGraphGroup>
  35. </div> -->
  36. </div>
  37. </div>
  38. </div>
  39. </template>
  40. <script>
  41. import { mapState, createNamespacedHelpers } from 'vuex'
  42. import dashboardList from '../../../components/dashboardList/index'
  43. import histogram from '../../../components/histogram/index'
  44. import pieDiagram from '../../../components/pieDiagram/index'
  45. import brokenLineGraph from '../../../components/brokenLineGraph/index'
  46. import ringChart from '../../../components/ringChart/index'
  47. import dashboard from '../../../components/dashboard/index'
  48. import brokenLineGraphGroup from '../../../components/brokenLineGraphGroup/index'
  49. const { mapActions: mapStaActions } = createNamespacedHelpers('sta')
  50. export default {
  51. name: '',
  52. data () {
  53. return {
  54. postData: {
  55. caseid: ''
  56. },
  57. pageData: [
  58. [
  59. { type: 'dashboardList', remark: '列表面板', data: { title: '', list: [{ name: '会员总数', value: '1000', }, { name: '课程预约总量', value: '1000', }, { name: '饮品下单总量', value: '1000', }] } }
  60. ],
  61. [
  62. { type: 'histogram', remark: '柱状图', data: { title: '今日数据', list: [{ x: '推荐会员新增', y: 38 }, { x: '课程数', y: 52 }, { x: '预约数', y: 61 }, { x: '到场人次', y: 145 }] } },
  63. { type: 'pieDiagram', remark: '扇形图', data: { title: '明日课程预约数据', list: [{ item: '小小体验官', count: 40, percent: 0.4 }, { item: '哈他瑜伽', count: 52, percent: 0.52 }, { item: '小小飞行家', count: 8, percent: 0.08 }] } }
  64. ],
  65. [
  66. { type: 'brokenLineGraph', remark: '折线图', data: { title: '下单饮品数据', list: [{ x: '09/05', y: 3 }, { x: '09/06', y: 4 }, { x: '09/07', y: 3.5 }, { x: '09/08', y: 5 }, { x: '09/09', y: 4.9 }, { x: '09/10', y: 6 }, { x: '09/11', y: 7 }, { x: '09/12', y: 9 }, { x: '09/13', y: 13 }] } },
  67. { type: 'ringChart', remark: '环形图', data: { title: '本月课程预约', list: [{ item: '健身课程', count: 40, percent: 0.4 }, { item: '社交课程', count: 21, percent: 0.21 }, { item: '教育课程', count: 17, percent: 0.17 }, { item: '健康课程', count: 13, percent: 0.13 }, { item: '艺术课程', count: 9, percent: 0.09 }] } },
  68. ],
  69. [
  70. { type: 'dashboard', remark: '仪表盘', data: { title: '参与率', list: [{ value: 5.6 }] } },
  71. { type: 'dashboard', remark: '仪表盘', data: { title: '参与率', list: [{ value: 3.1 }] } },
  72. ],
  73. [
  74. { type: 'brokenLineGraphGroup', remark: '折线图组合', data: { title: '下单饮品数据', list: [{ month: 'Jan', city: 'Tokyo', temperature: 7 }, { month: 'Jan', city: 'London', temperature: 3.9 }, { month: 'Feb', city: 'Tokyo', temperature: 6.9 }, { month: 'Feb', city: 'London', temperature: 4.2 }, { month: 'Mar', city: 'Tokyo', temperature: 9.5 }, { month: 'Mar', city: 'London', temperature: 5.7 }, { month: 'Apr', city: 'Tokyo', temperature: 14.5 }, { month: 'Apr', city: 'London', temperature: 8.5 }, { month: 'May', city: 'Tokyo', temperature: 18.4 }, { month: 'May', city: 'London', temperature: 11.9 }, { month: 'Jun', city: 'Tokyo', temperature: 21.5 }, { month: 'Jun', city: 'London', temperature: 15.2 }, { month: 'Jul', city: 'Tokyo', temperature: 25.2 }, { month: 'Jul', city: 'London', temperature: 17 }, { month: 'Aug', city: 'Tokyo', temperature: 26.5 }, { month: 'Aug', city: 'London', temperature: 16.6 }, { month: 'Sep', city: 'Tokyo', temperature: 23.3 }, { month: 'Sep', city: 'London', temperature: 14.2 }, { month: 'Oct', city: 'Tokyo', temperature: 18.3 }, { month: 'Oct', city: 'London', temperature: 10.3 }, { month: 'Nov', city: 'Tokyo', temperature: 13.9 }, { month: 'Nov', city: 'London', temperature: 6.6 }, { month: 'Dec', city: 'Tokyo', temperature: 9.6 }, { month: 'Dec', city: 'London', temperature: 4.8 }] } },
  75. ],
  76. ],
  77. }
  78. },
  79. components: {
  80. dashboardList,
  81. histogram,
  82. pieDiagram,
  83. brokenLineGraph,
  84. ringChart,
  85. dashboard,
  86. brokenLineGraphGroup,
  87. },
  88. computed: {
  89. ...mapState({
  90. cases: x => x.app.cases.list,
  91. defaultCaseId: x => x.app.cases.default
  92. }),
  93. CaseId: {
  94. get () {
  95. return this.postData.caseid || this.defaultCaseId || this.cases[0].CaseId
  96. },
  97. set (val) {
  98. this.postData.caseid = val
  99. }
  100. }
  101. },
  102. watch: {
  103. defaultCaseId: function (val) {
  104. if (!this.postData.caseid) {
  105. this.postData.caseid = val
  106. }
  107. this.getData(val)
  108. this.getBottomData(val, 'week')
  109. },
  110. },
  111. mounted () {
  112. this.$nextTick(function () {
  113. })
  114. },
  115. methods: {
  116. ...mapStaActions([
  117. 'getDashboardData',
  118. 'getDashboardBottomData',
  119. ]),
  120. getData (id) {
  121. this.getDashboardData({
  122. caseid: id
  123. }).then((res) => {
  124. this.pageData = []
  125. for (var n = 0; n < res.length; n++) {
  126. this.pageData.push([])
  127. for (var a = 0; a < res[n].length; a++) {
  128. if (res[n][a].type !== 'dashboardList' && res[n][a].value === null) res[n][a].value = []
  129. this.pageData[n].push(res[n][a])
  130. }
  131. }
  132. // console.log(JSON.stringify(this.pageData))
  133. })
  134. },
  135. getBottomData (id, type) {
  136. this.getDashboardBottomData({
  137. caseid: id,
  138. statype: type
  139. }).then((res) => {
  140. // console.log(JSON.stringify(res))
  141. })
  142. },
  143. }
  144. }
  145. </script>
  146. <!-- Add "scoped" attribute to limit CSS to this component only -->
  147. <style lang="scss" scoped>
  148. @import "page.scss";
  149. </style>