123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <template>
- <div>
- <m-search :items="searchItems" v-model="searchValues" @search="onSearch"></m-search>
- <m-card class="mt-3" v-loading="loading">
- <AnalysisChart class="mb-3" v-for="item in items" :key="item.key" :option="item.value" :init="drillInit"></AnalysisChart>
- <m-empty v-if="items.length === 0"></m-empty>
- </m-card>
- </div>
- </template>
- <script>
- import { mapGetters } from 'vuex'
- import AnalysisChart from './AnalysisChart.vue'
- export default {
- name: 'AnalysisPage',
- props: {
- searchApi: {
- type: Function,
- default: () => ({})
- },
- drillInit: {
- type: Function,
- default: () => ({})
- }
- },
- components: {
- AnalysisChart
- },
- data () {
- return {
- chart: {},
- loading: false,
- searchValues: {
- parentOrganizationNo: null
- },
- items: []
- }
- },
- computed: {
- ...mapGetters(['organizationTree']),
- searchItems () {
- return [
- {
- label: '上级机构',
- type: 'cascader',
- prop: 'parentOrganizationNo',
- options: {
- filterable: true,
- clearable: true,
- placeholder: '请选择上级机构',
- options: this.organizationTree,
- showAllLevels: false,
- props: {
- emitPath: false,
- checkStrictly: true,
- value: 'organizationNo',
- label: 'organizationName',
- children: 'child'
- }
- }
- }
- ]
- }
- },
- mounted () {
- this.searchValues.parentOrganizationNo = this.organizationTree[0].organizationNo
- this.onInit()
- },
- methods: {
- async onInit () {
- this.loading = true
- try {
- const { data } = await this.searchApi({
- ...this.searchValues
- })
- this.items = Object.keys(data).map(key => {
- return {
- key,
- value: data[key]
- }
- })
- } catch (error) {
- this.$message.error(error)
- } finally {
- this.loading = false
- }
- },
- onSearch () {
- if (this.searchValues.parentOrganizationNo === null) {
- this.searchValues.parentOrganizationNo = this.organizationTree[0].organizationNo
- }
- this.onInit()
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- </style>
|