Commit 3ba60a6372a38d6ca6746923bd23045b3f6ac555

Authored by 梁保满
1 parent 5be3bb70

发卡补卡,设备状态上传下载接口联调

src/api/apis/apis.js
... ... @@ -529,6 +529,13 @@ export default {
529 529 data,
530 530 });
531 531 },
  532 + // 导入基站模板下载地址
  533 + stationTemplateUrl() {
  534 + return service({
  535 + url: setUpUrls.stationTemplateUrl,
  536 + method: "POST",
  537 + });
  538 + },
532 539 // 查询下载配置列表
533 540 appConfigList(data) {
534 541 return service({
... ... @@ -594,6 +601,14 @@ export default {
594 601 responseType: 'arraybuffer',
595 602 });
596 603 },
  604 + // 发卡应用下载
  605 + latestClickersApp(data) {
  606 + return service({
  607 + url: setUpUrls.latestClickersApp,
  608 + method: "POST",
  609 + data,
  610 + });
  611 + },
597 612  
598 613 /**
599 614 * 集团管理员-学校管理
... ...
src/api/urls/apis.js
... ... @@ -134,6 +134,8 @@ export default {
134 134 updateDevice: "/api_html/school/manager/updateDevice",
135 135 // 新增基站
136 136 addStation: "/api_html/school/manager/addStation",
  137 + // 导入基站模板下载地址
  138 + stationTemplateUrl: "/api_html/school/manager/stationTemplateUrl",
137 139 // 查询下载配置列表
138 140 appConfigList: "/api_html/school/manager/appConfigList",
139 141 // 查询最新的授课端应用版本
... ... @@ -147,9 +149,11 @@ export default {
147 149 // 设备使用分析
148 150 usageAnalysis: "/api_html/school/manager/usageAnalysis",
149 151 // 发卡记录
150   - cardList: "/api_html/school/manager/cardList",
  152 + cardList: "/api_html/school/manager/clickersLogList",
151 153 // 导出设备使用分析
152 154 exportUsageAnalysis: "/api_html/school/manager/exportUsageAnalysis",
  155 + // 发卡应用下载
  156 + latestClickersApp: "/api_html/school/manager/latestClickersApp",
153 157  
154 158  
155 159 // 查询区域列表
... ...
src/components/upload.vue
... ... @@ -76,7 +76,6 @@ export default {
76 76 // }
77 77 },
78 78 upSuccess(res) {
79   - debugger
80 79 if (res && res.status == 0 ) {
81 80 this.$message.success("上传成功");
82 81 this.$emit("upSuccess");
... ... @@ -85,7 +84,6 @@ export default {
85 84 }
86 85 },
87 86 upError(res) {
88   - debugger
89 87 if (res && res.status == 0) {
90 88 this.$message.error("上传失败");
91 89 } else {
... ...
src/views/card/index.vue
... ... @@ -10,6 +10,7 @@
10 10 <div class="answer-header">
11 11 <div class="sel-box">
12 12 <el-cascader
  13 + @change="_QueryData(1)"
13 14 size="small"
14 15 class="sel"
15 16 clearable
... ... @@ -53,18 +54,20 @@
53 54 v-if="!tableData.length && !loading"
54 55 description="暂无数据"
55 56 ></el-empty>
56   - <div v-else class="table-box">
  57 + <div v-else class="table-box" v-loading="loading">
57 58 <el-table :data="tableData" border style="width: 100%">
58 59 <el-table-column
59 60 align="center"
60 61 label="答题器编码"
61   - prop="sn"
62   - ></el-table-column>
63   - <el-table-column
64   - align="center"
65   - label="班级"
66   - prop="className"
  62 + prop="clickerSn"
67 63 ></el-table-column>
  64 + <el-table-column align="center" label="班级">
  65 + <template slot-scope="scope">
  66 + <span v-for="item in scope.row.classList" :key="item.classCode">{{
  67 + item.className
  68 + }}</span>
  69 + </template>
  70 + </el-table-column>
68 71 <el-table-column
69 72 align="center"
70 73 label="学生姓名"
... ... @@ -75,22 +78,40 @@
75 78 label="学号"
76 79 prop="studentId"
77 80 ></el-table-column>
78   - <el-table-column
79   - align="center"
80   - label="类型"
81   - prop="type"
82   - ></el-table-column>
83   - <el-table-column
84   - align="center"
85   - label="描述"
86   - prop="desc"
87   - ></el-table-column>
  81 + <el-table-column align="center" label="类型">
  82 + <template slot-scope="scope">
  83 + {{ scope.row.operationType == 0 ? "发卡" : "补卡" }}
  84 + </template></el-table-column
  85 + >
  86 + <el-table-column align="center" label="描述">
  87 + <template slot-scope="scope">
  88 + {{
  89 + scope.row.operationType == 0
  90 + ? "--"
  91 + : scope.row.reason == 0
  92 + ? "丢失"
  93 + : "损坏"
  94 + }}
  95 + </template></el-table-column
  96 + >
88 97 <el-table-column
89 98 align="center"
90 99 label="操作时间"
91   - prop="time"
  100 + prop="modifiedTime"
92 101 ></el-table-column>
93 102 </el-table>
  103 + <div class="pagination-box">
  104 + <el-pagination
  105 + small=""
  106 + layout="total,prev, pager, next"
  107 + :hide-on-single-page="true"
  108 + :total="total"
  109 + @current-change="changePage"
  110 + :current-page="page"
  111 + :page-size="size"
  112 + >
  113 + </el-pagination>
  114 + </div>
94 115 </div>
95 116 </div>
96 117 </div>
... ... @@ -100,19 +121,23 @@
100 121 export default {
101 122 data() {
102 123 return {
103   - loading:false,
104   - props: { multiple: true, checkStrictly: false },
  124 + loading: false,
  125 + props: { multiple: false },
105 126 query: {
106   - classId: [],
  127 + classId: "",
107 128 studentName: "",
108 129 studentCode: "",
109 130 },
110 131 gradeList: [],
111 132 tableData: [],
  133 + page: 1,
  134 + size: 20,
  135 + total: 0,
112 136 };
113 137 },
114 138 created() {
115   - // this._QueryGradeList();
  139 + this._QueryGradeList();
  140 + this._QueryData();
116 141 },
117 142 methods: {
118 143 // 查找班级
... ... @@ -142,12 +167,15 @@ export default {
142 167 this.$message.error(info);
143 168 }
144 169 },
  170 + changePage(page) {
  171 + this.page = page;
  172 + this._QueryData(4);
  173 + },
145 174 async _QueryData(type) {
146 175 let query = {};
147 176 query.gradeName = this.query.gradeName;
148   - query.classId = this.query.classId;
149 177 if (type == 1) {
150   - query.classId = this.query.classId;
  178 + query.classId = this.query.classId[1] ? this.query.classId[1] : "";
151 179 this.query.studentCode = "";
152 180 this.query.studentName = "";
153 181 } else if (type == 2) {
... ... @@ -158,15 +186,20 @@ export default {
158 186 query.studentCode = this.query.studentCode;
159 187 this.query.classId = "";
160 188 this.query.studentName = "";
  189 + } else {
  190 + query = { ...this.query };
161 191 }
162 192 this.loading = true;
163 193 const { data, status, info } = await this.$request.cardList({
164 194 ...query,
  195 + page: this.page,
  196 + size: 20,
165 197 });
166 198 this.loading = false;
167 199 console.log(status);
168 200 if (status === 0) {
169 201 this.tableData = data.list || [];
  202 + this.total = data.count;
170 203 } else {
171 204 this.$message.error(info);
172 205 }
... ...
src/views/device/index.vue
... ... @@ -5,7 +5,7 @@
5 5 <span>设备管理</span>
6 6 </template>
7 7 <template slot="btns" v-if="role != 'ROLE_JITUAN' && type == 1 && !code">
8   - <!-- <el-tooltip effect="dark" content="设备导入" placement="bottom">
  8 + <el-tooltip effect="dark" content="设备导入" placement="bottom">
9 9 <el-button
10 10 type="primary"
11 11 icon="el-icon-upload2"
... ... @@ -14,7 +14,7 @@
14 14 circle
15 15 @click="diaUp = true"
16 16 ></el-button>
17   - </el-tooltip> -->
  17 + </el-tooltip>
18 18 <el-tooltip
19 19 v-if="role == 'ROLE_XUEXIAO'"
20 20 effect="dark"
... ... @@ -400,7 +400,6 @@
400 400 </div>
401 401 <el-dialog title="设备导入" :visible.sync="diaUp" width="400">
402 402 <up-load
403   - id="downDevice"
404 403 :url="url"
405 404 @upSuccess="upSuccess"
406 405 fileName="设备信息"
... ... @@ -526,7 +525,7 @@ export default {
526 525 role: "",
527 526 code: "",
528 527 loading: false,
529   - url: "/web/upLoadDevice",
  528 + url: "/api_html/teaching/importStation",
530 529 diaUp: false,
531 530 diaAnswerEqu: false,
532 531 gradeList: [],
... ... @@ -788,16 +787,17 @@ export default {
788 787 }
789 788 },
790 789 async downExcel() {
791   - let data = await this.$request.downDevice({
  790 + let { data, status, info } = await this.$request.stationTemplateUrl({
792 791 id: this.id,
793 792 });
794   - if (data && !data.code) {
795   - let blob = new Blob([data], {
796   - type: "application/vnd.ms-excel;charset=utf-8",
797   - });
798   - downloadFile(`设备信息.xlsx`, blob);
  793 + if (status == 0) {
  794 + const a = document.createElement("a");
  795 + a.href = data.downloadUrl;
  796 + document.body.appendChild(a);
  797 + a.click();
  798 + a.remove();
799 799 } else {
800   - this.$message.error(data.info);
  800 + this.$message.error(info);
801 801 }
802 802 },
803 803  
... ...
src/views/down/index.vue
... ... @@ -12,11 +12,11 @@
12 12 </p>
13 13 <el-button plan round @click="links">授课端下载</el-button>
14 14 </div>
15   - <div class="down-item">
  15 + <div class="down-item" v-loading="loading">
16 16 <p class="txt">
17 17 配合发卡器硬件,方便学校管理员进行发卡补卡操作的软件。
18 18 </p>
19   - <el-button plan round>发卡软件下载</el-button>
  19 + <el-button plan round @click="downCard">发卡软件下载</el-button>
20 20 </div>
21 21 </div>
22 22 </div>
... ... @@ -24,12 +24,33 @@
24 24  
25 25 <script>
26 26 export default {
  27 + data() {
  28 + return {
  29 + loading: false,
  30 + };
  31 + },
27 32 methods: {
28 33 links() {
29 34 this.$router.push({
30 35 path: "/downClient",
31 36 });
32 37 },
  38 + async downCard() {
  39 + if (this.loading == true) return;
  40 + this.loading = true;
  41 + const { data, status, info } = await this.$request.latestClickersApp();
  42 + this.loading = false;
  43 + if (status == 0) {
  44 + const a = document.createElement("a");
  45 + a.href = data.downloadUrl;
  46 + a.download = data.appName;
  47 + document.body.appendChild(a);
  48 + a.click();
  49 + a.remove();
  50 + } else {
  51 + this.$message.error(info);
  52 + }
  53 + },
33 54 },
34 55 };
35 56 </script>
... ...
src/views/examinationPaper/add.vue
... ... @@ -185,8 +185,19 @@
185 185 </el-dialog>
186 186 </div>
187 187 <div v-show="step == 1">
188   - <div v-for="(question, index) in form.questionList" :key="index">
  188 + <div
  189 + class="question-box"
  190 + v-for="(question, index) in form.questionList"
  191 + :key="index"
  192 + >
189 193 <p class="question-title">
  194 + <el-tooltip effect="dark" :content="question.show?'收起':'展开'" placement="left">
  195 + <i
  196 + class="el-icon-caret-right"
  197 + :class="question.show ? 'active' : ''"
  198 + @click="question.show = !question.show"
  199 + ></i>
  200 + </el-tooltip>
190 201 <span>{{ setBigNum(index) }}、</span>
191 202 <el-input
192 203 class="ipt"
... ... @@ -210,128 +221,143 @@
210 221 <span class="m20">共:{{ question.subQuestions.length }}题</span>
211 222 <span>共:{{ setScore(question) }}分</span>
212 223 </p>
213   - <ul class="questions-ul">
214   - <li class="sub-questions">
215   - <div class="qs-num">题号</div>
216   - <div class="qs-type">题型</div>
217   - <div class="qs-score">分数</div>
218   - <div class="qs-partScore">漏选得分</div>
219   - <div class="qs-options">选项设置</div>
220   - <div class="qs-set">操作</div>
221   - </li>
222   - <li
223   - class="sub-questions"
224   - v-for="(subQuestions, indexs) in question.subQuestions"
225   - :key="indexs"
226   - >
227   - <div class="qs-num">{{ setNum(index, indexs) }}</div>
228   - <div class="qs-type">
229   - <el-select
230   - v-model="subQuestions.questionType"
231   - placeholder="选择题目类型"
232   - @change="changeSubQuestions($event, subQuestions)"
233   - >
234   - <el-option label="单选题" :value="2"></el-option>
235   - <el-option label="多选题" :value="3"></el-option>
236   - <el-option label="判断题" :value="4"></el-option>
237   - <el-option label="主观题" :value="5"></el-option>
238   - </el-select>
239   - </div>
240   - <div class="qs-score">
241   - <el-input-number
242   - class="number-ipt"
243   - size="medium"
244   - :min="1"
245   - :max="200"
246   - :precision="2"
247   - :step="1"
248   - v-model="subQuestions.score"
249   - label="单题分值"
250   - ></el-input-number>
251   - </div>
252   - <div class="qs-partScore">
253   - <p v-if="subQuestions.questionType != 3">--</p>
254   - <el-input-number
255   - class="number-ipt"
256   - v-else
257   - size="medium"
258   - :min="0"
259   - :precision="2"
260   - :max="subQuestions.score"
261   - :step="0.5"
262   - v-model="subQuestions.partScore"
263   - label="漏选得分"
264   - ></el-input-number>
265   - </div>
266   - <div class="qs-options">
267   - <p v-if="subQuestions.questionType == 5">--</p>
268   - <p
269   - v-else-if="subQuestions.questionType == 4"
270   - class="answer-box"
271   - >
272   - <span class="answer-s">✓</span>
273   - <span class="answer-s">✗</span>
274   - </p>
275   - <p v-else class="answer-box">
276   - <span
277   - class="answer-s"
278   - v-for="option in subQuestions.answerOptions.split(',')"
279   - :key="option"
280   - >{{ option }}</span
  224 + <transition name="el-zoom-in-top">
  225 + <ul v-show="question.show" class="questions-ul">
  226 + <li class="sub-questions">
  227 + <div class="qs-num">题号</div>
  228 + <div class="qs-type">题型</div>
  229 + <div class="qs-score">分数</div>
  230 + <div class="qs-partScore">漏选得分</div>
  231 + <div class="qs-options">选项设置</div>
  232 + <div class="qs-set">操作</div>
  233 + </li>
  234 + <li
  235 + class="sub-questions"
  236 + v-for="(subQuestions, indexs) in question.subQuestions"
  237 + :key="indexs"
  238 + >
  239 + <div class="qs-num">{{ setNum(index, indexs) }}</div>
  240 + <div class="qs-type">
  241 + <el-select
  242 + v-model="subQuestions.questionType"
  243 + placeholder="选择题目类型"
  244 + @change="changeSubQuestions($event, subQuestions)"
281 245 >
282   - <el-button
283   - size="mini"
284   - type="primary"
285   - icon="el-icon-plus"
286   - circle
287   - @click="addOptions(subQuestions)"
288   - ></el-button>
289   - <el-button
290   - size="mini"
291   - type="primary"
292   - icon="el-icon-minus"
293   - round
294   - circle
295   - @click="removeOptions(subQuestions)"
296   - ></el-button>
297   - </p>
298   - </div>
299   - <div class="qs-set">
300   - <el-popconfirm
301   - title="确定删除这道题吗?"
302   - @confirm="delTabData(indexs, index)"
303   - >
304   - <el-button
305   - slot="reference"
306   - class="delete"
307   - type="danger"
308   - size="mini"
309   - circle
310   - icon="el-icon-delete"
311   - ></el-button>
312   - </el-popconfirm>
313   - </div>
314   - </li>
315   - <li class="sub-questions">
316   - <div class="qs-num">添加</div>
317   - <div class="qs-type">
318   - <el-select
319   - v-model="addSubQuestionsType"
320   - placeholder="选择题目类型"
321   - @change="changeAddSubQuestions($event, question)"
322   - >
323   - <el-option label="单选题" :value="2"></el-option>
324   - <el-option label="多选题" :value="3"></el-option>
325   - <el-option label="判断题" :value="4"></el-option>
326   - <el-option label="主观题" :value="5"></el-option>
327   - </el-select>
328   - </div>
329   - <div class="qs-score"></div>
330   - <div class="qs-partScore"></div>
331   - <div class="qs-options"></div>
332   - <div class="qs-set"></div>
333   - </li>
334   - </ul>
  246 + <el-option label="单选题" :value="2"></el-option>
  247 + <el-option label="多选题" :value="3"></el-option>
  248 + <el-option label="判断题" :value="4"></el-option>
  249 + <el-option label="主观题" :value="5"></el-option>
  250 + </el-select>
  251 + </div>
  252 + <div class="qs-score">
  253 + <el-input-number
  254 + class="number-ipt"
  255 + size="medium"
  256 + :min="1"
  257 + :max="200"
  258 + :precision="2"
  259 + :step="1"
  260 + v-model="subQuestions.score"
  261 + label="单题分值"
  262 + ></el-input-number>
  263 + </div>
  264 + <div class="qs-partScore">
  265 + <p v-if="subQuestions.questionType != 3">--</p>
  266 + <el-input-number
  267 + class="number-ipt"
  268 + v-else
  269 + size="medium"
  270 + :min="0"
  271 + :precision="2"
  272 + :max="subQuestions.score"
  273 + :step="0.5"
  274 + v-model="subQuestions.partScore"
  275 + label="漏选得分"
  276 + ></el-input-number>
  277 + </div>
  278 + <div class="qs-options">
  279 + <p v-if="subQuestions.questionType == 5">--</p>
  280 + <p
  281 + v-else-if="subQuestions.questionType == 4"
  282 + class="answer-box"
  283 + >
  284 + <span
  285 + class="answer-s"
  286 + :class="subQuestions.correctAnswer == 1 ? 'active' : ''"
  287 + >✓</span
  288 + >
  289 + <span
  290 + class="answer-s"
  291 + :class="subQuestions.correctAnswer == 2 ? 'active' : ''"
  292 + >✗</span
  293 + >
  294 + </p>
  295 + <p v-else class="answer-box">
  296 + <span
  297 + class="answer-s"
  298 + v-for="option in subQuestions.answerOptions.split(',')"
  299 + :key="option"
  300 + :class="
  301 + subQuestions.correctAnswer?.includes(option)
  302 + ? 'active'
  303 + : ''
  304 + "
  305 + >{{ option }}</span
  306 + >
  307 + <el-button
  308 + size="mini"
  309 + type="primary"
  310 + icon="el-icon-plus"
  311 + circle
  312 + @click="addOptions(subQuestions)"
  313 + ></el-button>
  314 + <el-button
  315 + size="mini"
  316 + type="primary"
  317 + icon="el-icon-minus"
  318 + round
  319 + circle
  320 + @click="removeOptions(subQuestions)"
  321 + ></el-button>
  322 + </p>
  323 + </div>
  324 + <div class="qs-set">
  325 + <el-popconfirm
  326 + title="确定删除这道题吗?"
  327 + @confirm="delTabData(indexs, index)"
  328 + >
  329 + <el-button
  330 + slot="reference"
  331 + class="delete"
  332 + type="danger"
  333 + size="mini"
  334 + circle
  335 + icon="el-icon-delete"
  336 + ></el-button>
  337 + </el-popconfirm>
  338 + </div>
  339 + </li>
  340 + <li class="sub-questions">
  341 + <div class="qs-num">添加</div>
  342 + <div class="qs-type">
  343 + <el-select
  344 + v-model="addSubQuestionsType"
  345 + placeholder="选择题目类型"
  346 + @change="changeAddSubQuestions($event, question)"
  347 + >
  348 + <el-option label="单选题" :value="2"></el-option>
  349 + <el-option label="多选题" :value="3"></el-option>
  350 + <el-option label="判断题" :value="4"></el-option>
  351 + <el-option label="主观题" :value="5"></el-option>
  352 + </el-select>
  353 + </div>
  354 + <div class="qs-score"></div>
  355 + <div class="qs-partScore"></div>
  356 + <div class="qs-options"></div>
  357 + <div class="qs-set"></div>
  358 + </li>
  359 + </ul>
  360 + </transition>
335 361 </div>
336 362 <div class="add-box">
337 363 <p class="add-question" @click="openQuestion">
... ... @@ -379,7 +405,11 @@
379 405 </el-col>
380 406 </el-form-item>
381 407 <el-form-item label="选择题型:">
382   - <el-select v-model="questionForm.questionType" placeholder="">
  408 + <el-select
  409 + v-model="questionForm.questionType"
  410 + placeholder=""
  411 + @change="setQuestionForm"
  412 + >
383 413 <el-option
384 414 v-for="item in questionOptions"
385 415 :key="item.value"
... ... @@ -393,6 +423,7 @@
393 423 <el-form-item label="题数:">
394 424 <el-input-number
395 425 v-model="questionForm.number"
  426 + @change="changeQesNum"
396 427 :min="1"
397 428 :max="100"
398 429 :step-strictly="true"
... ... @@ -439,6 +470,113 @@
439 470 label="label"
440 471 ></el-input-number>
441 472 </el-form-item>
  473 + <el-form-item
  474 + label="设置答案:"
  475 + v-show="questionForm.questionType != 5"
  476 + >
  477 + <div class="qs-options">
  478 + <p class="ipt">
  479 + <el-input
  480 + v-if="
  481 + questionForm.questionType == 2 ||
  482 + questionForm.questionType == 3 ||
  483 + questionForm.questionType == 6
  484 + "
  485 + v-model="questionForm.answerList"
  486 + @keydown.native="
  487 + keydownAnswer($event, questionForm.questionType, 1)
  488 + "
  489 + @input="
  490 + setAllAnswer($event, questionForm.questionType, 1)
  491 + "
  492 + ></el-input>
  493 + <el-input
  494 + v-if="questionForm.questionType == 4"
  495 + v-model="questionForm.answerList"
  496 + readonly=""
  497 + ></el-input>
  498 + </p>
  499 + <p class="answer-box">
  500 + <template v-if="questionForm.questionType == 4">
  501 + <span
  502 + class="answer-s active"
  503 + @click="
  504 + questionForm.answerList.length < questionForm.number
  505 + ? (questionForm.answerList += '✓')
  506 + : ''
  507 + "
  508 + >✓</span
  509 + >
  510 + <span
  511 + class="answer-s active"
  512 + @click="
  513 + questionForm.answerList.length < questionForm.number
  514 + ? (questionForm.answerList += '✗')
  515 + : ''
  516 + "
  517 + >✗</span
  518 + >
  519 + </template>
  520 + <template v-if="questionForm.questionType == 3">
  521 + <template v-for="(option, opIdx) in rightOptions">
  522 + <span
  523 + v-if="opIdx < questionForm.selectNum"
  524 + class="answer-s active"
  525 + :key="option"
  526 + @click="setMultiple(questionForm, option)"
  527 + >{{ option }}</span
  528 + >
  529 + </template>
  530 + <span
  531 + class="answer-s active"
  532 + @click="
  533 + questionForm.answerList.split(',').length <
  534 + questionForm.number
  535 + ? (questionForm.answerList += ',')
  536 + : ''
  537 + "
  538 + >,</span
  539 + >
  540 + </template>
  541 + <template
  542 + v-if="
  543 + questionForm.questionType == 2 ||
  544 + questionForm.questionType == 6
  545 + "
  546 + class="answer-box"
  547 + >
  548 + <template v-for="(option, opIdx) in rightOptions">
  549 + <span
  550 + v-if="opIdx < questionForm.selectNum"
  551 + class="answer-s active"
  552 + :key="option"
  553 + @click="
  554 + questionForm.answerList.length < questionForm.number
  555 + ? (questionForm.answerList += option)
  556 + : ''
  557 + "
  558 + >{{ option }}</span
  559 + >
  560 + </template>
  561 + </template>
  562 + <span
  563 + class="answer-s delButton"
  564 + @click="
  565 + questionForm.answerList = questionForm.answerList.slice(
  566 + 0,
  567 + -1
  568 + )
  569 + "
  570 + >x</span
  571 + >
  572 + <span
  573 + class="answer-s ac"
  574 + @click="questionForm.answerList = ''"
  575 + >ac</span
  576 + >
  577 + </p>
  578 + </div>
  579 + </el-form-item>
442 580 </el-form>
443 581 </div>
444 582 <div class="dialog-footer" slot="footer">
... ... @@ -452,208 +590,212 @@
452 590 <p class="name">{{ form.title }}</p>
453 591 <p class="totals">卷面总分:{{ allScore }}分</p>
454 592 </div>
455   - <div v-for="(question, index) in form.questionList" :key="index">
  593 + <div
  594 + class="question-box"
  595 + v-for="(question, index) in form.questionList"
  596 + :key="index"
  597 + >
456 598 <p class="question-title">
457 599 <span>{{ setBigNum(index) }}、</span>
458 600 <span class="title-txt">{{ question.questionTitle }}</span>
459 601 <span class="m20">共:{{ setNums(question.subQuestions) }}题</span>
460 602 <span>共:{{ setScore(question) }} 分</span>
461 603 </p>
462   - <ul class="questions-ul">
463   - <li class="sub-questions">
464   - <div class="qs-num">题号</div>
465   - <div class="qs-type">题型</div>
466   - <div class="qs-score">分数</div>
467   - <div class="qs-partScore">漏选得分</div>
468   - <div class="qs-options qs-options2">选项设置</div>
469   - </li>
470   - <li
471   - v-for="(subQuestions, indexs) in question.subQuestions"
472   - :key="indexs"
473   - >
474   - <p
475   - class="set-ans-btn"
476   - v-if="
477   - subQuestions.qusType &&
478   - subQuestions.subNum &&
479   - subQuestions.subNum > 4
480   - "
  604 + <ul class="questions-ul">
  605 + <li class="sub-questions">
  606 + <div class="qs-num">题号</div>
  607 + <div class="qs-type">题型</div>
  608 + <div class="qs-score">分数</div>
  609 + <div class="qs-partScore">漏选得分</div>
  610 + <div class="qs-options qs-options2">选项设置</div>
  611 + </li>
  612 + <li
  613 + v-for="(subQuestions, indexs) in question.subQuestions"
  614 + :key="indexs"
481 615 >
482   - <el-button type="primary" @click="setFormAns(indexs, index)"
483   - >批量设置答案</el-button
  616 + <p
  617 + class="set-ans-btn"
  618 + v-if="
  619 + subQuestions.qusType &&
  620 + subQuestions.subNum &&
  621 + subQuestions.subNum > 4
  622 + "
484 623 >
485   - </p>
486   - <div v-else class="sub-questions">
487   - <div class="qs-num">
488   - {{ setNum(index, indexs, subQuestions) }}
489   - </div>
490   - <div class="qs-type">
491   - {{ setSubPro(subQuestions.questionType) }}
492   - </div>
493   - <div class="qs-score">
494   - <el-input-number
495   - class="number-ipt"
496   - size="medium"
497   - :min="1"
498   - :max="200"
499   - :precision="2"
500   - v-model="subQuestions.score"
501   - label="单题分值"
502   - ></el-input-number>
503   - </div>
504   - <div class="qs-partScore">
505   - <p v-if="subQuestions.questionType != 3">--</p>
506   - <el-input-number
507   - class="number-ipt"
508   - v-else
509   - size="medium"
510   - :min="0"
511   - :precision="2"
512   - :max="subQuestions.score"
513   - :step="0.5"
514   - v-model="subQuestions.partScore"
515   - label="漏选得分"
516   - ></el-input-number>
517   - </div>
518   - <div class="qs-options qs-options2">
519   - <p v-if="subQuestions.questionType == 5">--</p>
520   - <p v-if="subQuestions.questionType == 4" class="answer-box">
521   - <span
522   - class="answer-s"
523   - :class="subQuestions.correctAnswer == 1 ? 'active' : ''"
524   - @click="subQuestions.correctAnswer = 1"
525   - >✓</span
526   - >
527   - <span
528   - class="answer-s"
529   - :class="subQuestions.correctAnswer == 2 ? 'active' : ''"
530   - @click="subQuestions.correctAnswer = 2"
531   - >✗</span
532   - >
533   - </p>
534   - <p v-if="subQuestions.questionType == 3" class="answer-box">
535   - <span
536   - class="answer-s"
537   - v-for="option in subQuestions.answerOptions.split(',')"
538   - :class="
539   - subQuestions.correctAnswer?.includes(option)
540   - ? 'active'
541   - : ''
542   - "
543   - :key="option"
544   - @click="changAnswer(subQuestions, option)"
545   - >{{ option }}</span
546   - >
547   - </p>
548   - <p v-if="subQuestions.questionType == 2" class="answer-box">
549   - <span
550   - class="answer-s"
551   - v-for="option in subQuestions.answerOptions.split(',')"
552   - :class="
553   - subQuestions.correctAnswer == option ? 'active' : ''
554   - "
555   - :key="option"
556   - @click="subQuestions.correctAnswer = option"
557   - >{{ option }}</span
558   - >
559   - </p>
560   - </div>
561   - </div>
562   - </li>
563   - </ul>
564   - <el-dialog
565   - title="批量设置答案"
566   - :visible.sync="diaSetAns"
567   - :close-on-click-modal="false"
568   - width="400"
569   - :modal-append-to-body="false"
570   - >
571   - <div class="qs-options">
572   - <p class="dia-tips">
573   - 请点击选项按钮设置答案,多选题题目之间用“,”隔开,若添加5道题:“AC,AD,BD,AC,CD”
574   - </p>
575   - <p>{{ setSubPro(formAns.qusType) }}:</p>
576   - <p class="ipt">
577   - <el-input
578   - v-if="formAns.qusType == 2 || formAns.qusType == 3"
579   - v-model="formAns.answerList"
580   - @keydown.native="keydownAnswer($event, formAns.qusType)"
581   - @input="setAllAnswer($event, formAns.qusType)"
582   - ></el-input>
583   - <el-input
584   - v-if="formAns.qusType == 4"
585   - v-model="formAns.answerList"
586   - readonly=""
587   - ></el-input>
588   - </p>
589   - <p class="answer-box">
590   - <template v-if="formAns.qusType == 4">
591   - <span
592   - class="answer-s active"
593   - @click="
594   - formAns.answerList.length < formAns.subNum
595   - ? (formAns.answerList += '✓')
596   - : ''
597   - "
598   - >✓</span
599   - >
600   - <span
601   - class="answer-s active"
602   - @click="
603   - formAns.answerList.length < formAns.subNum
604   - ? (formAns.answerList += '✗')
605   - : ''
606   - "
607   - >✗</span
608   - >
609   - </template>
610   - <template v-if="formAns.qusType == 3">
611   - <span
612   - class="answer-s active"
613   - v-for="option in formAns.answerOptions.split(',')"
614   - :key="option"
615   - @click="setMultiple(formAns, option)"
616   - >{{ option }}</span
  624 + <el-button type="primary" @click="setFormAns(indexs, index)"
  625 + >批量设置答案</el-button
617 626 >
618   - <span
619   - class="answer-s active"
620   - @click="
621   - formAns.answerList.split(',').length < formAns.subNum
622   - ? (formAns.answerList += ',')
623   - : ''
624   - "
625   - >,</span
626   - >
627   - </template>
628   - <template v-if="formAns.qusType == 2" class="answer-box">
629   - <span
630   - class="answer-s active"
631   - v-for="option in formAns.answerOptions.split(',')"
632   - :key="option"
633   - @click="
634   - formAns.answerList.length < formAns.subNum
635   - ? (formAns.answerList += option)
636   - : ''
637   - "
638   - >{{ option }}</span
639   - >
640   - </template>
  627 + </p>
  628 + <div v-else class="sub-questions">
  629 + <div class="qs-num">
  630 + {{ setNum(index, indexs, subQuestions) }}
  631 + </div>
  632 + <div class="qs-type">
  633 + {{ setSubPro(subQuestions.questionType) }}
  634 + </div>
  635 + <div class="qs-score">
  636 + <el-input-number
  637 + class="number-ipt"
  638 + size="medium"
  639 + :min="1"
  640 + :max="200"
  641 + :precision="2"
  642 + v-model="subQuestions.score"
  643 + label="单题分值"
  644 + ></el-input-number>
  645 + </div>
  646 + <div class="qs-partScore">
  647 + <p v-if="subQuestions.questionType != 3">--</p>
  648 + <el-input-number
  649 + class="number-ipt"
  650 + v-else
  651 + size="medium"
  652 + :min="0"
  653 + :precision="2"
  654 + :max="subQuestions.score"
  655 + :step="0.5"
  656 + v-model="subQuestions.partScore"
  657 + label="漏选得分"
  658 + ></el-input-number>
  659 + </div>
  660 + <div class="qs-options qs-options2">
  661 + <p v-if="subQuestions.questionType == 5">--</p>
  662 + <p v-if="subQuestions.questionType == 4" class="answer-box">
  663 + <span
  664 + class="answer-s"
  665 + :class="subQuestions.correctAnswer == 1 ? 'active' : ''"
  666 + @click="subQuestions.correctAnswer = 1"
  667 + >✓</span
  668 + >
  669 + <span
  670 + class="answer-s"
  671 + :class="subQuestions.correctAnswer == 2 ? 'active' : ''"
  672 + @click="subQuestions.correctAnswer = 2"
  673 + >✗</span
  674 + >
  675 + </p>
  676 + <p v-if="subQuestions.questionType == 3" class="answer-box">
  677 + <span
  678 + class="answer-s"
  679 + v-for="option in subQuestions.answerOptions.split(',')"
  680 + :class="
  681 + subQuestions.correctAnswer?.includes(option)
  682 + ? 'active'
  683 + : ''
  684 + "
  685 + :key="option"
  686 + @click="changAnswer(subQuestions, option)"
  687 + >{{ option }}</span
  688 + >
  689 + </p>
  690 + <p v-if="subQuestions.questionType == 2" class="answer-box">
  691 + <span
  692 + class="answer-s"
  693 + v-for="option in subQuestions.answerOptions.split(',')"
  694 + :class="
  695 + subQuestions.correctAnswer == option ? 'active' : ''
  696 + "
  697 + :key="option"
  698 + @click="subQuestions.correctAnswer = option"
  699 + >{{ option }}</span
  700 + >
  701 + </p>
  702 + </div>
  703 + </div>
  704 + </li>
  705 + </ul>
  706 + </div>
  707 + <el-dialog
  708 + title="批量设置答案"
  709 + :visible.sync="diaSetAns"
  710 + :close-on-click-modal="false"
  711 + width="400"
  712 + :modal-append-to-body="false"
  713 + >
  714 + <div class="qs-options">
  715 + <p class="dia-tips">
  716 + 请点击选项按钮设置答案,多选题题目之间用“,”隔开,若添加5道题:“AC,AD,BD,AC,CD”
  717 + </p>
  718 + <p>{{ setSubPro(formAns.qusType) }}:</p>
  719 + <p class="ipt">
  720 + <el-input
  721 + v-if="formAns.qusType == 2 || formAns.qusType == 3"
  722 + v-model="formAns.answerList"
  723 + @keydown.native="keydownAnswer($event, formAns.qusType)"
  724 + @input="setAllAnswer($event, formAns.qusType)"
  725 + ></el-input>
  726 + <el-input
  727 + v-if="formAns.qusType == 4"
  728 + v-model="formAns.answerList"
  729 + readonly=""
  730 + ></el-input>
  731 + </p>
  732 + <p class="answer-box">
  733 + <template v-if="formAns.qusType == 4">
641 734 <span
642   - class="answer-s delButton"
643   - @click="formAns.answerList = formAns.answerList.slice(0, -1)"
644   - >x</span
  735 + class="answer-s active"
  736 + @click="
  737 + formAns.answerList.length < formAns.subNum
  738 + ? (formAns.answerList += '✓')
  739 + : ''
  740 + "
  741 + >✓</span
645 742 >
646   - <span class="answer-s ac" @click="formAns.answerList = ''"
647   - >ac</span
  743 + <span
  744 + class="answer-s active"
  745 + @click="
  746 + formAns.answerList.length < formAns.subNum
  747 + ? (formAns.answerList += '✗')
  748 + : ''
  749 + "
  750 + >✗</span
648 751 >
649   - </p>
650   - </div>
651   - <div class="dialog-footer" slot="footer">
652   - <el-button @click="saveFormAns">确 定</el-button>
653   - <el-button @click="diaSetAns = false">取 消</el-button>
654   - </div>
655   - </el-dialog>
656   - </div>
  752 + </template>
  753 + <template v-if="formAns.qusType == 3">
  754 + <span
  755 + class="answer-s active"
  756 + v-for="option in formAns.answerOptions.split(',')"
  757 + :key="option"
  758 + @click="setMultiple(formAns, option)"
  759 + >{{ option }}</span
  760 + >
  761 + <span
  762 + class="answer-s active"
  763 + @click="
  764 + formAns.answerList.split(',').length < formAns.subNum
  765 + ? (formAns.answerList += ',')
  766 + : ''
  767 + "
  768 + >,</span
  769 + >
  770 + </template>
  771 + <template v-if="formAns.qusType == 2" class="answer-box">
  772 + <span
  773 + class="answer-s active"
  774 + v-for="option in formAns.answerOptions.split(',')"
  775 + :key="option"
  776 + @click="
  777 + formAns.answerList.length < formAns.subNum
  778 + ? (formAns.answerList += option)
  779 + : ''
  780 + "
  781 + >{{ option }}</span
  782 + >
  783 + </template>
  784 + <span
  785 + class="answer-s delButton"
  786 + @click="formAns.answerList = formAns.answerList.slice(0, -1)"
  787 + >x</span
  788 + >
  789 + <span class="answer-s ac" @click="formAns.answerList = ''"
  790 + >ac</span
  791 + >
  792 + </p>
  793 + </div>
  794 + <div class="dialog-footer" slot="footer">
  795 + <el-button @click="saveFormAns">确 定</el-button>
  796 + <el-button @click="diaSetAns = false">取 消</el-button>
  797 + </div>
  798 + </el-dialog>
657 799 <div class="btn-box">
658 800 <el-button type="danger" plain round @click="linkBack"
659 801 >取消</el-button
... ... @@ -675,6 +817,7 @@ const questionForm = {
675 817 selectNum: 4,
676 818 score: 1,
677 819 partScore: 0,
  820 + answerList: "",
678 821 };
679 822 const subQuesOptions = {
680 823 questionType: 2,
... ... @@ -878,6 +1021,28 @@ export default {
878 1021  
879 1022 return txt;
880 1023 },
  1024 + setQuestionForm(val) {
  1025 + //切换题型清空答案
  1026 + this.questionForm.answerList = "";
  1027 + },
  1028 + changeQesNum(val) {
  1029 + //减少题数设置答案
  1030 + if (
  1031 + this.questionForm.questionType == 2 ||
  1032 + this.questionForm.questionType == 4
  1033 + ) {
  1034 + this.questionForm.answerList = this.questionForm.answerList.substring(
  1035 + 0,
  1036 + val
  1037 + );
  1038 + } else {
  1039 + console.log(this.questionForm.answerList.split(","));
  1040 + this.questionForm.answerList = this.questionForm.answerList
  1041 + .split(",")
  1042 + .splice(0, val)
  1043 + .join(",");
  1044 + }
  1045 + },
881 1046 setFormAns(indexs, index) {
882 1047 //初始化要修改的答案
883 1048 this.formAns = { ...this.form.questionList[index].subQuestions[indexs] };
... ... @@ -904,12 +1069,17 @@ export default {
904 1069 //多选答案设置
905 1070 obj.answerList += answer;
906 1071 let str = obj.answerList;
907   - let str2 = checkAnswer(
908   - str,
909   - 3,
910   - obj.answerOptions.split(",").length,
911   - obj.answerList.length
912   - );
  1072 + let str2;
  1073 + if (!!obj.answerOptions) {
  1074 + str2 = checkAnswer(
  1075 + str,
  1076 + 3,
  1077 + obj.answerOptions.split(",").length,
  1078 + obj.answerList.length
  1079 + );
  1080 + } else {
  1081 + str2 = checkAnswer(str, 3, obj.selectNum, obj.answerList.length);
  1082 + }
913 1083 obj.answerList = str2;
914 1084 },
915 1085 saveFormAns() {
... ... @@ -931,7 +1101,6 @@ export default {
931 1101 correctAnswer = this.formAns.answerList[subNum - i];
932 1102 } else if (this.formAns.qusType == 3) {
933 1103 correctAnswer = this.formAns.answerList.split(",")[subNum - i];
934   -
935 1104 console.log(this.formAns.answerList.split(",")[subNum - i]);
936 1105 } else if (this.formAns.qusType == 4) {
937 1106 correctAnswer =
... ... @@ -969,11 +1138,16 @@ export default {
969 1138 // event.returnValue = "";
970 1139 // }
971 1140 // },
972   - keydownAnswer(event, type) {
  1141 + keydownAnswer(event, type, isAddBig) {
973 1142 let answerA = "ABCDEFG";
974 1143 let answer_a = "abcdefg";
975   - answerA = answerA.substring(0, this.formAns.subNum);
976   - answer_a = answer_a.substring(0, this.formAns.subNum);
  1144 + if (isAddBig) {
  1145 + answerA = answerA.substring(0, this.questionForm.selectNum);
  1146 + answer_a = answer_a.substring(0, this.questionForm.selectNum);
  1147 + } else {
  1148 + answerA = answerA.substring(0, this.formAns.subNum);
  1149 + answer_a = answer_a.substring(0, this.formAns.subNum);
  1150 + }
977 1151 answerA += answer_a;
978 1152 answerA = type == 2 ? answerA : answerA + ",";
979 1153 if (
... ... @@ -996,15 +1170,26 @@ export default {
996 1170 event.returnValue = "";
997 1171 }
998 1172 },
999   - setAllAnswer(event, type) {
1000   - let str = this.formAns.answerList;
1001   - let str2 = checkAnswer(
1002   - str,
1003   - type,
1004   - this.formAns.answerOptions.split(",").length,
1005   - this.formAns.subNum
1006   - );
1007   - this.formAns.answerList = str2;
  1173 + setAllAnswer(event, type, isAddBig) {
  1174 + if (isAddBig) {
  1175 + let str = this.questionForm.answerList;
  1176 + let str2 = checkAnswer(
  1177 + str,
  1178 + type,
  1179 + this.questionForm.selectNum,
  1180 + this.questionForm.number
  1181 + );
  1182 + this.questionForm.answerList = str2;
  1183 + } else {
  1184 + let str = this.formAns.answerList;
  1185 + let str2 = checkAnswer(
  1186 + str,
  1187 + type,
  1188 + this.formAns.answerOptions.split(",").length,
  1189 + this.formAns.subNum
  1190 + );
  1191 + this.formAns.answerList = str2;
  1192 + }
1008 1193 },
1009 1194 setAnswer(type, ans) {
1010 1195 let txt = "";
... ... @@ -1133,6 +1318,7 @@ export default {
1133 1318 this.addQuestionVisible = true;
1134 1319 },
1135 1320 addQuestion() {
  1321 + //添加大题
1136 1322 let subQuestions = [];
1137 1323 let questionsOptions = {
1138 1324 ...subQuesOptions,
... ... @@ -1164,6 +1350,20 @@ export default {
1164 1350 break;
1165 1351 }
1166 1352 for (let i = 0; i < this.questionForm.number; i++) {
  1353 + let answer = "";
  1354 + if (questionsOptions.questionType == 4) {
  1355 + answer =
  1356 + this.questionForm.answerList[i] == "✓"
  1357 + ? 1
  1358 + : this.questionForm.answerList[i] == "✗"
  1359 + ? 2
  1360 + : "";
  1361 + } else if (questionsOptions.questionType == 3) {
  1362 + answer = this.questionForm.answerList.split(",")[i] || "";
  1363 + } else if (questionsOptions.questionType == 2) {
  1364 + answer = this.questionForm.answerList[i] || "";
  1365 + }
  1366 + questionsOptions.correctAnswer = answer;
1167 1367 subQuestions.push({ ...questionsOptions });
1168 1368 }
1169 1369 this.form.questionList.push({
... ... @@ -1171,6 +1371,7 @@ export default {
1171 1371 number: this.questionForm.number,
1172 1372 source: 10,
1173 1373 subQuestions: [...subQuestions],
  1374 + show: false,
1174 1375 });
1175 1376 this.addQuestionVisible = false;
1176 1377 },
... ... @@ -1347,8 +1548,12 @@ export default {
1347 1548 if (this.saveLoading) return;
1348 1549 this.saveLoading = true;
1349 1550 this.formatQuestionList();
  1551 + let formDatas = deepClone(this.form)
  1552 + for (let i = 0; i < formDatas.questionList.length; i++) {
  1553 + delete formDatas.questionList[i].show
  1554 + }
1350 1555 const { data, status, info } = await this.$request.addPaper({
1351   - ...this.form,
  1556 + ...formDatas,
1352 1557 });
1353 1558 this.saveLoading = false;
1354 1559 if (status == 0) {
... ... @@ -1480,13 +1685,13 @@ export default {
1480 1685 background-size: 19px;
1481 1686 color: transparent;
1482 1687 }
1483   - .answer-s.ac{
1484   - border:none;
  1688 + .answer-s.ac {
  1689 + border: none;
1485 1690 }
1486 1691 .ac {
1487 1692 border-color: #ff6868;
1488 1693 background: #ff6868;
1489   - color: #fff!important;
  1694 + color: #fff !important;
1490 1695 }
1491 1696 }
1492 1697  
... ... @@ -1573,10 +1778,16 @@ export default {
1573 1778 margin: 0 12px;
1574 1779 }
1575 1780 }
  1781 +.question-box {
  1782 + margin-bottom: 20px;
  1783 +}
1576 1784 .question-title {
1577 1785 line-height: 40px;
  1786 + display: flex;
  1787 + align-items: center;
  1788 + margin-bottom: 12px;
1578 1789 .m20 {
1579   - margin-right: 20px;
  1790 + margin: 0 20px;
1580 1791 }
1581 1792 .ipt {
1582 1793 width: 300px;
... ... @@ -1595,6 +1806,20 @@ export default {
1595 1806 font-size: 16px;
1596 1807 font-weight: 700;
1597 1808 }
  1809 + .el-icon-caret-right {
  1810 + font-size: 24px;
  1811 + color: #888;
  1812 + transition: all 0.4s;
  1813 + margin-right: 12px;
  1814 + cursor: pointer;
  1815 + &.active {
  1816 + transform: rotate(90deg);
  1817 + }
  1818 + }
  1819 +}
  1820 +.questions-ul {
  1821 + border-left: 1px solid #e2e2e2;
  1822 + border-top: 1px solid #e2e2e2;
1598 1823 }
1599 1824 .el-input-number {
1600 1825 width: 140px;
... ... @@ -1630,11 +1855,6 @@ export default {
1630 1855 }
1631 1856 }
1632 1857 }
1633   -.questions-ul {
1634   - border-left: 1px solid #e2e2e2;
1635   - border-top: 1px solid #e2e2e2;
1636   - margin: 12px 0;
1637   -}
1638 1858 .qs-options {
1639 1859 .answer-s {
1640 1860 display: inline-block;
... ...
src/views/setUp/school.vue
... ... @@ -308,6 +308,9 @@ export default {
308 308 if (!this.subjectName) {
309 309 this.$message.warning("请填写科目名称");
310 310 return;
  311 + }else if(this.subjectList.includes(this.subjectName)){
  312 + this.$message.warning("科目已存在,请重新填写~");
  313 + return;
311 314 }
312 315 this.subjectList.push(this.subjectName);
313 316 this.formGrade.subjectNames.push(this.subjectName);
... ...