leftView.vue 2.77 KB
<template>
  <div class="left-container">
    <div class="data-view">
      <div v-for="item in submitArr"
           :key="item.name"
           class="item">
        <div class="name">
          {{ item.name }}
        </div>
        <div class="value">
          {{ item.value(dataView) }}
        </div>
      </div>
    </div>
    <div class="examination-result">
      <div class="title">
        考试结果等级分布
      </div>
      <EchartBar id="resultRef"
                 class="echart"
                 :x-data="xData"
                 :y-data="yData">
      </EchartBar>
      <div class="hint">
        <div v-for="(item, index) in queryData.examLevelDTOS"
             :key="index"
             class="item">
          <span>{{ item.levelName }}:</span>
          <span>{{ `${item.minScore}-${item.maxScore}` }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import echartBar from "./echartBar.vue";

export default {
	components: { EchartBar: echartBar },
	props: {
		dataView: {
			type: Object,
			default: () => {},
		},
		queryData: {
			type: Object,
			default: () => {},
		},
	},

	data() {
		return {
			submitArr: [
				{
					name: "已提交人数",
					value: (obj) => {
						console.log(obj);
						return obj.submitted || obj.submitted === 0 ? obj.submitted : "-";
					},
				},
				{
					name: "已提交人均得分",
					value: (obj) => {
						return obj.avg || obj.avg === 0 ? obj.avg : "-";
					},
				},
			],
			xData: [],
			yData: [],
		};
	},
	watch: {
		dataView: {
			handler(newValue, oldValue) {
				this.initEchartData(newValue);
			},
			deep: true,
			immediate: true,
		},
	},
	methods: {
		initEchartData(data) {
			console.log(data);
			let xData = [];
			data.scoreDistributions.forEach((item) => {
				xData.push(item.levelName);
			});
			this.xData = xData;
			this.yData = data.scoreDistributions;
		},
	},
};
</script>

<style lang="scss" scoped>
.left-container {
	// min-width: 800px;
	.data-view {
		display: flex;
		align-items: center;
		.item {
			flex: 1;
			height: 100px;
			border-radius: 4px;
			background: #f8faff;
			margin-right: 16px;
			padding: 16px 20px;
			box-sizing: border-box;
			margin-bottom: 16px;
			.name {
				color: #333333;
				font-size: 14px;
				font-weight: 400;
				margin-bottom: 8px;
			}
			.value {
				color: #1d1d1d;
				font-size: 32px;
				font-weight: 500;
			}
		}
	}
	.examination-result {
		position: relative;
		.title {
			color: #333333;
			font-size: 14px;
			font-weight: 400;
		}
		.hint {
			display: flex;
			flex-direction: column;
			align-items: flex-start;
			position: absolute;
			top: 52px;
			right: 45px;
			.item {
				display: flex;
				align-items: center;
				color: #000000a6;
				font-size: 11px;
				font-weight: 400;
				margin-bottom: 7px;
			}
		}
	}
}
</style>