|
@@ -31,7 +31,7 @@
|
|
|
<th>累计频数</th>
|
|
|
<th>累计频数(%)</th>
|
|
|
</tr>
|
|
|
- <tr v-for="(seg, index) in course.segements" :key="index">
|
|
|
+ <tr v-for="(seg, index2) in course.segements" :key="index2">
|
|
|
<td>{{ seg[0] }}-</td>
|
|
|
<td>{{ seg[1] }}</td>
|
|
|
<td v-number-to-percent>{{ seg[2] }}%</td>
|
|
@@ -67,7 +67,7 @@
|
|
|
<th>累计频数</th>
|
|
|
<th>累计频数(%)</th>
|
|
|
</tr>
|
|
|
- <tr v-for="(seg, index) in course.rangeSegements" :key="index">
|
|
|
+ <tr v-for="(seg, index3) in course.rangeSegements" :key="index3">
|
|
|
<td>{{ seg[0] }}-</td>
|
|
|
<td>{{ seg[1] }}</td>
|
|
|
<td v-number-to-percent>{{ seg[2] }}%</td>
|
|
@@ -100,7 +100,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { useMainStore } from "@/store";
|
|
|
+// import { useMainStore } from "@/store";
|
|
|
import { onMounted, watch } from "vue";
|
|
|
import { useRoute } from "vue-router";
|
|
|
import {
|
|
@@ -111,29 +111,36 @@ import EventBus from "@/plugins/eventBus";
|
|
|
import { message } from "ant-design-vue";
|
|
|
import { RANGE_POINT_TYPE } from "@/constants/constants";
|
|
|
import { EChartsOption } from "echarts";
|
|
|
+import CommonRangeConfig from "@/components/CommonRangeConfig.vue";
|
|
|
+import { RangeConfig, SasCourse } from "@/types";
|
|
|
|
|
|
let activeKey = $ref(["0"]);
|
|
|
|
|
|
-const store = useMainStore();
|
|
|
+// const store = useMainStore();
|
|
|
|
|
|
-let rootOrgId = $ref(undefined as unknown as number);
|
|
|
+// let rootOrgId = $ref(undefined as unknown as number);
|
|
|
let courseId = $ref(undefined as undefined | number);
|
|
|
const route = useRoute();
|
|
|
const projectId = +route.params.projectId;
|
|
|
|
|
|
-let courses = $ref([]);
|
|
|
+let courses = $ref<SasCourse[]>([]);
|
|
|
async function fetchData() {
|
|
|
const res = await getSasCourseList({
|
|
|
projectId,
|
|
|
courseId,
|
|
|
});
|
|
|
// console.log(Object.keys(JSON.parse(res.data[0].scoreRange)));
|
|
|
- res.data = res.data.map((v: any) => {
|
|
|
- v.scoreRange = Object.values(JSON.parse(v.scoreRange || "{}"));
|
|
|
+ res.data = res.data.map((v) => {
|
|
|
+ if (typeof v.scoreRange === "string") {
|
|
|
+ // scoreRange {1: 1, 2: 2}
|
|
|
+ const t: any = JSON.parse(v.scoreRange || "{}");
|
|
|
+ // eslint-disable-next-line
|
|
|
+ v.scoreRange = Object.values(t);
|
|
|
+ }
|
|
|
return v;
|
|
|
});
|
|
|
- res.data = res.data.map((v: any) => {
|
|
|
- v.rangeConfig = JSON.parse(v.rangeConfig || "0") || [
|
|
|
+ res.data = res.data.map((v) => {
|
|
|
+ v.rangeConfig = JSON.parse(<string>(<unknown>v.rangeConfig) || "0") || [
|
|
|
{
|
|
|
type: "ZERO",
|
|
|
baseScore: 0,
|
|
@@ -142,12 +149,13 @@ async function fetchData() {
|
|
|
];
|
|
|
return v;
|
|
|
});
|
|
|
- res.data = res.data.map((v: { scoreRange: number[] }) => {
|
|
|
+ res.data = res.data.map((v) => {
|
|
|
let acc = 0;
|
|
|
- v.scoreRangeAcc = v.scoreRange.map((_v, i, a) => {
|
|
|
- acc += a[i];
|
|
|
- return acc;
|
|
|
- });
|
|
|
+ if (Array.isArray(v.scoreRange))
|
|
|
+ v.scoreRangeAcc = v.scoreRange.map((_v, i, a) => {
|
|
|
+ acc += a[i];
|
|
|
+ return acc;
|
|
|
+ });
|
|
|
v.scoreRangeTotal = acc;
|
|
|
return v;
|
|
|
});
|
|
@@ -156,7 +164,7 @@ async function fetchData() {
|
|
|
}
|
|
|
|
|
|
onMounted(async () => {
|
|
|
- rootOrgId = store.userInfo.rootOrgId;
|
|
|
+ // rootOrgId = store.userInfo.rootOrgId;
|
|
|
await fetchData();
|
|
|
});
|
|
|
|
|
@@ -196,7 +204,7 @@ watch(
|
|
|
|
|
|
course.rangeSegements = [];
|
|
|
for (let i = 0; i < course.rangeConfig.length; i++) {
|
|
|
- const range = course.rangeConfig[i];
|
|
|
+ const range = course.rangeConfig[i]!;
|
|
|
const nextRange =
|
|
|
i === course.rangeConfig.length - 1
|
|
|
? { baseScore: course.totalScore, adjustScore: 0 }
|
|
@@ -243,16 +251,17 @@ watch(
|
|
|
let selectedRangeConfig = $ref([]);
|
|
|
let selectedCourseId = $ref(0);
|
|
|
|
|
|
-let rangeConfigRef = $ref(null);
|
|
|
+let rangeConfigRef = $ref<InstanceType<typeof CommonRangeConfig>>();
|
|
|
|
|
|
const openRangeConfigModal = (item: any) => {
|
|
|
selectedCourseId = item.courseId;
|
|
|
selectedRangeConfig = JSON.parse(JSON.stringify(item.rangeConfig));
|
|
|
- // @ts-ignore
|
|
|
+ // @ts-ignore https://github.com/vuejs/vue-next/issues/4397
|
|
|
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
|
rangeConfigRef.showModal();
|
|
|
};
|
|
|
|
|
|
-async function handleRangeConfigUpdate(rangeConfig: any) {
|
|
|
+async function handleRangeConfigUpdate(rangeConfig: RangeConfig) {
|
|
|
await setSasCourseRangeConfig({
|
|
|
courseId: selectedCourseId,
|
|
|
projectId: projectId,
|
|
@@ -263,7 +272,7 @@ async function handleRangeConfigUpdate(rangeConfig: any) {
|
|
|
window.location.reload();
|
|
|
}
|
|
|
|
|
|
-function scoreTitle(rangeConfig: any) {
|
|
|
+function scoreTitle(rangeConfig: RangeConfig) {
|
|
|
if (!rangeConfig) return false;
|
|
|
if (rangeConfig.type === "ZERO") return "0-";
|
|
|
|
|
@@ -280,7 +289,7 @@ function openModal2() {
|
|
|
EventBus.emit("SHOW_SETTING", "DESCRIBE030");
|
|
|
}
|
|
|
|
|
|
-function segementsLine(course: any) {
|
|
|
+function segementsLine(course: SasCourse) {
|
|
|
console.log(course);
|
|
|
return {
|
|
|
title: {
|
|
@@ -304,7 +313,7 @@ function segementsLine(course: any) {
|
|
|
} as EChartsOption;
|
|
|
}
|
|
|
|
|
|
-function rangeSegementsLine(course: any) {
|
|
|
+function rangeSegementsLine(course: SasCourse) {
|
|
|
console.log(course);
|
|
|
return {
|
|
|
title: {
|