Skip to content

Commit c54b960

Browse files
committed
fix: 解决其他两个修改的文件的lint和ts问题
1 parent de47855 commit c54b960

File tree

2 files changed

+47
-29
lines changed

2 files changed

+47
-29
lines changed

src/pages/DetailInfo/question/checkbox.vue

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
</div>
1919
</div>
2020
<div class="divider" />
21-
<div ref="scrollContainer" class="flex-col p-5 overflow-y-auto h-180 mt-10" style="scroll-behavior: smooth;">
21+
<div class="flex-col p-5 overflow-y-auto h-180 mt-10" style="scroll-behavior: smooth;">
2222
<div v-for="item in localOptions" :key="item.serialNum" class="my-5">
2323
<div class="flex items-center gap-10">
24-
<input type="checkbox" :name="item.serialNum" class="checkbox-sm my-5">
24+
<input type="checkbox" :name="`${item.serialNum}`" class="checkbox-sm my-5">
2525
<input
2626
v-model="item.content"
2727
type="text"
@@ -30,7 +30,12 @@
3030
>
3131
<div class="ml-10 flex items-center gap-20">
3232
<div v-if="item.img" class="mt-4">
33-
<img :src="item.img" :key="item.img" alt="Preview" style="max-width: 50px; max-height: 50px;">
33+
<img
34+
:key="item.img"
35+
:src="item.img"
36+
alt="Preview"
37+
style="max-width: 50px; max-height: 50px;"
38+
>
3439
</div>
3540
<input
3641
v-if="isActive"
@@ -58,7 +63,7 @@
5863
</template>
5964

6065
<script setup lang="ts">
61-
import { ref, watch, defineProps, defineEmits } from "vue";
66+
import { ref, watch } from "vue";
6267
import { useRequest } from "vue-hooks-plus";
6368
import { saveImgAPI } from "@/apis";
6469
import { ElNotification } from "element-plus";
@@ -80,8 +85,17 @@ const props = defineProps<{
8085
}[]
8186
}>();
8287
83-
const scrollContainer = ref<HTMLDivElement>();
84-
const emits = defineEmits(["update:unique", "on-click", "update:otherOption", "update:optionChoose", "update:title", "update:options", "update:describe"]);
88+
const emits = defineEmits([
89+
"update:unique",
90+
"on-click",
91+
"update:otherOption",
92+
"update:optionChoose",
93+
"update:title",
94+
"update:options",
95+
"update:describe",
96+
"update:minimum_option",
97+
"update:maximum_option"
98+
]);
8599
86100
// Local copies of props to maintain reactivity
87101
const localTitle = ref<string>(props.title || "");
@@ -97,37 +111,37 @@ const handleFileChange = async (event: Event, serialNum: number) => {
97111
const input = event.target as HTMLInputElement;
98112
const file = input.files?.[0];
99113
if (!file) return;
100-
114+
101115
const formData = new FormData();
102116
formData.append("img", file);
103-
104-
const currentOption = localOptions.value.find(item => item.serialNum === serialNum);
117+
118+
const currentOption = localOptions.value?.find(item => item.serialNum === serialNum);
105119
if (!currentOption) return;
106-
107-
const originalImg = currentOption.img || '';
108-
120+
121+
const originalImg = currentOption.img || "";
122+
109123
useRequest(() => saveImgAPI(formData), {
110124
onSuccess(res: any) {
111125
if (res.code === 200) {
112-
126+
113127
currentOption.img = res.data;
114128
ElNotification.success("上传图片成功");
115129
} else {
116130
throw new Error(res.msg || "上传失败");
117131
}
118132
},
119133
onError(error: any) {
120-
134+
121135
currentOption.img = originalImg;
122-
input.value = '';
136+
input.value = "";
123137
ElNotification.error("上传图片失败:" + (error.message || error));
124138
}
125139
});
126140
};
127141
128142
const deleteOption = (serialNum: number) => {
129-
localOptions.value = localOptions.value.filter(item => item.serialNum !== serialNum);
130-
localOptions.value.forEach((item) => {
143+
localOptions.value = localOptions.value?.filter(item => item.serialNum !== serialNum);
144+
localOptions.value?.forEach((item) => {
131145
if (item.serialNum > serialNum) {
132146
item.serialNum -= 1;
133147
}

src/pages/DetailInfo/question/radio.vue

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
</div>
1919
</div>
2020
<div class="divider" />
21-
<div ref="scrollContainer" class="flex-col p-5 overflow-y-auto h-180 mt-10" style="scroll-behavior: smooth;">
21+
<div class="flex-col p-5 overflow-y-auto h-180 mt-10" style="scroll-behavior: smooth;">
2222
<div v-for="item in localOptions" :key="item.serialNum" class="flex items-center gap-10 my-5">
23-
<input type="radio" :name="props.serialNum" class="radio-sm my-5">
23+
<input type="radio" :name="`${props.serialNum}`" class="radio-sm my-5">
2424
<input
2525
v-model="item.content"
2626
type="text"
@@ -29,7 +29,12 @@
2929
>
3030
<div class="ml-10 flex items-center gap-20">
3131
<div v-if="item.img" class="mt-4">
32-
<img :src="item.img" :key="item.img" alt="Preview" style="max-width: 50px; max-height: 50px;">
32+
<img
33+
:key="item.img"
34+
:src="item.img"
35+
alt="Preview"
36+
style="max-width: 50px; max-height: 50px;"
37+
>
3338
</div>
3439
<input
3540
v-if="isActive"
@@ -56,7 +61,7 @@
5661
</template>
5762

5863
<script setup lang="ts">
59-
import { ref, watch, defineProps, defineEmits } from "vue";
64+
import { ref, watch } from "vue";
6065
import { useRequest } from "vue-hooks-plus";
6166
import { saveImgAPI } from "@/apis";
6267
import { ElNotification } from "element-plus";
@@ -78,7 +83,6 @@ const props = defineProps<{
7883
7984
const emits = defineEmits(["update:unique", "on-click", "update:otherOption", "update:optionChoose", "update:title", "update:options", "update:describe"]);
8085
81-
const scrollContainer = ref<HTMLDivElement>();
8286
const localTitle = ref<string>(props.title || "");
8387
const localDescribe = ref<string>(props.describe || "");
8488
const localOptionChoose = ref<boolean>(props.optionChoose);
@@ -90,30 +94,30 @@ const handleFileChange = async (event: Event, serialNum: number) => {
9094
const input = event.target as HTMLInputElement;
9195
const file = input.files?.[0];
9296
if (!file) return;
93-
97+
9498
const formData = new FormData();
9599
formData.append("img", file);
96100
97101
const currentOption = localOptions.value.find(item => item.serialNum === serialNum);
98102
if (!currentOption) return;
99103
100-
const originalImg = currentOption.img || '';
101-
104+
const originalImg = currentOption.img || "";
105+
102106
useRequest(() => saveImgAPI(formData), {
103107
onSuccess(res: any) {
104108
if (res.code === 200) {
105-
109+
106110
currentOption.img = res.data;
107111
ElNotification.success("上传图片成功");
108112
} else {
109-
113+
110114
throw new Error(res.msg || "上传失败");
111115
}
112116
},
113117
onError(error: any) {
114-
118+
115119
currentOption.img = originalImg;
116-
input.value = '';
120+
input.value = "";
117121
ElNotification.error("上传图片失败:" + (error.message || error));
118122
}
119123
});

0 commit comments

Comments
 (0)