|
|
<!--ocr-import.wxml-->
|
|
|
<view class="container">
|
|
|
<!-- 页面标题 -->
|
|
|
<view class="page-header">
|
|
|
<text class="page-title">OCR课表导入</text>
|
|
|
</view>
|
|
|
|
|
|
<!-- 步骤指示器 -->
|
|
|
<view class="step-indicator">
|
|
|
<view class="step {{currentStep >= 1 ? 'active' : ''}}">
|
|
|
<view class="step-number">1</view>
|
|
|
<text class="step-text">选择图片</text>
|
|
|
</view>
|
|
|
<view class="step-line {{currentStep >= 2 ? 'active' : ''}}"></view>
|
|
|
<view class="step {{currentStep >= 2 ? 'active' : ''}}">
|
|
|
<view class="step-number">2</view>
|
|
|
<text class="step-text">识别课程</text>
|
|
|
</view>
|
|
|
<view class="step-line {{currentStep >= 3 ? 'active' : ''}}"></view>
|
|
|
<view class="step {{currentStep >= 3 ? 'active' : ''}}">
|
|
|
<view class="step-number">3</view>
|
|
|
<text class="step-text">导入课表</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
<!-- 内容区域 -->
|
|
|
<scroll-view class="content" scroll-y="true">
|
|
|
|
|
|
<!-- 步骤1: 选择图片 -->
|
|
|
<view wx:if="{{currentStep === 1}}" class="step-content">
|
|
|
<view class="upload-section">
|
|
|
<view class="upload-area" bindtap="onChooseImage">
|
|
|
<image wx:if="{{selectedImage}}"
|
|
|
class="preview-image"
|
|
|
src="{{selectedImage}}"
|
|
|
mode="aspectFit" />
|
|
|
<view wx:else class="upload-placeholder">
|
|
|
<image class="upload-icon" src="/images/camera-icon.png" mode="aspectFit" />
|
|
|
<text class="upload-text">点击选择课表图片</text>
|
|
|
<text class="upload-tip">支持拍照或从相册选择</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
<view wx:if="{{selectedImage}}" class="image-actions">
|
|
|
<button class="action-btn secondary" bindtap="onChooseImage">
|
|
|
<text class="btn-text">重新选择</text>
|
|
|
</button>
|
|
|
<button class="action-btn primary" bindtap="onStartOcr">
|
|
|
<text class="btn-text">开始识别</text>
|
|
|
</button>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
<!-- 步骤2: OCR识别中/结果 -->
|
|
|
<view wx:if="{{currentStep === 2}}" class="step-content">
|
|
|
<view wx:if="{{ocrLoading}}" class="loading-section">
|
|
|
<view class="loading-animation">
|
|
|
<view class="loading-dot"></view>
|
|
|
<view class="loading-dot"></view>
|
|
|
<view class="loading-dot"></view>
|
|
|
</view>
|
|
|
<text class="loading-text">正在识别课表信息...</text>
|
|
|
<text class="loading-tip">请稍候,这可能需要几秒钟</text>
|
|
|
</view>
|
|
|
|
|
|
<view wx:else class="ocr-result-section">
|
|
|
<view class="result-header">
|
|
|
<text class="result-title">识别结果</text>
|
|
|
<text class="result-count">共识别到 {{ocrResult.courses ? ocrResult.courses.length : 0}} 门课程</text>
|
|
|
</view>
|
|
|
|
|
|
<view wx:if="{{ocrResult.courses && ocrResult.courses.length > 0}}" class="course-list">
|
|
|
<view class="course-item"
|
|
|
wx:for="{{ocrResult.courses}}"
|
|
|
wx:key="index">
|
|
|
<view class="course-header">
|
|
|
<text class="course-name">{{item.courseName}}</text>
|
|
|
<view class="course-actions">
|
|
|
<button class="edit-btn"
|
|
|
bindtap="onEditCourse"
|
|
|
data-index="{{index}}"
|
|
|
size="mini">编辑</button>
|
|
|
<switch class="course-switch"
|
|
|
checked="{{item.selected}}"
|
|
|
bindchange="onCourseToggle"
|
|
|
data-index="{{index}}" />
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="course-details">
|
|
|
<text class="course-detail">{{item.classroom || '未识别到地点'}}</text>
|
|
|
<text class="course-detail">{{item.teacherName || '未识别到教师'}}</text>
|
|
|
<text class="course-detail">周{{weekNames[item.dayOfWeek - 1]}} {{item.startTime}}-{{item.endTime}}</text>
|
|
|
<text class="course-detail">第{{item.startWeek}}-{{item.endWeek}}周 {{item.weekType === 0 ? '每周' : (item.weekType === 1 ? '单周' : '双周')}}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
<view wx:else class="empty-result">
|
|
|
<image class="empty-icon" src="/images/empty-ocr.png" mode="aspectFit" />
|
|
|
<text class="empty-text">未识别到课程信息</text>
|
|
|
<text class="empty-tip">请尝试重新拍摄更清晰的课表图片</text>
|
|
|
</view>
|
|
|
|
|
|
<view class="result-actions">
|
|
|
<button class="action-btn secondary" bindtap="onBackToStep1">
|
|
|
<text class="btn-text">重新选择</text>
|
|
|
</button>
|
|
|
<button wx:if="{{hasSelectedCourses}}"
|
|
|
class="action-btn primary"
|
|
|
bindtap="onImportCourses">
|
|
|
<text class="btn-text">导入选中课程</text>
|
|
|
</button>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
<!-- 步骤3: 导入结果 -->
|
|
|
<view wx:if="{{currentStep === 3}}" class="step-content">
|
|
|
<view wx:if="{{importLoading}}" class="loading-section">
|
|
|
<view class="loading-animation">
|
|
|
<view class="loading-dot"></view>
|
|
|
<view class="loading-dot"></view>
|
|
|
<view class="loading-dot"></view>
|
|
|
</view>
|
|
|
<text class="loading-text">正在导入课程...</text>
|
|
|
</view>
|
|
|
|
|
|
<view wx:else class="import-result-section">
|
|
|
<view class="result-icon">
|
|
|
<image class="success-icon" src="/images/success-icon.png" mode="aspectFit" />
|
|
|
</view>
|
|
|
<text class="result-title">导入完成</text>
|
|
|
<view class="import-summary">
|
|
|
<text class="summary-text">成功导入 {{importResult.successCount}} 门课程</text>
|
|
|
<text wx:if="{{importResult.errorCount > 0}}" class="error-text">
|
|
|
{{importResult.errorCount}} 门课程导入失败
|
|
|
</text>
|
|
|
</view>
|
|
|
|
|
|
<!-- 显示错误详情 -->
|
|
|
<view wx:if="{{importResult.errorMessages && importResult.errorMessages.length > 0}}" class="error-details">
|
|
|
<text class="error-title">失败原因:</text>
|
|
|
<view class="error-list">
|
|
|
<text wx:for="{{importResult.errorMessages}}" wx:key="index" class="error-item">
|
|
|
{{item}}
|
|
|
</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
<view class="final-actions">
|
|
|
<button class="action-btn secondary" bindtap="onImportAgain">
|
|
|
<text class="btn-text">再次导入</text>
|
|
|
</button>
|
|
|
<button class="action-btn primary" bindtap="onViewSchedule">
|
|
|
<text class="btn-text">查看课表</text>
|
|
|
</button>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
</scroll-view>
|
|
|
|
|
|
<!-- 课程编辑弹窗 -->
|
|
|
<view wx:if="{{showEditModal}}" class="modal-overlay" bindtap="onCloseEditModal">
|
|
|
<view class="edit-modal" catchtap="stopPropagation">
|
|
|
<view class="modal-header">
|
|
|
<text class="modal-title">编辑课程信息</text>
|
|
|
<button class="close-btn" bindtap="onCloseEditModal">×</button>
|
|
|
</view>
|
|
|
|
|
|
<view class="modal-content">
|
|
|
<view class="form-group">
|
|
|
<text class="form-label">课程名称</text>
|
|
|
<input class="form-input"
|
|
|
value="{{editingCourse.courseName}}"
|
|
|
bindinput="onEditInput"
|
|
|
data-field="courseName"
|
|
|
placeholder="请输入课程名称" />
|
|
|
</view>
|
|
|
|
|
|
<view class="form-group">
|
|
|
<text class="form-label">任课教师</text>
|
|
|
<input class="form-input"
|
|
|
value="{{editingCourse.teacherName}}"
|
|
|
bindinput="onEditInput"
|
|
|
data-field="teacherName"
|
|
|
placeholder="请输入教师姓名" />
|
|
|
</view>
|
|
|
|
|
|
<view class="form-group">
|
|
|
<text class="form-label">上课地点</text>
|
|
|
<input class="form-input"
|
|
|
value="{{editingCourse.classroom}}"
|
|
|
bindinput="onEditInput"
|
|
|
data-field="classroom"
|
|
|
placeholder="请输入上课地点" />
|
|
|
</view>
|
|
|
|
|
|
<view class="form-group">
|
|
|
<text class="form-label">星期</text>
|
|
|
<picker range="{{weekNames}}"
|
|
|
value="{{editingCourse.dayOfWeek - 1}}"
|
|
|
bindchange="onDayChange">
|
|
|
<view class="picker-display">
|
|
|
周{{weekNames[editingCourse.dayOfWeek - 1]}}
|
|
|
</view>
|
|
|
</picker>
|
|
|
</view>
|
|
|
|
|
|
<view class="form-row">
|
|
|
<view class="form-group half">
|
|
|
<text class="form-label">开始时间</text>
|
|
|
<picker mode="time"
|
|
|
value="{{editingCourse.startTime}}"
|
|
|
bindchange="onStartTimeChange">
|
|
|
<view class="picker-display">{{editingCourse.startTime}}</view>
|
|
|
</picker>
|
|
|
</view>
|
|
|
|
|
|
<view class="form-group half">
|
|
|
<text class="form-label">结束时间</text>
|
|
|
<picker mode="time"
|
|
|
value="{{editingCourse.endTime}}"
|
|
|
bindchange="onEndTimeChange">
|
|
|
<view class="picker-display">{{editingCourse.endTime}}</view>
|
|
|
</picker>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
<view class="form-row">
|
|
|
<view class="form-group half">
|
|
|
<text class="form-label">开始周</text>
|
|
|
<input class="form-input"
|
|
|
type="number"
|
|
|
value="{{editingCourse.startWeek}}"
|
|
|
bindinput="onEditInput"
|
|
|
data-field="startWeek"
|
|
|
placeholder="1" />
|
|
|
</view>
|
|
|
|
|
|
<view class="form-group half">
|
|
|
<text class="form-label">结束周</text>
|
|
|
<input class="form-input"
|
|
|
type="number"
|
|
|
value="{{editingCourse.endWeek}}"
|
|
|
bindinput="onEditInput"
|
|
|
data-field="endWeek"
|
|
|
placeholder="16" />
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
<view class="form-group">
|
|
|
<text class="form-label">周次类型</text>
|
|
|
<picker range="{{weekTypeOptions}}"
|
|
|
value="{{editingCourse.weekType}}"
|
|
|
bindchange="onWeekTypeChange">
|
|
|
<view class="picker-display">
|
|
|
{{weekTypeOptions[editingCourse.weekType]}}
|
|
|
</view>
|
|
|
</picker>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
<view class="modal-actions">
|
|
|
<button class="action-btn secondary" bindtap="onCloseEditModal">取消</button>
|
|
|
<button class="action-btn primary" bindtap="onSaveEdit">保存</button>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|