Commit 82d4af61 authored by 李苏's avatar 李苏 💬

多选转化bug

parent 059dafaa
<template> <template>
<RelDialog :type='type' :editApp='editApp' :app='app' :buttonApp='buttonApp'> <RelDialog :type='type' :editApp='editApp' :app='app' :buttonApp='buttonApp'>
<!-- 填写表单内容,slot=form必写--> <!-- 填写表单内容,slot=form必写-->
<el-form slot="form" ref="form" :model="form" label-width="80px" :rules="rules"> <el-form slot="form" ref="form" :model="form" label-width="80px" :rules="rules">
<el-row :gutter="20"> <el-col :span="24"> <el-form-item label="题目 " ref="cont" prop="cont"> <el-input :readonly="readonly" v-model="form.cont"></el-input> <el-row :gutter="20"> <el-col :span="24"> <el-form-item label="题目 " ref="cont" prop="cont"> <el-input :readonly="readonly" v-model="form.cont"></el-input>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20" v-show="this.form.type=='S'||this.form.type=='M'" > <el-col :span="12"> <el-row :gutter="20" v-show="this.form.type=='S'||this.form.type=='M'" > <el-col :span="12">
<el-form-item label="选项A" ref="opta" prop="opta"> <el-form-item label="选项A" ref="opta" prop="opta">
<el-input :readonly="readonly" v-model="form.opta"></el-input> </el-form-item> </el-col> <el-input :readonly="readonly" v-model="form.opta"></el-input> </el-form-item> </el-col>
...@@ -50,15 +50,47 @@ ...@@ -50,15 +50,47 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="答案" ref="ans" prop="ans"> <el-form-item v-show="this.form.type" label="答案" ref="ans" prop="ans">
<el-input :readonly="readonly" v-model="form.ans"></el-input> <!-- <el-input :readonly="readonly" v-model="form.ans"></el-input> -->
<!-- 填空题-->
<el-input v-show="this.form.type=='F'" type="textarea" :readonly="readonly" v-model="form.ans"></el-input>
<!-- 单选题-->
<el-select style="width: 100%;" v-show="this.form.type=='S'" v-model="form.ans" placeholder="请选择">
<el-option
v-for="item in soptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<!-- 判断题-->
<el-select style="width: 100%;" v-show="this.form.type=='J'" v-model="form.ans" placeholder="请选择">
<el-option
v-for="item in joptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<!-- 多选题-->
<TransSelect v-if="this.form.type=='M'" v-model="form.ans" />
<!-- <el-select style="width: 100%;" multiple v-model="form.ans" placeholder="请选择">
<el-option
v-for="item in moptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select> -->
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="24"> <el-col :span="24">
<el-form-item label="答案描述" ref="desc" prop="desc"> <el-form-item label="答案描述" ref="desc" prop="desc">
<el-input type="textarea" :readonly="readonly" v-model="form.desc"></el-input> <el-input type="textarea" :readonly="readonly" v-model="form.desc"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
...@@ -70,7 +102,8 @@ ...@@ -70,7 +102,8 @@
</el-form> </el-form>
</RelDialog> </RelDialog>
</template> </template>
<script> <script>
import TransSelect from './transSelect.vue'
import { import {
editMixin editMixin
} from 'common' } from 'common'
...@@ -78,14 +111,44 @@ ...@@ -78,14 +111,44 @@
mixins: [editMixin], mixins: [editMixin],
/* 存放index页面传递的额外参数*/ /* 存放index页面传递的额外参数*/
mounted() { mounted() {
/* form.ans拦截*/
}, },
/* 组件名称*/ /* 组件名称*/
name: "pxglPxstEdit", name: "pxglPxstEdit",
/* 传递props模式一样必填,用于index,button,REdialog之间的组件通信*/ /* 传递props模式一样必填,用于index,button,REdialog之间的组件通信*/
computed:{
typess(){
return this.form.type
}
},
watch:{
typess(){
if(this.type=='add'){
this.form.ans=''
}
}
},
data() { data() {
return { return {
// moptions:[
// {value:'A',label:'A'},
// {value:'B',label:'B'},
// {value:'C',label:'C'},
// {value:'D',label:'D'},
// {value:'E',label:'E'},
// {value:'F',label:'F'}
// ],
mtrans:'',
soptions:[
{value:'A',label:'A'},
{value:'B',label:'B'},
{value:'C',label:'C'},
{value:'D',label:'D'}
],
joptions:[
{value:'A',label:'正确'},
{value:'B',label:'错误'},
],
/* 额外初始化,根据需求*/ /* 额外初始化,根据需求*/
systemType: [], systemType: [],
...@@ -133,10 +196,14 @@ ...@@ -133,10 +196,14 @@
required: true required: true
}, ], }, ],
ans: [{ ans: [{
required: true required: true,
message: '请填写答案'
}, ] }, ]
} }
} }
},
components:{
TransSelect
}, },
methods: { methods: {
......
<template>
<el-select @change='change' style="width: 100%;" v-model="newValue" multiple placeholder="请选择">
<el-option
v-for="item in moptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
<script>
export default {
props:['value'],
watch:{
'value':{
handler: function (val) {
if(val){
this.newValue=val.split(',')
}
},
deep:true,
// 立即以obj.name的当前值触发回调
immediate: true
},
// value(val){
// console.log(val,'val改变')
// if(val){
// if(typeof val!='object')
// this.newValue=val.split(',')
// }
// }
},
data(){
return{
newValue:'',
moptions:[
{value:'A',label:'A'},
{value:'B',label:'B'},
{value:'C',label:'C'},
{value:'D',label:'D'},
{value:'E',label:'E'},
{value:'F',label:'F'}
],
}
},
methods:{
change(val){
console.log(this.value)
let value= val.sort((s1, s2)=>{
let a1 = s1.toUpperCase();
let a2 = s2.toUpperCase();
if (a1 < a2) {
return -1;
}
if (a1 > a2) {
return 1;
}
return 0;
}).join(',')
this.$emit('input',value)
}
}
}
</script>
<style>
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment