瀏覽代碼

问卷选项

OnePsycho 4 年之前
父節點
當前提交
d963877c05

+ 0 - 144
TEAMModelOS/ClientApp/src/components/questionnaire/BaseAddItem.less

@@ -1,144 +0,0 @@
-@main-bgColor: #565656; 
-@borderColor: #585858;
-@primary-color:#1CC0F3;
-@primary-textColor: #fff; 
-@second-textColor: #CBCBCB; 
-@primary-fontSize: 14px;
-@second-fontSize: 16px;
-    
-.exersices-box{	
-	width: 96%;
-	margin-left: 2%;
-	
-	.title{
-		font-size: 16px;
-		font-weight: bold;
-		margin: 20px 5px;
-		display: flex;
-		align-items: center;
-		justify-content: space-between;
-		
-		.btn-add-option{
-			font-size: 14px;
-			color:@primary-color;
-			cursor: pointer;
-		}
-	}
-	
-	.w-e-toolbar {
-        background: @main-bgColor !important;
-        border-color: @borderColor !important;
-        margin-top: 10px;
-        z-index: 1 !important;
-    
-        .w-e-menu {
-            z-index: 1 !important;
-			
-			&:hover {
-				color:@primary-textColor;
-			}
-		}
-    }
-    
-    .w-e-text-container {
-        height: 150px !important;
-		background: #3b3b3b;
-        border-color: @borderColor !important;
-        z-index: 0 !important;
-    }
-	
-	.option-editors{
-		min-height: 200px;
-	}
-	
-	// 设置 选项 富文本的样式
-	.option-editor-wrap {
-	    position: relative;
-	    margin-top: 10px;
-		display: flex;
-	
-	    .option-order {
-			position: relative;
-	        display: inline-block;
-	        height: 42px;
-	        width: 10%;
-	        float: left;
-	        color: #a0a0a0;
-	        background: @main-bgColor;
-	        text-align: center;
-	        line-height: 42px;
-			
-			&:hover{
-				.btn-delete{
-					visibility: visible;
-				}
-			}
-			
-			.btn-delete{
-				position: absolute;
-				left: 35%;
-				top: 5px;
-				visibility: hidden;
-				cursor: pointer;
-			}
-	    }
-	
-	    .option-editor {
-	        position: relative;
-	        display: inline-block;
-	        height: 42px;
-	        border: none;
-	        width: 100%;
-	    }
-	
-	    .w-e-text-container {
-	        height: 42px !important;
-	        z-index: 0 !important;
-			border-top: 1px solid #4e4e4e !important;
-			border-left: none !important;
-	    }
-	
-	    .w-e-toolbar {
-	        position: absolute;
-	        top: -42px;
-	        left: 0px;
-	        height: 32px;
-	        line-height: 20px;
-	        visibility: hidden;
-	        font-size: 12px;
-	        width: 100%;
-	        background: #6c6c6c !important;
-	    }
-	}
-	
-	.w-e-text {
-        color: #fff;
-		// padding: 0;
-		// height: unset !important;
-		
-		p{
-			margin: 9px 0;
-		}
-		
-        &::-webkit-scrollbar {
-            width: 4px;
-            height: 16px;
-            background-color: #0E0D0D;
-        }
-        &::-webkit-scrollbar-track {
-            -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
-            border-radius: 10px;
-            background-color: #484848;
-        }
-        &::-webkit-scrollbar-thumb {
-            border-radius: 0;
-            -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
-            background-color: #989191;
-        }
-    }
-}
-
-	.related-modal .ivu-modal-body{
-		height: unset !important;
-		padding-bottom: 50px !important;
-	}

+ 0 - 235
TEAMModelOS/ClientApp/src/components/questionnaire/BaseAddItem.vue

@@ -1,235 +0,0 @@
-<template>
-	<div>
-		<div class="exersices-box">
-			<p class="title">题干</p>
-			<!-- 题干富文本 -->
-			<div ref="singleEditor" style="text-align:left"></div>
-			<!-- 选项富文本 -->
-			<p class="title">
-				<span>选项</span>
-				<span @click="addOption" class="btn-add-option" v-show="curType !== 'judge'">添加选项</span>
-			</p>
-			<div class="option-editors" id="optionEditors">
-					<div v-for="(item,index) in options" :key="index">
-						<div class="option-editor-wrap" v-show="(curType !== 'judge') || (curType === 'judge' && item < 2)">
-							<!-- 选项序号 -->
-							<div class="option-order">
-								<span>{{ index + 1 }}</span>
-								<span class="btn-delete" @click="deleteOption(index)" v-show="curType !== 'judge'">
-									<Icon type="md-trash" size="24" color="#fff" /></span>
-							</div>
-							<!-- 选项编辑器 -->
-							<div :ref="'singleOption' + item " style="text-align:left" class="option-editor" @click="optionClick(item)"></div>
-						</div>
-					</div>
-			</div>
-		</div>
-
-	</div>
-</template>
-<script>
-	import E from '@/utils/wangEditor.js'
-	export default {
-		props: ['type','editItem'],
-		data() {
-			return {
-				options: [],
-				trueIndex: 0,
-				curType: '',
-				editInfo: {},
-				stemEditor: null,
-				stemContent: '',
-				isChange:false,
-				optionsContent: [],
-				optionEditors:[],
-				existEditors:[],
-				defaultConfig: {
-					uploadImgServer: '/api/file/uploadWangEditor', // 图片上传地址
-					showLinkImg: false, // 是否展示网络图片链接上传
-					uploadFileName: 'files', // 上传图片后台获取的文件名
-					menus: this.$tools.wangEditorMenu
-				}
-			}
-		},
-		created() {
-			
-		},
-		methods: {
-			initEditors() {
-				console.log('进了initEditors')
-				console.log(this.options)
-				console.log(this.optionsContent)
-				console.log(this.optionEditors)
-				console.log(document.getElementsByClassName('option-editor').length)
-				// Editor默认配置
-				if (this.options.length > 0) {
-					this.$nextTick(() => {
-						this.options.forEach((item, i) => {
-							let that = this
-							if(i >= this.optionEditors.length){
-								let editor = new E(that.$refs['singleOption' + i][0])
-								editor.customConfig = this.defaultConfig
-								
-								// 选项编辑器失焦隐藏工具栏
-								editor.customConfig.onblur = function() {
-									let allToolbars = document.getElementsByClassName('option-editor')
-									for (let i = 0; i < allToolbars.length; i++) {
-										if (allToolbars[i].children.length) {
-											allToolbars[i].children[0].style.visibility = 'hidden'
-										}
-									}
-								}
-								
-								// 选项编辑器内容发生变化时
-								editor.customConfig.onchange = (html) => {
-									let key = String.fromCharCode(64 + parseInt(i + 1))
-									let codeArr = this.optionsContent.map((item,index) => String.fromCharCode(64 + parseInt(index + 1)))
-									// 如果已经编辑过则 修改选项内容
-									if (codeArr.indexOf(key) !== -1) {
-										this.optionsContent[codeArr.indexOf(key)].value = html
-									} else { // 否则创建新选项
-										this.optionsContent.push({
-											code: key,
-											value: html
-										})
-									}
-								}
-								editor.create()
-								
-								this.optionEditors.push(editor)
-							}else{
-								this.optionEditors[i].txt.clear()
-								// 如果是编辑状态 则将选项内容回显
-								if (this.editItem && Object.keys(this.editItem).length > 0) {
-									this.optionEditors[i].txt.html(this.editItem.option[i].value)
-								}
-							}
-						})
-					})
-				}
-			},
-			onAddNew(){
-				this.isChange = false
-				console.log('打开窗口')
-				this.options = []
-				this.optionsContent = []
-				this.resetContent()
-			},
-			// 添加选项
-			addOption() {
-				let that = this
-				let newIndex = parseInt(this.options[this.options.length - 1]) + 1
-				let optionsLength = this.options.length
-				if (optionsLength < 9) {
-					this.options.push(newIndex)
-					this.$nextTick(() => {
-						let editor = new E(that.$refs['singleOption' + newIndex][0])
-						editor.customConfig = this.defaultConfig
-
-						editor.customConfig.onchange = (html) => {
-							let key = String.fromCharCode(64 + parseInt(newIndex + 1))
-							let codeArr = this.optionsContent.map((item,index) => String.fromCharCode(64 + parseInt(index + 1)))
-							// 如果已经编辑过则 修改选项内容
-							if (codeArr.indexOf(key) !== -1) {
-								this.optionsContent[codeArr.indexOf(key)].value = html
-							} else { // 否则创建新选项
-								let option = {
-									code: key,
-									value: html
-								}
-								this.optionsContent.push(option)
-							}
-							console.log(this.optionsContent)
-						}
-						editor.create()
-					})
-				} else {
-					this.$Message.warning('最多只有9个选项!')
-				}
-			},
-			// 删除选项
-			deleteOption(index) {
-				console.log(index)
-				if (this.options.length > 2) {
-					this.options.splice(index, 1)
-					this.optionsContent.splice(index, 1)
-				} else {
-					this.$Message.warning('至少保留两个选项!')
-				}
-			},
-			// 模拟选项聚焦事件
-			optionClick(index) {
-				let allToolbars = document.getElementsByClassName('option-editor')
-				let that = this
-				for (let i = 0; i < allToolbars.length; i++) {
-					allToolbars[i].children[0].style.visibility = 'hidden'
-				}
-				setTimeout(function() {
-					let currentToolBar = that.$refs['singleOption' + index][0].children[0]
-					currentToolBar.style.visibility = 'visible'
-				}, 100)
-			},
-			// 置空内容
-			resetContent(){
-				this.options = [0,1,2,3]
-				this.optionsContent = []
-				this.stemContent = ''
-				this.stemEditor.txt.clear()
-				this.optionEditors.forEach(i => {
-					i.txt.clear()
-				})
-				this.isChange = true
-			},
-			
-			// 渲染编辑试题的内容
-			doRender(item){
-				let newValue = JSON.parse(JSON.stringify(item))
-				this.stemEditor.txt.html(newValue.question)
-				this.stemContent = newValue.question
-				this.optionsContent = newValue.option
-				this.options = newValue.option.map((item, index) => index)
-				// this.$nextTick(() => {
-				//     this.initEditors()
-				// })
-			}
-		},
-		mounted() {
-			let stemEditor = new E(this.$refs.singleEditor)
-			stemEditor.customConfig = this.defaultConfig
-			stemEditor.customConfig.onchange = (html) => {
-				this.stemContent = html
-			}
-			stemEditor.create()
-			this.stemEditor = stemEditor
-			this.$nextTick(() => {
-			    this.initEditors()
-			})
-		},
-		watch: {
-			type: {
-				handler(newValue) {
-					if (!newValue) return
-					console.log('进题型了')
-					this.curType = newValue
-					this.options = newValue === 'judge' ? [0,1] : [0,1,2,3]
-					this.optionsContent = []
-					this.$nextTick(() => {
-					    this.initEditors()
-					})
-				}
-			},
-			editItem: {
-				handler(newValue) {
-					if (!newValue) return
-					this.doRender(newValue)
-				},
-				
-			}
-
-		}
-	}
-</script>
-
-<style lang="less">
-	@import "./BaseAddItem.less";
-</style>

+ 0 - 214
TEAMModelOS/ClientApp/src/components/questionnaire/BaseAddSingle.vue

@@ -1,214 +0,0 @@
-<template>
-	<div>
-		<div class="exersices-box">
-			<p class="title">题干</p>
-			<!-- 题干富文本 -->
-			<div ref="singleEditor" style="text-align:left"></div>
-			<!-- 选项富文本 -->
-			<p class="title">
-				<span>选项</span>
-				<span @click="addOption" class="btn-add-option" v-show="curType !== 'judge'">添加选项</span>
-			</p>
-			<div class="option-editors" id="optionEditors">
-				<div v-for="(item,index) in options" :key="index" :class="'editor-wrap-'+item" style="margin-top:10px;display:flex">
-				    <span class="fl-center option-editor-wrap">{{String.fromCharCode(64 + parseInt(index+1))}}</span>
-				    <div :ref="'singleOption'+item" style="text-align:left" class="option-editor" @click="optionClick(item)"></div>
-				</div>
-			</div>
-			
-			
-		</div>
-
-	</div>
-</template>
-<script>
-	import E from '@/utils/wangEditor.js'
-	export default {
-		props: ['type','editItem'],
-		data() {
-			return {
-				options: [0,1,2,3],
-				trueIndex: 0,
-				curType: '',
-				editInfo: {},
-				stemEditor: null,
-				stemContent: '',
-				optionsContent: [],
-				optionEditors:[],
-				existEditors:[],
-				defaultConfig: {
-					uploadImgServer: '/api/file/uploadWangEditor', // 图片上传地址
-					showLinkImg: false, // 是否展示网络图片链接上传
-					uploadFileName: 'files', // 上传图片后台获取的文件名
-					menus: this.$tools.wangEditorMenu
-				}
-			}
-		},
-		created() {
-			
-		},
-		methods: {
-			
-			initEditors() {
-			    // Editor默认配置
-			    if (this.options.length > 0) {
-			        this.options.forEach((item, i) => {
-			            let that = this
-			            let editor = new E(that.$refs['singleOption' + i][0])
-			            editor.customConfig = this.defaultConfig
-						editor.customConfig.uploadVideoDisable = true,
-						// editor.customConfig.zIndex = 100
-			
-			            // 选项编辑器失焦隐藏工具栏
-			            editor.customConfig.onblur = function () {
-			                let allToolbars = document.getElementsByClassName('option-editor')
-			                for (let i = 0; i < allToolbars.length; i++) {
-			                    if (allToolbars[i].children.length) {
-			                        allToolbars[i].children[0].style.visibility = 'hidden'
-			                    }
-			                }
-			            }
-						
-						editor.customConfig.onVideoWarning = (text) => {
-							this.$Message.warning(text)
-						},
-			
-			            // 选项编辑器内容发生变化时
-			            editor.customConfig.onchange = (html) => {
-			                let key = String.fromCharCode(64 + parseInt(i + 1))
-			                let codeArr = this.optionsContent.map(item => item.code)
-			                // 如果已经编辑过则 修改选项内容
-			                if (codeArr.indexOf(key) !== -1) {
-			                    this.optionsContent[codeArr.indexOf(key)].value = html
-			                } else { // 否则创建新选项
-			                    let option = {
-			                        code: key,
-			                        value: html
-			                    }
-			                    this.optionsContent.push(option)
-			                }
-			            }
-			            editor.create()
-			
-			            // 如果是编辑状态 则将选项内容回显
-			            if (this.editItem && Object.keys(this.editItem).length > 0) {
-			            	editor.txt.html(this.editItem.option[i].value)
-			            }
-			        })
-			    }
-			},
-			// 添加选项
-			addOption() {
-				let that = this
-				let newIndex = parseInt(this.options[this.options.length - 1]) + 1
-				let optionsLength = this.options.length
-				if (optionsLength < 9) {
-					this.options.push(newIndex)
-					this.$nextTick(() => {
-						let editor = new E(that.$refs['singleOption' + newIndex][0])
-						editor.customConfig = this.defaultConfig
-
-						editor.customConfig.onchange = (html) => {
-							let key = String.fromCharCode(64 + parseInt(newIndex + 1))
-							let codeArr = this.optionsContent.map((item,index) => String.fromCharCode(64 + parseInt(index + 1)))
-							// 如果已经编辑过则 修改选项内容
-							if (codeArr.indexOf(key) !== -1) {
-								this.optionsContent[codeArr.indexOf(key)].value = html
-							} else { // 否则创建新选项
-								let option = {
-									code: key,
-									value: html
-								}
-								this.optionsContent.push(option)
-							}
-							console.log(this.optionsContent)
-						}
-						editor.create()
-					})
-				} else {
-					this.$Message.warning('最多只有9个选项!')
-				}
-			},
-			// 删除选项
-			deleteOption(index) {
-				console.log(index)
-				if (this.options.length > 2) {
-					this.options.splice(index, 1)
-					this.optionsContent.splice(index, 1)
-				} else {
-					this.$Message.warning('至少保留两个选项!')
-				}
-			},
-			// 模拟选项聚焦事件
-			optionClick(index) {
-				let allToolbars = document.getElementsByClassName('option-editor')
-				let that = this
-				for (let i = 0; i < allToolbars.length; i++) {
-					allToolbars[i].children[0].style.visibility = 'hidden'
-				}
-				setTimeout(function() {
-					let currentToolBar = that.$refs['singleOption' + index][0].children[0]
-					currentToolBar.style.visibility = 'visible'
-				}, 100)
-			},
-			// 置空内容
-			resetContent(){
-				this.options = [0,1,2,3]
-				this.stemEditor.txt.clear()
-				this.optionEditors.forEach(i => {
-					i.txt.clear()
-				})
-				
-			},
-			
-			// 渲染编辑试题的内容
-			doRender(item){
-				let newValue = JSON.parse(JSON.stringify(item))
-				this.stemEditor.txt.html(newValue.question)
-				this.stemContent = newValue.question
-				this.optionsContent = newValue.option
-				this.options = newValue.option.map((item, index) => index)
-				this.$nextTick(() => {
-				    this.initEditors()
-				})
-			}
-		},
-		mounted() {
-			let stemEditor = new E(this.$refs.singleEditor)
-			stemEditor.customConfig = this.defaultConfig
-			stemEditor.customConfig.onchange = (html) => {
-				this.stemContent = html
-			}
-			stemEditor.create()
-			this.stemEditor = stemEditor
-			// this.$nextTick(() => {
-			//     this.initEditors()
-			// })
-		},
-		watch: {
-			type: {
-				handler(newValue) {
-					if (!newValue) return
-					this.curType = newValue
-					this.options = [0,1,2,3]
-					this.optionsContent = []
-					this.$nextTick(() => {
-					    this.initEditors()
-					})
-				}
-			},
-			editItem: {
-				handler(newValue) {
-					if (!newValue) return
-					this.doRender(newValue)
-				},
-				
-			}
-
-		}
-	}
-</script>
-
-<style lang="less">
-	@import "./BaseAddItem.less";
-</style>

+ 1 - 2
TEAMModelOS/ClientApp/src/components/questionnaire/BaseJudge.vue

@@ -10,8 +10,7 @@
 				<div v-for="(item,index) in options" :key="index" class="option-editor-wrap" style="margin-top:10px;display:flex">
 					<span class="fl-center option-order">{{String.fromCharCode(64 + parseInt(index+1))}}</span>
 					<div :ref="'singleOption'+item" style="text-align:left" class="option-editor" @click="optionClick(item)"></div>
-					<!-- <span :class="['fl-center', 'option-setting', trueIndex === index ? 'option-true':'']" @click="settingAnswer(index)">{{ trueIndex === index ? '正确答案' :'设为答案' }}</span>
-					<span class="fl-center option-delete" @click="deleteOption(index)"><Icon type="ios-close-circle" /></span> -->
+					<span class="fl-center option-delete" @click="deleteOption(index)"><Icon type="md-close" /></span>
 				</div>
 			</div>
             <p class="option-add"><span @click="addOption()">+ 添加选项 </span></p>

+ 1 - 2
TEAMModelOS/ClientApp/src/components/questionnaire/BaseMultiple.vue

@@ -10,8 +10,7 @@
 				<div v-for="(item,index) in options" :key="index" class="option-editor-wrap" style="margin-top:10px;display:flex">
 					<span class="fl-center option-order">{{String.fromCharCode(64 + parseInt(index+1))}}</span>
 					<div :ref="'singleOption'+item" style="text-align:left" class="option-editor" @click="optionClick(item)"></div>
-					<!-- <span :class="['fl-center', 'option-setting', trueIndex === index ? 'option-true':'']" @click="settingAnswer(index)">{{ trueIndex === index ? '正确答案' :'设为答案' }}</span>
-					<span class="fl-center option-delete" @click="deleteOption(index)"><Icon type="ios-close-circle" /></span> -->
+					<span class="fl-center option-delete" @click="deleteOption(index)"><Icon type="md-close" /></span>
 				</div>
 			</div>
             <p class="option-add"><span @click="addOption()">+ 添加选项 </span></p>

+ 0 - 2
TEAMModelOS/ClientApp/src/components/questionnaire/BaseQuestionnaire.vue

@@ -88,7 +88,6 @@
 </template>
 <script>
 	import draggable from "vuedraggable"
-	import BaseAddItem from "./BaseAddItem.vue"
 	import BaseSingle from "./BaseSingle.vue"
 	import BaseMultiple from "./BaseMultiple.vue"
 	import BaseJudge from "./BaseJudge.vue"
@@ -97,7 +96,6 @@
 	export default {
 		components: {
 			draggable,
-			BaseAddItem,
 			BaseQnBar,
 			BaseSingle,
 			BaseMultiple,

+ 6 - 0
TEAMModelOS/ClientApp/src/components/questionnaire/BaseSingle.less

@@ -33,6 +33,12 @@
 			min-height: 200px;
 		}
 		
+		.option-delete{
+			margin: 7px 10px;
+			font-size: 18px;
+			color: #bfbfbf;
+		}
+		
 		.option-add{
 			float: right;
 			margin-top: 20px;

+ 2 - 2
TEAMModelOS/ClientApp/src/components/questionnaire/BaseSingle.vue

@@ -10,8 +10,8 @@
 				<div v-for="(item,index) in options" :key="index" class="option-editor-wrap" style="margin-top:10px;display:flex">
 					<span class="fl-center option-order">{{String.fromCharCode(64 + parseInt(index+1))}}</span>
 					<div :ref="'singleOption'+item" style="text-align:left" class="option-editor" @click="optionClick(item)"></div>
-					<!-- <span :class="['fl-center', 'option-setting', trueIndex === index ? 'option-true':'']" @click="settingAnswer(index)">{{ trueIndex === index ? '正确答案' :'设为答案' }}</span>
-					<span class="fl-center option-delete" @click="deleteOption(index)"><Icon type="ios-close-circle" /></span> -->
+					<!-- <span :class="['fl-center', 'option-setting', trueIndex === index ? 'option-true':'']" @click="settingAnswer(index)">{{ trueIndex === index ? '正确答案' :'设为答案' }}</span> -->
+					<span class="fl-center option-delete" @click="deleteOption(index)"><Icon type="md-close" /></span>
 				</div>
 			</div>
             <p class="option-add"><span @click="addOption()">+ 添加选项 </span></p>