zydx-plus 1.31.177 → 1.32.178

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zydx-plus",
3
- "version": "1.31.177",
3
+ "version": "1.32.178",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -0,0 +1,6 @@
1
+ import main from './src/question';
2
+
3
+ main.install = function(Vue) {
4
+ Vue.component(main.name, main);
5
+ };
6
+ export default main;
@@ -0,0 +1,257 @@
1
+ <template>
2
+ <div class="question">
3
+ <table border="0" cellspacing="0" cellpadding="0">
4
+ <tr>
5
+ <th>题序</th>
6
+ <th>题型</th>
7
+ <th>易</th>
8
+ <th>中</th>
9
+ <th>难</th>
10
+ <th>合计题量</th>
11
+ <th>合计分值</th>
12
+ <th v-if="!readOnly">操作</th>
13
+ </tr>
14
+ <tbody v-for="(item,index) in question" :key="index">
15
+ <tr>
16
+ <td rowspan="2">{{ toChineseNum(index + 1) }}</td>
17
+ <td rowspan="2">{{ item.quesName }}</td>
18
+ <td>
19
+ <div class="qu-input" :style="{'margin-left': readOnly?'0px':'-10px'}">
20
+ <span v-if="readOnly">{{ item.easy }}</span>
21
+ <input v-else type="number" placeholder="题量" :value="item.easy" @input="totalQuestions($event,1,index)" @keypress="isNumberKey($event,1)" />
22
+ </div>
23
+ </td>
24
+ <td>
25
+ <div class="qu-input" :style="{'margin-left': readOnly?'0px':'-10px'}">
26
+ <span v-if="readOnly">{{ item.hard }}</span>
27
+ <input v-else type="number" placeholder="题量" :value="item.hard" @input="totalQuestions($event,2,index)" @keypress="isNumberKey($event,1)" />
28
+ </div>
29
+ </td>
30
+ <td>
31
+ <div class="qu-input" :style="{'margin-left': readOnly?'0px':'-10px'}">
32
+ <span v-if="readOnly">{{ item.mid }}</span>
33
+ <input v-else type="number" placeholder="题量" :value="item.mid" @input="totalQuestions($event,3,index)" @keypress="isNumberKey($event,1)" />
34
+ </div>
35
+ </td>
36
+ <td rowspan="2">{{ item.count }}</td>
37
+ <td rowspan="2">{{ item.allScore }}</td>
38
+ <td rowspan="2" v-if="!readOnly">
39
+ <button class="but" @click="cancel(index)">撤销选择</button>
40
+ </td>
41
+ </tr>
42
+ <tr>
43
+ <td>
44
+ <div class="qu-input" :style="{'margin-left': readOnly?'0px':'-10px'}">
45
+ <span v-if="readOnly">{{ item.easyScore }}</span>
46
+ <input v-else type="number" placeholder="分值" :value="item.easyScore" @input="totalQuestions($event,4,index)" @keypress="isNumberKey($event,2)" />
47
+ </div>
48
+ </td>
49
+ <td>
50
+ <div class="qu-input" :style="{'margin-left': readOnly?'0px':'-10px'}">
51
+ <span v-if="readOnly">{{ item.hardScore }}</span>
52
+ <input v-else type="number" placeholder="分值" :value="item.hardScore" @input="totalQuestions($event,5,index)" @keypress="isNumberKey($event,2)" />
53
+ </div>
54
+ </td>
55
+ <td>
56
+ <div class="qu-input" :style="{'margin-left': readOnly?'0px':'-10px'}">
57
+ <span v-if="readOnly">{{ item.midScore }}</span>
58
+ <input v-else type="number" placeholder="分值" :value="item.midScore" @input="totalQuestions($event,6,index)" @keypress="isNumberKey($event,2)" />
59
+ </div>
60
+ </td>
61
+ </tr>
62
+ </tbody>
63
+ <tr>
64
+ <td colspan="2">合计分值</td>
65
+ <td>{{ easyNum === 0? '-': easyNum }}</td>
66
+ <td>{{ hardNum === 0? '-': hardNum }}</td>
67
+ <td>{{ midNum === 0? '-': midNum }}</td>
68
+ <td>试卷总分</td>
69
+ <td :colspan="readOnly? 1: 2">{{ totalNum === 0? '-': totalNum }}</td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ </template>
74
+
75
+ <script>
76
+
77
+ export default {
78
+ name: "zydx-question",
79
+ data() {
80
+ return {
81
+ question: [],
82
+ easyNum: 0,
83
+ hardNum: 0,
84
+ midNum: 0,
85
+ totalNum: 0
86
+ }
87
+ },
88
+ props: {
89
+ data: {
90
+ type: Array,
91
+ default: []
92
+ },
93
+ readOnly: {
94
+ type: Boolean,
95
+ default: false
96
+ },
97
+ },
98
+ watch: {
99
+ data: {
100
+ handler(val) {
101
+ this.getQuestionReadOnly(val)
102
+ },
103
+ immediate: true
104
+ }
105
+ },
106
+ emits: ['cancel'],
107
+ methods: {
108
+ getQuestionReadOnly(v) {
109
+ let arr = []
110
+ v.forEach(item => {
111
+ arr.push({
112
+ quesType: item.quesType,
113
+ quesName: item.quesName,
114
+ easyScore: item.easyScore? item.easyScore: '',
115
+ hardScore: item.hardScore? item.hardScore: '',
116
+ midScore: item.midScore? item.midScore: '',
117
+ easy: item.easy? item.easy: '',
118
+ hard: item.hard? item.hard: '',
119
+ mid: item.mid? item.mid: '',
120
+ allScore: item.allScore? item.allScore: '-',
121
+ count: item.count? item.count: '-',
122
+ })
123
+ })
124
+ this.question = arr
125
+ this.totalScore()
126
+ },
127
+ getContent() {
128
+ return {
129
+ data: this.question,
130
+ total: this.totalNum,
131
+ }
132
+ },
133
+ // 添加数据
134
+ addData(v) {
135
+ this.question.push({
136
+ quesType: v.quesType,
137
+ quesName: v.quesName,
138
+ easyScore:'',
139
+ hardScore:'',
140
+ midScore: '',
141
+ easy: '',
142
+ hard: '',
143
+ mid: '',
144
+ allScore: '-',
145
+ count: '-',
146
+ })
147
+ },
148
+ cancel(i) {
149
+ this.$emit('cancel',this.question[i])
150
+ this.question.splice(i,1)
151
+ this.totalScore()
152
+ },
153
+ totalQuestions(v,i,n) {
154
+ const value = Number(v.target.value);
155
+ if(i === 1) this.question[n].easy = value === 0? '' : value
156
+ if(i === 2) this.question[n].hard = value === 0? '' : value
157
+ if(i === 3) this.question[n].mid = value === 0? '' : value
158
+ if(i === 4) this.question[n].easyScore = value === 0? '' : value
159
+ if(i === 5) this.question[n].hardScore = value === 0? '' : value
160
+ if(i === 6) this.question[n].midScore = value === 0? '' : value
161
+ const total = (this.question[n].easy === ''? 0: this.question[n].easy) + (this.question[n].hard === ''? 0: this.question[n].hard) + (this.question[n].mid === ''? 0: this.question[n].mid)
162
+ this.question[n].count = (total === 0)? '-' : total
163
+ const total2 = (this.question[n].easyScore === ''? 0: this.question[n].easyScore) + (this.question[n].hardScore === ''? 0: this.question[n].hardScore) + (this.question[n].midScore === ''? 0: this.question[n].midScore)
164
+ this.question[n].allScore = (total2 === 0)? '-' : total2
165
+ this.totalScore()
166
+ },
167
+ totalScore() {
168
+ this.easyNum = 0
169
+ this.hardNum = 0
170
+ this.midNum = 0
171
+ this.question.forEach(x => {
172
+ this.easyNum += x.easyScore === '' ? 0: Number(x.easyScore)
173
+ this.hardNum += x.hardScore === '' ? 0: Number(x.hardScore)
174
+ this.midNum += x.midScore === '' ? 0: Number(x.midScore)
175
+ })
176
+ this.totalNum = this.easyNum + this.hardNum + this.midNum
177
+ },
178
+ // 数字转大写
179
+ toChineseNum(num) {
180
+ const chnNumChar = ["零","一","二","三","四","五","六","七","八","九"];
181
+ if(num >= 10) {
182
+ if(num === 10) {
183
+ return "十"
184
+ }else {
185
+ return "十" + chnNumChar[num % 10]
186
+ }
187
+ }
188
+ return chnNumChar[num];
189
+ },
190
+ isNumberKey(event,num) {
191
+ const charCode = (event.which) ? event.which : event.keyCode;
192
+ const val = event.target.value;
193
+ if(val.length > 2) event.preventDefault();
194
+ if(num === 1) {
195
+ if (charCode > 31 && (charCode < 48 || charCode > 57)) event.preventDefault();
196
+ }else {
197
+ if (charCode === 46) {
198
+ if (val.indexOf('.') !== -1)
199
+ event.preventDefault();
200
+ else
201
+ return true;
202
+ } else if (charCode > 31 && (charCode < 48 || charCode > 57))
203
+ event.preventDefault();
204
+ }
205
+ if (this.valueState(event.target.value) && String.fromCharCode(charCode) === '0') event.preventDefault();
206
+ },
207
+ valueState(v) {
208
+ return v === '' || v === undefined || v === null;
209
+ },
210
+ }
211
+ }
212
+ </script>
213
+
214
+ <style scoped>
215
+ .question {
216
+ width: 100%;
217
+ }
218
+
219
+ .question table {
220
+ width: 100%;
221
+ border-top: 1px solid #ccc;
222
+ border-left: 1px solid #ccc;
223
+ }
224
+
225
+ .question table th, .question table td {
226
+ font-size: 14px;
227
+ text-align: center;
228
+ padding: 5px 0;
229
+ border-bottom: 1px solid #ccc;
230
+ border-right: 1px solid #ccc;
231
+ font-weight: 400;
232
+ }
233
+
234
+ .qu-input {
235
+ width: 60px;
236
+ display: inline-block;
237
+ overflow: hidden;
238
+ }
239
+ .qu-input input{
240
+ border: 0;
241
+ outline: none;
242
+ text-align: center;
243
+ width: 80px;
244
+ }
245
+
246
+ .but {
247
+ margin-left: 1px;
248
+ font-size: 12px;
249
+ background-color: transparent;
250
+ border: 1px solid #000;
251
+ border-radius: 3px;
252
+ padding: 2px 5px;
253
+ cursor: pointer;
254
+ min-width: 60px;
255
+ height: 21px;
256
+ }
257
+ </style>
package/src/index.js CHANGED
@@ -31,6 +31,7 @@ import sketchpad from './components/sketchpad/index';
31
31
  import pictureViewer from './components/pictureViewer/index';
32
32
  import lessonTemplate from './components/lesson_template/index';
33
33
  import paper from './components/word2/index';
34
+ import question from './components/question/index';
34
35
 
35
36
  const components = [
36
37
  Calendar,
@@ -63,7 +64,8 @@ const components = [
63
64
  sketchpad,
64
65
  pictureViewer,
65
66
  lessonTemplate,
66
- paper
67
+ paper,
68
+ question
67
69
  ];
68
70
 
69
71
  function install(app) {
@@ -75,7 +77,7 @@ function install(app) {
75
77
  }
76
78
 
77
79
  export default {
78
- version: '1.31.177',
80
+ version: '1.32.178',
79
81
  install,
80
82
  Calendar,
81
83
  Message,
@@ -109,6 +111,7 @@ export default {
109
111
  sketchpad,
110
112
  pictureViewer,
111
113
  lessonTemplate,
112
- paper
114
+ paper,
115
+ question
113
116
  };
114
117