Blame view

src/views/TestPaper/ManualTestPaper.vue 11.9 KB
b89c8760   wangming   项目初始化
1
2
3
4
5
  <template>
  	<div class="app-container">
  		<el-row :gutter="20">
  			<el-col :span="6" :style="{'height':contentHeight+'px'}">
  				<div class="grid-content bg-purple">
172a152f   yangzhi   组卷左侧题目的分类
6
7
  					<el-tabs
                v-model="activeTab"
172a152f   yangzhi   组卷左侧题目的分类
8
9
10
11
12
13
14
                style="padding: 0 20px"
                :stretch="true"
              >
                <el-tab-pane label="专业类" name="6"></el-tab-pane>
                <el-tab-pane label="测评类" name="1"></el-tab-pane>
              </el-tabs>
  			<div style="padding:0 10px">
f2be913b   yangzhi   王哥yyds
15
  				<el-input size="small" placeholder="输入关键字搜索" v-model="parameter.keyWord"></el-input>
172a152f   yangzhi   组卷左侧题目的分类
16
17
18
19
20
21
22
23
  			</div>
  			<draggable :options="{animation:380,filter:'.unmover'}" group="itxst" v-model="arr1" @end="end1"
  				@add="RemoveHere" :move="onMove" class="infinite-list" :style="{'height':contentHeight-80+'px'}"
  				infinite-scroll-disabled="disabled" v-infinite-scroll="load" style="overflow:auto">
  				<li v-for="i in arr1" class="infinite-list-item" :key="i.id">{{ i.subject }}</li>
  				<p v-if="loading" style="text-align: center;color: #cdcdcd;" class="unmover">加载中...</p>
  				<p v-if="noMore" style="text-align: center;color: #cdcdcd;" class="unmover">没有更多了</p>
  			</draggable>
b89c8760   wangming   项目初始化
24
25
26
  
  				</div>
  			</el-col>
ab275674   yangzhi   我在阳台抽烟 风抽一半我抽一半 我...
27
  			<el-col :span="10" :style="{'height':contentHeight+'px'}">
b89c8760   wangming   项目初始化
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  				<div class="grid-content bg-purple">
  					<div class="areahead">
  						<span v-show="!edit" style="font-weight: bold;">{{ TestPaper.TestPaperTitle }}</span>
  						<el-input v-show="edit" style="width: 400px;" v-model="TestPaper.TestPaperTitle"></el-input>
  						<i :class="{'el-icon-edit': !edit, 'el-icon-check': edit}" @click="edit = !edit"
  							style="margin-left: 5px;cursor: pointer;"></i>
  					</div>
  					<draggable :options="{animation:380}" group="itxst" v-model="arr2" class="infinite-list" @end="end2"
  						@add="ComeHere" :style="{'height':contentHeight-60+'px'}"
  						style="overflow:auto;padding-top: 10px;">
  						<li v-for="i in arr2" class="infinite-list-item">
  							<label>[{{i.subjectName}}]{{ i.subject }}</label>
  							<div v-for="item in JSON.parse(i.subjectContent)">
  								<p class="option-p">{{item.option}}:{{item.optionContent}}</p>
  							</div>
  						</li>
  						</li>
  					</draggable>
  				</div>
ab275674   yangzhi   我在阳台抽烟 风抽一半我抽一半 我...
47
48
  			</el-col>
  			<el-col :span="8" :style="{'height':contentHeight+'px'}">
b89c8760   wangming   项目初始化
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
  				<div class="grid-content bg-purple">
  					<div class="areahead">组卷基本信息</div>
  					<el-form ref="form" class="testPaper-manager" :rules="rules" :model="TestPaper" label-width="100px">
  						<el-form-item label="试卷名称:" class="el-form-item-custom">
  							{{TestPaper.TestPaperTitle}}
  						</el-form-item>
  						<el-form-item label="题目数量:" class="el-form-item-custom">
  							{{arr2.length}}
  						</el-form-item>
  						<el-form-item label="题型数量:" class="el-form-item-custom">
  							<span style="margin-right: 10px;">单选题:{{TestPaper.SingleNumber}}</span>
  							<span style="margin-right: 10px;">多选题:{{TestPaper.MultipleNumber}}</span>
  							<span style="margin-right: 10px;">主观题:{{TestPaper.SubjectiveNumber}}</span>
  						</el-form-item>
  						<el-form-item label="题目总分:" class="el-form-item-custom">
  							{{TestPaper.TotalScore}}
  						</el-form-item>
  						<el-form-item label="分类" class="el-form-item-custom">
  							<el-cascader class="testpaper-input" v-model="TestPaper.QuestionClassId"
  								style="width:400px;margin-bottom: 20px;" :props="{emitPath:false}" :clearable=true
  								:options="QuestionClass">
  							</el-cascader>
  						</el-form-item>
  						<el-form-item label="试卷原价:" prop="OriginalPrice" v-show="false">
  							<el-input class="testpaper-input" oninput="value=value.replace(/[^0-9.]/g,'')"
  								v-model="TestPaper.OriginalPrice" :precision="0">
  								<template slot="append">元</template>
  							</el-input>
  						</el-form-item>
  						<el-form-item label="试卷价格:" prop="PresentPrice">
  							<el-input class="testpaper-input" oninput="value=value.replace(/[^0-9.]/g,'')"
  								v-model="TestPaper.PresentPrice">
  								<template slot="append">元</template>
  							</el-input>
  						</el-form-item>
  						<el-form-item label="会员价:" prop="MembershipPrice" v-show="false">
  							<el-input class="testpaper-input" oninput="value=value.replace(/[^0-9.]/g,'')"
  								v-model="TestPaper.MembershipPrice">
  								<template slot="append">元</template>
  							</el-input>
  						</el-form-item>
  						<el-form-item label="试卷简介:">
  							<el-input class="testpaper-input" :rows="10" type="textarea" v-model="TestPaper.Describe">
  							</el-input>
  						</el-form-item>
  						<el-button type="primary" style="float: right;" @click="SubmitTestPaper">保存
  						</el-button>
  					</el-form>
  				</div>
ab275674   yangzhi   我在阳台抽烟 风抽一半我抽一半 我...
98
  			</el-col>
b89c8760   wangming   项目初始化
99
100
101
102
103
  		</el-row>
  	</div>
  </template>
  
  <script>
172a152f   yangzhi   组卷左侧题目的分类
104
105
106
107
108
109
110
111
112
113
  import draggable from "vuedraggable";
  import { getQuestionClassList, getQuestionList } from "@/api/QuestionBank";
  import { EditTestPaper, GetToplevel } from "@/api/TestPaper";
  export default {
    //注册draggable组件
    components: {
      draggable,
    },
    data() {
      return {
f2be913b   yangzhi   王哥yyds
114
        activeTab: "6",
172a152f   yangzhi   组卷左侧题目的分类
115
        parameter: {
f2be913b   yangzhi   王哥yyds
116
117
118
119
120
          pageIndex: 0,
          pageSize: 20,
          sort: "id",
          sortOrder: 1,
          keyWord: "",
4952fc5a   yangzhi   王哥牛批
121
          QuestionClassId: 6,
f2be913b   yangzhi   王哥yyds
122
          status: 1,
172a152f   yangzhi   组卷左侧题目的分类
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
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
        },
        contentHeight: 0,
        count: 0,
        edit: false,
        arr1: [],
        arr2: [],
        moveId: -1,
        TestPaper: {
          TestPaperTitle: "未命名试卷标题",
          TestPaperClassId: 0,
          TotalScore: 0,
          Describe: "",
          SingleNumber: 0,
          MultipleNumber: 0,
          SubjectiveNumber: 0,
          OriginalPrice: "0",
          PresentPrice: "0",
          MembershipPrice: "0",
          QuestionBankIds: [],
        },
        loading: false,
        rules: {
          OriginalPrice: [
            {
              required: true,
              message: "不能为空",
            },
          ],
          PresentPrice: [
            {
              required: true,
              message: "不能为空",
            },
          ],
          MembershipPrice: [
            {
              required: true,
              message: "不能为空",
            },
          ],
        },
        QuestionClass: [],
        treeData: [
          {
            value: 0,
            label: "全部",
          },
        ],
        timeout: 0,
      };
    },
    watch: {
      activeTab() {
f2be913b   yangzhi   王哥yyds
176
        console.log("activeTab watch");
172a152f   yangzhi   组卷左侧题目的分类
177
178
        this.search();
      },
f2be913b   yangzhi   王哥yyds
179
180
181
182
183
184
185
      "parameter.keyWord": {
        handler() {
          clearTimeout(this.timeout);
          this.timeout = setTimeout(() => {
            this.search();
          }, 200);
        },
172a152f   yangzhi   组卷左侧题目的分类
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
      },
    },
    computed: {
      noMore() {
        return this.arr1.length >= this.count;
      },
      disabled() {
        return this.loading || this.noMore;
      },
    },
    created() {},
    mounted() {
      //计算页面内容区域的高度
      this.contentHeight = window.innerHeight - 90;
      this.getQuestionClassListHeadler();
      //this.GetList();
    },
    methods: {
      search() {
        this.parameter.pageIndex = 1;
4952fc5a   yangzhi   王哥牛批
206
        this.parameter.QuestionClassId = Number(this.activeTab);
172a152f   yangzhi   组卷左侧题目的分类
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
        this.GetList();
      },
      SubmitTestPaper() {
        if (this.arr2.length > 0) {
          EditTestPaper(this.TestPaper).then((res) => {
            if (res.data.code == 200) {
              this.$confirm("组卷成功!", "消息");
            } else {
              this.$confirm("组卷失败!", "消息");
            }
          });
        } else {
          this.$confirm("试题未有题目!", "消息");
        }
      },
      load() {
        this.loading = true;
f2be913b   yangzhi   王哥yyds
224
        this.parameter.pageIndex++;
172a152f   yangzhi   组卷左侧题目的分类
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
        this.GetList();
        this.loading = false;
      },
      GetList() {
        getQuestionList(this.parameter).then((res) => {
          if (this.parameter.pageIndex == 1) {
            this.arr1 = [];
          }
          res.data.data.rows.forEach((item, i) => {
            this.arr1.push(item);
          });
          this.count = res.data.data.total;
          this.$forceUpdate();
        });
      },
      end1(e) {
        var that = this;
        if (that.arr1.length < 10) {
          this.load();
        }
b89c8760   wangming   项目初始化
245
  
172a152f   yangzhi   组卷左侧题目的分类
246
247
248
        var items = this.arr2.filter(function (m) {
          return m.id == that.moveId;
        });
b89c8760   wangming   项目初始化
249
  
172a152f   yangzhi   组卷左侧题目的分类
250
251
252
        //如果左边
        if (items.length < 2) return;
        this.arr2.splice(e.newDraggableIndex, 1);
b89c8760   wangming   项目初始化
253
  
172a152f   yangzhi   组卷左侧题目的分类
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
        //	SingleNumber:0,
        // MultipleNumber:0,
        // SubjectiveNumber:0,
      },
      //从右边移除到左边
      RemoveHere(e) {
        if (e.item._underlying_vm_.subjectType == 1) {
          this.TestPaper.SingleNumber -= 1;
        }
        if (e.item._underlying_vm_.subjectType == 2) {
          this.TestPaper.MultipleNumber -= 1;
        }
        if (e.item._underlying_vm_.subjectType == 3) {
          this.TestPaper.SubjectiveNumber -= 1;
        }
        this.TestPaper.TotalScore -= e.item._underlying_vm_.fraction;
        this.TestPaper.QuestionBankIds = this.arr2.map((u) => u.id);
      },
      //从左边添加到右边
      ComeHere(e) {
        if (e.item._underlying_vm_.subjectType == 1) {
          this.TestPaper.SingleNumber += 1;
        }
        if (e.item._underlying_vm_.subjectType == 2) {
          this.TestPaper.MultipleNumber += 1;
        }
        if (e.item._underlying_vm_.subjectType == 3) {
          this.TestPaper.SubjectiveNumber += 1;
        }
        this.TestPaper.TotalScore += e.item._underlying_vm_.fraction;
b89c8760   wangming   项目初始化
284
  
172a152f   yangzhi   组卷左侧题目的分类
285
286
287
288
289
290
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
        this.TestPaper.QuestionBankIds = this.arr2.map((u) => u.id);
      },
      //右边往左边拖动时的事件
      end2(e) {
        var that = this;
        var items = this.arr1.filter(function (m) {
          return m.id == that.moveId;
        });
        //如果左边
        if (items.length < 2) return;
        this.arr1.splice(e.newDraggableIndex, 1);
      },
      //move回调方法
      onMove(e, originalEvent) {
        //this.moveId = e.relatedContext.element.id;
        return true;
      },
      getQuestionClassListHeadler() {
        let _this = this;
        GetToplevel().then((res) => {
          var gettree = function (titem) {
            titem.children = [];
            let childrenList = res.data.data.filter(
              (u) => u.ParentId == titem.value
            );
            if (childrenList.length == 0) titem.children = undefined;
            res.data.data
              .filter((u) => u.ParentId == titem.value)
              .forEach((item, i) => {
                var model = {
                  value: item.id,
                  label: item.ClassTitle,
                };
                gettree(model);
                titem.children.push(model);
              });
          };
          res.data.data
            .filter((u) => u.ParentId == 0)
            .forEach((item, i) => {
              var model = {
                value: item.id,
                label: item.ClassTitle,
              };
              gettree(model);
              _this.QuestionClass.push(model);
              _this.treeData.push(model);
            });
        });
      },
    },
  };
b89c8760   wangming   项目初始化
337
338
339
  </script>
  
  <style lang="scss" scoped>
172a152f   yangzhi   组卷左侧题目的分类
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
  .el-row {
    /* margin-bottom: 20px; */
    &:last-child {
      margin-bottom: 0;
    }
  }
  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #99a9bf;
  }
  .bg-purple {
    background: #efefef;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
    height: 100%;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }
  .infinite-list {
    list-style: none;
    margin: 0px;
    padding: 0px;
    &::-webkit-scrollbar {
      width: 6px;
    }
    //滚动条小方块
    &::-webkit-scrollbar-thumb {
      border-radius: 10px;
      background: #304156;
    }
    //滚动条轨道
    &::-webkit-scrollbar-track {
      // border-radius: 10px;
      height: 100px;
      background: #cdcdcd;
    }
    .infinite-list-item {
      padding: 10px;
      min-height: 60px;
      width: 95%;
      margin: auto;
      background-color: #fff;
      margin-bottom: 10px;
      border-radius: 5px;
      box-shadow: 0 0 5px #cdcdcd;
      &:first-child {
        margin-top: 10px;
      }
    }
  }
  .option-p {
    line-height: 15px;
  }
  .areahead {
    text-align: center;
    height: 60px;
    line-height: 60px;
    border-bottom: 1px solid #cdcdcd;
  }
  .testPaper-manager {
    margin: 10px 20px 10px 10px;
  }
  .testPaper-manager .el-form-item {
    margin-bottom: 20px;
  }
  .el-form-item-custom {
    margin-bottom: 0px !important;
  }
  .testpaper-input {
    //max-width: 400px;
  }
b89c8760   wangming   项目初始化
420
  </style>