上传文件至 /
这个提交包含在:
373
ExperimentArea.vue
普通文件
373
ExperimentArea.vue
普通文件
@ -0,0 +1,373 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import type { ExperimentArea } from '@/types/experiment'
|
||||||
|
import { renderTextWithLatex } from '@/utils/latex'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
config: ExperimentArea
|
||||||
|
result: {
|
||||||
|
value: any
|
||||||
|
formatted: string
|
||||||
|
error?: string
|
||||||
|
}
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const areaLabel = computed(() => renderTextWithLatex(props.config.label))
|
||||||
|
const areaExpression = computed(() => renderTextWithLatex(props.config.expression))
|
||||||
|
|
||||||
|
const areaStyle = computed(() => {
|
||||||
|
const baseStyle = {
|
||||||
|
margin: '0',
|
||||||
|
padding: '1.5rem',
|
||||||
|
border: 'none',
|
||||||
|
borderRadius: '16px',
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...baseStyle,
|
||||||
|
...props.config.style,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const resultStyle = computed(() => {
|
||||||
|
const baseStyle = {
|
||||||
|
fontSize: '1.25rem',
|
||||||
|
fontWeight: '600',
|
||||||
|
padding: '1rem 1.5rem',
|
||||||
|
marginTop: '0.75rem',
|
||||||
|
borderRadius: '12px',
|
||||||
|
backgroundColor: 'white',
|
||||||
|
border: '1px solid #dee2e6',
|
||||||
|
textAlign: 'center',
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.result.error) {
|
||||||
|
return {
|
||||||
|
...baseStyle,
|
||||||
|
color: '#dc3545',
|
||||||
|
backgroundColor: 'rgba(220, 53, 69, 0.08)',
|
||||||
|
borderColor: 'rgba(220, 53, 69, 0.2)',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...baseStyle,
|
||||||
|
color: '#155724',
|
||||||
|
backgroundColor: 'rgba(21, 87, 36, 0.08)',
|
||||||
|
borderColor: 'rgba(40, 167, 69, 0.2)',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const statusText = computed(() => {
|
||||||
|
if (props.result.error) {
|
||||||
|
return '计算错误'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.result.value === null || props.result.value === undefined) {
|
||||||
|
return '等待输入...'
|
||||||
|
}
|
||||||
|
|
||||||
|
return '计算结果'
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="experiment-area" :style="areaStyle">
|
||||||
|
<div class="area-header">
|
||||||
|
<div class="area-label" v-html="areaLabel" />
|
||||||
|
<div class="area-expression" v-html="areaExpression" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="area-result">
|
||||||
|
<div class="result-status">
|
||||||
|
<span class="status-icon">
|
||||||
|
<svg v-if="result.error" width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z" stroke="currentColor" stroke-width="2"/>
|
||||||
|
<path d="M12 6V12L16 14" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
<svg v-else-if="result.value === null || result.value === undefined" width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M12 8V12L15 15" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
<path d="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z" stroke="currentColor" stroke-width="2"/>
|
||||||
|
</svg>
|
||||||
|
<svg v-else width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M20 6L9 17L4 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
{{ statusText }}
|
||||||
|
</div>
|
||||||
|
<div class="result-value" :style="resultStyle">
|
||||||
|
{{ props.result.formatted }}
|
||||||
|
</div>
|
||||||
|
<div v-if="props.result.error" class="error-message">
|
||||||
|
<span class="error-icon">❌</span>
|
||||||
|
{{ props.result.error }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.experiment-area {
|
||||||
|
font-family: inherit;
|
||||||
|
background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(240, 242, 245, 0.95) 100%);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.4);
|
||||||
|
border-radius: 20px;
|
||||||
|
padding: 2rem;
|
||||||
|
margin: 0;
|
||||||
|
box-shadow: 0 6px 24px rgba(0, 0, 0, 0.06);
|
||||||
|
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.experiment-area::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 4px;
|
||||||
|
background: linear-gradient(90deg, #4cd964 0%, #5ac8fa 100%);
|
||||||
|
opacity: 0.8;
|
||||||
|
transition: opacity 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.experiment-area:hover {
|
||||||
|
transform: translateY(-4px);
|
||||||
|
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
|
||||||
|
border-color: rgba(76, 217, 100, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.experiment-area:hover::before {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.area-header {
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
padding-bottom: 1.25rem;
|
||||||
|
border-bottom: 2px dashed rgba(0, 0, 0, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
.area-label {
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 1.35rem;
|
||||||
|
margin-bottom: 0.875rem;
|
||||||
|
color: #2c3e50;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.area-label::before {
|
||||||
|
content: '🧮';
|
||||||
|
font-size: 1.6rem;
|
||||||
|
background: linear-gradient(135deg, #4cd964 0%, #5ac8fa 100%);
|
||||||
|
-webkit-background-clip: text;
|
||||||
|
-webkit-text-fill-color: transparent;
|
||||||
|
background-clip: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
.area-label :deep(.katex) {
|
||||||
|
font-size: 1.15em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.area-expression {
|
||||||
|
font-size: 1.15rem;
|
||||||
|
color: #5d6d7e;
|
||||||
|
font-style: italic;
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
background: rgba(255, 255, 255, 0.9);
|
||||||
|
border-radius: 12px;
|
||||||
|
border-left: 4px solid #667eea;
|
||||||
|
margin-top: 0.75rem;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
|
||||||
|
}
|
||||||
|
|
||||||
|
.area-expression :deep(.katex) {
|
||||||
|
font-size: 1.05em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.area-result {
|
||||||
|
margin-top: 1.25rem;
|
||||||
|
padding: 1.25rem 1.5rem;
|
||||||
|
background: rgba(255, 255, 255, 0.8);
|
||||||
|
border-radius: 16px;
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.06);
|
||||||
|
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-status {
|
||||||
|
font-size: 1rem;
|
||||||
|
color: #667eea;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
font-weight: 600;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-icon {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-value {
|
||||||
|
font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
|
||||||
|
text-align: center;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
font-size: 1.75rem;
|
||||||
|
font-weight: 700;
|
||||||
|
padding: 1.5rem;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
color: white;
|
||||||
|
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
|
||||||
|
animation: pulse 3s infinite;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-value::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: -100%;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
|
||||||
|
transition: left 0.8s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-value:hover::before {
|
||||||
|
left: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes pulse {
|
||||||
|
0% {
|
||||||
|
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
box-shadow: 0 4px 25px rgba(102, 126, 234, 0.5);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-message {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
color: #e74c3c;
|
||||||
|
margin-top: 1rem;
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
background: linear-gradient(135deg, rgba(231, 76, 60, 0.1) 0%, rgba(231, 76, 60, 0.05) 100%);
|
||||||
|
border-radius: 12px;
|
||||||
|
border-left: 4px solid #e74c3c;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.875rem;
|
||||||
|
box-shadow: 0 2px 8px rgba(231, 76, 60, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-icon {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 响应式设计 */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.experiment-area {
|
||||||
|
padding: 1.5rem;
|
||||||
|
border-radius: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.area-label {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.area-expression {
|
||||||
|
font-size: 1.05rem;
|
||||||
|
padding: 0.875rem 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-value {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
padding: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.area-result {
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.experiment-area {
|
||||||
|
padding: 1.25rem;
|
||||||
|
border-radius: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.area-label {
|
||||||
|
font-size: 1.15rem;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.area-expression {
|
||||||
|
font-size: 1rem;
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-value {
|
||||||
|
font-size: 1.35rem;
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-status {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 暗色模式支持 */
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
.experiment-area {
|
||||||
|
background: linear-gradient(135deg, rgba(15, 52, 96, 0.9) 0%, rgba(26, 32, 44, 0.9) 100%);
|
||||||
|
border-color: rgba(255, 255, 255, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.area-header {
|
||||||
|
border-bottom-color: rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.area-label {
|
||||||
|
color: #e2e8f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.area-expression {
|
||||||
|
color: #a0aec0;
|
||||||
|
background: rgba(255, 255, 255, 0.08);
|
||||||
|
border-left-color: #667eea;
|
||||||
|
}
|
||||||
|
|
||||||
|
.area-result {
|
||||||
|
background: rgba(255, 255, 255, 0.08);
|
||||||
|
border-color: rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-status {
|
||||||
|
color: #90cdf4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-value {
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-message {
|
||||||
|
color: #fc8181;
|
||||||
|
background: rgba(252, 129, 129, 0.15);
|
||||||
|
border-left-color: #fc8181;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
170
ExperimentContainer.vue
普通文件
170
ExperimentContainer.vue
普通文件
@ -0,0 +1,170 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import type { ExperimentContainer } from '@/types/experiment'
|
||||||
|
import ExperimentLabel from './ExperimentLabel.vue'
|
||||||
|
import ExperimentField from './ExperimentField.vue'
|
||||||
|
import ExperimentArea from './ExperimentArea.vue'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
config: ExperimentContainer
|
||||||
|
fieldData: Record<
|
||||||
|
string,
|
||||||
|
{
|
||||||
|
value: any
|
||||||
|
validated: boolean
|
||||||
|
validationResult?: { accept: boolean; message: string }
|
||||||
|
}
|
||||||
|
>
|
||||||
|
areaResults: Record<
|
||||||
|
string,
|
||||||
|
{
|
||||||
|
value: any
|
||||||
|
formatted: string
|
||||||
|
error?: string
|
||||||
|
}
|
||||||
|
>
|
||||||
|
onFieldUpdate: (fieldId: string, value: any) => void
|
||||||
|
onFieldValidate: (fieldId: string) => void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const containerStyle = computed(() => {
|
||||||
|
const baseStyle: Record<string, string> = {
|
||||||
|
padding: '1.5rem',
|
||||||
|
margin: '0',
|
||||||
|
border: 'none',
|
||||||
|
borderRadius: '20px',
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
}
|
||||||
|
|
||||||
|
const layoutStyles: Record<string, Record<string, string>> = {
|
||||||
|
vertical: {
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
gap: '1.25rem',
|
||||||
|
},
|
||||||
|
horizontal: {
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'row',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
gap: '1.25rem',
|
||||||
|
alignItems: 'flex-start',
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
display: 'grid',
|
||||||
|
gridTemplateColumns: 'repeat(auto-fill, minmax(280px, 1fr))',
|
||||||
|
gap: '1.25rem',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const layout = props.config.layout || 'vertical'
|
||||||
|
const layoutStyle = layoutStyles[layout] || layoutStyles.vertical
|
||||||
|
|
||||||
|
return {
|
||||||
|
...baseStyle,
|
||||||
|
...layoutStyle,
|
||||||
|
...(props.config.style || {}),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const getFieldDependenciesSatisfied = (fieldId: string): boolean => {
|
||||||
|
// 这里简化处理,实际应该检查字段的依赖关系
|
||||||
|
// 在这个简单实现中,我们假设所有字段都可以独立填写
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="experiment-container" :style="containerStyle">
|
||||||
|
<template v-for="child in config.children" :key="child.id">
|
||||||
|
<!-- 标签 -->
|
||||||
|
<ExperimentLabel v-if="child.type === 'label'" :config="child" />
|
||||||
|
|
||||||
|
<!-- 字段 -->
|
||||||
|
<ExperimentField
|
||||||
|
v-else-if="child.type === 'field'"
|
||||||
|
:config="child"
|
||||||
|
:value="fieldData[child.id]?.value"
|
||||||
|
:validated="fieldData[child.id]?.validated || false"
|
||||||
|
:validation-result="fieldData[child.id]?.validationResult"
|
||||||
|
:dependencies-satisfied="getFieldDependenciesSatisfied(child.id)"
|
||||||
|
@update:value="(value) => onFieldUpdate(child.id, value)"
|
||||||
|
@validate="() => onFieldValidate(child.id)"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 计算区域 -->
|
||||||
|
<ExperimentArea
|
||||||
|
v-else-if="child.type === 'area'"
|
||||||
|
:config="child"
|
||||||
|
:result="areaResults[child.id] || { value: null, formatted: '等待计算...' }"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.experiment-container {
|
||||||
|
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.06) 100%);
|
||||||
|
backdrop-filter: blur(18px);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||||
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.experiment-container::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 4px;
|
||||||
|
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
|
||||||
|
opacity: 0.8;
|
||||||
|
transition: opacity 0.3s ease, transform 0.3s ease;
|
||||||
|
transform: scaleX(0.9);
|
||||||
|
transform-origin: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.experiment-container:hover {
|
||||||
|
transform: translateY(-3px);
|
||||||
|
box-shadow: 0 10px 30px rgba(102, 126, 234, 0.12);
|
||||||
|
border-color: rgba(102, 126, 234, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.experiment-container:hover::before {
|
||||||
|
transform: scaleX(1);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 响应式设计 */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.experiment-container {
|
||||||
|
margin: 0 !important;
|
||||||
|
padding: 1.25rem !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.experiment-container {
|
||||||
|
margin: 0 !important;
|
||||||
|
padding: 1rem !important;
|
||||||
|
border-radius: 16px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 暗色模式支持 */
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
.experiment-container {
|
||||||
|
background: linear-gradient(135deg, rgba(10, 24, 46, 0.4) 0%, rgba(10, 24, 46, 0.2) 100%);
|
||||||
|
border-color: rgba(255, 255, 255, 0.12);
|
||||||
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.experiment-container:hover {
|
||||||
|
box-shadow: 0 8px 26px rgba(0, 0, 0, 0.25);
|
||||||
|
border-color: rgba(102, 126, 234, 0.3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
495
ExperimentField.vue
普通文件
495
ExperimentField.vue
普通文件
@ -0,0 +1,495 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, computed, watch, onMounted } from 'vue'
|
||||||
|
import type { ExperimentField } from '@/types/experiment'
|
||||||
|
import { renderTextWithLatex } from '@/utils/latex'
|
||||||
|
import { validateNumberRange, validateRegex } from '@/utils/calculation'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
config: ExperimentField
|
||||||
|
value: any
|
||||||
|
validated: boolean
|
||||||
|
validationResult?: { accept: boolean; message: string }
|
||||||
|
dependenciesSatisfied: boolean
|
||||||
|
disabled?: boolean
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:value': [value: any]
|
||||||
|
validate: []
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const inputValue = ref(props.value)
|
||||||
|
const isTouched = ref(false)
|
||||||
|
const localValidation = ref<{ valid: boolean; message: string } | null>(null)
|
||||||
|
|
||||||
|
const fieldId = computed(() => props.config.id)
|
||||||
|
const fieldLabel = computed(() => renderTextWithLatex(props.config.label))
|
||||||
|
const fieldPlaceholder = computed(() => props.config.placeholder || '请输入值')
|
||||||
|
const fieldUnit = computed(() => (props.config.unit ? renderTextWithLatex(props.config.unit) : ''))
|
||||||
|
|
||||||
|
const fieldStyle = computed(() => {
|
||||||
|
const baseStyle = {
|
||||||
|
margin: '0',
|
||||||
|
padding: '1.25rem',
|
||||||
|
borderRadius: '16px',
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...baseStyle,
|
||||||
|
...props.config.style,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const inputStyle = computed(() => {
|
||||||
|
const baseStyle: Record<string, string> = {
|
||||||
|
padding: '0.875rem 1.25rem',
|
||||||
|
border: '2px solid #e0e0e0',
|
||||||
|
borderRadius: '12px',
|
||||||
|
fontSize: '1rem',
|
||||||
|
width: '100%',
|
||||||
|
boxSizing: 'border-box' as any,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.disabled || !props.dependenciesSatisfied) {
|
||||||
|
return {
|
||||||
|
...baseStyle,
|
||||||
|
backgroundColor: 'rgba(248, 249, 250, 0.8)',
|
||||||
|
cursor: 'not-allowed',
|
||||||
|
opacity: '0.7',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isTouched.value && localValidation.value && !localValidation.value.valid) {
|
||||||
|
return {
|
||||||
|
...baseStyle,
|
||||||
|
borderColor: '#dc3545',
|
||||||
|
backgroundColor: 'rgba(255, 245, 245, 0.8)',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.validated && props.validationResult) {
|
||||||
|
return {
|
||||||
|
...baseStyle,
|
||||||
|
borderColor: props.validationResult.accept ? '#28a745' : '#dc3545',
|
||||||
|
backgroundColor: props.validationResult.accept ? 'rgba(240, 255, 244, 0.8)' : 'rgba(255, 245, 245, 0.8)',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseStyle
|
||||||
|
})
|
||||||
|
|
||||||
|
const validationMessage = computed(() => {
|
||||||
|
if (localValidation.value && !localValidation.value.valid) {
|
||||||
|
return localValidation.value.message
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.validationResult && !props.validationResult.accept) {
|
||||||
|
return props.validationResult.message
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
})
|
||||||
|
|
||||||
|
const showValidationMessage = computed(() => {
|
||||||
|
return validationMessage.value !== null && isTouched.value
|
||||||
|
})
|
||||||
|
|
||||||
|
const performLocalValidation = (value: any): { valid: boolean; message: string } => {
|
||||||
|
const validation = props.config.validation
|
||||||
|
|
||||||
|
if (!validation) {
|
||||||
|
return { valid: true, message: '' }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (validation.required && (value === null || value === undefined || value === '')) {
|
||||||
|
return { valid: false, message: '此字段为必填项' }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (validation.type === 'number') {
|
||||||
|
const numValue = Number(value)
|
||||||
|
if (isNaN(numValue)) {
|
||||||
|
return { valid: false, message: '请输入有效的数字' }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!validateNumberRange(numValue, validation.min, validation.max)) {
|
||||||
|
let message = '数值'
|
||||||
|
if (validation.min !== undefined && validation.max !== undefined) {
|
||||||
|
message += `应在 ${validation.min} 到 ${validation.max} 之间`
|
||||||
|
} else if (validation.min !== undefined) {
|
||||||
|
message += `应大于等于 ${validation.min}`
|
||||||
|
} else if (validation.max !== undefined) {
|
||||||
|
message += `应小于等于 ${validation.max}`
|
||||||
|
}
|
||||||
|
return { valid: false, message }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (validation.type === 'regex' && validation.pattern && typeof value === 'string') {
|
||||||
|
if (!validateRegex(value, validation.pattern)) {
|
||||||
|
return { valid: false, message: '格式不正确' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { valid: true, message: '' }
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleInput = (event: Event) => {
|
||||||
|
const target = event.target as HTMLInputElement
|
||||||
|
const newValue = target.value
|
||||||
|
|
||||||
|
inputValue.value = newValue
|
||||||
|
isTouched.value = true
|
||||||
|
|
||||||
|
// 本地验证
|
||||||
|
localValidation.value = performLocalValidation(newValue)
|
||||||
|
|
||||||
|
// 触发验证事件
|
||||||
|
if (localValidation.value.valid) {
|
||||||
|
emit('update:value', newValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleBlur = () => {
|
||||||
|
if (localValidation.value?.valid) {
|
||||||
|
emit('validate')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleFocus = () => {
|
||||||
|
isTouched.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监听外部值变化
|
||||||
|
watch(
|
||||||
|
() => props.value,
|
||||||
|
(newValue) => {
|
||||||
|
inputValue.value = newValue
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
// 初始化本地验证
|
||||||
|
onMounted(() => {
|
||||||
|
if (props.value !== null && props.value !== undefined && props.value !== '') {
|
||||||
|
localValidation.value = performLocalValidation(props.value)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="experiment-field" :style="fieldStyle">
|
||||||
|
<label :for="fieldId" class="field-label" v-html="fieldLabel">
|
||||||
|
<span v-if="config.validation?.required" class="required-indicator">*</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="input-container">
|
||||||
|
<input
|
||||||
|
:id="fieldId"
|
||||||
|
v-model="inputValue"
|
||||||
|
:placeholder="fieldPlaceholder"
|
||||||
|
:disabled="disabled || !dependenciesSatisfied"
|
||||||
|
:style="inputStyle"
|
||||||
|
@input="handleInput"
|
||||||
|
@blur="handleBlur"
|
||||||
|
@focus="handleFocus"
|
||||||
|
class="field-input"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<span v-if="fieldUnit" class="field-unit" v-html="fieldUnit" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="showValidationMessage"
|
||||||
|
class="validation-message"
|
||||||
|
:class="{ error: !props.validated }"
|
||||||
|
>
|
||||||
|
<span class="message-icon">⚠️</span>
|
||||||
|
{{ validationMessage }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="!dependenciesSatisfied" class="dependency-warning">
|
||||||
|
<span class="warning-icon">⏳</span>
|
||||||
|
请先填写依赖字段
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.experiment-field {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 1.5rem;
|
||||||
|
background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.7) 100%);
|
||||||
|
border-radius: 20px;
|
||||||
|
border: 1px solid rgba(226, 232, 240, 0.8);
|
||||||
|
transition: all 0.4s ease;
|
||||||
|
position: relative;
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
.experiment-field::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 4px;
|
||||||
|
height: 100%;
|
||||||
|
background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
|
||||||
|
opacity: 0.7;
|
||||||
|
transition: opacity 0.3s ease;
|
||||||
|
border-radius: 4px 0 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.experiment-field:hover {
|
||||||
|
background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.85) 100%);
|
||||||
|
border-color: rgba(102, 126, 234, 0.3);
|
||||||
|
box-shadow: 0 8px 24px rgba(102, 126, 234, 0.1);
|
||||||
|
transform: translateY(-2px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.experiment-field:hover::before {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-label {
|
||||||
|
font-weight: 600;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
color: #2c3e50;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.required-indicator {
|
||||||
|
color: #e74c3c;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-label::before {
|
||||||
|
content: '•';
|
||||||
|
color: #667eea;
|
||||||
|
font-size: 1.4rem;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-label :deep(.katex) {
|
||||||
|
font-size: 1.05em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1rem;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-input {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
border: 2px solid #e2e8f0;
|
||||||
|
border-radius: 12px;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-family: inherit;
|
||||||
|
background: rgba(255, 255, 255, 0.95);
|
||||||
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
color: #333;
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-input:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #667eea;
|
||||||
|
box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-input:disabled {
|
||||||
|
background: rgba(248, 249, 250, 0.9);
|
||||||
|
color: #6c757d;
|
||||||
|
cursor: not-allowed;
|
||||||
|
border-color: #dee2e6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-unit {
|
||||||
|
font-size: 1rem;
|
||||||
|
color: #667eea;
|
||||||
|
white-space: nowrap;
|
||||||
|
font-weight: 500;
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
background: rgba(102, 126, 234, 0.1);
|
||||||
|
border-radius: 10px;
|
||||||
|
border: 1px solid rgba(102, 126, 234, 0.15);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-unit:hover {
|
||||||
|
background: rgba(102, 126, 234, 0.15);
|
||||||
|
border-color: rgba(102, 126, 234, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-unit :deep(.katex) {
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.validation-message {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
margin-top: 0.75rem;
|
||||||
|
padding: 0.875rem 1.25rem;
|
||||||
|
border-radius: 10px;
|
||||||
|
animation: slideIn 0.3s ease;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-icon {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.validation-message.error {
|
||||||
|
color: #e74c3c;
|
||||||
|
background: linear-gradient(135deg, rgba(231, 76, 60, 0.12) 0%, rgba(231, 76, 60, 0.06) 100%);
|
||||||
|
border-left: 4px solid #e74c3c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dependency-warning {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: #f39c12;
|
||||||
|
margin-top: 0.75rem;
|
||||||
|
padding: 0.875rem 1.25rem;
|
||||||
|
background: linear-gradient(135deg, rgba(243, 156, 18, 0.12) 0%, rgba(243, 156, 18, 0.06) 100%);
|
||||||
|
border-radius: 10px;
|
||||||
|
border-left: 4px solid #f39c12;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
animation: slideIn 0.3s ease;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
.warning-icon {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 动画 */
|
||||||
|
@keyframes slideIn {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(-10px);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 响应式设计 */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.experiment-field {
|
||||||
|
padding: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-label {
|
||||||
|
font-size: 1rem;
|
||||||
|
margin-bottom: 0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-input {
|
||||||
|
padding: 0.875rem 1rem;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-unit {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
padding: 0.625rem 0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-container {
|
||||||
|
gap: 0.875rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.experiment-field {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-label {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-input {
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-container {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-unit {
|
||||||
|
align-self: flex-start;
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 暗色模式支持 */
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
.experiment-field {
|
||||||
|
background: linear-gradient(135deg, rgba(15, 52, 96, 0.6) 0%, rgba(26, 32, 44, 0.6) 100%);
|
||||||
|
border-color: rgba(255, 255, 255, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.experiment-field:hover {
|
||||||
|
background: linear-gradient(135deg, rgba(15, 52, 96, 0.7) 0%, rgba(26, 32, 44, 0.7) 100%);
|
||||||
|
border-color: rgba(102, 126, 234, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-label {
|
||||||
|
color: #e2e8f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-input {
|
||||||
|
background: rgba(26, 32, 44, 0.8);
|
||||||
|
border-color: #4a5568;
|
||||||
|
color: #e2e8f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-input:focus {
|
||||||
|
border-color: #667eea;
|
||||||
|
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
|
||||||
|
background: #1a202c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-input:disabled {
|
||||||
|
background: rgba(45, 55, 72, 0.8);
|
||||||
|
color: #a0aec0;
|
||||||
|
border-color: #4a5568;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-unit {
|
||||||
|
color: #90cdf4;
|
||||||
|
background: rgba(144, 205, 244, 0.15);
|
||||||
|
border-color: rgba(144, 205, 244, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.validation-message.error {
|
||||||
|
color: #fc8181;
|
||||||
|
background: rgba(252, 129, 129, 0.15);
|
||||||
|
border-left-color: #fc8181;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dependency-warning {
|
||||||
|
color: #f6ad55;
|
||||||
|
background: rgba(246, 173, 85, 0.15);
|
||||||
|
border-left-color: #f6ad55;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
374
ExperimentForm.vue
普通文件
374
ExperimentForm.vue
普通文件
@ -0,0 +1,374 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, watch } from 'vue'
|
||||||
|
import type { ExperimentFormConfig } from '@/types/experiment'
|
||||||
|
import ExperimentContainer from './ExperimentContainer.vue'
|
||||||
|
import { useExperimentStore } from '@/stores/experiment'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
config: ExperimentFormConfig
|
||||||
|
validationUrl?: string
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'field-update': [fieldId: string, value: any]
|
||||||
|
'field-validate': [fieldId: string]
|
||||||
|
'all-validated': []
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const experimentStore = useExperimentStore()
|
||||||
|
|
||||||
|
// 初始化store
|
||||||
|
experimentStore.setConfig(props.config, props.validationUrl)
|
||||||
|
|
||||||
|
const fieldData = computed(() => experimentStore.data)
|
||||||
|
const areaResults = computed(() => experimentStore.areaResults)
|
||||||
|
const allFieldsValidated = computed(() => experimentStore.allFieldsValidated)
|
||||||
|
|
||||||
|
const handleFieldUpdate = (fieldId: string, value: any) => {
|
||||||
|
experimentStore.setFieldValue(fieldId, value)
|
||||||
|
emit('field-update', fieldId, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleFieldValidate = async (fieldId: string) => {
|
||||||
|
const result = await experimentStore.validateField(fieldId)
|
||||||
|
emit('field-validate', fieldId)
|
||||||
|
|
||||||
|
// 如果所有字段都验证通过,触发事件
|
||||||
|
if (experimentStore.allFieldsValidated) {
|
||||||
|
emit('all-validated')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监听所有字段验证状态
|
||||||
|
watch(allFieldsValidated, (newValue) => {
|
||||||
|
if (newValue) {
|
||||||
|
emit('all-validated')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="experiment-form">
|
||||||
|
<div class="form-header">
|
||||||
|
<h2 class="form-title">{{ config.title }}</h2>
|
||||||
|
<p v-if="config.description" class="form-description">{{ config.description }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-containers">
|
||||||
|
<ExperimentContainer
|
||||||
|
v-for="container in config.containers"
|
||||||
|
:key="container.id"
|
||||||
|
:config="container"
|
||||||
|
:field-data="fieldData"
|
||||||
|
:area-results="areaResults"
|
||||||
|
:on-field-update="handleFieldUpdate"
|
||||||
|
:on-field-validate="handleFieldValidate"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-status">
|
||||||
|
<div class="status-indicator" :class="{ 'all-valid': allFieldsValidated }">
|
||||||
|
<span class="status-icon">
|
||||||
|
<svg v-if="allFieldsValidated" width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M20 6L9 17L4 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
<svg v-else width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z" stroke="currentColor" stroke-width="2"/>
|
||||||
|
<path d="M12 6V12L16 14" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
{{ allFieldsValidated ? '所有字段已验证' : '请完成所有字段验证' }}
|
||||||
|
</div>
|
||||||
|
<div class="progress">
|
||||||
|
<div class="progress-bar">
|
||||||
|
<div
|
||||||
|
class="progress-fill"
|
||||||
|
:style="{ width: `${(Object.values(fieldData).filter((f) => f.validated).length / Object.keys(fieldData).length) * 100}%` }"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
<span class="progress-text">
|
||||||
|
已完成 {{ Object.values(fieldData).filter((f) => f.validated).length }} /
|
||||||
|
{{ Object.keys(fieldData).length }} 个字段
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.experiment-form {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: 1.5rem auto;
|
||||||
|
padding: 1.5rem 2rem;
|
||||||
|
background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.08) 100%);
|
||||||
|
min-height: 100%;
|
||||||
|
border-radius: 28px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.25);
|
||||||
|
backdrop-filter: blur(20px);
|
||||||
|
box-sizing: border-box;
|
||||||
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.experiment-form::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 6px;
|
||||||
|
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-header {
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
text-align: center;
|
||||||
|
padding: 2rem 1.5rem;
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
border-radius: 20px;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||||
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-header::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 4px;
|
||||||
|
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-title {
|
||||||
|
font-size: 2.4rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #2c3e50;
|
||||||
|
margin-bottom: 1.25rem;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
-webkit-background-clip: text;
|
||||||
|
-webkit-text-fill-color: transparent;
|
||||||
|
background-clip: text;
|
||||||
|
letter-spacing: -0.5px;
|
||||||
|
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-description {
|
||||||
|
font-size: 1.15rem;
|
||||||
|
color: #5d6d7e;
|
||||||
|
line-height: 1.7;
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 0 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-containers {
|
||||||
|
margin-bottom: 3rem;
|
||||||
|
display: grid;
|
||||||
|
gap: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-status {
|
||||||
|
position: sticky;
|
||||||
|
bottom: 1.5rem;
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
padding: 1.5rem 2rem;
|
||||||
|
border-radius: 20px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 2rem;
|
||||||
|
backdrop-filter: blur(20px);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.25);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-status:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-indicator {
|
||||||
|
padding: 1rem 1.75rem;
|
||||||
|
border-radius: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
background: rgba(255, 255, 255, 0.25);
|
||||||
|
color: #2f3f5f;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.25);
|
||||||
|
backdrop-filter: blur(12px);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
min-width: 200px;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-indicator.all-valid {
|
||||||
|
background: linear-gradient(135deg, rgba(76, 217, 100, 0.15) 0%, rgba(76, 217, 100, 0.08) 100%);
|
||||||
|
color: #1f4d32;
|
||||||
|
border-color: rgba(76, 217, 100, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-icon {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.75rem;
|
||||||
|
width: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-bar {
|
||||||
|
height: 8px;
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
border-radius: 4px;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-fill {
|
||||||
|
height: 100%;
|
||||||
|
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: width 0.5s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-text {
|
||||||
|
font-size: 1rem;
|
||||||
|
color: #4b5874;
|
||||||
|
font-weight: 500;
|
||||||
|
padding: 0.75rem 1.25rem;
|
||||||
|
background: rgba(255, 255, 255, 0.25);
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.35);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 响应式设计 */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.experiment-form {
|
||||||
|
padding: 1rem;
|
||||||
|
border-radius: 20px;
|
||||||
|
margin: 1rem auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-header {
|
||||||
|
padding: 1.5rem 1rem;
|
||||||
|
margin-bottom: 1.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-title {
|
||||||
|
font-size: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-description {
|
||||||
|
font-size: 1rem;
|
||||||
|
padding: 0 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-containers {
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-status {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1.25rem;
|
||||||
|
padding: 1.25rem 1.5rem;
|
||||||
|
bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-indicator {
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.experiment-form {
|
||||||
|
padding: 0.75rem;
|
||||||
|
border-radius: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-header {
|
||||||
|
padding: 1.25rem 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-title {
|
||||||
|
font-size: 1.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-description {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-status {
|
||||||
|
padding: 1rem;
|
||||||
|
border-radius: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 暗色模式支持 */
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
.experiment-form {
|
||||||
|
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
||||||
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-header {
|
||||||
|
background: #0f3460;
|
||||||
|
border-color: rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-title {
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
-webkit-background-clip: text;
|
||||||
|
background-clip: text;
|
||||||
|
-webkit-text-fill-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-description {
|
||||||
|
color: #a0aec0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-status {
|
||||||
|
background: rgba(15, 52, 96, 0.95);
|
||||||
|
border-color: rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-bar {
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
border-color: rgba(255, 255, 255, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-text {
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
color: #a0aec0;
|
||||||
|
border-color: rgba(255, 255, 255, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-indicator {
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
border-color: rgba(255, 255, 255, 0.15);
|
||||||
|
color: #e2e8f0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
438
QuestionTable.vue
普通文件
438
QuestionTable.vue
普通文件
@ -0,0 +1,438 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { defineComponent, type PropType } from 'vue'
|
||||||
|
import { type QuestionType } from '@/types/question'
|
||||||
|
|
||||||
|
type answerStatus = 'right' | 'wrong' | 'part' | 'blank' | 'waiting'
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
props: {
|
||||||
|
question: {
|
||||||
|
type: Object as PropType<QuestionType>,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
doAnswer: {
|
||||||
|
type: Function as any,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
choice: '', // 单选
|
||||||
|
choices: [] as number[], // 多选
|
||||||
|
answers: [] as string[], // 填空
|
||||||
|
answer: '', // 简答
|
||||||
|
|
||||||
|
enabled: true, // 是否可编辑
|
||||||
|
corret: null as boolean | null, // 正确
|
||||||
|
|
||||||
|
optionStatus: [] as Array<'correct' | 'wrong' | ''>, // 每个选项的状态
|
||||||
|
fillStatuses: [] as Array<boolean>, // 每个填空的状态
|
||||||
|
essayStatus: { isCorrect: false, correctAnswer: '' }, // 简答题状态
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
calc(): [number, answerStatus] {
|
||||||
|
this.enabled = false
|
||||||
|
let score = 0
|
||||||
|
let fullScore = 0
|
||||||
|
let status: answerStatus = 'wrong'
|
||||||
|
|
||||||
|
switch (this.question.type) {
|
||||||
|
case '单选题': {
|
||||||
|
fullScore = 10
|
||||||
|
const correctAnswer = this.question.answer
|
||||||
|
const userChoice = this.choice
|
||||||
|
const isCorrect = userChoice !== '' && Number(userChoice) === correctAnswer
|
||||||
|
score = isCorrect ? fullScore : 0
|
||||||
|
this.corret = isCorrect
|
||||||
|
status = isCorrect ? 'right' : 'wrong'
|
||||||
|
// 设置每个选项的样式标记
|
||||||
|
const choicesLen = this.question.choices.length
|
||||||
|
const statuses = new Array(choicesLen).fill('') as Array<'correct' | 'wrong' | ''>
|
||||||
|
// 正确选项永远标绿
|
||||||
|
statuses[correctAnswer] = 'correct'
|
||||||
|
// 如果用户选错,把用户选的选项标红
|
||||||
|
if (!isCorrect && userChoice !== '') {
|
||||||
|
statuses[Number(userChoice)] = 'wrong'
|
||||||
|
}
|
||||||
|
this.optionStatus = statuses
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
case '多选题': {
|
||||||
|
fullScore = 12
|
||||||
|
const correctAnswers: number[] = this.question.answer
|
||||||
|
const userChoices: number[] = this.choices
|
||||||
|
const correctSet = new Set(correctAnswers)
|
||||||
|
const userSet = new Set(userChoices)
|
||||||
|
let hasWrong = false
|
||||||
|
for (const choice of userChoices) {
|
||||||
|
if (!correctSet.has(choice)) {
|
||||||
|
hasWrong = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasWrong) {
|
||||||
|
// 多选(选择了错误选项)得0分
|
||||||
|
score = 0
|
||||||
|
this.corret = false
|
||||||
|
status = 'wrong'
|
||||||
|
} else {
|
||||||
|
// 只有正确选项(可能少选)
|
||||||
|
const unitScore = fullScore / correctAnswers.length
|
||||||
|
let correctSelectedCount = 0
|
||||||
|
for (const ans of correctAnswers) {
|
||||||
|
if (userSet.has(ans)) correctSelectedCount++
|
||||||
|
}
|
||||||
|
score = correctSelectedCount * unitScore
|
||||||
|
score = Math.round(score * 100) / 100
|
||||||
|
this.corret = score === fullScore
|
||||||
|
status = this.corret ? 'right' : score == 0 ? 'wrong' : 'part'
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置每个选项的样式标记(正确选项标绿,错误选项标红)
|
||||||
|
const totalOptions = this.question.choices.length
|
||||||
|
const statuses = new Array(totalOptions).fill('') as Array<'correct' | 'wrong' | ''>
|
||||||
|
for (let i = 0; i < totalOptions; i++) {
|
||||||
|
if (correctSet.has(i)) {
|
||||||
|
statuses[i] = 'correct' // 正确答案永远标绿
|
||||||
|
} else if (userSet.has(i) && !correctSet.has(i)) {
|
||||||
|
statuses[i] = 'wrong' // 用户错误选择的选项标红
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.optionStatus = statuses
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
case '填空题': {
|
||||||
|
const standardAnswer = this.question.answer
|
||||||
|
const userAnswer = this.answers
|
||||||
|
let fullScore = standardAnswer.length * 5
|
||||||
|
for (const i in standardAnswer) {
|
||||||
|
let right = standardAnswer[i]?.trim() == userAnswer[i]?.trim()
|
||||||
|
this.fillStatuses[i] = right
|
||||||
|
score += right ? 5 : 0
|
||||||
|
}
|
||||||
|
status = fullScore == score ? 'right' : score == 0 ? 'wrong' : 'part'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
case '简答题': {
|
||||||
|
this.essayStatus = {
|
||||||
|
isCorrect: true,
|
||||||
|
correctAnswer: '(无参考答案)',
|
||||||
|
}
|
||||||
|
status = 'right'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [score, status]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="QuestionArea" @focusin="doAnswer">
|
||||||
|
<!-- 题目头部:包含题型标签 + 题目文本 -->
|
||||||
|
<div class="question-header">
|
||||||
|
<span class="question-type-tag">{{ question.type }}</span>
|
||||||
|
<span
|
||||||
|
class="question-text"
|
||||||
|
:class="{
|
||||||
|
'text-green-600': corret === true,
|
||||||
|
'text-red-600': corret === false
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{ question.question }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 单选题 -->
|
||||||
|
<div class="options-group" v-if="question.type === '单选题'">
|
||||||
|
<div
|
||||||
|
class="option-item"
|
||||||
|
v-for="(c, i) in question.choices"
|
||||||
|
:key="i"
|
||||||
|
>
|
||||||
|
<label class="option-label">
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
v-model="choice"
|
||||||
|
:value="i"
|
||||||
|
:disabled="!enabled"
|
||||||
|
class="option-radio"
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
class="option-content"
|
||||||
|
:class="{
|
||||||
|
'correct-option': optionStatus[i] === 'correct',
|
||||||
|
'wrong-option': optionStatus[i] === 'wrong',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{ c }}
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 多选题 -->
|
||||||
|
<div class="options-group" v-if="question.type === '多选题'">
|
||||||
|
<div
|
||||||
|
class="option-item"
|
||||||
|
v-for="(c, i) in question.choices"
|
||||||
|
:key="i"
|
||||||
|
>
|
||||||
|
<label class="option-label">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
v-model="choices"
|
||||||
|
:value="i"
|
||||||
|
:disabled="!enabled"
|
||||||
|
class="option-checkbox"
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
class="option-content"
|
||||||
|
:class="{
|
||||||
|
'correct-option': optionStatus[i] === 'correct',
|
||||||
|
'wrong-option': optionStatus[i] === 'wrong',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{ c }}
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 填空题 -->
|
||||||
|
<div class="fill-group" v-if="question.type === '填空题'">
|
||||||
|
<div class="fill-item" v-for="(c, i) in question.answer" :key="i">
|
||||||
|
<span class="fill-label">({{ i + 1 }})</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="answers[i]"
|
||||||
|
:disabled="!enabled"
|
||||||
|
class="fill-input"
|
||||||
|
:class="{
|
||||||
|
'correct-input': fillStatuses[i] == true,
|
||||||
|
'wrong-input': fillStatuses[i] == false,
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
<!-- 错误时显示正确答案(绿色) -->
|
||||||
|
<span v-if="fillStatuses[i] == false" class="correct-hint">
|
||||||
|
(正确答案:{{ question.answer[i] }})
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 简答题 -->
|
||||||
|
<div class="essay-group" v-if="question.type === '简答题'">
|
||||||
|
<textarea
|
||||||
|
v-model="answer"
|
||||||
|
:disabled="!enabled"
|
||||||
|
class="essay-textarea"
|
||||||
|
:class="{
|
||||||
|
'correct-input': essayStatus.isCorrect,
|
||||||
|
'wrong-input': !essayStatus.isCorrect && !enabled,
|
||||||
|
}"
|
||||||
|
placeholder="请输入你的答案..."
|
||||||
|
></textarea>
|
||||||
|
<!-- 错误时显示正确答案(绿色) -->
|
||||||
|
<div v-if="!essayStatus.isCorrect && !enabled" class="correct-hint essay-hint">
|
||||||
|
参考答案:{{ essayStatus.correctAnswer }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
/* 基础容器样式 */
|
||||||
|
.QuestionArea {
|
||||||
|
border: 1px solid #e5e7eb;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
background-color: #ffffff;
|
||||||
|
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.QuestionArea:hover {
|
||||||
|
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 题目头部样式 */
|
||||||
|
.question-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.question-type-tag {
|
||||||
|
background-color: #f3f4f6;
|
||||||
|
color: #4b5563;
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.question-text {
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 1.5;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-green-600 {
|
||||||
|
color: #16a34a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-red-600 {
|
||||||
|
color: #dc2626;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 选项组通用样式 */
|
||||||
|
.options-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.option-item {
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
padding: 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.option-item:hover {
|
||||||
|
background-color: #f9fafb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.option-label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.option-radio,
|
||||||
|
.option-checkbox {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
accent-color: #3b82f6;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.option-content {
|
||||||
|
font-size: 15px;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 选项状态样式 */
|
||||||
|
.correct-option {
|
||||||
|
color: #16a34a;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wrong-option {
|
||||||
|
color: #dc2626;
|
||||||
|
text-decoration: line-through;
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 填空题样式 */
|
||||||
|
.fill-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fill-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fill-label {
|
||||||
|
font-size: 15px;
|
||||||
|
color: #374151;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fill-input {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 200px;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 4px;
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
font-size: 15px;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fill-input:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #3b82f6;
|
||||||
|
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 填空题/简答题输入框状态 */
|
||||||
|
.correct-input {
|
||||||
|
border: 2px solid #16a34a !important;
|
||||||
|
background-color: #f0fdf4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wrong-input {
|
||||||
|
border: 2px solid #dc2626 !important;
|
||||||
|
background-color: #fef2f2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 正确答案提示 */
|
||||||
|
.correct-hint {
|
||||||
|
color: #16a34a;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 简答题样式 */
|
||||||
|
.essay-group {
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.essay-textarea {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 120px;
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 6px;
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: 15px;
|
||||||
|
line-height: 1.5;
|
||||||
|
resize: vertical;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.essay-textarea:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #3b82f6;
|
||||||
|
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.essay-hint {
|
||||||
|
margin-top: 8px;
|
||||||
|
padding: 8px 12px;
|
||||||
|
background-color: #f0fdf4;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 禁用状态样式 */
|
||||||
|
input:disabled,
|
||||||
|
textarea:disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
在新工单中引用
屏蔽一个用户