Blame view

admin-web-master/src/views/investigation/question.vue 32.8 KB
3f535f30   杨鑫   '初始'
1
  <template>
95f61c80   杨鑫   '最新'
2
    <div style="background-color: #f7f7f7; padding: 10px 10px">
3f535f30   杨鑫   '初始'
3
      <div class="zhuti">
95f61c80   杨鑫   '最新'
4
5
6
7
8
        <div style="height: 58px; line-height: 58px">
          <div style="color: #0006">
            <span>问卷调查</span> <span style="padding: 0 5px">></span>
            <span style="color: #000000e6">题库管理</span>
          </div>
3f535f30   杨鑫   '初始'
9
10
11
12
13
14
        </div>
        <!-- 线上 -->
        <div>
          <!-- 搜索 -->
  
          <div class="formSearch">
3f535f30   杨鑫   '初始'
15
16
            <el-form :inline="true" :model="formSel">
              <el-form-item label="题库管理">
95f61c80   杨鑫   '最新'
17
18
19
20
21
22
                <el-select v-model="formSel.questionBank" placeholder="请选择" style="width: 168px; margin-right: 15px"
                  @change="tikuBox">
                  <el-option label="用户端题库" value="用户端题库" />
                  <el-option label="商户端题库" value="商户端题库" />
                  <el-option label="公共端题库" value="公共端题库" />
                </el-select>
3f535f30   杨鑫   '初始'
23
24
              </el-form-item>
              <el-form-item label="题目">
95f61c80   杨鑫   '最新'
25
                <el-input v-model="formSel.tikuTitle" placeholder="请输入" style="width: 168px" />
3f535f30   杨鑫   '初始'
26
27
              </el-form-item>
              <el-form-item label="题型">
95f61c80   杨鑫   '最新'
28
                <el-select v-model="formSel.questionType" placeholder="请选择" style="width: 168px; margin-right: 15px">
3f535f30   杨鑫   '初始'
29
30
31
32
33
                  <el-option label="单选" value="单选" />
                  <el-option label="多选" value="多选" />
                  <el-option label="文本" value="文本" />
                </el-select>
              </el-form-item>
3f535f30   杨鑫   '初始'
34
35
            </el-form>
            <div>
95f61c80   杨鑫   '最新'
36
              <el-button style="background-color: #3f9b6a; color: #fff" @click="onSubmit">查询
3f535f30   杨鑫   '初始'
37
              </el-button>
95f61c80   杨鑫   '最新'
38
39
40
41
42
              <el-button class="buttonHover" style="
                  color: #606266;
                  border: 1px solid #dddfe5;
                  background-color: #fff;
                " @click="resetting">重置
3f535f30   杨鑫   '初始'
43
44
45
              </el-button>
            </div>
          </div>
95f61c80   杨鑫   '最新'
46
          <div style="margin-bottom: 20px">
3f535f30   杨鑫   '初始'
47
            <div>
95f61c80   杨鑫   '最新'
48
49
              <el-button style="background-color: #3f9b6a; color: #fff; padding: 8px 15px"
                icon="el-icon-circle-plus-outline" @click="addTimu">新增</el-button>
3f535f30   杨鑫   '初始'
50
51
52
53
            </div>
          </div>
          <!-- 表格 -->
  
95f61c80   杨鑫   '最新'
54
55
56
57
58
59
60
61
62
63
          <el-table :data="tableData.slice(
  					(currentPage - 1) * pageSize,
  					currentPage * pageSize
  				)
  					" :header-cell-style="{
  						fontSize: '14px',
  						color: '#0009',
  						fontWeight: 'normal',
  						backgroundColor: '#F2F3F5',
  					}" tooltip-effect="dark custom-tooltip-effect">
3f535f30   杨鑫   '初始'
64
65
            <el-table-column label="序号" min-width="150">
              <template slot-scope="scope">
95f61c80   杨鑫   '最新'
66
                {{ scope.$index + 1 }}
3f535f30   杨鑫   '初始'
67
68
69
              </template>
            </el-table-column>
  
95f61c80   杨鑫   '最新'
70
71
            <el-table-column label="题目" prop="tikuTitle" min-width="300" show-overflow-tooltip />
            <el-table-column label="题型" prop="questionType" min-width="150" />
3f535f30   杨鑫   '初始'
72
73
74
  
            <!-- <el-table-column label="创建人" prop="createUser" min-width="150">
            </el-table-column> -->
95f61c80   杨鑫   '最新'
75
            <el-table-column prop="createDate" label="创建时间" min-width="200" />
3f535f30   杨鑫   '初始'
76
77
            <el-table-column label="操作" min-width="200">
              <template slot-scope="scope">
95f61c80   杨鑫   '最新'
78
79
80
81
                <div class="tableBtn greens" @click="details(0, scope.row)">
                  查看
                </div>
                <div class="tableBtn greens" @click="bianls(scope.row)">编辑</div>
3f535f30   杨鑫   '初始'
82
83
                <!-- <div @click="" class="tableBtn greens">发布</div>
                <div @click="" class="tableBtn greens">下架</div> -->
95f61c80   杨鑫   '最新'
84
85
86
                <div class="tableBtn greens" @click="tikuDel(scope.row)">
                  删除
                </div>
3f535f30   杨鑫   '初始'
87
88
89
90
91
                <!-- <div @click="addbuss(3,scope.row)" class="tableBtn greens">终止</div> -->
              </template>
            </el-table-column>
          </el-table>
          <div class="fenye">
95f61c80   杨鑫   '最新'
92
93
            <el-pagination :hide-on-single-page="flag" background small size="mini" :current-page="currentPage"
              :page-sizes="[10, 20, 50, 100]" layout="prev, pager, next,total" :total="total"
3f535f30   杨鑫   '初始'
94
95
96
              @size-change="handleSizeChange" @current-change="handleCurrentChange" />
          </div>
        </div>
3f535f30   杨鑫   '初始'
97
98
      </div>
      <!-- 详情框 -->
95f61c80   杨鑫   '最新'
99
      <el-dialog :visible.sync="detbox" custom-class="tongyong_css" style="padding: 0" width="50%" center
3f535f30   杨鑫   '初始'
100
        :close-on-click-modal="false" :show-close="false">
95f61c80   杨鑫   '最新'
101
102
103
104
        <div style="padding: 20px">
          <div style="font-size: 14px; padding-bottom: 20px; color: #000">
            详情页
          </div>
3f535f30   杨鑫   '初始'
105
          <div>
95f61c80   杨鑫   '最新'
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
            <el-descriptions class="margin-top" :column="1" border :label-style="labelStyle"
              :content-style="contentStyle">
              <el-descriptions-item>
                <template slot="label"> 题目 </template>
                {{ secondData.tikuTitle }}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 题型 </template>
                {{ secondData.questionType }}
              </el-descriptions-item>
  			<el-descriptions-item v-if="secondData.questionType == '多选'">
                <template slot="label"> 最多可选 </template>
                {{ secondData.maxChoose || '0' }}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 隶属题库 </template>
                {{ secondData.questionBank }}
              </el-descriptions-item>
            </el-descriptions>
            <el-descriptions v-if="secondData.questionType != '文本'" class="margin-top" :column="1" border
              :label-style="labelStyle" :content-style="contentStyle">
              <el-descriptions-item>
                <template slot="label"> 默认是否必填 </template>
                {{ secondData.isRequired }}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label"> 设置内容 </template>
                <div v-for="(value, key) in secondData.optionSettings" :key="key">
                  {{ key }}:{{ value }}
                </div>
              </el-descriptions-item>
            </el-descriptions>
3f535f30   杨鑫   '初始'
138
          </div>
95f61c80   杨鑫   '最新'
139
140
141
142
143
144
          <div style="padding-top: 20px; display: flex; justify-content: flex-end">
            <el-button class="buttonHover" style="
                color: #606266;
                border: 1px solid #dddfe5;
                background-color: #fff;
              " @click="detbox = false">返回</el-button>
3f535f30   杨鑫   '初始'
145
146
          </div>
        </div>
3f535f30   杨鑫   '初始'
147
148
149
      </el-dialog>
  
      <!-- 新增 -->
95f61c80   杨鑫   '最新'
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
      <el-dialog :visible.sync="ggXin" custom-class="tongyong_css" style="padding: 0" width="60%" class="dialog_css_Xq"
        center :close-on-click-modal="false" :show-close="false">
        <div style="padding: 20px">
          <div style="font-size: 14px; padding-bottom: 20px; color: #000">
            新增题目
          </div>
          <div style="padding: 20px">
            <el-form ref="reform" :model="formInline" label-width="140px" :rules="rules">
              <el-form-item label="题目" prop="tikuTitle">
                <el-input v-model="formInline.tikuTitle" maxlength="100" />
              </el-form-item>
              <el-form-item label="题型" prop="questionType">
                <el-select v-model="formInline.questionType" placeholder="请选择">
                  <el-option label="单选" value="单选" />
                  <el-option label="多选" value="多选" />
                  <el-option label="文本" value="文本" />
                </el-select>
              </el-form-item>
              <!-- 如果formInline.questionType为多选,那么就显示最多可以选择多少个,计步器来设置,默认是 0 -->
              <el-form-item v-if="formInline.questionType == '多选'" label="最多可选" prop="maxChoose">
                <el-input-number v-model="formInline.maxChoose" :min="0" :max="options.length" />0为不限制填写数量
              </el-form-item>
              <el-form-item label="隶属题库" prop="questionBank">
                <el-select v-model="formInline.questionBank" placeholder="请选择">
                  <el-option label="用户端题库" value="用户端题库" />
                  <el-option label="商户端题库" value="商户端题库" />
                  <el-option label="公共端题库" value="公共端题库" />
                </el-select>
              </el-form-item>
              <el-form-item label="布局类型" prop="layoutType">
                <el-radio-group v-model="formInline.layoutType" style="margin-top: 13px">
                  <el-radio :label="1">垂直布局</el-radio>
                  <el-radio :label="2">自由布局</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="是否必填" prop="isRequired">
                <!-- <el-select v-model="formInline.isRequired" placeholder="请选择">
3f535f30   杨鑫   '初始'
187
188
189
                   <el-option label="必填" value="必填" />
                   <el-option label="非必填" value="非必填" />
                 </el-select> -->
95f61c80   杨鑫   '最新'
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
                <el-radio-group v-model="formInline.isRequired" style="margin-top: 13px">
                  <el-radio label="必填">必填</el-radio>
                  <el-radio label="非必填">非必填</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item v-if="formInline.questionType != '文本'" label="答案设置" prop="optionSettings">
                <el-table :data="options" :header-cell-style="{
  								fontSize: '14px',
  								color: '#0009',
  								fontWeight: 'normal',
  								backgroundColor: '#F2F3F5',
  							}">
                  <el-table-column prop="index" label="序号" width="80">
                    <template #default="scope">
                      {{ scope.$index + 1 }}
                    </template>
                  </el-table-column>
                  <el-table-column prop="name" label="选项名称" width="300">
                    <template #default="scope">
                      <el-input v-model="scope.row.name" :readonly="scope.row.readonly" maxlength="50" />
                    </template>
                  </el-table-column>
                  <el-table-column prop="name" label="分数">
                    <template #default="scope">
                      <el-input v-model.number="scope.row.num" :min="0" :max="100" :readonly="scope.row.readonly"
                        @input="validateScore(scope.row)" />
                    </template>
                  </el-table-column>
                  <el-table-column label=""  min-width="120">
                    <template #default="{ $index }">
                      <span style="cursor: pointer;margin-right: 5px; color: #3F9B6A;" @click="answerMoveUp($index)"
                        v-if="$index != 0">↑</span>
                      <span style="cursor: pointer; color: #3F9B6A;" @click="answerMoveDown($index)"
                        v-if="$index != (options.length - 1)">↓</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="操作">
                    <template #default="scope">
                      <div class="tableBtn greens" @click="deleteOption(scope.$index)">
                        删除
                      </div>
                    </template>
                  </el-table-column>
                </el-table>
                <el-button style="width: 100%; background-color: #3f9b6a; color: #fff" @click="addOption">+
                  添加</el-button>
              </el-form-item>
            </el-form>
          </div>
3f535f30   杨鑫   '初始'
239
  
95f61c80   杨鑫   '最新'
240
241
242
243
244
245
246
          <div style="padding-top: 20px; display: flex; justify-content: flex-end">
            <el-button class="buttonHover" style="
                color: #606266;
                border: 1px solid #dddfe5;
                background-color: #fff;
              " @click="closeFn(1)">返回</el-button>
            <el-button style="background-color: #3f9b6a; color: #fff" @click="addCheck(2)">确认</el-button>
3f535f30   杨鑫   '初始'
247
248
          </div>
        </div>
3f535f30   杨鑫   '初始'
249
250
      </el-dialog>
      <!-- 编辑 -->
95f61c80   杨鑫   '最新'
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
      <el-dialog :visible.sync="bainjiBox" custom-class="tongyong_css" style="padding: 0" width="60%" center
        :close-on-click-modal="false" :show-close="false">
        <div style="padding: 20px">
          <div style="font-size: 14px; padding-bottom: 20px; color: #000">
            编辑题目
          </div>
          <div style="padding: 20px">
            <el-form ref="bianform" :model="secondData" :rules="rules" label-width="140px">
              <el-form-item label="题目" prop="tikuTitle">
                <el-input v-model="secondData.tikuTitle" maxlength="100" />
              </el-form-item>
              <el-form-item label="题型" prop="questionType">
                <el-select v-model="secondData.questionType" placeholder="请选择" disabled>
                  <el-option label="单选" value="单选" />
                  <el-option label="多选" value="多选" />
                  <el-option label="文本" value="文本" />
                </el-select>
              </el-form-item>
              <!-- 如果formInline.questionType为多选,那么就显示最多可以选择多少个,计步器来设置,默认是 0 -->
              <el-form-item v-if="secondData.questionType == '多选'" label="最多可选" prop="maxChoose">
                <el-input-number v-model="secondData.maxChoose" :min="0" :max="options.length" /> 0为不限制填写数量
              </el-form-item>
              <el-form-item label="隶属题库" prop="questionBank">
                <el-select v-model="secondData.questionBank" placeholder="请选择">
                  <el-option label="用户端题库" value="用户端题库" />
                  <el-option label="商户端题库" value="商户端题库" />
                  <el-option label="公共端题库" value="公共端题库" />
                </el-select>
              </el-form-item>
              <el-form-item label="布局类型" prop="layoutType">
                <el-radio-group v-model="secondData.layoutType" style="margin-top: 13px">
                  <el-radio :label="1">垂直布局</el-radio>
                  <el-radio :label="2">自由布局</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="是否必填" prop="isRequired">
                <!-- <el-select v-model="secondData.isRequired" placeholder="请选择">
3f535f30   杨鑫   '初始'
288
289
290
                     <el-option label="必填" value="必填" />
                     <el-option label="非必填" value="非必填" />
                   </el-select> -->
95f61c80   杨鑫   '最新'
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
                <el-radio-group v-model="secondData.isRequired" style="margin-top: 13px">
                  <el-radio label="必填">必填</el-radio>
                  <el-radio label="非必填">非必填</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item v-if="secondData.questionType != '文本'" label="答案设置">
                <el-table :data="options" :header-cell-style="{
  								fontSize: '14px',
  								color: '#0009',
  								fontWeight: 'normal',
  								backgroundColor: '#F2F3F5',
  							}">
  
                  <el-table-column prop="index" label="序号" width="180">
                    <template #default="scope">
                      {{ scope.$index + 1 }}
                    </template>
                  </el-table-column>
                  <el-table-column prop="name" label="选项名称">
                    <template #default="scope">
                      <el-input v-model="scope.row.name" :readonly="scope.row.readonly" />
                    </template>
                  </el-table-column>
                  <el-table-column prop="name" label="分数">
                    <template #default="scope">
                      <el-input v-model="scope.row.num" :min="0" :max="100" :readonly="scope.row.readonly"
                        @input="validateScore(scope.row)" />
                    </template>
                  </el-table-column>
                  <el-table-column label=""  min-width="120">
                                        <template #default="{ $index }">
                                            <span style="cursor: pointer;margin-right: 5px; color: #3F9B6A;"
                        @click="answerMoveUp($index)" v-if="$index != 0">↑</span>
                                            <span style="cursor: pointer; color: #3F9B6A;" @click="answerMoveDown($index)"
                        v-if="$index != (options.length - 1)">↓</span>
                                          </template>
                                      </el-table-column>
                  <el-table-column label="操作">
                    <template #default="scope">
                      <div class="tableBtn greens" @click="deleteOption(scope.$index)">
                        删除
                      </div>
                    </template>
                  </el-table-column>
  
                </el-table>
  
                <el-button style="width: 100%; background-color: #3f9b6a; color: #fff" @click="addOption">+
                  添加</el-button>
              </el-form-item>
            </el-form>
          </div>
  
          <div style="padding-top: 20px; display: flex; justify-content: flex-end">
            <el-button class="buttonHover" style="
                color: #606266;
                border: 1px solid #dddfe5;
                background-color: #fff;
              " @click="closeFn(2)">返回</el-button>
            <el-button style="background-color: #3f9b6a; color: #fff" @click="bianCheck">确认</el-button>
3f535f30   杨鑫   '初始'
351
352
353
354
          </div>
        </div>
      </el-dialog>
    </div>
3f535f30   杨鑫   '初始'
355
356
357
358
359
  </template>
  
  <script>
    import {
      async
95f61c80   杨鑫   '最新'
360
361
362
363
364
365
366
367
368
    } from "q";
    import axios from "axios";
    import {
      QuestionGetAll,
      QuestionAdd,
      QuestionEdit,
      QuestionDel,
    } from "../../api/question.js";
    import upimg from "@/components/ImageUpload/index";
3f535f30   杨鑫   '初始'
369
370
    export default {
      components: {
95f61c80   杨鑫   '最新'
371
        upimg,
3f535f30   杨鑫   '初始'
372
373
374
      },
      data() {
        return {
95f61c80   杨鑫   '最新'
375
          detbox: false, // 详情
3f535f30   杨鑫   '初始'
376
377
378
379
380
381
          currentPage: 1,
          total: 10,
          flag: false,
          pageSize: 10,
          ggXin: false,
          formInline: {
95f61c80   杨鑫   '最新'
382
383
384
385
386
387
388
            tikuTitle: "",
            questionType: "",
            questionBank: "用户端题库",
            isRequired: "必填",
            maxChoose: 0,
            questionDescription: "",
            optionSettings: {},
3f535f30   杨鑫   '初始'
389
          },
95f61c80   杨鑫   '最新'
390
          tableData: [],
3f535f30   杨鑫   '初始'
391
392
          secondData: {},
          formSel: {
95f61c80   杨鑫   '最新'
393
394
395
396
397
            questionBank: "用户端题库",
            tikuTitle: "",
            questionType: "",
            pageNumber: 0,
            pageSize: 10,
3f535f30   杨鑫   '初始'
398
399
400
401
          },
          pageindex: {
            pageNumber: 0,
            pageSize: 10,
95f61c80   杨鑫   '最新'
402
            questionBank: "用户端题库",
3f535f30   杨鑫   '初始'
403
          },
95f61c80   杨鑫   '最新'
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
          bainjiBox: false,
          options: [],
          labelStyle: {
            width: "160px",
          },
          contentStyle: {
            width: "246px",
          },
          rules: {
            tikuTitle: [{
              required: true,
              message: "请输入题目",
              trigger: "blur"
            }],
            questionType: [{
              required: true,
              message: "请选择题型",
              trigger: "change"
            }, ],
            questionBank: [{
              required: true,
              message: "请选择所属题库",
              trigger: "change"
            }, ],
            layoutType: [{
              required: true,
              message: "请选择布局类型",
              trigger: "change"
            }, ],
            optionSettings: [{
              required: true,
              message: "请设置答案",
              trigger: "change"
            }, ],
          },
        };
3f535f30   杨鑫   '初始'
440
      },
95f61c80   杨鑫   '最新'
441
      computed: {},
3f535f30   杨鑫   '初始'
442
      mounted() {
95f61c80   杨鑫   '最新'
443
        this.getAll();
3f535f30   杨鑫   '初始'
444
445
446
447
      },
      methods: {
        chenge(val) {
          this.formSel = {
95f61c80   杨鑫   '最新'
448
449
450
451
452
453
            questionBank: "用户端题库",
            tikuTitle: "",
            questionType: "",
            pageNumber: 0,
            pageSize: 10,
          };
3f535f30   杨鑫   '初始'
454
        },
95f61c80   杨鑫   '最新'
455
456
457
458
459
        getAll() {
          QuestionGetAll(this.pageindex).then((res) => {
            this.tableData = res.data.content;
            this.total = res.data.totalElements;
          });
3f535f30   杨鑫   '初始'
460
461
462
        },
  
        // 新增确定按钮
95f61c80   杨鑫   '最新'
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
        addCheck(val) {
          this.$refs.reform.validate((valid) => {
            if (valid) {
              if (
                this.formInline.questionType != "文本" &&
                this.options.length == 0
              ) {
                this.$message({
                  message: "请添加答案选项",
                });
                return;
              }
              for (let i = 0; i < this.options.length; i++) {
                if (this.options[i].name == "") {
                  this.$message({
                    message: "答案选项不能为空",
                  });
                  return;
3f535f30   杨鑫   '初始'
481
                }
95f61c80   杨鑫   '最新'
482
483
484
485
486
487
              }
              let accumulator = {}
              let fenshu = {}
              this.options.forEach((item, index) => {
                accumulator[index] = item.name
                fenshu[index] = Number(item.num) || 0
3f535f30   杨鑫   '初始'
488
              })
95f61c80   杨鑫   '最新'
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
              this.formInline.optionSettings = accumulator
              this.formInline.score = fenshu
              this.formInline.optionSettings = JSON.stringify(
                this.formInline.optionSettings
              );
              this.formInline.score = JSON.stringify(this.formInline.score);
              this.formInline.createDate = this.currentTime();
  			console.log({...this.formInline})
  			// return
              QuestionAdd(this.formInline).then((res) => {
                this.$message({
                  message: "保存成功",
                  type: "success",
                });
                this.formInline = {
                  tikuTitle: "",
                  questionType: "",
                  questionBank: "用户端题库",
                  isRequired: "必填",
                  questionDescription: "",
                  optionSettings: {},
                };
                this.getAll();
              });
  
              this.ggXin = false;
            } else {
              return false;
            }
          });
3f535f30   杨鑫   '初始'
519
520
        },
        // 编辑确定
95f61c80   杨鑫   '最新'
521
522
523
524
525
526
527
528
529
530
531
        async bianCheck() {
          this.$refs.bianform.validate((valid) => {
            if (valid) {
              if (
                this.secondData.questionType != "文本" &&
                this.options.length == 0
              ) {
                this.$message({
                  message: "请添加答案选项",
                });
                return;
e5b57447   杨鑫   '分包问卷'
532
              }
95f61c80   杨鑫   '最新'
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
              for (let i = 0; i < this.options.length; i++) {
                if (this.options[i].name == "") {
                  this.$message({
                    message: "答案选项不能为空",
                  });
                  return;
                }
              }
              let accumulator = {}
              let fenshu = {}
              this.options.forEach((item, index) => {
  
                accumulator[index] = item.name
                fenshu[index] = Number(item.num) || 0
              })
              this.secondData.optionSettings = JSON.stringify(
                accumulator
              );
              this.secondData.score = JSON.stringify(fenshu);
  			console.log({...this.secondData})
  			// return
              QuestionEdit(this.secondData).then((res) => {
                this.$message({
                  message: "保存成功",
                  type: "success",
                });
  
                this.getAll();
              });
  
              this.bainjiBox = false;
            } else {
              this.$message({
                message: "请填写完整信息",
                type: "error",
              });
              return false;
            }
          });
3f535f30   杨鑫   '初始'
572
573
574
        },
        // 获取时间
        currentTime() {
95f61c80   杨鑫   '最新'
575
576
          const date = new Date();
          const year = date.getFullYear();
3f535f30   杨鑫   '初始'
577
578
579
580
581
582
583
          let month = date.getMonth() + 1; // 月份从0~11,所以加一
          let day = date.getDate();
          let hours = date.getHours();
          let minutes = date.getMinutes();
          let seconds = date.getSeconds();
  
          // 为月、日、小时、分钟和秒添加前导零(如果需要)
95f61c80   杨鑫   '最新'
584
585
586
587
588
          month = month < 10 ? "0" + month : month;
          day = day < 10 ? "0" + day : day;
          hours = hours < 10 ? "0" + hours : hours;
          minutes = minutes < 10 ? "0" + minutes : minutes;
          seconds = seconds < 10 ? "0" + seconds : seconds;
3f535f30   杨鑫   '初始'
589
590
591
592
593
  
          // 返回格式化的日期和时间字符串
          return `${year}-${month}-${day} ${hours}:${minutes}`;
        },
  
95f61c80   杨鑫   '最新'
594
595
596
597
598
599
        // 详情
        details(val, item) {
          this.secondData = item;
  
          if (typeof item.optionSettings === "string") {
            this.secondData.optionSettings = JSON.parse(item.optionSettings);
3f535f30   杨鑫   '初始'
600
          }
95f61c80   杨鑫   '最新'
601
          this.detbox = true;
3f535f30   杨鑫   '初始'
602
603
        },
        addbuss(val, item) {
95f61c80   杨鑫   '最新'
604
605
          this.detbox = false;
          this.ggXin = true;
3f535f30   杨鑫   '初始'
606
607
        },
        handleSizeChange(val) {
95f61c80   杨鑫   '最新'
608
          this.pageSize = val;
3f535f30   杨鑫   '初始'
609
610
611
        },
        handleCurrentChange(val) {
          // this.currentPage = val
95f61c80   杨鑫   '最新'
612
613
614
615
          this.pageindex.pageNumber = val - 1;
          QuestionGetAll(this.pageindex).then((res) => {
            this.tableData = res.data.content;
          });
3f535f30   杨鑫   '初始'
616
617
618
619
        },
  
        closeFn(val) {
          if (val == 1) {
95f61c80   杨鑫   '最新'
620
            this.ggXin = false;
3f535f30   杨鑫   '初始'
621
          } else {
95f61c80   杨鑫   '最新'
622
            this.bainjiBox = false;
3f535f30   杨鑫   '初始'
623
624
625
626
627
          }
        },
  
        // 查询按钮
        async onSubmit() {
95f61c80   杨鑫   '最新'
628
629
630
          const res = await QuestionGetAll(this.formSel);
          this.tableData = res.data.content;
          this.total = res.data.totalElements;
3f535f30   杨鑫   '初始'
631
        },
95f61c80   杨鑫   '最新'
632
        // 重置按钮
3f535f30   杨鑫   '初始'
633
634
        resetting() {
          this.formSel = {
95f61c80   杨鑫   '最新'
635
636
637
638
639
640
641
            questionBank: "用户端题库",
            pageNumber: 0,
            pageSize: 10,
          };
          this.currentPage = 1;
          this.pageindex.pageNumber = 0;
          this.getAll();
3f535f30   杨鑫   '初始'
642
        },
95f61c80   杨鑫   '最新'
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
        addOption() {
          const newOption = {
            index: this.options.length + 1,
            name: "",
            readonly: false,
          };
          this.options.push(newOption);
        },
        deleteOption(index) {
          this.options.splice(index, 1);
        },
        bianls(item) {
          let settings = null;
          let socer = null;
          if (typeof item.optionSettings !== "object") {
            settings = JSON.parse(item.optionSettings);
          } else {
            settings = item.optionSettings;
          }
          if (typeof item.score !== "object") {
            socer = JSON.parse(item.score);
          } else {
            socer = item.score;
          }
          console.log("我是点击后的数据", item)
3f535f30   杨鑫   '初始'
668
          const keys = Object.keys(settings);
95f61c80   杨鑫   '最新'
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
          this.options = keys.map((key) => ({
            index: parseInt(key), // 将字符串键转换为整数
            name: settings[key],
            num: socer[key], // 添加 socer 的值
          }));
  
          this.bainjiBox = true;
          //判断item.maxChoose是undefined的话,默认为0
  
          this.secondData = item;
          
  		console.error({...this.secondData} )
  		// 刷新渲染层
  		this.$nextTick(() => {
  			this.secondData.maxChoose = item.maxChoose || 0;
  		});
3f535f30   杨鑫   '初始'
685
        },
95f61c80   杨鑫   '最新'
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
        tikuDel(item) {
          const h = this.$createElement;
          this.$msgbox({
            title: "消息",
            message: h("p", null, [h("span", null, "是否删除 ")]),
            showCancelButton: true,
            showClose: false,
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            customClass: "oe-dialog-btn",
            beforeClose: (action, instance, done) => {
              if (action === "confirm") {
                QuestionDel({
                  id: item.id,
                }).then((res) => {
                  this.getAll();
                  done();
                });
              } else {
                done();
              }
            },
          });
3f535f30   杨鑫   '初始'
709
        },
95f61c80   杨鑫   '最新'
710
711
        async tikuBox(val) {
          this.pageindex.questionBank = val;
3f535f30   杨鑫   '初始'
712
  
95f61c80   杨鑫   '最新'
713
714
715
          const res = await QuestionGetAll(this.pageindex);
          this.tableData = res.data.content;
          this.total = res.data.totalElements;
3f535f30   杨鑫   '初始'
716
        },
95f61c80   杨鑫   '最新'
717
718
719
720
721
722
723
724
725
726
727
728
        addTimu() {
          this.formInline = {
            tikuTitle: "",
            questionType: "",
            questionBank: "用户端题库",
            isRequired: "必填",
            maxChoose: 0,
            layoutType: 1,
            questionDescription: "",
            optionSettings: {},
          };
          this.options = [];
3f535f30   杨鑫   '初始'
729
          // this.$refs.reform.resetFields()
95f61c80   杨鑫   '最新'
730
          this.ggXin = true;
3f535f30   杨鑫   '初始'
731
        },
95f61c80   杨鑫   '最新'
732
        validateScore(row) {
3f535f30   杨鑫   '初始'
733
734
735
736
737
738
739
740
741
          // 如果输入的不是数字或者是NaN,则重置为1
          if (isNaN(row.num) || row.num < 0) {
            row.num = 0;
          }
          // 如果输入的数字大于100,则重置为100
          if (row.num > 100) {
            row.num = 100;
          }
        },
95f61c80   杨鑫   '最新'
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
        answerMoveUp(index) {
          [this.options[index], this.options[index - 1]] = [this.options[index - 1], this.options[index]]
          console.log(this.options[index])
          this.options[index].index = index - 1
          this.options.sort()
  
  
        },
        answerMoveDown(index) {
          [this.options[index], this.options[index + 1]] = [this.options[index + 1], this.options[index]]
          this.options[index].index = index + 1
          this.options.sort()
  
        },
      },
    };
3f535f30   杨鑫   '初始'
758
759
760
761
762
763
  </script>
  
  <style scoped>
    .zhuti {
      padding: 0 20px 20px 20px;
      min-height: calc(100vh - 50px - 20px);
95f61c80   杨鑫   '最新'
764
      background-color: #fff;
3f535f30   杨鑫   '初始'
765
766
767
    }
  
    .chengeXia {
95f61c80   杨鑫   '最新'
768
      border-bottom: 6px solid #3f9b6a;
3f535f30   杨鑫   '初始'
769
      padding-bottom: 4px;
95f61c80   杨鑫   '最新'
770
      color: #3f9b6a;
3f535f30   杨鑫   '初始'
771
772
773
774
775
776
777
778
779
    }
  
    /deep/ .el-form-item__content {
      line-height: 0;
    }
  
    .tableBtn {
      display: inline-block;
      margin-right: 10px;
95f61c80   杨鑫   '最新'
780
781
      color: #acacac;
      cursor: pointer;
3f535f30   杨鑫   '初始'
782
783
784
785
786
787
788
789
790
791
    }
  
    .formSearch {
      display: flex;
      width: 100%;
      font-size: 14px;
      justify-content: space-between;
    }
  
    .greens {
95f61c80   杨鑫   '最新'
792
      color: #3f9b6a;
3f535f30   杨鑫   '初始'
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
    }
  
    /deep/ .el-table__row {
      font-size: 14px;
      color: #000000e6;
      height: 42px;
    }
  
    .fenye {
      margin-top: 20px;
      display: flex;
      justify-content: flex-end;
    }
  
    /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
95f61c80   杨鑫   '最新'
808
      background-color: #3f9b6a;
3f535f30   杨鑫   '初始'
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
    }
  
    .el-row {
      margin-bottom: 20px;
  
      &:last-child {
        margin-bottom: 0;
      }
    }
  
    .el-col {
      border-radius: 4px;
    }
  
    .bg-purple-dark {
      background: #99a9bf;
    }
  
    .bg-purple {
      background: #d3dce6;
    }
  
    .bg-purple-light {
      background: #e5e9f2;
    }
  
    .grid-content {
      border-radius: 4px;
      min-height: 36px;
    }
  
    .row-bg {
      padding: 10px 0;
      background-color: #f9fafc;
    }
  
    /deep/ .bg-purple[data-v-0e3fe4ec] {
      background: #fff;
      height: 50px;
    }
  
    /deep/ .bg-purple[data-v-3bebae82] {
      background: #fff;
      height: 50px;
    }
  
    ::v-deep .bg-purple {
      background: #fff;
      height: 50px;
    }
  
    /deep/ .el-form--label-top .el-form-item__label {
      padding: 0;
    }
  
    ::v-deep .el-form-item {
      margin-bottom: 16px;
    }
  
    .device-form .el-form-item__label::after {
      content: "*";
95f61c80   杨鑫   '最新'
870
      color: #1a1a1a;
3f535f30   杨鑫   '初始'
871
872
873
874
      margin-left: 5px;
      font-size: 16px;
    }
  
3f535f30   杨鑫   '初始'
875
876
    ::v-deep .el-dialog__wrapper {
      .el-dialog__header {
95f61c80   杨鑫   '最新'
877
        background-color: #fafafa;
3f535f30   杨鑫   '初始'
878
879
880
881
      }
    }
  
    ::v-deep .el-input__inner:focus {
95f61c80   杨鑫   '最新'
882
      border: #3f9b6a 1px solid;
3f535f30   杨鑫   '初始'
883
884
885
886
887
888
889
890
891
892
    }
  
    .dialog-footer {
      display: flex;
      justify-content: flex-end;
      border-top: solid rgba(209, 209, 209, 0.2) 2px;
      padding-top: 20px;
    }
  
    ::v-deep .el-input__inner:focus {
95f61c80   杨鑫   '最新'
893
      border: #3f9b6a 1px solid;
3f535f30   杨鑫   '初始'
894
895
896
    }
  
    ::v-deep .el-input__inner:hover {
95f61c80   杨鑫   '最新'
897
      border: #3f9b6a 1px solid;
3f535f30   杨鑫   '初始'
898
899
900
    }
  
    ::v-deep .el-select .el-input.is-focus .el-input__inner {
95f61c80   杨鑫   '最新'
901
      border-color: #3f9b6a;
3f535f30   杨鑫   '初始'
902
903
904
    }
  
    .el-select-dropdown__item.selected {
95f61c80   杨鑫   '最新'
905
      color: #3f9b6a;
3f535f30   杨鑫   '初始'
906
907
908
    }
  
    .el-pagination__sizes .el-input .el-input__inner:hover {
95f61c80   杨鑫   '最新'
909
      border-color: #3f9b6a;
3f535f30   杨鑫   '初始'
910
911
912
    }
  
    ::v-deep .el-dialog__wrapper {
3f535f30   杨鑫   '初始'
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
      .dialog_css {
        margin-right: 12px;
        margin-top: 61px !important;
  
        .el-dialog__title {
          font-size: 16px !important;
          font-weight: 600;
          color: #000;
        }
      }
  
      .diaslog_zhong {
        margin-left: 25%;
        margin-top: 61px !important;
      }
3f535f30   杨鑫   '初始'
928
929
930
931
932
933
934
935
    }
  
    ::v-deep .diaslog_zhong {
      margin-left: 20%;
      margin-top: 61px !important;
  
      .el-dialog__header {
        background-color: #fff;
95f61c80   杨鑫   '最新'
936
        border-bottom: 1px solid #efefef;
3f535f30   杨鑫   '初始'
937
938
939
940
941
942
943
944
  
        .el-dialog__title {
          font-size: 14px;
          color: #000000e6;
        }
      }
  
      .el-dialog__body {
95f61c80   杨鑫   '最新'
945
        padding: 10px 30px 30px 20px;
3f535f30   杨鑫   '初始'
946
947
948
949
      }
    }
  
    /deep/ .el-table_1_column_8 .hetong {
95f61c80   杨鑫   '最新'
950
      color: #7dbb9a;
3f535f30   杨鑫   '初始'
951
952
953
954
      text-decoration: underline;
    }
  
    /deep/ .first-column-bg {
95f61c80   杨鑫   '最新'
955
      background-color: #fafafa !important;
3f535f30   杨鑫   '初始'
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
    }
  
    ::v-deep .textarea {
      width: 85%;
  
      .el-textarea__inner {
        width: 100%;
      }
    }
  
    ::v-deep .pass_input {
      width: 100%;
  
      .el-input__inner {
        border: none;
        padding: 0;
      }
    }
  
    ::v-deep .pass_select {
      width: 100%;
  
      .el-input__inner {
        border: none;
        padding: 0;
      }
  
      .el-icon-arrow-up:before {
95f61c80   杨鑫   '最新'
984
        content: "";
3f535f30   杨鑫   '初始'
985
      }
3f535f30   杨鑫   '初始'
986
987
988
989
990
    }
  
    /deep/ .el-table--enable-row-hover .el-table__body tr:hover>td.el-table__cell {
      background-color: #fff;
    }
95f61c80   杨鑫   '最新'
991
992
993
994
995
996
997
  
    /deep/ .el-input-number__decrease,
    /deep/.el-input-number__increase {
      height: 30px !important;
      line-height: 32px !important;
      margin-top: 3px;
    }
3f535f30   杨鑫   '初始'
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
  </style>
  <style lang="scss" scoped>
    ::v-deep .bian_css {
      .el-dialog__header {
        padding: 0px;
      }
  
      .el-input__inner {
        height: 18px;
        border: 0px;
        margin-top: 0px;
      }
  
      .el-input__inner:hover {
        border: 0px;
      }
  
      .el-input__inner:focus {
        border: 0px;
      }
    }
  
    ::v-deep .buttonHover:hover {
      color: #3f9b6a !important;
      border-color: #c5e1d2 !important;
      background-color: #ecf5f0 !important;
      outline: none;
    }
  
    ::v-deep .el-pagination__total {
      position: absolute;
      left: 33px;
    }
  
    ::v-deep .diaslog_zhong {
      .el-dialog__body {
        padding: 10px 20px 20px 20px;
      }
  
      .el-upload--picture-card {
        width: 130px;
        height: 130px;
      }
    }
  </style>