Browse Source

第三次

master
xiezhenghui 4 years ago
parent
commit
b22539aed9

+ 24
- 1
src/api/data.js View File

@@ -10,7 +10,30 @@ export const getTableData = () => {
10 10
 export const getDragList = () => {
11 11
   return axios.request({
12 12
     url: 'get_drag_list',
13
-    method: 'get'
13
+    method: 'get' 
14
+  })
15
+}
16
+
17
+
18
+export const newsAdd = ({params}) => {
19
+  console.log(params)
20
+  return  axios.request({
21
+    url: 'news/add',
22
+    params,
23
+    method: 'post'
24
+  })
25
+}
26
+
27
+export const getInfoList = () => {
28
+  return axios.request({
29
+    url: 'newstype/list',
30
+    method: 'post'
31
+  })
32
+}
33
+export const getLabelList = () => {
34
+  return axios.request({
35
+    url: 'newstag/list',
36
+    method: 'post'
14 37
   })
15 38
 }
16 39
 

BIN
src/assets/viedo.jpg View File


+ 3
- 3
src/components/editor/editor.vue View File

@@ -54,7 +54,7 @@ export default {
54 54
     this.editor = new Editor(`#${this.editorId}`)
55 55
     this.editor.customConfig.onchange = (html) => {
56 56
       let text = this.editor.txt.text()
57
-      if (this.cache) localStorage.editorCache = html
57
+      // if (this.cache) localStorage.editorCache = html
58 58
       this.$emit('input', this.valueType === 'html' ? html : text)
59 59
       this.$emit('on-change', html, text)
60 60
     }
@@ -62,8 +62,8 @@ export default {
62 62
     // create这个方法一定要在所有配置项之后调用
63 63
     this.editor.create()
64 64
     // 如果本地有存储加载本地存储内容
65
-    let html = this.value || localStorage.editorCache
66
-    if (html) this.editor.txt.html(html)
65
+    // let html = this.value || localStorage.editorCache
66
+    // if (html) this.editor.txt.html(html)
67 67
   }
68 68
 }
69 69
 </script>

+ 2
- 1
src/locale/lang/en-US.js View File

@@ -45,5 +45,6 @@ export default {
45 45
   tree_select_page: 'Tree Selector',
46 46
   organ:'分机构统计',
47 47
   organ_admin:'分机构管理',
48
-  organ_mon:'月报'
48
+  organ_mon:'月报',
49
+  test:"试题"
49 50
 }

+ 2
- 1
src/locale/lang/zh-CN.js View File

@@ -45,5 +45,6 @@ export default {
45 45
   tree_select_page: '树状下拉选择器',
46 46
   organ:'分机构统计',
47 47
   organ_admin:'分机构管理',
48
-  organ_mon:'月报'
48
+  organ_mon:'月报',
49
+  test:"试题"
49 50
 }

+ 2
- 1
src/locale/lang/zh-TW.js View File

@@ -45,5 +45,6 @@ export default {
45 45
   tree_select_page: '樹狀下拉選擇器',
46 46
   organ:'分机构统计',
47 47
   organ_admin:'分机构管理',
48
-  organ_mon:'月报'
48
+  organ_mon:'月报',
49
+  test:"试题"
49 50
 }

+ 9
- 0
src/router/routers.js View File

@@ -72,6 +72,15 @@ export default [
72 72
           title: '月报'
73 73
         },
74 74
         component: () => import('@/view/organ_admin/info/info.vue')
75
+      },
76
+      {
77
+        path: 'test',
78
+        name: 'test',
79
+        meta: {
80
+          icon: 'ios-paper',
81
+          title: '试题'
82
+        },
83
+        component: () => import('@/view/organ_admin/test/test.vue')
75 84
       }
76 85
     ]
77 86
   }, 

+ 11
- 1
src/store/module/user.js View File

@@ -18,6 +18,7 @@ export default {
18 18
     avatarImgPath: '',
19 19
     token: getToken(),
20 20
     access: '',
21
+    $userList:{},
21 22
     hasGetInfo: false,
22 23
     unreadCount: 0,
23 24
     messageUnreadList: [],
@@ -54,6 +55,9 @@ export default {
54 55
     setMessageReadedList (state, list) {
55 56
       state.messageReadedList = list
56 57
     },
58
+    set$userList (state, obj) {
59
+      state.$userList = obj
60
+    },
57 61
     setMessageTrashList (state, list) {
58 62
       state.messageTrashList = list
59 63
     },
@@ -81,11 +85,16 @@ export default {
81 85
           loginname,
82 86
           loginpwd
83 87
         }).then(res => {
84
-          const data = res.data.obj
88
+          // console.log(res.data)
89
+          const data = res.data.obj[0];
90
+          var { token,userid,edid,schoolid,createid }=res.data.obj[0];
91
+          var obj={token,userid,edid,schoolid,createid};
92
+          // console.log(obj)
85 93
           // console.log(data)
86 94
           commit('setToken', data.token)
87 95
           commit('setUserName', data.username)
88 96
           commit('setUserId', data.userid)
97
+          commit('set$userList', obj)
89 98
           resolve()
90 99
         }).catch(err => {
91 100
           reject(err)
@@ -98,6 +107,7 @@ export default {
98 107
         logout(state.token).then(() => {
99 108
           commit('setToken', '')
100 109
           commit('setAccess', [])
110
+          commit('set$userList', {})
101 111
           resolve()
102 112
         }).catch(err => {
103 113
           reject(err)

+ 2
- 1
src/view/components/editor/editor.vue View File

@@ -18,7 +18,8 @@ export default {
18 18
   },
19 19
   methods: {
20 20
     handleChange (html, text) {
21
-      console.log(html)
21
+      var obj={html,text}
22
+      this.$emit('func',obj)
22 23
     }
23 24
   }
24 25
 }

+ 32
- 2
src/view/organ_admin/info/info.less View File

@@ -1,7 +1,17 @@
1 1
 .istop{
2 2
     display: inline-block;
3 3
     width: 200px;
4
-   margin-left: 20px;
4
+    margin-left: 20px;
5
+    
6
+}
7
+.sort{
8
+    display: inline-block;
9
+    width: 167px;
10
+    .sort-div{
11
+        display: flex;
12
+        justify-content: space-between;
13
+        align-items: center;
14
+    }
5 15
 }
6 16
 div /deep/ .ivu-form-item{
7 17
     margin-bottom: 10px;
@@ -25,9 +35,29 @@ div /deep/ .ivu-form-item{
25 35
             display: flex;
26 36
             justify-content: center;
27 37
             align-items: center;
28
-            padding: 120px;
38
+            width: 300px;
39
+            height: 300px;
29 40
             border: 1px dashed #E9E9E9;
30 41
             border-radius: 6px;
42
+            overflow: hidden;
43
+            .video-div{
44
+                display: flex;
45
+                flex-direction: column;
46
+                justify-content: center;
47
+                align-items: center;
48
+                & img {
49
+                    width: 200px;
50
+                    height: 200px;
51
+                    border-radius: 10px;
52
+                }
53
+                & span {
54
+                    font-size: 16px;
55
+                }
56
+            }
57
+            .imgActive{
58
+                width: 100%;
59
+                max-height: 296px;
60
+            }
31 61
         }
32 62
     }
33 63
 }

+ 148
- 31
src/view/organ_admin/info/info.vue View File

@@ -2,62 +2,92 @@
2 2
   <div>
3 3
     <Form label-position="left" :label-width="40">
4 4
         <FormItem label="标题">
5
-            <Input></Input>
5
+            <Input v-model="ntitle"></Input>
6 6
         </FormItem>
7 7
         <FormItem label="分类">
8
-          <Select v-model="select" style="width:180px">
9
-              <Option v-for="(item,index) in selectList" :value="item.id" :key="index">{{ item.title }}</Option>
8
+          <Select v-model="selectInfo" style="width:180px">
9
+              <Option v-for="(info,index) in infoList" :value="info.ntypeid" :key="index">{{ info.ntypename }}</Option>
10 10
           </Select>
11 11
           <div class="istop">
12 12
             <FormItem label="是否置顶"  :label-width="60">
13 13
               <RadioGroup v-model="radio">
14
-                  <Radio label="notop">不置顶</Radio>
15
-                  <Radio label="istop">置顶</Radio>
14
+                  <Radio label="0">不置顶</Radio>
15
+                  <Radio label="1">置顶</Radio>
16 16
               </RadioGroup>
17 17
             </FormItem>
18 18
           </div>
19
+          <!-- <span v-if="radio==1" class="sort">
20
+            <FormItem label="排序"  :label-width="40">
21
+              <Input v-model="sort">
22
+                <Button @click="sortcut"  slot="prepend">-</Button>
23
+                <Button @click="sortadd" slot="append">+</Button>
24
+              </Input>
25
+            </FormItem>
26
+          </span> -->
27
+          <div v-show="radio==1" class="sort">
28
+            <div class="sort-div">
29
+              <span>排序</span>
30
+              <Input v-model="sort" type="text" style="width:130px">
31
+                <Button @click="sortcut"  slot="prepend">-</Button>
32
+                <Button @click="sortadd" slot="append">+</Button>
33
+              </Input>
34
+            </div>
35
+          </div>
19 36
           <div class="istop">
20 37
             <FormItem label="是否广告位"  :label-width="80" inline>
21 38
               <RadioGroup v-model="poster">
22
-                  <Radio label="noPoster">否</Radio>
23
-                  <Radio label="isPoster">是</Radio>
39
+                  <Radio label="0">否</Radio>
40
+                  <Radio label="1">是</Radio>
24 41
               </RadioGroup>
25 42
             </FormItem>
26 43
           </div>
27 44
         </FormItem>
28 45
         <FormItem label="标签">
29
-            <Input  style="width:420px"></Input>
46
+            <!-- <Input  style="width:420px"></Input> -->
47
+          <Select v-model="selectLabel" multiple :max-tag-count="3" :max-tag-placeholder="maxTagPlaceholder" style="width:420px">
48
+              <Option v-for="(label,i) in labelList" :value="label.ntagname" :key="i">{{ label.ntagname }}</Option>
49
+          </Select>
30 50
         </FormItem>
31 51
     </Form>
32 52
     <div>
33 53
       <div>
34 54
         <div>咨讯内容</div>
35
-          <paste-editor></paste-editor>
55
+          <paste-editor @func="getObjFormSon"></paste-editor>
36 56
       </div>
37 57
     </div>
38 58
     <div class="upLoad">
39 59
       <div class="upLoad-div">
40 60
         <span>封面图<span class="upLoad-size">(建议图片尺寸:840 x 400)</span></span>
41
-        <Upload class="upLoad-border" :before-upload="handleUpload" action="//jsonplaceholder.typicode.com/posts/" >
61
+        <Upload  
62
+          :before-upload="handleImgUpload" 
63
+          action="//jsonplaceholder.typicode.com/posts/"
64
+          class="upLoad-border" >
42 65
             <div>
43
-              <Icon type="md-add" size="52" style="color: #3399ff"></Icon>
66
+              <img v-if="imgAcitve" :src="imgAcitve.result" class="imgActive">
67
+              <Icon v-else type="md-add" size="52" style="color: #3399ff"></Icon>
44 68
             </div>
45 69
         </Upload>
46 70
       </div>
47 71
       <div class="upLoad-div">
48 72
         <span>视频</span>
49
-        <Upload class="upLoad-border" action="//jsonplaceholder.typicode.com/posts/">
50
-            <div>
51
-              <Icon type="md-add" size="52" style="color: #3399ff"></Icon>
52
-            </div>
73
+        <Upload 
74
+          :before-upload="handleVideoUpload" 
75
+          :format="['mp4']"
76
+          action="//jsonplaceholder.typicode.com/posts/"
77
+          class="upLoad-border" >
78
+          <div v-if="videoName" class="video-div">
79
+            <img src="../../../assets/viedo.jpg">
80
+            <span>{{videoName}}</span>
81
+          </div>
82
+          <Icon v-else type="md-add" size="52" style="color: #3399ff"></Icon>
53 83
         </Upload>
54 84
       </div>
55 85
     </div>
56
-    <Button size="large" type="primary">完成</Button>
57
-    <img :src="logoPreview" alt="">
86
+    <Button size="large" @click="submit" type="primary">完成</Button>
58 87
   </div>
59 88
 </template>
60 89
 <script>
90
+import { getInfoList,getLabelList,newsAdd } from '@/api/data'
61 91
 import pasteEditor from "../../components/editor/editor.vue"
62 92
 export default {
63 93
   name: 'info',
@@ -66,28 +96,115 @@ export default {
66 96
   },
67 97
   data(){
68 98
     return {
69
-      selectList:[
70
-        {id:1,title:"时事"},
71
-        {id:2,title:"最新"},
72
-        {id:3,title:"国家"},
73
-        {id:4,title:"教育"}
74
-      ],
75
-      select:"",
76
-      radio:"notop",
77
-      poster:"noPoster",
78
-      logoPreview:''
99
+      infoList:[], // 分类列表
100
+      selectInfo:"", // 选中分类
101
+      labelList:[],  //标签列表
102
+      selectLabel: [],  // 选中标签
103
+      radio:"0",  // 是否置顶
104
+      poster:"0",  // 是否广告
105
+      sort:9999,  // 置顶排序
106
+      imgAcitve:'',  // 预览图片路径
107
+      videoAcitve:'',  // 选中视频信息
108
+      videoName:'',  // 选中视频名
109
+      ntitle:'',  // 标题
110
+      oldActiveImg:'',
111
+      objFormSon:{}
112
+    }
113
+  },
114
+  watch:{
115
+    selectLabel(){
116
+      this.selectLabel.toString()
79 117
     }
80 118
   },
119
+  created(){
120
+    // 获取分类列表
121
+    getInfoList().then(res=>{
122
+      if(res.status==200){
123
+        this.infoList=res.data.obj;
124
+      }
125
+    }),
126
+    // 获取标签列表
127
+    getLabelList().then(res=>{
128
+      if(res.status==200){
129
+        this.labelList=res.data.obj;
130
+      }
131
+    })
132
+  },
81 133
   methods:{
82
-    handleUpload(file){
83
-      this.file = file
134
+    getObjFormSon(data){
135
+      this.objFormSon = data
136
+      console.log(this.objFormSon)
137
+    },
138
+    // 提交咨讯添加
139
+    submit(){
140
+      var ntitle=this.ntitle;
141
+      var ntypeid=this.selectInfo;
142
+      var nistop=this.radio;
143
+      var norder=nistop==1?this.sort:'';
144
+      var ntagname="{"+this.selectLabel.toString()+"}";
145
+      var ncover=this.oldActiveImg.name;
146
+      var nvideo=this.videoAcitve.name;
147
+      var nvsize=this.videoAcitve.size;
148
+      var nvsuffix=this.videoAcitve.type;
149
+      var ncontent=this.objFormSon.html;
150
+      var ncontxt=this.objFormSon.text;
151
+      var {token,userid,edid,schoolid,createid}=this.$store.state.user.$userList;
152
+      var device="web"
153
+      // var {edid,schoolid,createid}=userList;
154
+      // console.log(edid,schoolid,createid)+
155
+
156
+      var params={device,userid,token,ntitle,ntypeid,nistop,norder,ntagname,ncover,nvideo,nvsize,nvsuffix,ncontent,ncontxt,edid,schoolid,createid};
157
+      console.log(params)
158
+      if(params){
159
+        newsAdd(params).then(res=>{
160
+          console.log(res.data)
161
+          if(res.status==200){
162
+            this.labelList=res.data.obj;
163
+          }
164
+        })
165
+      }
166
+      // console.log(ntitle,ntypeid,nistop,norder,ntagname,ncover,nvideo,nvsize,nvsuffix,ncontent,ncontxt,edid,schoolid,createid)
167
+    },
168
+    // 标签隐藏
169
+    maxTagPlaceholder (num) {
170
+      return 'more '+ num;
171
+    },
172
+    // 选中图片文件
173
+    handleImgUpload(file){
174
+      this.oldActiveImg = file
175
+      // console.log(this.oldActiveImg)
84 176
       const reader = new FileReader()
85 177
       reader.readAsDataURL(file)
86 178
         reader.onload = () => {
87
-          const _base64 = reader.result
88
-          this.logoPreview = _base64
179
+          const _base64 = reader;
180
+          this.imgAcitve = _base64;
89 181
         }
90 182
       return false;
183
+    },
184
+    // 选中视频文件
185
+    handleVideoUpload(file){
186
+      this.videoAcitve=file;
187
+      console.log(file)
188
+      this.videoName=file.name;
189
+      return false;
190
+    },
191
+    // 置顶排序 +
192
+    sortadd(){
193
+      var sort=this.sort+1;
194
+      if(sort<9999){
195
+        this.sort=sort;
196
+      }else{
197
+        this.sort=9999
198
+      }
199
+    },
200
+    // 置顶排序 -
201
+    sortcut(){
202
+      var sort=this.sort-1;
203
+      if(sort>1){
204
+        this.sort=sort;
205
+      }else{
206
+        this.sort=1;
207
+      }
91 208
     }
92 209
   }
93 210
 }

+ 40
- 0
src/view/organ_admin/test/components/exercise/exercise.vue View File

@@ -0,0 +1,40 @@
1
+<template>
2
+  <div>
3
+    <div>
4
+      <span>题干:</span><input type="text" v-model="title">
5
+    </div>
6
+    <div>
7
+      <span>答案:</span><input type="text" v-model="key">
8
+    </div>
9
+    <Button @click="add">提交</Button>
10
+  </div>
11
+</template>
12
+<script>
13
+export default {
14
+  data(){
15
+    return {
16
+      title:"",
17
+      key:""
18
+    }
19
+  },
20
+  methods:{
21
+    add(){
22
+      var title=this.title;
23
+      if(!title){
24
+        this.$Message.warning('请输入题干内容');
25
+        return;
26
+      }
27
+      var key=this.key;
28
+      if(!key){
29
+        this.$Message.warning('请输入答案内容');
30
+        return;
31
+      }
32
+      var exercise={
33
+        title,
34
+        key
35
+      }
36
+      this.$emit('exercise',exercise);
37
+    }
38
+  }
39
+}
40
+</script>

+ 38
- 0
src/view/organ_admin/test/components/gestalts/gestalts.less View File

@@ -0,0 +1,38 @@
1
+.radio-div{
2
+  display: flex;
3
+  justify-content: space-around;
4
+}
5
+.select-input{
6
+  width: 130px;
7
+}
8
+.radio-div-text{
9
+  display: flex;
10
+  margin-right: 10px;
11
+  .radio-text{
12
+    width: 168px;
13
+  }
14
+}
15
+.div-border{
16
+  padding: 4px 0;
17
+  border: 1px solid #ffffff;
18
+}
19
+.div-border:hover{
20
+  .select-fun{
21
+    display:inline-block;
22
+  }
23
+}
24
+.show-border{
25
+  border: 1px solid rgb(47, 128, 221);
26
+}
27
+.select-fun-hove{
28
+  display: inline-block;
29
+}
30
+.select-fun{
31
+  display: none;
32
+  & span{
33
+    background-color: rgb(47, 128, 221);
34
+    padding: 5px;
35
+    color: #ffffff;
36
+    border-radius: 2px;
37
+  }
38
+}

+ 215
- 0
src/view/organ_admin/test/components/gestalts/gestalts.vue View File

@@ -0,0 +1,215 @@
1
+<template>
2
+  <div>
3
+    <!-- 题干内容 star -->
4
+    <div>
5
+      <span>题干:</span><input type="text" v-model="title">
6
+    </div>
7
+    <!-- 题干内容 end -->
8
+
9
+    <!-- 小题选项区域 star -->
10
+    <div v-for="(questions,index) in s_questions" :key="index" class="div-border" :class="{'show-border':!questions.show}">
11
+      <!-- 小题编号star -->
12
+      <span>({{index+1}})</span>
13
+      <!-- 小题编号end -->
14
+
15
+      <!-- 小题选项star -->
16
+      <RadioGroup v-model="questions.labelActive">
17
+        <div class="radio-div">
18
+          <div class="radio-div-text" v-for="(chart,i) in char" :key="i">
19
+            <div v-if="questions.show" class="radio-text">
20
+              <span>{{chart}}.</span>
21
+              <span>{{questions.obj[chart]}}</span>
22
+            </div>
23
+            <div v-else>
24
+              <!-- 单选标记star -->
25
+              <Radio :label="chart">{{chart}}.</Radio>
26
+              <!-- 单选标记end -->
27
+              <!-- <span>{{chart}}.</span> -->
28
+              <!-- 单选输入框star -->
29
+              <input type="text" class="select-input" v-model="questions.obj[chart]">
30
+              <!-- 单选输入框end -->
31
+            </div>
32
+          </div>
33
+        </div>
34
+      </RadioGroup>
35
+      <!-- 小题选项end -->
36
+      <div class="select-fun" :class="{'select-fun-hove':questions.show}">
37
+        <span  v-show="questions.show" @click="zIndexUp(index)">向上</span>
38
+        <span  v-show="questions.show" @click="zIndexDown(index)">向下</span>
39
+        <span  v-show="questions.show" @click="edit(index)">编辑</span>
40
+        <span v-show="!questions.show" @click="preserve(index)">保存</span>
41
+        <span @click="del(index)">删除</span>
42
+      </div>
43
+    </div>
44
+    <!-- 小题选项区域 end -->
45
+
46
+
47
+    <div>
48
+      <Button @click="addQuestions">添加小题</Button>
49
+    </div>
50
+      <Button @click="add">提交</Button>
51
+  </div>
52
+</template>
53
+<script>
54
+export default {
55
+  data(){
56
+    return {
57
+      title:"",  // 题干
58
+      char:["A","B","C","D"],  // 小题选项
59
+      s_questions:[],  // 小题选项列表
60
+      index:"",
61
+      clear:false
62
+    }
63
+  },
64
+  watch:{
65
+    clear(){
66
+      var modal=this.modal
67
+      console.log(modal)
68
+      if(this.modal==false){
69
+        localStorage.clear();
70
+      }
71
+    }
72
+  },
73
+  // 挂载结束后触发
74
+  mounted(){
75
+    var local=localStorage.getItem('gestList')
76
+    if(!local){
77
+      // 触发一行小题选项
78
+      var arr=[];
79
+      // 创建一个空对象
80
+      var obj={};
81
+      // 创建一个小题选项答案为空
82
+      var data={};
83
+      var show=false;
84
+      var labelActive="";
85
+      // 循环小题选项 this.char
86
+      for(var char in this.char){
87
+        obj[this.char[char]]=""
88
+      }
89
+      data={
90
+        obj,
91
+        labelActive,
92
+        show
93
+      }
94
+      this.s_questions.push(data);
95
+    }else{
96
+      console.log(999)
97
+      var questions=JSON.parse(local);
98
+      this.s_questions=questions.list.questions;
99
+      this.title=questions.list.title
100
+      console.log(this.s_questions)
101
+      this.index=questions.index
102
+    }
103
+  },
104
+  methods:{
105
+    // 首次加载
106
+    swapArray(arr, index1, index2) {
107
+      this.s_questions[index1] = this.s_questions.splice(index2, 1, arr[index1])[0];
108
+        return this.s_questions;
109
+    },
110
+    zIndexDown(index){
111
+      var arr=this.s_questions;
112
+      var length=this.s_questions.length;
113
+      if(index+1 != length){
114
+          arr=this.swapArray(arr, index, index+1);
115
+          this.s_questions=arr
116
+      }else{
117
+        this.$Message.warning('已经处于置底,无法下移');
118
+      }
119
+    },
120
+    zIndexUp(index){
121
+      var arr=this.s_questions;
122
+      var length=this.s_questions.length;
123
+      if(index!= 0){
124
+          arr=this.swapArray(arr, index, index-1);
125
+          this.s_questions=arr
126
+      }else{
127
+        this.$Message.warning('已经处于置顶,无法上移');
128
+      }
129
+    },
130
+    edit(i){
131
+      var questions=this.s_questions;
132
+      for(var list in questions){
133
+        if(questions[list].labelActive==""||questions[list].show==false){
134
+          this.$Message.warning('尚有小题未保存');
135
+          return; 
136
+        }
137
+      }
138
+      this.s_questions[i].show=false
139
+    },
140
+    preserve(i){
141
+      if(this.s_questions[i].labelActive==""){
142
+        this.$Message.warning('未选择正确项');
143
+        return;
144
+      }
145
+      this.s_questions[i].show=true
146
+    },
147
+    del(i){
148
+      this.s_questions.splice(i,1)
149
+    },
150
+    // 提交试题
151
+    add(){
152
+      var uid=this.index;
153
+      var title=this.title;
154
+      if(title==""){
155
+        this.$Message.warning('题干未填写');
156
+        return;
157
+      }
158
+      var questions=this.s_questions;
159
+      if(questions.length==0){
160
+        this.$Message.warning('小题未填写');
161
+        return;
162
+      }
163
+      for(var list in questions){
164
+        if(questions[list].labelActive==""||questions[list].show==false){
165
+          this.$Message.warning('尚有小题未保存');
166
+          return; 
167
+        }
168
+      }
169
+      var gestalts={
170
+        title,
171
+        questions,
172
+        uid
173
+      }
174
+      // console.log(gestalts)
175
+      this.$emit('gestalts',gestalts)
176
+    },
177
+    // 添加一行小题选项
178
+    addQuestions(){
179
+      // 创建一个空数组
180
+      var arr=[];
181
+      // 创建一个空对象
182
+      var obj={};
183
+      var show=false;
184
+      // 创建一个小题选项答案为空
185
+      var data={};
186
+      var labelActive="";
187
+      for(var label in this.s_questions){
188
+        // console.log(this.s_questions)
189
+        if(this.s_questions[label].labelActive==""||this.s_questions[label].show==false){
190
+          // console.log(1)
191
+          
192
+          this.$Message.warning('尚有小题未保存');
193
+          return;
194
+        }
195
+      }
196
+      // 循环小题选项 this.char
197
+      for(var char in this.char){
198
+        obj[this.char[char]]=""
199
+      }
200
+      data={
201
+        obj,
202
+        labelActive,
203
+        show
204
+      }
205
+      // arr.push(data)
206
+      this.s_questions.push(data);
207
+      // console.log(arr)
208
+      // console.log(this.s_questions)
209
+    }
210
+  }
211
+}
212
+</script>
213
+<style lang="less">
214
+  @import './gestalts';
215
+</style>

+ 75
- 0
src/view/organ_admin/test/components/question/question.vue View File

@@ -0,0 +1,75 @@
1
+<template>
2
+  <div>
3
+    <!-- 题干 -->
4
+    <div>
5
+      <span>题干:</span><input v-model="title" type="text">
6
+    </div>
7
+    <!-- 题干结束 -->
8
+    <div>
9
+      <div v-for="(cont,index) in content" :key="index">
10
+        <span>{{char[index]}}</span>.<input v-model="charList[index]" type="text">
11
+      </div>
12
+      <Button @click="addContent">添加选项</Button>
13
+      <Button @click="delContent">删除选项</Button>
14
+    </div>
15
+    <div>
16
+      <RadioGroup v-model="labelActive">
17
+        <Radio v-for="(cont,index) in content" :key="index" :label="char[index]"></Radio>
18
+      </RadioGroup>
19
+    </div>
20
+    <div>
21
+      <Button @click="add">提交</Button>
22
+    </div>
23
+  </div>
24
+</template>
25
+<script>
26
+export default {
27
+  data(){
28
+    return {
29
+      title:"",
30
+      char:["A","B","C","D","E","F","G","H","I","J","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],
31
+      content:[0,1,2,3],
32
+      charList:[],
33
+      labelActive:""
34
+    }
35
+  },
36
+  methods:{
37
+    add(){
38
+      var title=this.title;
39
+      if(!title){
40
+        this.$Message.warning('请输入题干内容');
41
+        return;
42
+      }
43
+      var selectObj={}
44
+      for(var obj in this.content){
45
+        selectObj[this.char[obj]]=this.charList[obj]
46
+      }
47
+      var labelActive=this.labelActive;
48
+      if(!labelActive){
49
+        this.$Message.warning('请选择答案选项');
50
+        return;
51
+      }
52
+      var question={
53
+        title,
54
+        selectObj,
55
+        labelActive
56
+      };
57
+      this.$emit('question',question);
58
+      this.title="";
59
+      this.labelActive="";
60
+      this.charList=[];
61
+      this.content=[0,1,2,3]
62
+    },
63
+    addContent(){
64
+      this.content.push(this.content.length);
65
+    },
66
+    delContent(){
67
+      if(this.content.length>2){
68
+        this.content.pop()
69
+      }else{
70
+        this.$Message.warning('至少保留两个选项');
71
+      }
72
+    }
73
+  }
74
+}
75
+</script>

+ 131
- 0
src/view/organ_admin/test/test.vue View File

@@ -0,0 +1,131 @@
1
+<template>
2
+  <div>
3
+    <Button @click="modal = true">添加试卷</Button>
4
+    <Modal
5
+        width="980"
6
+        v-model="modal"
7
+        title="试题上传"
8
+        @on-ok="ok"
9
+        @on-cancel="cancel">
10
+        <div>
11
+          <Select v-model="select" style="width:200px">
12
+            <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
13
+          </Select>
14
+          <div>
15
+            <question @question="getquestion" v-if="select==1"></question>
16
+            <exercise @exercise="getexercise" v-if="select==2"></exercise>
17
+            <gestalts @gestalts="getGestalts" v-if="select==3"></gestalts>
18
+          </div>
19
+        </div>
20
+        <div slot="footer"></div>
21
+    </Modal>
22
+    <div v-show="getGestaltList.length>0">
23
+      一.单选题
24
+      <div v-for="(gest,i) in getGestaltList" :key="i">
25
+        <div @click="revise(i,gest)">
26
+          {{i+1}}.{{gest.title}}
27
+          <div v-for="(item,id) in gest.questions" :key="id">
28
+            ({{id+1}})
29
+            <div v-for="(obj,ip) in item.obj" :key="ip" class="erji">
30
+              <span>{{ip}}.</span><span>{{obj}}</span>
31
+            </div>
32
+          </div>
33
+        </div>
34
+      </div>
35
+    </div>
36
+  </div>
37
+</template>
38
+<script>
39
+import question from "./components/question/question.vue";
40
+import exercise from "./components/exercise/exercise.vue"
41
+import gestalts from "./components/gestalts/gestalts.vue"
42
+export default {
43
+  data () {
44
+    return {
45
+      modal: false,
46
+      select:'1',
47
+      cityList: [
48
+        {
49
+          value: '1',
50
+          label: '选择题'
51
+        },
52
+        {
53
+          value: '2',
54
+          label: '填空题'
55
+        },
56
+        {
57
+          value: '3',
58
+          label: '完形填空'
59
+        }
60
+      ],
61
+      // selectList:[],
62
+      getquestionList:[],
63
+      getexerciseList:[],
64
+      getGestaltList:[],
65
+      char:["A","B","C","D","E","F","G","H","I","J","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
66
+    }
67
+  },
68
+  components:{
69
+    question,
70
+    exercise,
71
+    gestalts
72
+  },
73
+  watch:{
74
+    modal(){
75
+      var modal=this.modal
76
+      if(this.modal==false){
77
+        localStorage.clear();
78
+      }
79
+    }
80
+  },
81
+  methods: {
82
+    revise(index,list){
83
+      // console.log(index,list)
84
+      var data={index,list};
85
+      var obj=JSON.stringify(data)
86
+      localStorage.setItem('gestList',obj)
87
+      var list = localStorage.getItem('gestList')
88
+      console.log(list)
89
+      var arr=JSON.parse(list)
90
+      console.log(arr)
91
+      this.modal=true;
92
+      this.select="3"
93
+    },
94
+    getquestion(data){
95
+      this.getquestionList.push(data);
96
+      console.log(data)
97
+      this.modal=false;
98
+      this.select="1"
99
+      localStorage.clear();
100
+    },
101
+    getexercise(data){
102
+      this.getexerciseList.push(data);
103
+      this.modal=false;
104
+      this.select="1"
105
+      localStorage.clear();
106
+    },
107
+    getGestalts(data){
108
+      this.getGestaltList.push(data);
109
+      console.log(this.getGestaltList)
110
+      this.modal=false;
111
+      this.select="1"
112
+      localStorage.clear();
113
+    },
114
+    ok () {
115
+      this.$Message.info('Clicked ok');
116
+    },
117
+    cancel () {
118
+      this.$Message.info('Clicked cancel');
119
+    }
120
+  }
121
+}
122
+</script>
123
+<style scoped>
124
+.yiji{
125
+  display: flex;
126
+  justify-content: flex-start;
127
+}
128
+.erji{
129
+  display: inline-block;
130
+}
131
+</style>

Loading…
Cancel
Save