|
@@ -1,213 +1,214 @@
|
|
|
<template>
|
|
|
- <div id="space-info"></div>
|
|
|
+ <div id="space-info"></div>
|
|
|
</template>
|
|
|
<script>
|
|
|
import BlobTool from '@/utils/blobTool.js'
|
|
|
import { mapGetters } from 'vuex'
|
|
|
import elementResizeDetectorMaker from "element-resize-detector"
|
|
|
export default {
|
|
|
- name: 'SpaceInfo',
|
|
|
- computed: {
|
|
|
- ...mapGetters({
|
|
|
- PRIVATE_SPACE: 'PRIVATE_SPACE'
|
|
|
- }),
|
|
|
- },
|
|
|
- data() {
|
|
|
- return {
|
|
|
- warningPercent: 10,
|
|
|
- content: ['res', 'image', 'video', 'doc', 'audio', 'other'],
|
|
|
- itemAndPaperKey: ['item', 'paper'], //试题试卷
|
|
|
- //与返回数据key对应的模块
|
|
|
- spaceInfo: {
|
|
|
- total: this.$t('auth.totalSpace'),
|
|
|
- exam: this.$t('auth.exam'), //评测
|
|
|
- vote: this.$t('auth.vote'), //投票
|
|
|
- survey: this.$t('auth.survey'), //问卷
|
|
|
- homework: this.$t('auth.homework'), //作业
|
|
|
- train: this.$t('auth.train'), //研修
|
|
|
- records: this.$t('auth.records'), //课堂记录
|
|
|
- syllabus: this.$t('auth.syllabus'), //课纲
|
|
|
+ name: 'SpaceInfo',
|
|
|
+ computed: {
|
|
|
+ ...mapGetters({
|
|
|
+ PRIVATE_SPACE: 'PRIVATE_SPACE'
|
|
|
+ }),
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ warningPercent: 10,
|
|
|
+ content: ['res', 'image', 'video', 'doc', 'audio', 'other'],
|
|
|
+ itemAndPaperKey: ['item', 'paper'], //试题试卷
|
|
|
+ //与返回数据key对应的模块
|
|
|
+ spaceInfo: {
|
|
|
+ total: this.$t('auth.totalSpace'),
|
|
|
+ exam: this.$t('auth.exam'), //评测
|
|
|
+ vote: this.$t('auth.vote'), //投票
|
|
|
+ survey: this.$t('auth.survey'), //问卷
|
|
|
+ homework: this.$t('auth.homework'), //作业
|
|
|
+ train: this.$t('auth.train'), //研修
|
|
|
+ records: this.$t('auth.records'), //课堂记录
|
|
|
+ syllabus: this.$t('auth.syllabus'), //课纲
|
|
|
+ },
|
|
|
+ formatData: [],
|
|
|
+ typeCountPie: undefined,
|
|
|
+ option: {
|
|
|
+ color: ['#cccccc', '#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'],
|
|
|
+ tooltip: {
|
|
|
+ trigger: 'item',
|
|
|
+ // formatter: '{b}({c})',
|
|
|
+ formatter: (params) => {
|
|
|
+ return `${params.name}:${this.$jsFn.formatBytes(params.value)}`
|
|
|
+ },
|
|
|
+ textStyle: {
|
|
|
+ color: '#000'
|
|
|
+ },
|
|
|
+ backgroundColor: '#fff',
|
|
|
+ extraCssText: 'box-shadow: 0px 0px 10px 0px rgba(19,83,88,0.2);'
|
|
|
+ },
|
|
|
+ title: [],
|
|
|
+ legend: {
|
|
|
+ data: [],
|
|
|
+ textStyle: {
|
|
|
+ color: '#757575',
|
|
|
+ padding: [5, 0, 5, 0]
|
|
|
+ },
|
|
|
+ icon: 'circle',
|
|
|
+ bottom: 15
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ type: 'pie',
|
|
|
+ center: ['50%', '35%'],
|
|
|
+ radius: ['48%', '60%'],
|
|
|
+ labelLine: {
|
|
|
+ show: false
|
|
|
},
|
|
|
- formatData: [],
|
|
|
- typeCountPie: undefined,
|
|
|
- option: {
|
|
|
- color: ['#cccccc', '#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'],
|
|
|
- tooltip: {
|
|
|
- trigger: 'item',
|
|
|
- // formatter: '{b}({c})',
|
|
|
- formatter: (params) => {
|
|
|
- return `${params.name}:${this.$jsFn.formatBytes(params.value)}`
|
|
|
- },
|
|
|
- textStyle: {
|
|
|
- color: '#000'
|
|
|
- },
|
|
|
- backgroundColor: '#fff',
|
|
|
- extraCssText: 'box-shadow: 0px 0px 10px 0px rgba(19,83,88,0.2);'
|
|
|
- },
|
|
|
- title: [],
|
|
|
- legend: {
|
|
|
- data: [],
|
|
|
- textStyle: {
|
|
|
- color: '#757575',
|
|
|
- padding: [5, 0, 5, 0]
|
|
|
- },
|
|
|
- icon: 'circle',
|
|
|
- bottom: 15
|
|
|
- },
|
|
|
- series: [
|
|
|
- {
|
|
|
- type: 'pie',
|
|
|
- center: ['50%', '35%'],
|
|
|
- radius: ['48%', '60%'],
|
|
|
- labelLine: {
|
|
|
- show: false
|
|
|
- },
|
|
|
- label: {
|
|
|
- show: false
|
|
|
- },
|
|
|
- data: []
|
|
|
- }
|
|
|
- ]
|
|
|
+ label: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ data: []
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ if (!this.typeCountPie) this.typeCountPie = this.$echarts.init(document.getElementById('space-info'))
|
|
|
+ this.typeCountPie.setOption(this.option)
|
|
|
+ this.erd = elementResizeDetectorMaker()
|
|
|
+ this.erd.listenTo(document.getElementById("space-info"), () => {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ //监听到事件后执行的业务逻辑
|
|
|
+ this.typeCountPie.resize()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 获取容器空间情况
|
|
|
+ getSize() {
|
|
|
+ console.error('xxxxxxxxxxxxxxxxxxxx')
|
|
|
+ BlobTool.getContainerSize(this.$store.state.userInfo.TEAMModelId, 'private').then(
|
|
|
+ res => {
|
|
|
+ console.log(res)
|
|
|
+ this.sizeInfo = res
|
|
|
+ let formatData = []
|
|
|
+ let other = {
|
|
|
+ name: this.$t('auth.appData'),
|
|
|
+ value: 0
|
|
|
+ }
|
|
|
+ let content = {
|
|
|
+ name: this.$t('auth.content'),
|
|
|
+ value: 0
|
|
|
+ }
|
|
|
+ // 试题试卷
|
|
|
+ let itemAndPaper = {
|
|
|
+ name: this.$t('auth.itemAndPaper'),
|
|
|
+ value: 0
|
|
|
+ }
|
|
|
+ if (res) {
|
|
|
+ for (const key in res) {
|
|
|
+ if (key != 'total' && key != 'appData') {
|
|
|
+ if (this.spaceInfo[key]) {
|
|
|
+ formatData.push({
|
|
|
+ name: this.spaceInfo[key],
|
|
|
+ value: res[key]
|
|
|
+ })
|
|
|
+ } else if (this.content.includes(key)) {
|
|
|
+ content.value += res[key]
|
|
|
+ }
|
|
|
+ else if (this.itemAndPaperKey.includes(key)) {
|
|
|
+ itemAndPaper.value += res[key]
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ other.value += res[key]
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- },
|
|
|
- mounted() {
|
|
|
- if (!this.typeCountPie) this.typeCountPie = this.$echarts.init(document.getElementById('space-info'))
|
|
|
- this.typeCountPie.setOption(this.option)
|
|
|
- this.erd = elementResizeDetectorMaker()
|
|
|
- this.erd.listenTo(document.getElementById("space-info"), () => {
|
|
|
- this.$nextTick(() => {
|
|
|
- //监听到事件后执行的业务逻辑
|
|
|
- this.typeCountPie.resize()
|
|
|
+ }
|
|
|
+ formatData.push(content)
|
|
|
+ formatData.push(itemAndPaper)
|
|
|
+ formatData.push(other)
|
|
|
+ let last = this.PRIVATE_SPACE * 1024 * 1024 * 1024 - res.teachSpace - res.total
|
|
|
+ if (last > 0) {
|
|
|
+ formatData.unshift({
|
|
|
+ name: this.$t('auth.over'),
|
|
|
+ value: last
|
|
|
})
|
|
|
- })
|
|
|
- },
|
|
|
- methods: {
|
|
|
- // 获取容器空间情况
|
|
|
- getSize() {
|
|
|
- BlobTool.getContainerSize(this.$store.state.userInfo.TEAMModelId, 'private').then(
|
|
|
- res => {
|
|
|
- console.log(res)
|
|
|
- this.sizeInfo = res
|
|
|
- let formatData = []
|
|
|
- let other = {
|
|
|
- name: this.$t('auth.appData'),
|
|
|
- value: 0
|
|
|
- }
|
|
|
- let content = {
|
|
|
- name: this.$t('auth.content'),
|
|
|
- value: 0
|
|
|
- }
|
|
|
- // 试题试卷
|
|
|
- let itemAndPaper = {
|
|
|
- name: this.$t('auth.itemAndPaper'),
|
|
|
- value: 0
|
|
|
- }
|
|
|
- if (res) {
|
|
|
- for (const key in res) {
|
|
|
- if (key != 'total' && key != 'appData') {
|
|
|
- if (this.spaceInfo[key]) {
|
|
|
- formatData.push({
|
|
|
- name: this.spaceInfo[key],
|
|
|
- value: res[key]
|
|
|
- })
|
|
|
- } else if (this.content.includes(key)) {
|
|
|
- content.value += res[key]
|
|
|
- }
|
|
|
- else if (this.itemAndPaperKey.includes(key)) {
|
|
|
- itemAndPaper.value += res[key]
|
|
|
- }
|
|
|
- else {
|
|
|
- other.value += res[key]
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- formatData.push(content)
|
|
|
- formatData.push(itemAndPaper)
|
|
|
- formatData.push(other)
|
|
|
- let last = this.PRIVATE_SPACE * 1024 * 1024 * 1024 - res.teachSpace - res.total
|
|
|
- if (last > 0) {
|
|
|
- formatData.unshift({
|
|
|
- name: this.$t('auth.over'),
|
|
|
- value: last
|
|
|
- })
|
|
|
- }
|
|
|
- let percent = last * 100 / (this.PRIVATE_SPACE * 1024 * 1024 * 1024)
|
|
|
- // percent = 0
|
|
|
- console.log(percent)
|
|
|
- if (percent < this.warningPercent && percent > 0) {
|
|
|
- this.$emit('on-space-warning')
|
|
|
- } else if (percent <= 0) {
|
|
|
- this.$emit('on-space-error')
|
|
|
- }
|
|
|
- formatData = formatData.filter(item => !!item.value)
|
|
|
- this.option.legend.data = formatData.map(item => {
|
|
|
- return item.name
|
|
|
- })
|
|
|
- this.option.series[0].data = formatData
|
|
|
- this.option.title = []
|
|
|
- this.option.title.push({
|
|
|
- text: '{name|' + this.$t('auth.totalSpace') + ': ' + '}{val|' + this.PRIVATE_SPACE + 'G' + '}\n' + '{name|' + this.$t('auth.used') + '}{use|' + this.$jsFn.formatBytes(res.total + res.teachSpace) + '}',
|
|
|
- top: '22%',
|
|
|
- left: 'center',
|
|
|
- textStyle: {
|
|
|
- rich: {
|
|
|
- name: {
|
|
|
- fontSize: 16,
|
|
|
- fontWeight: 'normal',
|
|
|
- color: '#757575',
|
|
|
- padding: [10, 0],
|
|
|
- },
|
|
|
- val: {
|
|
|
- fontSize: 20,
|
|
|
- fontWeight: '600',
|
|
|
- color: '#303030',
|
|
|
- },
|
|
|
- use: {
|
|
|
- fontSize: 20,
|
|
|
- fontWeight: '600',
|
|
|
- color: '#ed4014',
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- })
|
|
|
- this.$nextTick(() => {
|
|
|
- if (!this.typeCountPie) {
|
|
|
- this.typeCountPie = this.$echarts.init(document.getElementById('space-info'))
|
|
|
- }
|
|
|
- this.typeCountPie.setOption(this.option)
|
|
|
- })
|
|
|
+ }
|
|
|
+ let percent = last * 100 / (this.PRIVATE_SPACE * 1024 * 1024 * 1024)
|
|
|
+ // percent = 0
|
|
|
+ console.log(percent)
|
|
|
+ if (percent < this.warningPercent && percent > 0) {
|
|
|
+ this.$emit('on-space-warning')
|
|
|
+ } else if (percent <= 0) {
|
|
|
+ this.$emit('on-space-error')
|
|
|
+ }
|
|
|
+ formatData = formatData.filter(item => !!item.value)
|
|
|
+ this.option.legend.data = formatData.map(item => {
|
|
|
+ return item.name
|
|
|
+ })
|
|
|
+ this.option.series[0].data = formatData
|
|
|
+ this.option.title = []
|
|
|
+ this.option.title.push({
|
|
|
+ text: '{name|' + this.$t('auth.totalSpace') + ': ' + '}{val|' + this.PRIVATE_SPACE + 'G' + '}\n' + '{name|' + this.$t('auth.used') + '}{use|' + this.$jsFn.formatBytes(res.total + res.teachSpace) + '}',
|
|
|
+ top: '22%',
|
|
|
+ left: 'center',
|
|
|
+ textStyle: {
|
|
|
+ rich: {
|
|
|
+ name: {
|
|
|
+ fontSize: 16,
|
|
|
+ fontWeight: 'normal',
|
|
|
+ color: '#757575',
|
|
|
+ padding: [10, 0],
|
|
|
},
|
|
|
- err => {
|
|
|
- this.$Message.error(this.$t('teachContent.sizeErr'))
|
|
|
- }
|
|
|
- ).finally(() => {
|
|
|
- this.sizeLoading = false
|
|
|
- })
|
|
|
+ val: {
|
|
|
+ fontSize: 20,
|
|
|
+ fontWeight: '600',
|
|
|
+ color: '#303030',
|
|
|
+ },
|
|
|
+ use: {
|
|
|
+ fontSize: 20,
|
|
|
+ fontWeight: '600',
|
|
|
+ color: '#ed4014',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ })
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (!this.typeCountPie) {
|
|
|
+ this.typeCountPie = this.$echarts.init(document.getElementById('space-info'))
|
|
|
+ }
|
|
|
+ this.typeCountPie.setOption(this.option)
|
|
|
+ })
|
|
|
},
|
|
|
+ err => {
|
|
|
+ this.$Message.error(this.$t('teachContent.sizeErr'))
|
|
|
+ }
|
|
|
+ ).finally(() => {
|
|
|
+ this.sizeLoading = false
|
|
|
+ })
|
|
|
},
|
|
|
- mounted() {
|
|
|
- this.getSize()
|
|
|
- },
|
|
|
- watch: {
|
|
|
- // PRIVATE_SPACE: {
|
|
|
- // handler(n, o) {
|
|
|
- // console.log('空间', n)
|
|
|
- // },
|
|
|
- // immediate: true,
|
|
|
- // deep: true
|
|
|
- // }
|
|
|
- }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.getSize()
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ // PRIVATE_SPACE: {
|
|
|
+ // handler(n, o) {
|
|
|
+ // console.log('空间', n)
|
|
|
+ // },
|
|
|
+ // immediate: true,
|
|
|
+ // deep: true
|
|
|
+ // }
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
<style scoped lang="less">
|
|
|
#space-info {
|
|
|
- margin: auto;
|
|
|
- margin-top: 10px;
|
|
|
- width: 95%;
|
|
|
- // max-width: 300px;
|
|
|
- height: 300px;
|
|
|
+ margin: auto;
|
|
|
+ margin-top: 10px;
|
|
|
+ width: 95%;
|
|
|
+ // max-width: 300px;
|
|
|
+ height: 300px;
|
|
|
}
|
|
|
</style>
|
|
|
<style>
|