Browse Source

日历

master
xiezhenghui 4 years ago
parent
commit
743babcca0

+ 6
- 1
.eslintrc.js View File

@@ -6,9 +6,14 @@ module.exports = {
6 6
   ],
7 7
   rules: {
8 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 14
     'generator-star-spacing': 'off',
10 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 17
     'vue/no-parsing-error': [2, {
13 18
       'x-invalid-end-tag': false
14 19
     }],

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

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

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

@@ -7,14 +7,14 @@
7 7
     <!-- 题干结束 -->
8 8
     <div>
9 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 11
       </div>
12 12
       <Button @click="addContent">添加选项</Button>
13 13
       <Button @click="delContent">删除选项</Button>
14 14
     </div>
15 15
     <div>
16 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 18
       </RadioGroup>
19 19
     </div>
20 20
     <div>
@@ -28,12 +28,61 @@ export default {
28 28
     return {
29 29
       title:"",
30 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 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 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 86
     add(){
38 87
       var title=this.title;
39 88
       if(!title){
@@ -42,26 +91,36 @@ export default {
42 91
       }
43 92
       var selectObj={}
44 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 100
       var labelActive=this.labelActive;
48
-      if(!labelActive){
101
+      var i=this.content.indexOf(labelActive);
102
+      if(!labelActive||i<0){
49 103
         this.$Message.warning('请选择答案选项');
50 104
         return;
51 105
       }
106
+      var uid=this.index;
52 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 116
       this.$emit('question',question);
58 117
       this.title="";
59 118
       this.labelActive="";
60 119
       this.charList=[];
61
-      this.content=[0,1,2,3]
120
+      this.content=["A","B","C","D"]
62 121
     },
63 122
     addContent(){
64
-      this.content.push(this.content.length);
123
+      this.content.push(this.char[this.content.length]);
65 124
     },
66 125
     delContent(){
67 126
       if(this.content.length>2){

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

@@ -1,131 +1,277 @@
1 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 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 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 10
         </div>
34 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 42
     </div>
43
+    <div v-if="incident">
44
+      {{incident}}
45
+    </div>
46
+    <Button>+</Button>
36 47
   </div>
37 48
 </template>
49
+
38 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 51
 export default {
52
+  name: 'calender',
43 53
   data () {
44 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 173
 </script>
123 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 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 277
 </style>

Loading…
Cancel
Save