{"size": 2006, "ext": "js", "max_stars_repo_path": "ui/sidebar/panels/ResearchPanel.js", "max_stars_repo_name": "bdf1/bdf", "max_stars_repo_stars_event_min_datetime": "2017-02-13T11:00:55.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-25T09:03:11.000Z", "max_issues_repo_path": "ui/sidebar/panels/ResearchPanel.js", "max_issues_repo_name": "bdf1/bdf", "max_issues_repo_issues_event_min_datetime": "2021-11-26T17:56:46.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-28T14:13:08.000Z", "max_forks_repo_path": "ui/sidebar/panels/ResearchPanel.js", "max_forks_repo_name": "bdf1/bdf", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 30.3939393939, "max_line_length": 67, "alphanum_fraction": 0.4750747757}
import { extendUI } from "../../index.js";
import { WIcon } from "../../components/Icon/index.js";
import { UnitIcon } from "../../components/UnitIcon/index.js";
import { createStore } from "../../store/index.js";

export const ResearchPanel = Vue.extend({
    template: /* HTML */`
    <div class="sidebar-item research" @click="openResearchModal">
        <div v-if="field > 0" class="container">
            <unit-icon :unit="field" :level="level+1" />
            <div class="process">
                <div class="process-label">
                    <!-- <div class="name">{{ name }}</div> -->
                    <div class="value">{{ pass }}/{{ total }}</div>
                </div>
                <div class="process-bar">
                    <div class="pass" :style="barStyle"></div>
                </div>
            </div>
        </div>
        <div v-else class="empty">
            <w-icon class="blink warning" icon="warning" />选择研究方向
        </div>
    </div>
    `,
    data: () => createStore("research-panel", {
        name: "",
        field: 0,
        level: 0,
        pass: 0,
        total: 0,
    }, (data) => {
        if (!flags.xzgj) return;
        const research = core.createResearch(flags.gj[flags.xzgj]);
        if (research.field === 0) {
            return;
        }
        data.field = research.field;
        const field = research.fields[data.field];
        data.pass = field.pass;
        data.level = field.level;
        data.total = field.levels[data.level+1];
        data.name = flags.mil[data.field][data.level+1].nm;
    }),
    computed: {
        barStyle() {
            let ratio = 0;
            if (this.total > 0) {
                ratio = this.pass / this.total * 100;
            }
            return `width: ${ ratio.toFixed(3) }%;`;
        }
    },
    created() {
    },
    methods: {
        openResearchModal() {
            extendUI.callModal("research");
        },
    },
    components: {
        UnitIcon,
        WIcon,
    }
});
