<template>
	<uni-row>
		<uni-col :span="5" style="margin-top: 1vh">
			<uni-card style="height: 92vh;">
				<l-divider color="#00a60d">
					<view style="font-size: 2vh;">题库名称</view>
				</l-divider>
				<view
					style="font-family: '微软雅黑' , serif;font-size: 2vh;color: #8c8c8c;height: 30px;text-align: center;padding:5px;">
					{{title}}
				</view>
				<l-divider color="#00a60d">
					<view style="font-size: 2vh;">题型</view>
				</l-divider>
				<radio-group>
					<label v-for="(item, index) in repositoryType" :key="item">
						<view>
							<view v-if=" item.type!==6" class="paperCss"
								:style="'border: #757575 solid 1px;background-color: '+(item.type === subjectType?'#b5aa09 ;':'#f9f9f9 ;')"
								@click="subjectTypeClick(item)">
								<view style="color: #000000; ">
									<uni-row>
										<uni-col :span="12">
											<strong style="font-size: 2vh;">{{subjectTypes[item.type-1]}}</strong>
										</uni-col>
										<uni-col :span="12">
											<view style="font-size: 2vh;">数量：{{item.num}}</view>
										</uni-col>
									</uni-row>
								</view>
							</view>
						</view>
					</label>
				</radio-group>
				<l-divider color="#b3b3b3">
				</l-divider>
				<button type="primary" style="margin-top: 2%;width: 92%;" @click="backPage"><view style="font-size: 2vh;">返回</view></button>
			</uni-card>
		</uni-col>
		<uni-col :span="15" style="margin-top: 1vh">
			<uni-card style="height: 92vh;">
				<scroll-view scroll-y="true" scroll-x="true" class="scroll-Y">
					<uni-section :title="subjectTypes[subjectType-1]+'、'+(subjectNum+(pageNo-1)*pageSize)" type="line"
						padding>
						<view id="scantronNodes">
						</view>
						<template v-if="scantron.type===1||scantron.type===3">
							<view>
								<l-divider color="#aaaa7f">
								</l-divider>
							</view>
							<view>
								<radio-group>
									<label v-for="(item, index) in scantron.answerList" :key="item">
										<view>
											<button @click="radioAdd(item,index,scantron)"
												:style="'margin-top: 1%;padding-left:15px;font-size: 20px;text-align: left;background-color: '+(item.right?'#f9ea0d;':'#f0eff0')"><strong
													style="color: #0072eb;">{{item.tag+"、"}}</strong>{{item.content}}</button>
										</view>
									</label>
								</radio-group>
							</view>
						</template>
						<template v-if="scantron.type===2">
							<view>
								<l-divider color="#aaaa7f">
								</l-divider>
							</view>
							<view>
								<radio-group>
									<label v-for="(item, index) in scantron.answerList" :key="item.value">
										<view>
											<button @click="item.right=!item.right;radioAdd(item,index,scantron);"
												:style="'margin-top: 15px;padding-left:15px;font-size: 20px;text-align: left;background-color: '+(item.right?'#f9ea0d;':'#f0eff0')"><strong
													style="color: #0072eb;">{{item.tag+"、"}}</strong>{{item.content}}</button>
										</view>
									</label>
								</radio-group>
							</view>
						</template>
						<template v-if="scantron.type===4">
							<view>
								<l-divider color="#aaaa7f">
								</l-divider>
							</view>
							<view>
								<view>
									<view class="uni-textarea"
										style="border: #8c8c8c solid 2px;border-radius: 5px;height: 20vh;">
										<textarea @blur="radioAdd(null,null,scantron)"
											v-model="scantron.subjectiveAnswer" placeholder-style="color:#c7c7c7"
											placeholder="请输入答案" />
									</view>
								</view>
							</view>
						</template>
						<template v-if="scantron.type===5">
							<view>
								<l-divider color="#aaaa7f">
								</l-divider>
							</view>
							<view>
								<label v-for="(item, index) in scantron.answerList" :key="item.value">
									<view class="allceter"
										style="background-color: #e7f4ff; text-align: left;padding: 10px;margin-bottom: 10px;border: #2a7eeb solid 1px;border-radius: 5px;">
										<view style="display: inline-block;padding-left: 10px;">
											<strong style="font-size: 20px;color: #0072eb;">{{item.tag}}</strong>
										</view>
										<input @blur="radioAdd(item.blankcontent,item.tag,scantron)" class="uni-input"
											style="display: inline-block;background-color: white;" type="text"
											v-model="item.blankcontent" :placeholder="item.tag" />
									</view>
								</label>
							</view>
						</template>
						<template v-if="scantron.type===6">
							<view>
								<l-divider color="#aaaa7f">
								</l-divider>
							</view>
							<view class="" v-for="(combinationItem,index) in scantron.subQuestionList">
								<uni-card>
									<strong>{{subjectNum+'.'+combinationItem.questionIndex+'、'+combinationItem.typeName}}</strong>
									<view :id="'combinationItemNodes'+index" style="height: 45vh;">
										<!-- <rich-text :nodes="combinationItem.content"></rich-text> -->
									</view>
									<template v-if="combinationItem.type===1||combinationItem.type===3">

										<view>
											<l-divider color="#aaaa7f">
											</l-divider>
										</view>
										<view>
											<radio-group>
												<label v-for="(item, index0) in combinationItem.answerList" :key="item">
													<view>
														<button @click="radioAdd(item,index0,scantron,combinationItem)"
															:style="'margin-top: 15px;padding-left:15px;font-size: 20px;text-align: left;background-color: '+(item.right?'#f9ea0d;':'#f0eff0')"><strong
																style="color: #0072eb;">{{item.tag+"、"}}</strong>{{item.content}}</button>
													</view>
												</label>
											</radio-group>
										</view>
									</template>
									<template v-if="combinationItem.type===2">
										<view>
											<l-divider color="#aaaa7f">
											</l-divider>
										</view>
										<view>
											<radio-group>
												<label v-for="(item, index) in combinationItem.answerList"
													:key="item.value">
													<view>
														<button
															@click="item.right=!item.right;radioAdd(item,index0,scantron,combinationItem);"
															:style="'margin-top: 15px;padding-left:15px;font-size: 20px;text-align: left;background-color: '+(item.right?'#f9ea0d;':'#f0eff0')"><strong
																style="color: #0072eb;">{{item.tag+"、"}}</strong>{{item.content}}</button>
													</view>
												</label>
											</radio-group>
										</view>
									</template>

									<template v-if="combinationItem.type===4">

										<view>
											<l-divider color="#aaaa7f">
											</l-divider>
										</view>
										<view>
											<view>
												<view class="uni-textarea"
													style="border: #8c8c8c solid 2px;border-radius: 5px;height: 20vh;">
													<textarea v-model="combinationItem.subjectiveAnswer"
														placeholder-style="color:#c7c7c7" placeholder="请输入答案" />
												</view>
											</view>
										</view>
									</template>
									<template v-if="combinationItem.type===5">

										<view>
											<l-divider color="#aaaa7f">
											</l-divider>
										</view>
										<view>
											<label v-for="(item, index) in combinationItem.answerList"
												:key="item.value">
												<view class="allceter"
													style="background-color: #e7f4ff; text-align: left;padding: 10px;margin-bottom: 10px;border: #2a7eeb solid 1px;border-radius: 5px;">
													<view style="display: inline-block;padding-left: 10px;">
														<strong
															style="font-size: 20px;color: #0072eb;">{{item.tag}}</strong>
													</view>
													<input
														@blur="radioAdd(item.blankcontent,item.tag,scantron,combinationItem)"
														class="uni-input"
														style="display: inline-block;background-color: white;"
														type="text" v-model="item.blankcontent"
														:placeholder="item.tag" />
												</view>
											</label>
										</view>
									</template>
									<template v-if="combinationItem.type===7">
										<view style="height: 5vh;">
											<rich-text :nodes="combinationItem.content"></rich-text>
										</view>
										<view>
											<l-divider color="#aaaa7f">
											</l-divider>
										</view>
										<view style=" height: 500px;width: 700px;background-color: #ff3807;">

											<movable-area style="height: 500px;width: 700px;background-color: #8c8c8c;">

												<movable-view style="width: 50px;height: 50px;border:solid 1px black;"
													:x="x" :y="y">

												</movable-view>



												<movable-view
													style="width: 40px;height: 40px;background-color: #f90005;"
													direction="all" :x="x" :y="y" @change="onChange">

													text
												</movable-view>

											</movable-area>

										</view>

									</template>
									<template v-if="combinationItem.type===8">
										<view style="height: 5vh;">
											<rich-text :nodes="combinationItem.content"></rich-text>
										</view>
										<view>
											<l-divider color="#aaaa7f">
											</l-divider>
										</view>

										<view>
											<view style="height: 600px;width: 800;background-color: #8c8c8c;">

												<movable-area
													style="height: 100%;width: 100%;background-color: #8c8c8c;">

													<movable-view
														style="width: 50px;height: 50px;border:solid 1px black;" :x="95"
														:y="95">

													</movable-view>

													<movable-view
														style="width: 40px;height: 40px;background-color: #f90005;"
														direction="all" :x="x" :y="y" @change="onChange">

														text
													</movable-view>

												</movable-area>

											</view>

										</view>

									</template>


								</uni-card>
							</view>

						</template>
						<template v-if="scantron.type===7">
							<button @click="restart">重置</button>
							<view>
								<l-divider color="#aaaa7f">
								</l-divider>
							</view>
							<view style="height: 600px;width: 800;background-color: #ffffff;">
								<movable-area
									:style="`height: 500px;width: 700px;background-color: #8c8c8c;margin: auto;background-image: url('${drag[subjectNum].background.url}');background-size:${drag[subjectNum].background.width}px ${drag[subjectNum].background.height}px;background-repeat: no-repeat;`">
									<!-- <rich-text :nodes="scantron.content"></rich-text> -->
									<!-- <img v-if="drag.background.url!==''"  :style="`width:${drag.background.width} px;height:${drag.background.height} px;`"  :src="drag.background.url"/> -->
									<template v-for="item in drag[subjectNum].answer">
										<view
											:style="`position: absolute;width: ${item.width}px;height: ${item.height}px;border:solid 1px black;left:${item.x}px;top:${item.y}px;`">
											{{Number(item.id.replace('answer',''))+1}}
										</view>
									</template>
									<template v-for="item in drag[subjectNum].option">
										<movable-view v-if="mbvShow" :id="item.id" :disabled="!disabledDrag"
											:style="'width: '+item.width+'px;height: '+item.height+'px;background-color: '+item.backgroundColor+';'"
											direction="all" :x="item.x" :y="item.y" @mousedown="onMousedown(item)"
											@change="onChange">
										</movable-view>
										<movable-view v-if="!mbvShow" :id="item.id" :disabled="!disabledDrag"
											:style="'width: '+item.width+'px;height: '+item.height+'px;background-color: '+item.backgroundColor+';'"
											direction="all" :x="item.x" :y="item.y" @mousedown="onMousedown(item)"
											@change="onChange">
										</movable-view>
									</template>
								</movable-area>
							</view>
						</template>
						<template v-if="scantron.type===8">
							<view style="height: 5vh;">
							</view>
							<view>
								<l-divider color="#aaaa7f">
								</l-divider>
							</view>
							<view>
								<view
									style="height: 600px;width: 800px;background-color: #8c8c8c;margin: auto;padding-top: 50px;">
									<movable-area
										style="height: 550px;width: 700px;background-color: #f6f6f6;margin: auto;">
										<canvas canvas-id="lineCanvas" style="width: 700px; height: 500px;">
											<template v-for="(item,index)  in connectionHtml">
												<view
													style="display: inline-block;margin-top: 30px;margin-left: 30px;margin-right: 70px;">
													<!-- <rich-text :nodes="item.innerHTML"></rich-text> -->
													<view v-for="(item0,index0) in item.children" :key="index">
														<view :id="'option'+index+'-'+(index0+1)"
															style="width: 90px;height: 100px;padding: 10px;padding-bottom:0 ;margin-bottom: 10px;border-radius: 5px;border: #007aff solid 1px;background-color: #e0eef9;overflow: hidden;">
														</view>
													</view>
												</view>
											</template>
										</canvas>
									</movable-area>
								</view>
							</view>
						</template>
					</uni-section>
					<view v-if="examObject.records[subjectNum-1].disable"
						style="position: absolute;top: 0;background-color:rgb(255, 255, 255,0) ;width: 100%;height: 140%;">
					</view>
				</scroll-view>
				<view style="height: 8vh;">
					<button :disabled="!disabledDrag" v-if="scantron.type!==1&&scantron.type!==3" type="primary"
						style="width: 10vh;display: inline-block;margin-right: 1%;" @click="answerConfirm"><view style="font-size: 2vh;">答案确认</view>
					</button>
					<button type="primary" style="width: 10vh;display: inline-block;"
						@click="answerInspect(3)"> <view style="font-size: 2vh;">答案解析</view>
					</button>
				</view>
				<scroll-view scroll-y="true" style="height: 22vh;border: #a7a7a7 solid 1px;border-radius: 10px;">
					<view style="padding: 1%;">
						<view style="height:20px;">
							<view v-if="answerAnalysis.youAnswerState===0" style="font-size: 20px;color: #00ff00;">
								<strong>恭喜你，做对了！</strong>
							</view>
							<view v-if="answerAnalysis.youAnswerState===1" style="font-size: 20px;color: #c10003;">
								<strong>很遗憾，做错了！</strong>
							</view>
						</view>
						<view style="font-family:  '黑体';font-size: 20px;padding-top: 10px;">
							<strong>答案：</strong>
						</view>
						<view style="font-family:  '楷体';font-size: 20px;padding-top: 10px;">
							{{"　　"+answerAnalysis.answer}}
						</view>
						<view style="font-family:  '黑体';font-size: 20px;padding-top: 10px;">
							<strong>解析：</strong>
						</view>
						<view v-if="answerAnalysis.analysis!==null"
							style="font-family:  '楷体';font-size: 20px;padding-top: 10px;">
							{{"　　"+answerAnalysis.analysis}}
						</view>
					</view>
				</scroll-view>
				<view style="height: 5vh;">
					<button type="primary" style="margin-top: 10px;width: 48%;display: inline-block;font-size: 100%;"
						@click="previousQuestion">上一题</button>
					<button type="primary" style="margin-left: 1%;margin-top: 10px;width: 48%;display: inline-block;font-size:100%;"
						@click="nextQuestion">下一题</button>
				</view>
			</uni-card>
		</uni-col>
		<uni-col :span="4" style="margin-top: 1vh">
			<uni-card style="height: 92vh;">

				<l-divider color="#8f960c" style="margin-top: 5%;">
					<view style="font-size: 2vh;">当前题型数量</view>
				</l-divider>
				<view
					style="font-family: '微软雅黑', serif;font-size: 1%;color: #000000;height: 30px;text-align: center;padding:1vh;font-size: 3vh;">
					<strong>共{{this.repository.num}}题</strong>
				</view>
				<l-divider color="#251e75">
					<view style="font-size: 2vh;">答题卡</view>
				</l-divider>
				<view>
					<scroll-view scroll-y="true" style="height: 50vh;">
						<label v-for="(item, index) in  examObject.records" :key="item">
							<view style="display: inline-block;margin-left: 5px;" @mousedown="radioScantron(index+1)">
								<view>
									<button type="radio"
										:style="'width: 30px;height: 30px;padding:0px;color:#FFFFFF;font-size: 12px;text-align: center;background-color: '+(index+1 === subjectNum?'#b5aa09;':(this.examObject.records[index].isAnswer?'#18da59':'#007aff'))">{{index+1+(pageNo-1)*pageSize}}</button>
								</view>
								<view>
									{{item.level_dictText}}
								</view>
							</view>
						</label>
					</scroll-view>
				</view>
				<view >
					<view style="text-align: left;;align-items: center;font-size: 15px;width: 200px;display: flex;"> 
					当前<input
							style="display: inline-block;width: 40px;border: #c1c1c1 solid 1px;border-radius: 3px;font-size: 2vh;padding-top: 3px;"
							v-model="writePageNo" type="number" min='1' max="100" @input='inspect'
							@blur=" pageReplace(writePageNo,pageSize,0)" />页
					</view>
					<view  style="text-align: left;align-items: center;font-size: 15px;width: 200px;display: flex;">
						每页
						<input
							style="display: inline-block;width: 40px;border: #c1c1c1 solid 1px;border-radius: 3px;font-size: 2vh;padding-top: 3px;"
							v-model="pageSize" type="number" @blur="writePageNo=1;pageReplace(1,pageSize,0)" />条
					</view>


				</view>
				<l-divider color="#251e75" />
				<view style="height: 12vh;">
					<button type="primary" style="margin-top: 1%;height:  5vh;" @click="previousPage" ><view style="font-size: 2vh;">上一页</view></button>
					<button type="primary" style="margin-top: 5%;height:  5vh;" @click="nextPage"><view style="font-size: 2vh;">下一页</view></button>
				</view>
			</uni-card>
		</uni-col>
	</uni-row>
	<uni-popup ref="message" type="message">
		<uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
	</uni-popup>
	<uni-popup ref="inputDialog" type="dialog">
		<uni-popup-dialog ref="inputClose" title="提交试卷" @confirm="dialogInputConfirm">
			<view>
				<view>1、提交当前试卷后不可再次作答</view>
				<view>2、本试卷剩余时间不计入下一套</view>
				<view>3、最终试卷提交将结束考试</view>
				<view style="text-align: center;">确认提交？</view>
			</view>
		</uni-popup-dialog>
	</uni-popup>
	<uni-popup ref="cheat" type="dialog">
		<uni-popup-dialog style="width: 50vh;" ref="inputClose" title="作弊提醒">
			<view style="color: red;">
				<view>1、鼠标请勿点击窗口之外的地方</view>
				<view>2、如果不小心退出全屏，请按F11恢复到全屏</view>
				<view>3、鼠标多次点击窗口之外的地方将按作弊处理</view>
			</view>
		</uni-popup-dialog>
	</uni-popup>
</template>

<script>
	import {
		exit,
		request,
		getExamDetail,
		getCacheAnswer,
		submitExamPaper,
		getExamQueryById,
		getRepositoryById,
		getListQuestionByMode
	} from '../../examJs/examRequest';
	import screenfull from "screenfull";
	import {
		redirectTo,
		toExamInfo,
		toLogin
	} from '../../examJs/examRoute';
	export default {
		name: "examStart",
		data() {
			return {
				// 所有方块============拖拽
				drag: [],
				// 拖拽元素刷新
				mbvShow: true,
				// 拖拽的方块信息
				dragItem: {},
				// 拖拽位置记录
				subDrag: [],
				// 拖拽后动作未完成禁用
				disabledDrag: true,
				// ==================================
				// 连线===============================
				// 连线题内容页面展示
				connectionHtml: [],
				// 连线题中间存储
				connectionInfo: [],
				// 连线题连线内容保存
				connectionContentALL: [],
				// 连线绘制
				ctx: null,
				// 点击过程颜色
				clickColor: '0px 0px 5px 2px rgba(80, 85, 83, 0.7)',
				// 点击结束颜色
				connectionColor: ['#ffaa00', '#00ff7f', '#6ca7ff', '#1d00ff', '#aa00ff', '#ffff00', '#550000', '#ff0000'],
				// ==============================
				// 所有试卷和试题
				examObject: {},
				// ==========================================
				// 当前题库所有类型
				repositoryType: [],
				repository: '',
				subjectTypes: ['单选题', '多选题', '判断题', '简答题', '填空题', '组合题', '拖拽题', '连线题'],
				subjectType: 1,
				subjectNum: 1,
				pageNo: 1,
				pageSize: 5,
				writePageNo: 1,
				writePageSize: 5,
				title: '',
				answerAnalysis: {
					analysis: '这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析这是一道题的解析',
					answer: 'ABCD',
					youAnswerState: 0
				},
				// ===========================================
				// 当前题目
				examTopic: {},
				// 答题卡
				scantron: '',
				//选项
				answer: {},
				typeThree: '',
				userExamAnswers: [],
				user: {},
				// 拖动监听测试
				b: true,
				count: 0,
				canvasWidth: 300,
				canvasHeight: 300,
				// 用户当前考试
				userExamPaper: {},
				// 消息弹窗记录=================
				msgType: 'success',
				messageText: '这是一条成功提示',
			};
		},
		methods: {
			// 消息提示
			messageToggle(type, message) {
				this.msgType = type
				this.messageText = message
				this.$refs.message.open()
			},
			// 输入检查
			inspect() {
				this.pageNo = Number(this.pageNo)
				if (this.pageNo < 1) {
					this.pageNo = 1
				}
			},
			// 重置
			restart() {
				this.disabledDrag = true
				this.drag[this.subjectNum].answer = []
				this.drag[this.subjectNum].option = []
				let content = this.stringToHTML(this.scantron.content)
				console.log(content);
				for (var i = 0; i < content.children.length; i++) {
					let thisTop = content.children[i].style.top.toString().replace("px", "")
					let thisLeft = content.children[i].style.left.toString().replace("px", "")
					let thisWidth = content.children[i].style.width.toString().replace("px", "")
					let thisHeight = content.children[i].style.height.toString().replace("px", "")
					let thisBackgroundColor = content.children[i].style.backgroundColor
					let thisInnerHTML = content.children[i].innerHTML
					if (content.children[i].id.includes("option")) {
						this.drag[this.subjectNum].option.push({
							id: content.children[i].id,
							x: Number(thisLeft),
							y: Number(thisTop),
							old: {
								x: 0,
								y: 0,
								ax: Number(thisLeft),
								by: Number(thisTop)
							},
							// 只添加一次拖拽监听
							b: true,
							width: thisWidth,
							height: thisHeight,
							backgroundColor: thisBackgroundColor,
							innerHTML: thisInnerHTML
						})
					}
					if (content.children[i].id.includes("answer")) {
						this.drag[this.subjectNum].answer.push({
							id: content.children[i].id,
							x: Number(thisLeft),
							y: Number(thisTop),
							old: {
								x: 0,
								y: 0
							},
							width: thisWidth,
							height: thisHeight,
							backgroundColor: thisBackgroundColor
						})
					}
				}
			},
			// 上一题目
			previousQuestion() {
				if (this.subjectNum > 1) {
					this.radioScantron(--this.subjectNum)
				}
			},
			// 下一题目
			nextQuestion() {
				if (this.subjectNum < this.examObject.records.length) {
					// this.scantron = this.examObject.records[this.subjectNum]
					this.radioScantron(++this.subjectNum)
				}
			}, // 上一题目
			// 下一页
			previousPage() {
				if (this.pageNo > 1) {
					this.pageReplace(this.pageNo, this.pageSize, -1)
				} else {
					this.messageToggle('warn', "当前在第一页")
				}
			},
			// 下一页
			nextPage() {
				this.pageReplace(this.pageNo, this.pageSize, 1)
			},

			pageReplace(thisPageNo, thisPageSize, num) {
				this.drag = []
				thisPageNo = Number(thisPageNo) + Number(num)
				thisPageSize = Number(thisPageSize)
				num =
					getListQuestionByMode({
						mode: 3,
						pageNo: thisPageNo,
						pageSize: thisPageSize,
						questionType: this.subjectType,
						repositoryId: sessionStorage.getItem('repositoryId')
					}).then(data => {
						if (0 === data.data.result.records.length) {
							this.messageToggle('warn', "新页没有数据")
							return
						}
						this.pageNo = thisPageNo
						this.writePageNo = thisPageNo
						console.log(data);
						this.examObject = data.data.result
						this.scantron = this.examObject.records[0]
						this.radioScantron(1)
					})
			},
			// 答题卡单击题目
			radioScantron(value) {
				this.analysisBlank()
				document.getElementById('scantronNodes').innerHTML = ''
				this.subjectNum = value
				this.scantron = this.examObject.records[value - 1]
				console.log(this.scantron);
				if (this.scantron.type !== 7 && this.scantron.type !== 8) {
					document.getElementById('scantronNodes').innerHTML = this.scantron.content
				} else {
					console.log(this.scantron.content.split('%||||||||%')[0]);
					document.getElementById('scantronNodes').innerHTML = this.scantron.content.split('%||||||||%')[0]
				}

				let combination = setInterval(() => {
					if (this.scantron.type === 6) {
						for (var i = 0; i < this.scantron.subQuestionList.length; i++) {
							if (document.getElementById('combinationItemNodes' + i) === null) {
								console.log("加载中");
								break;
							}
							document.getElementById('combinationItemNodes' + i).innerHTML = this.scantron
								.subQuestionList[i].content
						}
						clearInterval(combination);
					}
				}, 10)


				// 拖拽加载
				if (this.scantron.type == 7) {
					this.mbvShow = !this.mbvShow
					this.disabledDrag = true
					console.log(this.drag[this.subjectNum]);
					if (this.drag[this.subjectNum] !== undefined) {
						setTimeout(() => {
							for (var i = 0; i < this.drag[this.subjectNum].option.length; i++) {
								let drags = this.drag[this.subjectNum].option[i]
								console.log(document.getElementById(drags.id));
								console.log(drags);
								document.getElementById(drags.id).innerHTML = drags.innerHTML
							}
						}, 10)
						return
					}
					this.drag[this.subjectNum] = {}
					this.drag[this.subjectNum].answer = []
					this.drag[this.subjectNum].option = []
					this.drag[this.subjectNum].background = {}
					let content = this.stringToHTML(this.scantron.content)

					for (var i = 0; i < content.children.length; i++) {
						console.log(content.children[i]);
						let thisTop = content.children[i].style.top.toString().replace("px", "")
						let thisLeft = content.children[i].style.left.toString().replace("px", "")
						let thisWidth = content.children[i].style.width.toString().replace("px", "")
						let thisHeight = content.children[i].style.height.toString().replace("px", "")
						let thisBackgroundColor = content.children[i].style.backgroundColor
						let thisInnerHTML = content.children[i].innerHTML
						if (content.children[i].id.includes("option")) {
							this.drag[this.subjectNum].option.push({
								id: content.children[i].id,
								x: Number(thisLeft),
								y: Number(thisTop),
								old: {
									x: 0,
									y: 0,
									ax: Number(thisLeft),
									by: Number(thisTop)
								},
								// 只添加一次拖拽监听
								b: true,
								width: thisWidth,
								height: thisHeight,
								backgroundColor: thisBackgroundColor,
								innerHTML: thisInnerHTML
							})
						}
						if (content.children[i].id.includes("answer")) {
							this.drag[this.subjectNum].answer.push({
								id: content.children[i].id,
								x: Number(thisLeft),
								y: Number(thisTop),
								old: {
									x: 0,
									y: 0
								},
								width: thisWidth,
								height: thisHeight,
								backgroundColor: thisBackgroundColor
							})
						}
						if (content.children[i].tagName === 'IMG') {
							this.drag[this.subjectNum].background.url = content.children[i].src
							this.drag[this.subjectNum].background.width = content.children[i].style.width.toString()
								.replace("px", "")
							this.drag[this.subjectNum].background.height = content.children[i].style.height.toString()
								.replace("px", "")
						}
					}
					console.log(this.drag[this.subjectNum].option.length);
					setTimeout(() => {
						for (var i = 0; i < this.drag[this.subjectNum].option.length; i++) {
							let drags = this.drag[this.subjectNum].option[i]
							console.log(document.getElementById(drags.id));
							document.getElementById(drags.id).innerHTML = drags.innerHTML
						}
					}, 10)
				}
				// 连线题添加监听
				if (this.scantron.type == 8) {
					this.connectionHtml = []
					let content = this.stringToHTML(this.scantron.content)
					for (var i = 0; i < content.children.length; i++) {
						let child = content.children[i]
						for (var j = 0; j < child.children.length; j++) {
							if (child.children[j].id !== undefined && child.children[j].id.includes("option")) {
								this.connectionHtml.push(child.children[j])
							}
						}
					}

					if (this.connectionContentALL[value] === undefined) {
						this.connectionContentALL[value] = []
					}
					this.connectionInfo = []
					setTimeout(() => {
						// 画内容
						this.drawLineWriteContent()
						// 画缓存线
						this.drawLineWrite(value)
					}, 100)
					for (var i = 0; i < this.connectionHtml.length; i++) {
						let option = this.connectionHtml[i]
						for (var j = 0; j < option.children.length; j++) {
							let ids = "option" + i + "-" + (j + 1)
							if (document.getElementById(ids) === null) {
								setTimeout(() => {
									let optionCol = document.getElementById(ids)
									optionCol.addEventListener("mousedown", (event) => {
										console.log(event);

										let id = event.currentTarget.id
										console.log(id);
										let colId = Number(id.replace('option', '').split('-')[0])
										let rowId = Number(id.replace('option', '').split('-')[1])
										let left = event.target.offsetLeft
										let right = Number(event.target.offsetLeft + event.target
											.offsetWidth)
										let top = Number(event.target.offsetTop + event.target
											.offsetHeight / 2)
										if (this.connectionInfo.length === this.connectionHtml.length &&
											colId === 0) {
											this.connectionContentALL[this.subjectNum].push(this
												.connectionInfo)
											this.radioAdd(this.connectionInfo, this
												.connectionInfo[0].id.replace('option', '').split('-')[
													1], this.scantron)
											this.connectionInfo = []

										}
										let arr = []
										for (var i = 0; i < this.connectionContentALL[this.subjectNum]
											.length; i++) {
											let all = this.connectionContentALL[this.subjectNum][i]
											if (all[0].id !== id) {
												arr.push(this.connectionContentALL[this.subjectNum][i])
											}
										}
										this.connectionContentALL[this.subjectNum] = arr
										let infoLength = this.connectionInfo.length
										if (infoLength <= this.connectionHtml.length) {
											if (infoLength !== 0) {
												if (!this.isLine(id, this.subjectNum)) {
													this.messageToggle('error', "这个已经连过了")
													this.drawLineWrite(this.subjectNum)
													return
												}
												let last = this.connectionInfo[infoLength -
													1]
												let lastId = Number(last.id.replace('option', '').split(
													'-')[0])
												if (lastId + 1 === colId) {
													this.connectionInfo.push({
														'id': id,
														'left': left,
														'right': right,
														'top': top
													})
												}
												if (lastId === colId && colId !== this.connectionHtml
													.length - 1) {
													this.connectionInfo[infoLength - 1] = {
														'id': id,
														'left': left,
														'right': right,
														'top': top
													}
													document.getElementById(ids).style.boxShadow = this
														.clickColor
													if (Number(last.id.replace('option', '').split(
															'-')[1]) === rowId &&
														this.connectionInfo.length === this.connectionHtml
														.length) {
														this.connectionContentALL[this.subjectNum].push(
															this.connectionInfo)
														console.log(this.connectionContentALL[this.scantron
															.sort]);
														this.radioAdd(this.connectionInfo, this
															.connectionInfo[0].id.replace('option', '')
															.split('-')[1], this.scantron)
														this.connectionInfo = []
													}
												} else if (colId === this.connectionHtml.length - 1) {

													this.connectionContentALL[this.subjectNum].push(
														this.connectionInfo)
													console.log(this.connectionContentALL[this.scantron
														.sort]);
													this.radioAdd(this.connectionInfo, this
														.connectionInfo[0].id.replace('option', '')
														.split('-')[1], this.scantron)
													this.connectionInfo = []
												}


											} else if (infoLength === 0) {
												if (colId === 0) {
													this.connectionInfo.push({
														'id': id,
														'left': left,
														'right': right,
														'top': top
													})
													console.log(document.getElementById(id + ''));
													document.getElementById(id + '').style.boxShadow = this
														.clickColor
													console.log(document.getElementById(id));
												}

											}
										}
										this.shadowClean()
										this.drawLineWrite(this.subjectNum)


									})
								}, 10)
							} else {
								setTimeout(() => {
									this.shadowClean()
								}, 10)
							}

						}
					}

				}
			},
			// 连线绘制
			drawLine(x1, y1, x2, y2, index) {
				this.ctx = uni.createCanvasContext('lineCanvas');
				this.ctx.beginPath();
				let color = this.connectionColor[index]
				if (index === -1) {
					color = '#000000'
					this.ctx.shadowColor = 'red';
					// 设置阴影的模糊级别
					this.ctx.setshadowBlur = 100;
					// 设置阴影的水平偏移
					this.ctx.shadowOffsetX = 1;
					// 设置阴影的垂直偏移
					this.ctx.shadowOffsetY = 1;
				} else {
					this.ctx.shadowColor = '#000000';
					this.ctx.setshadowBlur = 0;
					this.ctx.shadowOffsetX = 0;
					this.ctx.shadowOffsetY = 0;
				}
				this.ctx.setStrokeStyle(color)
				this.ctx.lineWidth = 3
				this.ctx.moveTo(x1, y1); // 开始点
				this.ctx.lineTo(x2, y2); // 结束点
				this.ctx.stroke(); // 绘制线条
				this.ctx.draw(true);
			},
			// 连线清理
			clearRect() {
				const canvas = uni.createCanvasContext('lineCanvas');
				// 使用clearRect方法清空整个画布
				canvas.clearRect(0, 0, 700, 500); // 这里的300x300是画布的宽高，应该与你的实际画布尺寸相匹配
				canvas.draw(true); // 调用draw方法将清空操作应用到画布上
			},
			// 阴影清理
			shadowClean() {
				for (var i = 0; i < this.connectionHtml.length; i++) {
					let option = this.connectionHtml[i]
					for (var j = 0; j < option.children.length; j++) {
						let ids = "option" + i + "-" + (j + 1)
						document.getElementById(ids).style.boxShadow = ''

					}
				}
			},
			isLine(id, value) {
				for (var i = 0; i < this.connectionContentALL[value].length; i++) {
					let option = this.connectionContentALL[value][i]
					for (var j = 0; j < option.length; j++) {
						let oldId = option[j].id
						if (oldId === id) {
							return false
						}
					}
				}
				return true
			},
			// 连线题画内容
			drawLineWriteContent() {
				for (var i = 0; i < this.connectionHtml.length; i++) {
					let option = this.connectionHtml[i]
					for (var j = 0; j < option.children.length; j++) {
						let ids = "option" + i + "-" + (j + 1)

						document.getElementById(ids).innerHTML = option.children[j].innerHTML
					}
				}
			}, // 连线画线
			drawLineWrite(value) {
				this.clearRect()
				if (this.connectionInfo.length >= 2) {
					for (var i = 0; i < this.connectionInfo.length - 1; i++) {
						let one = this.connectionInfo[i]
						let two = this.connectionInfo[i + 1]
						// box-shadow: ;
						document.getElementById(one.id).style.boxShadow = this.clickColor
						document.getElementById(two.id).style.boxShadow = this.clickColor
						this.drawLine(one.right, one.top, two.left, two.top, -1)
					}
				} else if (this.connectionInfo.length === 1) {
					document.getElementById(this.connectionInfo[0].id).style.boxShadow = this.clickColor
				}

				for (var i = 0; i < this.connectionContentALL[value].length; i++) {
					let option = this.connectionContentALL[value][i]
					for (var j = 0; j < option.length - 1; j++) {
						let one = option[j]
						let two = option[j + 1]
						document.getElementById(one.id).style.boxShadow = '0px 0px 5px 2px ' + this.connectionColor[i]
						document.getElementById(two.id).style.boxShadow = '0px 0px 5px 2px ' + this.connectionColor[i]
						this.drawLine(one.right, one.top, two.left, two.top, i)
					}
				}
			},
			// 字符转换html对象
			stringToHTML(str) {
				var dom = document.createElement('div');
				dom.innerHTML = str;
				return dom;
			},
			// 拖动位置固定
			tap(index, subX, subY) {
				let x = subX
				let y = subY
				this.drag[this.subjectNum].option[index].x = this.drag[this.subjectNum].option[index].old.x
				this.drag[this.subjectNum].option[index].y = this.drag[this.subjectNum].option[index].old.y
				this.$nextTick(function() {
					this.drag[this.subjectNum].option[index].x = x
					this.drag[this.subjectNum].option[index].y = y
				})
			},
			// 鼠标按下
			onMousedown(item) {
				console.log(this.drag[this.subjectNum].option.length);
				this.dragItem = item;
				this.count = 0
			},
			// 拖动监听
			onChange: function(e) {
				if (!this.disabledDrag) {
					return
				}
				let index = -1
				for (var j = 0; j < this.drag[this.subjectNum].option.length; j++) {
					let option = this.drag[this.subjectNum].option[j]
					if (option.id === this.dragItem.id) {
						index = j
						break;
					}

				}
				this.drag[this.subjectNum].option[index].old.x = e.detail.x
				this.drag[this.subjectNum].option[index].old.y = e.detail.y
				let asda = (event) => {
					document.removeEventListener('mouseup', asda)
					this.disabledDrag = false
					let bxs = true
					let dragOne;
					// 处理鼠标抬起事件
					for (var i = 0; i < this.drag[this.subjectNum].answer.length; i++) {
						let drag = this.drag[this.subjectNum].answer[i]
						let x = drag.x
						let y = drag.y
						if (
							(Number(this.drag[this.subjectNum].option[index].old.x) <= (Number(drag.x) + Number(
								drag
								.width))) &&
							(Number(this.drag[this.subjectNum].option[index].old.x) + Number(this.drag[this
									.subjectNum].option[index]
								.width)) >= drag.x &&
							(Number(this.drag[this.subjectNum].option[index].old.y) <= (Number(drag.y) + Number(
								drag
								.height))) &&
							(Number(this.drag[this.subjectNum].option[index].old.y) + Number(this.drag[this
									.subjectNum].option[index]
								.height)) >= drag.y
						) {
							for (var p = 0; p < this.drag[this.subjectNum].answer.length; p++) {
								if (this.drag[this.subjectNum].answer[p].op !== undefined && this.drag[this
										.subjectNum].answer[p].op === index) {
									this.drag[this.subjectNum].answer[p].op = undefined
								}
							}
							if (this.drag[this.subjectNum].answer[i].op !== undefined) {
								this.tap(this.drag[this.subjectNum].answer[i].op, this.drag[this.subjectNum]
									.option[this.drag[this.subjectNum].answer[i].op].old.ax, this.drag[this
										.subjectNum]
									.option[this.drag[this.subjectNum].answer[i].op].old.by);
								this.drag[this.subjectNum].answer[i].op = index
							} else {
								this.drag[this.subjectNum].answer[i].op = index
							}
							this.tap(index, x, y);
							dragOne = drag
							bxs = false
							break;
						}
					}
					// console.log(this.drag[this.subjectNum].option[index]);
					if (bxs) {
						this.tap(index, this.drag[this.subjectNum].option[index].old.ax, this.drag[this.subjectNum]
							.option[index].old.by);
					}
					setTimeout(() => {
						// for (var i = 0; i < this.drag[this.subjectNum].option.length; i++) {
						// 	let op = this.drag[this.subjectNum].option[i]

						// 	for (var j = 0; j < this.drag[this.subjectNum].answer.length; j++) {
						// 		let an = this.drag[this.subjectNum].answer[j]

						// 	}
						// }
						if (dragOne !== undefined) {
							this.radioAdd(this.dragItem, dragOne.id.replace("answer", ""), this.scantron)
						}


						this.disabledDrag = true

					}, 700)
				}

				// if (this.drag[this.subjectNum].option[index].b) {
				// 	this.drag[this.subjectNum].option[index].b = false
				document.addEventListener('mouseup', asda);
				// }

			},
			// 题目做答
			radioAdd(value, index, scantron, combinationItem) {

				index = index + ''
				let qIndex = this.subjectNum + ""
				let arr = []
				this.examObject.records[this.subjectNum - 1].isAnswer = true
				if (this.scantron.type === 1 || this.scantron.type === 3) {
					for (var i = 0; i < scantron.answerList.length; i++) {
						scantron.answerList[i].right = false
					}
					scantron.answerList[index].right = true
					this.answerInspect()
					for (var i = 0; i < this.userExamAnswers.length; i++) {
						if (this.userExamAnswers[i].index !== qIndex) {
							arr.push(this.userExamAnswers[i])
						}
					}
					arr.push({
						answerIndex: [index],
						answers: [value.id],
						index: qIndex,
						questionType: this.scantronType
					})
				} else if (this.scantron.type === 2) {
					let b = true
					for (var i = 0; i < this.userExamAnswers.length; i++) {

						if (this.userExamAnswers[i].index !== qIndex) {
							arr.push(this.userExamAnswers[i])
						} else {
							b = false
							let bc = true
							let arrAnswer = []
							let arrAnswerId = []
							let num = this.userExamAnswers[i].answers.length;
							for (var j = 0; j < num; j++) {
								if (this.userExamAnswers[i].answerIndex[j] !== index) {
									arrAnswer.push(this.userExamAnswers[i].answerIndex[j])
									arrAnswerId.push(this.userExamAnswers[i].answers[j])
								} else {
									if (!value.right) {
										bc = false
									}

								}
							}
							if (bc) {
								arrAnswer.push(index)
								arrAnswerId.push(value.id)
							}
							if (arrAnswer.length !== 0) {
								arr.push({
									answerIndex: arrAnswer,
									answers: arrAnswerId,
									index: qIndex,
									questionType: this.scantron.type
								})
							} else {
								this.examObject.records[this.subjectNum - 1].isAnswer = false
							}

						}
					}
					if (b) {
						arr.push({
							answerIndex: [index],
							answers: [value.id],
							index: qIndex,
							questionType: this.scantronType
						})
					}
				} else if (this.scantron.type === 4) {
					for (var i = 0; i < this.userExamAnswers.length; i++) {
						if (this.userExamAnswers[i].index !== qIndex) {
							arr.push(this.userExamAnswers[i])
						}
					}
					if (scantron.subjectiveAnswer === null || scantron.subjectiveAnswer === "") {
						this.examObject.records[this.subjectNum - 1].isAnswer = false
					}
					arr.push({
						subjectiveAnswer: scantron.subjectiveAnswer,
						index: qIndex,
						questionType: this.scantronType
					})
				} else if (this.scantron.type === 5) {
					if (value === undefined) {
						return
					}
					let b = true
					for (var i = 0; i < this.userExamAnswers.length; i++) {

						if (this.userExamAnswers[i].index !== qIndex) {
							arr.push(this.userExamAnswers[i])
						} else {
							b = false
							let bc = true
							let arrAnswer = []
							let blankAnswer = JSON.parse(this.userExamAnswers[i].blankAnswer)
							let num = blankAnswer.length;
							for (var j = 0; j < num; j++) {
								if (blankAnswer[j].tag !== index) {
									arrAnswer.push({
										tag: blankAnswer[j].tag,
										content: blankAnswer[j].content
									})
								} else {
									bc = false
								}
							}
							if (bc) {
								arrAnswer.push({
									tag: index,
									content: value
								})
							}
							if (arrAnswer.length !== 0) {
								arr.push({
									blankAnswer: JSON.stringify(arrAnswer),
									index: qIndex,
									questionType: this.scantronType
								})
							} else {
								this.examObject.records[this.subjectNum - 1].isAnswer = false
							}

						}
					}
					if (b) {
						if (value === null || value === "") {
							this.examObject.records[this.subjectNum - 1].isAnswer = false
						}
						arr.push({
							blankAnswer: JSON.stringify([{
								tag: index,
								content: value
							}]),
							index: qIndex,
							questionType: this.scantronType
						})
					}

				} else if (this.scantron.type === 6) {


					qIndex = qIndex + "." + combinationItem.sort

					if (combinationItem.questionType === 1 || combinationItem.questionType ===
						3) {
						for (var j = 0; j < combinationItem.answerList.length; j++) {
							combinationItem.answerList[j].right = false
						}
						combinationItem.answerList[index].right = true
						for (var j = 0; j < this.userExamAnswers.length; j++) {
							if (this.userExamAnswers[j].index !== qIndex) {

								arr.push(this.userExamAnswers[j])
							}
						}
						arr.push({
							answerIndex: [index],
							answers: [value.id],
							index: qIndex,
							questionType: combinationItem.questionType
						})

					} else if (combinationItem.questionType === 2) {
						let b = true
						for (var j = 0; j < this.userExamAnswers.length; j++) {

							if (this.userExamAnswers[j].index !== qIndex) {
								arr.push(this.userExamAnswers[j])
							} else {
								b = false
								let bca = true
								let arrAnswer = []
								let arrAnswerId = []
								let num = this.userExamAnswers[j].answers.length;
								for (var k = 0; k < num; k++) {
									if (this.userExamAnswers[j].answerIndex[k] !== index) {
										arrAnswer.push(this.userExamAnswers[j].answerIndex[k])
										arrAnswerId.push(this.userExamAnswers[j].answers[k])
									} else {
										if (!value.right) {
											bca = false
										}

									}
								}
								if (bca) {
									arrAnswer.push(index)
									arrAnswerId.push(value.id)
								}
								if (arrAnswer.length !== 0) {
									arr.push({
										answerIndex: arrAnswer,
										answers: arrAnswerId,
										index: qIndex,
										questionType: combinationItem.questionType
									})
								} else {
									this.examObject.records[this.subjectNum - 1].question
										.isAnswer =
										false
								}
							}
						}
						if (b) {
							arr.push({
								answerIndex: [index],
								answers: [value.id],
								index: qIndex,
								questionType: combinationItem.questionType
							})
						}
					} else if (combinationItem.questionType === 4) {
						for (var j = 0; j < this.userExamAnswers.length; j++) {
							if (this.userExamAnswers[j].index !== qIndex) {
								arr.push(this.userExamAnswers[j])
							}
						}
						if (combinationItem.subjectiveAnswer === null || scantron.subQuestionList[
								i].subjectiveAnswer === "") {
							this.examObject.records[this.subjectNum - 1].isAnswer = false
						}
						arr.push({
							subjectiveAnswer: combinationItem.subjectiveAnswer,
							index: qIndex,
							questionType: combinationItem.questionType
						})
					} else if (combinationItem.questionType === 5) {
						if (value === undefined) {
							return
						}
						let b = true
						for (var j = 0; j < this.userExamAnswers.length; j++) {

							if (this.userExamAnswers[j].index !== qIndex) {
								arr.push(this.userExamAnswers[j])
							} else {
								b = false
								let bc = true
								let arrAnswer = []
								let blankAnswer = JSON.parse(this.userExamAnswers[j].blankAnswer)
								let num = blankAnswer.length;
								for (var q = 0; q < num; q++) {
									if (blankAnswer[q].tag !== index) {
										arrAnswer.push({
											tag: blankAnswer[q].tag,
											content: blankAnswer[q].content
										})
									} else {
										bc = false
									}
								}
								if (bc) {
									arrAnswer.push({
										tag: index,
										content: value
									})
								}
								if (arrAnswer.length !== 0) {
									arr.push({
										blankAnswer: JSON.stringify(arrAnswer),
										index: qIndex,
										questionType: scantron.subQuestionList[i].questionType
									})
								} else {
									this.examObject.records[this.subjectNum - 1].question
										.isAnswer = false
								}
							}
						}
						if (b) {
							if (value === null || value === "") {
								this.examObject.records[this.subjectNum - 1].isAnswer = false
							}

							arr.push({
								blankAnswer: JSON.stringify([{
									tag: index,
									content: value
								}]),
								index: qIndex,
								questionType: scantron.subQuestionList[i].questionType
							})
						}

					}

				} else if (this.scantron.type === 7) {
					if (value === undefined || this.count > 0) {
						return
					}
					console.log(this.drag);
					this.count++
					index = (Number(index) + 1) + ""

					let b = true
					for (var i = 0; i < this.userExamAnswers.length; i++) {
						if (this.userExamAnswers[i].index !== qIndex) {
							arr.push(this.userExamAnswers[i])
						} else {
							b = false
							let bc = true
							let arrAnswer = []
							let blankAnswer = JSON.parse(this.userExamAnswers[i].blankAnswer)
							let num = blankAnswer.length;
							for (var j = 0; j < num; j++) {
								if (blankAnswer[j].tag !== index) {
									arrAnswer.push({
										tag: blankAnswer[j].tag,
										content: blankAnswer[j].content
									})
								} else {
									arrAnswer.push({
										tag: index,
										content: value.id
									})
									this.scantron.answerList[Number(index) - 1].blankcontent = value.id
									bc = false
								}
							}
							console.log(arrAnswer);
							if (bc) {
								arrAnswer.push({
									tag: index,
									content: value.id
								})
								this.scantron.answerList[Number(index) - 1].blankcontent = value.id
							}
							if (arrAnswer.length !== 0) {
								arr.push({
									blankAnswer: JSON.stringify(arrAnswer),
									coordinates: JSON.stringify(this.drag[qIndex]),
									index: qIndex,
									questionType: this.scantronType
								})
								this.scantron.answerList[Number(index) - 1].blankcontent = value.id
							} else {
								this.examObject.records[this.subjectNum - 1].isAnswer = false
							}

						}
					}
					if (b) {
						if (value === null || value === "") {
							this.examObject.records[this.subjectNum - 1].isAnswer = false
						}
						arr.push({
							blankAnswer: JSON.stringify([{
								tag: index,
								content: value.id
							}]),
							coordinates: JSON.stringify(this.drag[qIndex]),
							index: qIndex,
							questionType: this.scantronType
						})
						this.scantron.answerList[Number(index) - 1].blankcontent = value.id
					}
				} else if (this.scantron.type === 8) {
					console.log(this.connectionContentALL[qIndex]);
					let info = value
					value = ""
					for (var i = 0; i < info.length; i++) {
						console.log(info);
						value += info[i].id.replace('option', '').split('-')[1]
					}
					// connectingCoordinates
					if (value === undefined) {
						return
					}
					let b = true
					console.log(this.userExamAnswers.length);
					this.scantron.answerList[Number(index) - 1].blankcontent = value
					for (var j = 0; j < this.userExamAnswers.length; j++) {
						if (this.userExamAnswers[j].index !== qIndex) {
							arr.push(this.userExamAnswers[j])
						} else {
							b = false
							let bc = true
							let arrAnswer = []
							let blankAnswer = JSON.parse(this.userExamAnswers[j].blankAnswer)
							let num = blankAnswer.length;
							for (var q = 0; q < num; q++) {
								if (blankAnswer[q].tag !== index) {
									arrAnswer.push({
										tag: blankAnswer[q].tag,
										content: blankAnswer[q].content
									})
								} else {
									console.log(value);

									bc = false
								}
							}
							if (bc) {
								console.log(value);
								arrAnswer.push({
									tag: index,
									content: value
								})

							}
							if (arrAnswer.length !== 0) {
								arr.push({
									blankAnswer: JSON.stringify(arrAnswer),
									index: qIndex,
									coordinates: JSON.stringify(this.connectionContentALL[qIndex]),
									questionType: this.scantronType
								})

							} else {
								this.examObject.records[this.subjectNum - 1].isAnswer =
									false
							}

						}
					}
					if (b) {
						if (value === null || value === "") {
							this.examObject.records[this.subjectNum - 1].isAnswer =
								false
						}
						this.scantron.answerList[Number(index) - 1].blankcontent = value
						arr.push({
							blankAnswer: JSON.stringify([{
								tag: index,
								content: value
							}]),
							coordinates: JSON.stringify(this.connectionContentALL[qIndex]),
							index: qIndex,
							questionType: this.scantronType
						})
					}
				}
				this.userExamAnswers = arr
				console.log(this.scantron.answerList[Number(index) - 1]);
				console.log(this.userExamAnswers);
			},
			// 类型点击
			subjectTypeClick(item) {
				this.repository = item
				this.pageNo = 1
				setTimeout(() => {
					this.drag = []
					this.shadowClean()
					this.clearRect()
					this.connectionContentALL = []
				}, 100)

				getListQuestionByMode({
					mode: 3,
					pageNo: 1,
					pageSize: this.pageSize,
					questionType: item.type,
					repositoryId: sessionStorage.getItem('repositoryId')
				}).then(data => {
					if (0 === data.data.result.total) {
						this.messageToggle('warn', "该题型数量为空")
						return
					}
					for (var i = 0; i < data.data.result.records.length; i++) {
						data.data.result.records[i].disable = false
					}
					this.subjectType = item.type
					this.examObject = data.data.result
					console.log(this.examObject);
					console.log(this.subjectNum);
					this.scantron = this.examObject.records[0]
					this.radioScantron(1)
				})
			},
			// 答案确认
			answerConfirm() {

				this.answerInspect()
			}, // 答案检查
			answerInspect(state) {
				console.log(this.examObject.records[this.subjectNum - 1]);
				if (this.examObject.records[this.subjectNum - 1].disable) {
					console.log("0");
					return
				}
				this.analysisBlank()
				this.answerAnalysis.youAnswerState = 1
				if (this.scantron.type === 1 || this.scantron.type === 3) {
					for (var i = 0; i < this.scantron.answerList.length; i++) {
						if (this.scantron.answerList[i].isRight && this.scantron.answerList[i].right) {
							this.answerAnalysis.youAnswerState = 0
						}
						if (this.scantron.answerList[i].isRight && !this.scantron.answerList[i].right) {
							this.answerAnalysis.youAnswerState = 1
						}
						if (this.scantron.answerList[i].isRight) {
							this.answerAnalysis.answer += this.scantron.answerList[i].tag
						}
					}
				} else if (this.scantron.type === 5) {
					if (!this.examObject.records[this.subjectNum - 1].answerOrder) {
						console.log(this.scantron.answerList);
						for (var i = 0; i < this.scantron.answerList.length; i++) {
							this.answerAnalysis.youAnswerState = 1
							for (var j = 0; j < this.scantron.answerList.length; j++) {
								if (this.scantron.answerList[i].isRight) {
									let arrAwn = this.scantron.answerList[i].content.split("||")
									for (var a = 0; a < arrAwn.length; a++) {
										if (arrAwn[a] === this.scantron.answerList[j].blankcontent) {
											this.answerAnalysis.youAnswerState = 0
											break
										}
									}

								}
							}
							if (this.answerAnalysis.youAnswerState === 1) {
								break
							}
						}
						for (var i = 0; i < this.scantron.answerList.length; i++) {
							if (this.scantron.answerList[i].isRight) {
								this.answerAnalysis.answer += (i + 1) + "、" + this.scantron.answerList[i].content + ";"
							}
						}
					} else {
						for (var i = 0; i < this.scantron.answerList.length; i++) {
							if (this.scantron.answerList[i].isRight) {
								let arrAwn = this.scantron.answerList[i].content.split("||")
								for (var a = 0; a < arrAwn.length; a++) {
									if (arrAwn[a] === this.scantron.answerList[i].blankcontent) {
										this.answerAnalysis.youAnswerState = 0
										break
									}
								}

							}
							if (this.answerAnalysis.youAnswerState === 1) {
								break
							}
						}
						for (var i = 0; i < this.scantron.answerList.length; i++) {
							if (this.scantron.answerList[i].isRight) {
								this.answerAnalysis.answer += (i + 1) + "、" + this.scantron.answerList[i].content + ";"
							}
						}
					}

				} else if (this.scantron.type === 7 || this.scantron.type === 8) {
					let a = 1
					this.answerAnalysis.youAnswerState = 0
					console.log(this.scantron.answerList);
					for (var i = 0; i < this.scantron.answerList.length; i++) {
						let a = 1
						for (var j = 0; j < this.scantron.answerList.length; j++) {

							if (this.scantron.answerList[i].isRight) {
								if (this.scantron.answerList[i].content === this.scantron.answerList[j].blankcontent) {
									a = 0
								}
							}

						}
						console.log(this.scantron.answerList);
						if (this.scantron.answerList[i].isRight) {
							this.answerAnalysis.answer += (i + 1) + "、" + this.scantron.answerList[i].content + ";"
						}
						if (a === 1) {
							this.answerAnalysis.youAnswerState = 1
						}
					}
				}
				if (state === 3) {
					this.answerAnalysis.youAnswerState = state
				}
				this.answerAnalysis.analysis = this.scantron.analysis
				this.examObject.records[this.subjectNum - 1].disable = true
			},
			// 解析置空
			analysisBlank() {
				this.answerAnalysis.analysis = ''
				this.answerAnalysis.answer = ''
				this.answerAnalysis.youAnswerState = -1
			},
			// 返回
			backPage() {
				toExamInfo()
			}
		},
		mounted() {
			this.user = JSON.parse(sessionStorage.getItem("user"))
			let examId = sessionStorage.getItem('repositoryId')
			getRepositoryById({
				'id': examId,
				't': new Date().toString()
			}).then(data => {
				if (data.data.code !== 200) {
					sessionStorage.removeItem('examId')
					toLogin()
				}
				this.repositoryType = data.data.result.questionDTOList

				this.subjectTypeClick(this.repositoryType[0])
				console.log(this.repositoryType);

				this.title = data.data.result.title

			})
		}
	}
</script>

<style scoped>
	.svg-container {
		width: 100%;
		height: 100%;
		overflow: hidden;
		position: runiative;
	}

	svg {
		display: block;
		width: 100%;
		height: 100%;
	}

	.scroll-Y {
		height: 50vh;
	}

	.allceter {
		display: flex;
		align-items: center;
		height: 50px;
	}

	.scroll-view_H {
		white-space: nowrap;
		width: 100%;
	}

	.scroll-view-item {
		height: 300rpx;
		line-height: 300rpx;
		text-align: center;
		font-size: 36rpx;
	}

	.scroll-view-item_H {
		display: inline-block;
		width: 100%;
		height: 300rpx;
		line-height: 300rpx;
		text-align: center;
		font-size: 36rpx;
	}



	div {
		margin: 0;
		padding: 0;
	}

	/* CSS 预设*/
	* {
		margin: 0;
		padding: 0;
	}

	a {
		text-decoration: none;
		outline: none;
	}

	body a {
		outline: none;
		blr: expression(this.onFocus=this.blur());
	}

	.uni-input {
		padding-left: 20px;
		border: 1rpx solid #5bb4ee;
		height: 50px;
		margin-left: 10px;


		color: #000000;
		width: 90%;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	img {
		border: none;
	}



	.dialog-text {
		font-size: 14px;
		color: #333;
	}

	.paperCss {
		width: 85%;
		border-radius: 5px;
		padding: 1vh;
		margin-top: 1vh;

		font-size: 15px;
		text-align: left;
	}
</style>