| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- <!-- -->
- <template>
- <div class="chart-template chart-template-withperiod">
- <p>
- <span> 问题整改</span>
- </p>
- <div>
- <el-tabs v-model="activeName" @tab-click="handleClick">
- <el-tab-pane
- v-for="t in types"
- :key="t.value"
- :label="t.text"
- :name="t.value"
- ></el-tab-pane>
- </el-tabs>
- </div>
- <div id="question_Chart"></div>
- </div>
- </template>
- <script>
- import "./../../board.scss";
- import * as echarts from "echarts";
- import {
- findMaxIndex,
- getChartDOMSize,
- getNextPeriod,
- getPeriodText,
- } from "../../utils.js";
- import { question } from "@/api/board/cockpit.js";
- const types = [
- {
- text: "今天",
- value: "1",
- },
- {
- text: "近7天",
- value: "2",
- },
- {
- text: "近30天",
- value: "3",
- },
- {
- text: "近90天",
- value: "4",
- },
- {
- text: "本年",
- value: "5",
- },
- ];
- export default {
- props: {
- orgId: {
- type: String,
- isRequired: true,
- },
- },
- data() {
- return {
- data: {
- all: [],
- completed: [],
- name: [],
- },
- types,
- activeName: types[0].value,
- };
- },
- components: {},
- computed: {},
- watch: {
- orgId: {
- deep: true,
- handler(val) {
- this.resetTimer();
- this.getData();
- },
- },
- data: {
- deep: true,
- handler() {
- this.initMap();
- },
- },
- },
- created() {
- // this.types = types;
- this.maxDisplay = 16;
- this.refreshTime = 1 * 10 * 1000;
- this.isMouseOver = false;
- },
- async mounted() {
- window.addEventListener("resize", this.windowResize);
- },
- beforeDestroy() {
- this.timer && clearInterval(this.timer);
- this.timer = null;
- window.removeEventListener("resize", this.windowResize);
- },
- methods: {
- handleClick() {
- this.resetTimer();
- this.getData();
- },
- handleMouseEnter() {
- this.isMouseOver = true;
- },
- handleMouseLeave() {
- this.isMouseOver = false;
- },
- async getData() {
- // let bs = parseInt(this.activeName) + 1;
- // this.data = {
- // all: 500*bs,
- // unconfirm: 112*bs, //未确认
- // auditing: 20*bs, //异议审批中
- // unreform: 50*bs, //待整改
- // notQuestion: 4*bs,
- // reformed: (500 - 112 - 20 - 50 - 4)*bs,
- // };
- let r = (await question({ orgId: this.orgId, period: this.activeName }))
- .data;
- this.data = r;
- if (r.total == 0) {
- this.data.reformRate = 100;
- } else {
- this.data.reformRate = ((r.reformed / r.total) * 100).toFixed(0);
- }
- },
- windowResize() {
- this.myChart && this.myChart.resize();
- },
- initMap() {
- this.myChart && this.myChart.dispose();
- // 基于准备好的dom,初始化echarts实例
- this.myChart = echarts.init(document.getElementById("question_Chart"));
- let chartData = [
- {
- name: "待确认",
- value: this.data.unconfirm,
- },
- {
- name: "有异议",
- value: this.data.dissent,
- },
- {
- name: "已关闭",
- value: this.data.closed,
- },
- {
- name: "待整改",
- value: this.data.unreform,
- },
- {
- name: "已整改",
- value: this.data.reformed,
- },
- {
- name: "已逾期",
- value: this.data.overdue,
- },
- {
- value: this.sum(
- this.data.unconfirm,
- this.data.dissent,
- this.data.closed,
- this.data.unreform,
- this.data.reformed,
- this.data.overdue
- ),
- itemStyle: {
- color: "none",
- decal: {
- symbol: "none",
- },
- label: {
- show: false,
- },
- },
- },
- ];
- let t = this;
- // 指定图表的配置项和数据
- var option = {
- // title: {
- // left: "center",
- // },
- tooltip: {
- trigger: "item",
- show: false,
- // formatter: "{a} <br/>{b} : {c} ({d}%)",
- },
- title: {
- text: `总数: ${this.data.total}`,
- subtext: `整改率: ${Math.round(this.data.reformed * 100)}%`,
- left: "center",
- top: "50%",
- textStyle: {
- fontSize: 16,
- color: "#fff",
- fontWeight: 200,
- // fontFamily:'SYNormal, Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif',
- align: "center",
- },
- subtextStyle: {
- fontSize: 16,
- color: "#fff",
- fontWeight: 200,
- // fontFamily:'SYNormal, Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif',
- align: "center",
- },
- },
- legend: {
- show: false,
- selectedMode: false,
- // type: "scroll",
- // orient: "vertical",
- // right: 10,
- // top: 20,
- // bottom: 20,
- // data: chartData.map((d) => d.name),
- // formatter: function (name) {
- // let d = chartData.find((c) => c.name === name);
- // return (
- // d.name + ":" + (d.value ? (d.value * 100).toFixed(2) + "%" : "-")
- // );
- // },
- // textStyle: {
- // color: "white",
- // },
- },
- series: [
- {
- name: "问题整改",
- type: "pie",
- radius: ["70%", "110%"],
- center: ["50%", "75%"],
- startAngle: 180,
- data: chartData,
- label: {
- show: true,
- // position: "center",
- color: "#8e949c",
- fontSize: 12,
- formatter: function (param) {
- if (param.name) {
- return `${param.name}(${Math.round(param.value * 100)}%)`;
- } else {
- return "";
- }
- },
- },
- // emphasis: {
- // itemStyle: {
- // shadowBlur: 10,
- // shadowOffsetX: 0,
- // shadowColor: "rgba(0, 0, 0, 0.5)",
- // },
- // },
- },
- ],
- };
- if (option && typeof option === "object") {
- this.myChart.setOption(option);
- }
- },
- resetTimer() {
- this.timer && clearInterval(this.timer);
- this.timer = setInterval(() => {
- if (this.isMouseOver) {
- return;
- }
- this.activeName = getNextPeriod(this.types, this.activeName);
- this.getData();
- }, this.refreshTime);
- },
- sum(...values) {
- let t = 0;
- values.forEach((v) => {
- if (v) {
- t = t + parseFloat(v);
- }
- });
- return t;
- },
- },
- };
- </script>
- <style lang="less" scoped></style>
|