Browse Source

日历

master
xiezhenghui 4 years ago
parent
commit
743babcca0

+ 6
- 1
.eslintrc.js View File

6
   ],
6
   ],
7
   rules: {
7
   rules: {
8
     // allow async-await
8
     // allow async-await
9
+    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
10
+
11
+    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
12
+
13
+    "no-unused-vars": 'off',
9
     'generator-star-spacing': 'off',
14
     'generator-star-spacing': 'off',
10
     // allow debugger during development
15
     // allow debugger during development
11
-    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
16
+    // 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
12
     'vue/no-parsing-error': [2, {
17
     'vue/no-parsing-error': [2, {
13
       'x-invalid-end-tag': false
18
       'x-invalid-end-tag': false
14
     }],
19
     }],

+ 26
- 12
src/view/organ_admin/test/components/gestalts/gestalts.vue View File

42
       </div>
42
       </div>
43
     </div>
43
     </div>
44
     <!-- 小题选项区域 end -->
44
     <!-- 小题选项区域 end -->
45
-
45
+    <div>
46
+      {{modal?"1":"0"}}
47
+    </div>
46
 
48
 
47
     <div>
49
     <div>
48
       <Button @click="addQuestions">添加小题</Button>
50
       <Button @click="addQuestions">添加小题</Button>
57
       title:"",  // 题干
59
       title:"",  // 题干
58
       char:["A","B","C","D"],  // 小题选项
60
       char:["A","B","C","D"],  // 小题选项
59
       s_questions:[],  // 小题选项列表
61
       s_questions:[],  // 小题选项列表
60
-      index:"",
62
+      indexActive:"",
61
       clear:false
63
       clear:false
62
     }
64
     }
63
   },
65
   },
66
+  props:[
67
+    'modal'
68
+  ],
64
   watch:{
69
   watch:{
65
-    clear(){
70
+    modal(){
66
       var modal=this.modal
71
       var modal=this.modal
67
-      console.log(modal)
68
       if(this.modal==false){
72
       if(this.modal==false){
69
         localStorage.clear();
73
         localStorage.clear();
74
+        this.title="";
75
+        this.s_questions=[]
76
+      }else{
77
+        if(this.title==""){
78
+          this.mountedList()
79
+        }
70
       }
80
       }
71
     }
81
     }
72
   },
82
   },
73
   // 挂载结束后触发
83
   // 挂载结束后触发
74
   mounted(){
84
   mounted(){
85
+    this.mountedList()
86
+  },
87
+  methods:{
88
+    mountedList(){
75
     var local=localStorage.getItem('gestList')
89
     var local=localStorage.getItem('gestList')
76
     if(!local){
90
     if(!local){
77
       // 触发一行小题选项
91
       // 触发一行小题选项
93
       }
107
       }
94
       this.s_questions.push(data);
108
       this.s_questions.push(data);
95
     }else{
109
     }else{
96
-      console.log(999)
97
       var questions=JSON.parse(local);
110
       var questions=JSON.parse(local);
98
       this.s_questions=questions.list.questions;
111
       this.s_questions=questions.list.questions;
99
       this.title=questions.list.title
112
       this.title=questions.list.title
100
-      console.log(this.s_questions)
101
-      this.index=questions.index
113
+      this.indexActive=questions.index
102
     }
114
     }
103
-  },
104
-  methods:{
115
+    },
105
     // 首次加载
116
     // 首次加载
106
     swapArray(arr, index1, index2) {
117
     swapArray(arr, index1, index2) {
107
       this.s_questions[index1] = this.s_questions.splice(index2, 1, arr[index1])[0];
118
       this.s_questions[index1] = this.s_questions.splice(index2, 1, arr[index1])[0];
149
     },
160
     },
150
     // 提交试题
161
     // 提交试题
151
     add(){
162
     add(){
152
-      var uid=this.index;
163
+      var uid=this.indexActive;
153
       var title=this.title;
164
       var title=this.title;
154
       if(title==""){
165
       if(title==""){
155
         this.$Message.warning('题干未填写');
166
         this.$Message.warning('题干未填写');
167
         }
178
         }
168
       }
179
       }
169
       var gestalts={
180
       var gestalts={
170
-        title,
171
-        questions,
181
+        list:{
182
+          title,
183
+          questions,
184
+          order:2
185
+        },
172
         uid
186
         uid
173
       }
187
       }
174
       // console.log(gestalts)
188
       // console.log(gestalts)

+ 70
- 11
src/view/organ_admin/test/components/question/question.vue View File

7
     <!-- 题干结束 -->
7
     <!-- 题干结束 -->
8
     <div>
8
     <div>
9
       <div v-for="(cont,index) in content" :key="index">
9
       <div v-for="(cont,index) in content" :key="index">
10
-        <span>{{char[index]}}</span>.<input v-model="charList[index]" type="text">
10
+        <span>{{cont}}</span>.<input v-model="charList[index]" type="text">
11
       </div>
11
       </div>
12
       <Button @click="addContent">添加选项</Button>
12
       <Button @click="addContent">添加选项</Button>
13
       <Button @click="delContent">删除选项</Button>
13
       <Button @click="delContent">删除选项</Button>
14
     </div>
14
     </div>
15
     <div>
15
     <div>
16
       <RadioGroup v-model="labelActive">
16
       <RadioGroup v-model="labelActive">
17
-        <Radio v-for="(cont,index) in content" :key="index" :label="char[index]"></Radio>
17
+        <Radio v-for="(cont,index) in content" :key="index" :label="cont"></Radio>
18
       </RadioGroup>
18
       </RadioGroup>
19
     </div>
19
     </div>
20
     <div>
20
     <div>
28
     return {
28
     return {
29
       title:"",
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"],
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],
31
+      content:["A","B","C","D"],
32
       charList:[],
32
       charList:[],
33
-      labelActive:""
33
+      labelActive:"",
34
+      index:""
34
     }
35
     }
35
   },
36
   },
37
+  props:[
38
+    'modal'
39
+  ],
40
+  watch:{
41
+    modal(){
42
+      var modal=this.modal
43
+      if(modal==false){
44
+        localStorage.clear();
45
+        this.title="";
46
+        this.charList=[];
47
+        this.labelActive="";
48
+        this.index="";
49
+      }else{
50
+        if(this.title==""){
51
+          this.mountedList()
52
+        }
53
+      }
54
+    }
55
+  },
56
+  // mounted(){
57
+  //   this.mountedList()
58
+  // },
36
   methods:{
59
   methods:{
60
+    mountedList(){
61
+      var local=localStorage.getItem('questList');
62
+      if(!local){
63
+
64
+      }else{
65
+        var question=JSON.parse(local)
66
+        var list=question.list;
67
+        console.log(question.list)
68
+        this.index=question.index;
69
+        this.title=list.title;
70
+        this.labelActive=list.labelActive;
71
+        var obj=list.selectObj;
72
+        this.content=[];
73
+        var num=0;
74
+        for(var arr in obj){
75
+          this.content[num]=this.char[num]
76
+          num=num+1;
77
+          console.log(num)
78
+          this.charList.push(obj[arr])
79
+        }
80
+        // console.log(this.content.length,num)
81
+        // if(this.content.length!=num){
82
+        //   this.content.pop()
83
+        // }
84
+      }
85
+    },
37
     add(){
86
     add(){
38
       var title=this.title;
87
       var title=this.title;
39
       if(!title){
88
       if(!title){
42
       }
91
       }
43
       var selectObj={}
92
       var selectObj={}
44
       for(var obj in this.content){
93
       for(var obj in this.content){
45
-        selectObj[this.char[obj]]=this.charList[obj]
94
+        if(!this.charList[obj]){
95
+          selectObj[this.char[obj]]=""
96
+        }else{
97
+          selectObj[this.char[obj]]=this.charList[obj]
98
+        }
46
       }
99
       }
47
       var labelActive=this.labelActive;
100
       var labelActive=this.labelActive;
48
-      if(!labelActive){
101
+      var i=this.content.indexOf(labelActive);
102
+      if(!labelActive||i<0){
49
         this.$Message.warning('请选择答案选项');
103
         this.$Message.warning('请选择答案选项');
50
         return;
104
         return;
51
       }
105
       }
106
+      var uid=this.index;
52
       var question={
107
       var question={
53
-        title,
54
-        selectObj,
55
-        labelActive
108
+        uid,
109
+        list:{
110
+          title,
111
+          selectObj,
112
+          labelActive,
113
+          order:1
114
+        }
56
       };
115
       };
57
       this.$emit('question',question);
116
       this.$emit('question',question);
58
       this.title="";
117
       this.title="";
59
       this.labelActive="";
118
       this.labelActive="";
60
       this.charList=[];
119
       this.charList=[];
61
-      this.content=[0,1,2,3]
120
+      this.content=["A","B","C","D"]
62
     },
121
     },
63
     addContent(){
122
     addContent(){
64
-      this.content.push(this.content.length);
123
+      this.content.push(this.char[this.content.length]);
65
     },
124
     },
66
     delContent(){
125
     delContent(){
67
       if(this.content.length>2){
126
       if(this.content.length>2){

+ 249
- 103
src/view/organ_admin/test/test.vue View File

1
 <template>
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">
2
+  <div class="calender">
3
+    <div class="top">
4
+      <div class="top_date">
10
         <div>
5
         <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>
6
+          {{new Date().getDate()}}
19
         </div>
7
         </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>
8
+        <div>
9
+          星期{{week[new Date().getDay()]}}
33
         </div>
10
         </div>
34
       </div>
11
       </div>
12
+      <div class="btn_wrap">
13
+        <ul>
14
+          <li @click="handleShowNextMonth">
15
+            下个月
16
+          </li>
17
+          <li @click="handleShowToday">
18
+            {{year}}年{{month}}月
19
+          </li>
20
+          <li @click="handleShowLastMonth">
21
+            上个月
22
+          </li>
23
+        </ul>
24
+      </div>
25
+    </div>
26
+    <div class="date_wrap">
27
+      <ul class="week">
28
+        <li v-for="(day,d_index) in week" :key="d_index+'d'">{{day}}</li>
29
+      </ul>
30
+      <ul class="day">
31
+        <li v-for="(last,l_index) in days.last_list" :key="l_index+'l'" class="last">
32
+          {{last}}
33
+        </li>
34
+        <li v-for="(when,w_index) in days.when_list" :key="w_index+'w'" :class="{now:nowLi==year.toString()+month.toString()+when}">
35
+          {{when}}
36
+        </li>
37
+        <li v-for="(next,n_index) in days.next_list" :key="n_index+'n'" class="last">
38
+          {{next}}
39
+          <div class="active-time"></div>
40
+        </li>
41
+      </ul>
35
     </div>
42
     </div>
43
+    <div v-if="incident">
44
+      {{incident}}
45
+    </div>
46
+    <Button>+</Button>
36
   </div>
47
   </div>
37
 </template>
48
 </template>
49
+
38
 <script>
50
 <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 {
51
 export default {
52
+  name: 'calender',
43
   data () {
53
   data () {
44
     return {
54
     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
-      }
55
+     year:'',
56
+     month:'',
57
+     days:{},
58
+     nowLi:'',
59
+     week:['日','一','二','三','四','五','六'],
60
+     incident:"代办事项",
61
+     active:[{
62
+       time:'9:00',
63
+       day:'528',
64
+       title:'校长找我'
65
+     },
66
+     {
67
+       time:'10:00',
68
+       day:'529',
69
+       title:'教导主任找我'
70
+     },
71
+     {
72
+       time:'11:00',
73
+       day:'520',
74
+       title:'学生家长找我'
75
+     }]
79
     }
76
     }
80
   },
77
   },
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"
78
+  methods:{
79
+    //控制当前日期显示特殊样式
80
+    handleShowDateStyle(){
81
+      let now = new Date()
82
+      this.nowLi=now.getFullYear().toString()+(now.getMonth()+1).toString()+now.getDate().toString()
93
     },
83
     },
94
-    getquestion(data){
95
-      this.getquestionList.push(data);
96
-      console.log(data)
97
-      this.modal=false;
98
-      this.select="1"
99
-      localStorage.clear();
84
+    //得到当前年这个月分有多少天
85
+    getDays(Y,M){
86
+      let day = new Date(Y, M, 0).getDate()
87
+      return day;
100
     },
88
     },
101
-    getexercise(data){
102
-      this.getexerciseList.push(data);
103
-      this.modal=false;
104
-      this.select="1"
105
-      localStorage.clear();
89
+    //得到当前年,这个月的一号是周几
90
+    getWeek(Y,M){
91
+        let now = new Date()
92
+        now.setFullYear(this.year)
93
+        now.setMonth(this.month-1)
94
+        now.setDate(1);
95
+        let week = now.getDay();
96
+        return week;
106
     },
97
     },
107
-    getGestalts(data){
108
-      this.getGestaltList.push(data);
109
-      console.log(this.getGestaltList)
110
-      this.modal=false;
111
-      this.select="1"
112
-      localStorage.clear();
98
+    getaddWeek(Y,M){
99
+        let now = new Date()
100
+        now.setFullYear(this.year)
101
+        now.setMonth(this.month)
102
+        now.setDate(1);
103
+        let week = now.getDay();
104
+        return week;
113
     },
105
     },
114
-    ok () {
115
-      this.$Message.info('Clicked ok');
106
+    pushDays(){
107
+      //将这个月多少天加入数组days
108
+      let when_list=[];
109
+      for(let i = 1; i<=this.getDays(this.year,this.month);i++){
110
+        when_list.push(i)
111
+      }
112
+      //将下个月要显示的天数加入days
113
+      let week_day=1;
114
+      let next_list=[];
115
+      for(let i=this.getaddWeek(this.year,this.month);i<7;i++){
116
+          next_list.push(week_day++)
117
+      }
118
+      //将上个月要显示的天数加入days
119
+      let last_list=[];
120
+      for(let i=0;i<this.getWeek(this.year,this.month);i++){
121
+        var lastMonthDays=this.getDays(this.year,this.month-1)
122
+          last_list.unshift(lastMonthDays-i)
123
+      }
124
+      this.days={last_list,when_list,next_list}
125
+      console.log(this.days)
126
+    },
127
+    getDate(){
128
+            let now = new Date();
129
+            this.year = now.getFullYear();
130
+            this.month = now.getMonth()+1;
131
+            this.pushDays();
132
+            
133
+    },
134
+    handleShowNextMonth(){
135
+       this.days=[];
136
+      if(this.month<12){
137
+        this.month=this.month+1;
138
+         this.pushDays();
139
+      }else{
140
+        this.month= this.month=1;
141
+        this.year=this.year+1;
142
+        this.pushDays();
143
+      }
144
+      
145
+    },
146
+    handleShowToday(){
147
+      this.days=[];
148
+      let now = new Date();
149
+      this.year=now.getFullYear();
150
+      this.month=now.getMonth()+1;
151
+      this.pushDays();
116
     },
152
     },
117
-    cancel () {
118
-      this.$Message.info('Clicked cancel');
153
+    handleShowLastMonth(){
154
+       this.days=[];
155
+      if(this.month>1){
156
+         this.month=this.month-1;
157
+      this.pushDays();
158
+      }else if( this.year>1970){
159
+        this.month=12;
160
+        this.year=this.year-1;
161
+        this.pushDays();
162
+      }else{
163
+        alert("不能查找更远的日期")
164
+      }
165
+      
119
     }
166
     }
167
+  },
168
+  mounted(){
169
+    this.getDate();
170
+    this.handleShowDateStyle();
120
   }
171
   }
121
 }
172
 }
122
 </script>
173
 </script>
123
 <style scoped>
174
 <style scoped>
124
-.yiji{
175
+.calender{
176
+  width: 600px;
177
+  position: relative;
178
+  margin: 0 auto;
179
+  margin-top: 50px;
180
+  border: 1px solid #ddd;
181
+  padding: 20px;
182
+  color: #333;
183
+}
184
+.top{
185
+  width: 100%;
186
+  position: relative;
187
+  display: flex;
188
+  border-bottom: 1px solid #ddd;
189
+  padding-bottom: 20px;
190
+}
191
+.top_date{
192
+  width: 100px;
193
+  text-align: left;
194
+  line-height: 42px;
195
+}
196
+.btn_wrap{
197
+  flex: 1;
198
+  text-align: right
199
+}
200
+ul{
201
+  list-style: none;
202
+}
203
+.btn_wrap ul{
125
   display: flex;
204
   display: flex;
126
-  justify-content: flex-start;
205
+  flex-direction: row-reverse
206
+}
207
+.btn_wrap ul li{
208
+  padding: 10px 20px;
209
+  border: 1px solid #ddd;
210
+  font-size: 14px;
211
+  line-height: 20px;
212
+  cursor: pointer;
213
+}
214
+.btn_wrap ul li:hover{
215
+  background: #ddd;
216
+  color:red;
217
+}
218
+.btn_wrap ul li:first-child{
219
+  border-left: none;
220
+}
221
+.btn_wrap ul li:last-child{
222
+  border-right: none;
223
+}
224
+.date_wrap{
225
+  position: relative;
226
+}
227
+.week{
228
+  display: flex;
229
+  flex-direction: row;
230
+  padding: 20px;
231
+  font-size: 16px;
232
+}
233
+.week li{
234
+  text-align: center;
235
+  width: 14.28%;
236
+}
237
+.day{
238
+  display: flex;
239
+  flex-direction: row;
240
+  padding: 20px;
241
+  font-size: 16px;
242
+  flex-wrap: wrap;
243
+}
244
+.day li{
245
+  width: 14.28%;
246
+  padding: 20px;
247
+  text-align: center;
248
+  box-sizing: border-box;
249
+  cursor: pointer;
250
+  position: relative;
251
+  /* border: 1px solid #ddd */
252
+}
253
+.day li:nth-child(n+8){
254
+  border-top:none;
255
+}
256
+.day li:nth-child(n+1){
257
+  border-right: none;
258
+}
259
+/* .day li:nth-child(7n){
260
+  border-right: 1px solid #ddd
261
+} */
262
+.now{
263
+  color: #f2f8fe;
264
+  background:#1989fa;
265
+  border-radius: 50%;
266
+}
267
+.last{
268
+  color: #CBD1DA;
127
 }
269
 }
128
-.erji{
129
-  display: inline-block;
270
+.active-time{
271
+  border:6px solid #ff0000;
272
+  border-radius: 50%;
273
+  position: absolute;
274
+  bottom: 4px;
275
+  right: 6px;
130
 }
276
 }
131
 </style>
277
 </style>

Loading…
Cancel
Save