b441010d
yangzhi
超哥牛批 超时yyds
|
1
|
<template>
|
cf176b8f
周超
3
|
2
|
<el-dialog title="编辑" :visible.sync="dialogFormVisible" @closed="handleclose" width="650px">
|
f7d4b60e
周超
完成维度编辑
|
3
|
<el-form :model="data">
|
b32564ca
周超
11
|
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<el-form-item label="上级分类" style="padding-top: 5px">
<el-cascader filterable v-model="data.ParentId" style="width: 400px"
:props="{ emitPath: false ,checkStrictly:true}" :clearable="true" :options="QuestionClass">
<template slot-scope="{ node, data }">
<span>{{ data.label }}</span>
<span v-if="!node.isLeaf"> ({{ data.subjectCount || 0 }}) </span>
</template>
</el-cascader>
</el-form-item>
|
f7d4b60e
周超
完成维度编辑
|
18
19
|
<el-form-item label="名称">
<el-input v-model="data.ClassificationName"></el-input>
|
6963d762
周超
拉取志哥最新的
|
20
|
|
b441010d
yangzhi
超哥牛批 超时yyds
|
21
|
</el-form-item>
|
f7d4b60e
周超
完成维度编辑
|
22
|
|
6963d762
周超
拉取志哥最新的
|
23
|
<el-form-item label="规则" v-show="level ==3">
|
f7d4b60e
周超
完成维度编辑
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<div style="padding:10px 5px 0px 5px">
<el-table v-if="data.rules" :data="data.rules" style="width: 100%;">
<el-table-column align="left" label="状态">
<template slot-scope="{row}">
<div style="display: flex;">
<el-input placeholder="请输入标题" v-model="row.DimensionTitle"></el-input>
<div style="width:60px;margin-left:5px;padding-top:3px">
<el-button type="text" style="font-size:16px" size="mini" icon="el-icon-circle-plus-outline"
@click="addtablerow(row.sort,data)"></el-button>
<el-button type="text" style="font-size:16px;margin-left:5px" size="mini"
icon="el-icon-remove-outline" @click="deltablerow(row.sort,data)"></el-button>
</div>
</div>
</template>
</el-table-column>
<el-table-column align="center" label="计分规则">
<template slot-scope="{row}">
<el-select style="width:16%;margin-right:1%" v-model="row.ScoreType" placeholder="计分类型" clearable>
<el-option :value="1" label="按照总分"> 按照总分 </el-option>
<el-option :value="2" label="按照平均分"> </el-option>
</el-select>
<el-select style="width:18%;margin-right:1%" v-model="row.StartFormula" placeholder="规则" clearable>
<el-option v-for="item in ruleOptions" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
<el-input style="width:20%;margin-right:1%" type="number" v-model="row.StartScore"
|
6963d762
周超
拉取志哥最新的
|
52
|
:placeholder="'开始分值'">
|
f7d4b60e
周超
完成维度编辑
|
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
98
99
|
</el-input>
<el-select style="width:18%;margin-right:1%" v-model="row.EndFormula" placeholder="规则" clearable>
<el-option v-for="item in ruleOptions" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
<el-input style="width:22%" v-model="row.EndScore" type="number" :placeholder="'结束分值'"></el-input>
</template>
</el-table-column>
<el-table-column align="center" width="50" label="排序">
<template slot-scope="{row}">
<el-button v-if="row.sort > 0" type="text" size="small" icon="el-icon-top"
@click="tablesort(0,row.sort,data)">
</el-button>
<el-button v-if="row.sort < (data.rules.length-1) && data.rules.length >1" type="text" size="small"
icon="el-icon-bottom" @click="tablesort(1,row.sort,data)"></el-button>
</template>
</el-table-column>
</el-table>
<div>
<el-collapse v-model="activeName" accordion>
<el-collapse-item v-for="(citem,index) in data.rules" :title="citem.DimensionTitle" :name="index"
:key="index">
<div>
<div style="width:100%;margin-top:10px;color:#409EFF;">
分值解析
</div>
<div style="display: flex;">
<div style="width:50%">
<tinymce ref="content" v-model="citem.DimensionContent" :height="650" />
</div>
<div style="width:50%;padding:0px 20px" v-html="citem.DimensionContent">
</div>
</div>
</div>
</el-collapse-item>
</el-collapse>
</div>
</div>
|
b441010d
yangzhi
超哥牛批 超时yyds
|
100
101
102
103
|
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">取 消</el-button>
|
f7d4b60e
周超
完成维度编辑
|
104
|
<el-button type="primary" @click="handleSave">确 定</el-button>
|
b441010d
yangzhi
超哥牛批 超时yyds
|
105
106
107
108
|
</div>
</el-dialog>
</template>
<script>
|
f7d4b60e
周超
完成维度编辑
|
109
110
111
112
113
114
115
116
|
import Tinymce from '@/components/Tinymce'
import {
EditQuestionClass,
getQuestionClass,
} from "@/api/QuestionClass";
|
b32564ca
周超
11
|
117
118
119
|
import {
getQuestionClassList
} from "@/api/QuestionBank";
|
f7d4b60e
周超
完成维度编辑
|
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
export default {
components: {
Tinymce
},
props: {
model: {
type: Object,
default() {
return {};
}
},
},
data() {
return {
data: {
scoring_type: 0
|
b441010d
yangzhi
超哥牛批 超时yyds
|
138
|
},
|
f7d4b60e
周超
完成维度编辑
|
139
140
141
|
activeName: '',
dialogFormVisible: false,
form: {},
|
6963d762
周超
拉取志哥最新的
|
142
|
level:0,
|
b32564ca
周超
11
|
143
|
QuestionClass: [],
|
f7d4b60e
周超
完成维度编辑
|
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
ruleOptions: [
{ label: '大于', value: '>' },
{ label: '小于', value: '<' },
{ label: '大于等于', value: '>=' },
{ label: '小于等于', value: '<=' },
{ label: '等于', value: '=' },
],
evalutionRules: [
{
id: '',
QuestionClassId: 0,
DimensionTitle: '',
DimensionContent: '',
StartScore: '',
StartFormula: '',
EndScore: '',
EndFormula: '',
ScoreType: 1
}
],
};
|
b441010d
yangzhi
超哥牛批 超时yyds
|
165
|
},
|
f7d4b60e
周超
完成维度编辑
|
166
167
168
169
170
171
172
173
174
175
176
|
watch: {
model: {
deep: true,
handler(val) {
this.form = val;
}
}
},
created() {
// this.show();
|
b32564ca
周超
11
|
177
178
179
180
|
},
mounted(){
|
f7d4b60e
周超
完成维度编辑
|
181
|
},
|
b32564ca
周超
11
|
182
183
184
185
186
187
188
189
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
|
methods: {
getSubTree(id, list) {
let result = [];
result = list.filter((t) => t.ParentId == id);
if (result.length) {
result = result.map((item) => {
item.children = this.getSubTree(item.id, list);
return item;
});
}
return result;
},
getQuestionClassListHeadler(node) {
var classtype = node.data.ClassType || 0;
let _this = this;
getQuestionClassList().then((res) => {
let list = [{id:0,ClassificationName:'顶级',ClassType : classtype}];
res.data.data.forEach(o=>{list.push(o);});
var rootlist = list.filter(o=> o.ClassType == classtype && (!o.ParentId || o.ParentId == 0 )).map((t) => {
t.value = t.id;
t.label = t.ClassificationName;
return t;
});
// let firstClass = list.find((t) => t.id == 6);
// firstClass.children = this.getSubTree(6, list);
// let secondClass = list.find((t) => t.id == 1);
// secondClass.children = this.getSubTree(1, list);
this.QuestionClass = rootlist;
var firstlist = rootlist.filter(o => o.ClassType == 0 && o.ParentId == 0).map(o => {
o.children = this.getSubTree(o.id, list);
return o;
});
var twolist = rootlist.filter(o => o.ClassType == 2 && o.ParentId == 0).map(o => {
o.children = this.getSubTree(o.id, list);
return o;
});
// _this.$nextTick(()=>{
// if(_this.currentEditNode){
// _this.$refs.tree.getNode(_this.currentEditNode.parent).loaded = false
// _this.$refs.tree.getNode(_this.currentEditNode.parent).expand();
// _this.$refs.tree.getNode(_this.currentEditNode.parent).expanded=true;
// _this.$forceUpdate()
// }
// });
// this.firstTreeData = [firstClass];
// this.secondTreeData = [secondClass];
});
},
|
94c54e92
周超
1
|
235
236
237
238
|
handleclose(){
this.dialogFormVisible = false;
this.$emit('close',this.data);
},
|
f7d4b60e
周超
完成维度编辑
|
239
240
241
242
243
244
245
246
247
248
|
handleSave() {
if (!this.data.ClassificationName) {
this.$message.warning('请填写名称!', "消息");
return;
}
this.data.ClassType = 2;//默认维度
EditQuestionClass(this.data).then(res => {
if (res.data.code == 200) {
this.$message.success('保存成功!', "消息");
this.dialogFormVisible = false;
|
94c54e92
周超
1
|
249
|
this.$emit('save',this.data);
|
f7d4b60e
周超
完成维度编辑
|
250
251
|
this.data = {
rules: [
|
b441010d
yangzhi
超哥牛批 超时yyds
|
252
|
{
|
f7d4b60e
周超
完成维度编辑
|
253
254
255
256
257
258
259
260
261
|
QuestionClassId: 0,
DimensionTitle: '',
DimensionContent: '',
StartScore: '',
StartFormula: '',
EndScore: '',
EndFormula: '',
ScoreType: 1,
sort: 0
|
b441010d
yangzhi
超哥牛批 超时yyds
|
262
|
}
|
f7d4b60e
周超
完成维度编辑
|
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
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
|
]
};
}
else {
this.$message.error('保存失败!', "消息");
}
});
},
addtablerow(index, row) {
row.rules.splice(index + 1, 0, { sort: index + 1, id: (new Date().valueOf() + 1).toString(), ScoreType: 1 })
this.sortdata(index + 1)
},
deltablerow(index, row) {
if (row.rules.length <= 1) return;
row.rules.splice(index, 1)
var sort = index - 1;
if (sort < 0) sort = 0;
this.sortdata(sort)
},
tablesort(type, index, row) {
if (type == 0) { //-
var prevsort = row.rules[index - 1].sort;
row.rules[index - 1].sort = row.rules[index].sort;
row.rules[index].sort = prevsort;
row.rules = row.rules.sort((a, b) => {
return a.sort - b.sort;
});
}
else { //+
var prevsort = row.rules[index + 1].sort;
row.rules[index + 1].sort = row.rules[index].sort;
row.rules[index].sort = prevsort;
row.rules = row.rules.sort((a, b) => {
return a.sort - b.sort;
});
}
},
sortdata(index) {
try {
var tmp = index;
var data = this.tableData;
data = data.forEach((e, itemindex) => {
if (itemindex > index) {
tmp++;
e.sort = tmp;
}
});
this.tableData = tmpdata
} catch (e) { }
},
|
6963d762
周超
拉取志哥最新的
|
319
|
show(id,node) {
|
b32564ca
周超
11
|
320
321
|
this.getQuestionClassListHeadler(node);
|
6963d762
周超
拉取志哥最新的
|
322
|
if(node) this.level = node.level;
|
e011bf15
周超
我先走一步
|
323
|
this.data = {
|
f7d4b60e
周超
完成维度编辑
|
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
// id: Date.parse(new Date()) + '_' + Math.ceil(Math.random() * 99999),
// key: Date.parse(new Date()) + '_' + Math.ceil(Math.random() * 99999),
rules: [
{
QuestionClassId: 0,
DimensionTitle: '',
DimensionContent: '',
StartScore: '',
StartFormula: '',
EndScore: '',
EndFormula: '',
ScoreType: 1,
sort: 0
}
]
};
|
e011bf15
周超
我先走一步
|
340
341
|
if (id) {
|
f7d4b60e
周超
完成维度编辑
|
342
343
|
this.dialogFormVisible = true;
getQuestionClass({ id }).then(res => {
|
6963d762
周超
拉取志哥最新的
|
344
|
|
f7d4b60e
周超
完成维度编辑
|
345
346
|
if (res) {
var data = res.data.data;
|
b32564ca
周超
11
|
347
|
if (!data.rules || data.rules.length <1) {
|
f7d4b60e
周超
完成维度编辑
|
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
|
data.rules = [
{
QuestionClassId: 0,
DimensionTitle: '',
DimensionContent: '',
StartScore: '',
StartFormula: '',
EndScore: '',
EndFormula: '',
ScoreType: 1,
sort: 0
}
];
}
this.data = data;
|
b441010d
yangzhi
超哥牛批 超时yyds
|
364
|
}
|
f7d4b60e
周超
完成维度编辑
|
365
|
});
|
b441010d
yangzhi
超哥牛批 超时yyds
|
366
|
}
|
f7d4b60e
周超
完成维度编辑
|
367
368
369
370
371
|
}
}
}
|
b441010d
yangzhi
超哥牛批 超时yyds
|
372
|
</script>
|