Commit f7d4b60e98e4d47db3a9eb5609685b330e61c564

Authored by 周超
1 parent f6d2db76

完成维度编辑

src/api/QuestionClass.js
... ... @@ -6,4 +6,20 @@ export default {
6 6 method: 'post'
7 7 });
8 8 },
  9 +}
  10 +
  11 +export function getQuestionClass(params) {
  12 + return request({
  13 + url: `/QuestionClass/Get`,
  14 + method: 'get',
  15 + params
  16 + })
  17 +}
  18 +// 修改 | 保存
  19 +export function EditQuestionClass(params) {
  20 + return request({
  21 + url: `/QuestionClass/Update`,
  22 + method: 'post',
  23 + data: params
  24 + })
9 25 }
10 26 \ No newline at end of file
... ...
src/views/QuestionBank/components/EditDimension.vue
1 1 <template>
2   - <el-dialog title="维度编辑" :visible.sync="dialogFormVisible" @closed="dialogFormVisible = false">
3   - <el-form :model="form">
4   - <el-form-item label="名称" >
5   - <el-input v-model="form.ClassificationName"></el-input>
  2 + <el-dialog title="维度编辑" :visible.sync="dialogFormVisible" @closed="dialogFormVisible = false" width="75%">
  3 + <el-form :model="data">
  4 + <el-form-item label="名称">
  5 + <el-input v-model="data.ClassificationName"></el-input>
6 6 </el-form-item>
7   - <el-form-item label="规则" >
8   - <ul class="evaluation-rules">
9   - <li v-for="item in evalutionRules" :key="item.id">
10   - <el-input placeholder="请输入标题" v-model="item.DimensionTitle"></el-input>
11   - <span>范围</span>
12   -
13   - </li>
14   - </ul>
  7 +
  8 + <el-form-item label="规则">
  9 + <div style="padding:10px 5px 0px 5px">
  10 + <el-table v-if="data.rules" :data="data.rules" style="width: 100%;">
  11 + <el-table-column align="left" label="状态">
  12 + <template slot-scope="{row}">
  13 + <div style="display: flex;">
  14 + <el-input placeholder="请输入标题" v-model="row.DimensionTitle"></el-input>
  15 + <div style="width:60px;margin-left:5px;padding-top:3px">
  16 + <el-button type="text" style="font-size:16px" size="mini" icon="el-icon-circle-plus-outline"
  17 + @click="addtablerow(row.sort,data)"></el-button>
  18 + <el-button type="text" style="font-size:16px;margin-left:5px" size="mini"
  19 + icon="el-icon-remove-outline" @click="deltablerow(row.sort,data)"></el-button>
  20 + </div>
  21 + </div>
  22 + </template>
  23 + </el-table-column>
  24 +
  25 + <el-table-column align="center" label="计分规则">
  26 + <template slot-scope="{row}">
  27 + <el-select style="width:16%;margin-right:1%" v-model="row.ScoreType" placeholder="计分类型" clearable>
  28 + <el-option :value="1" label="按照总分"> 按照总分 </el-option>
  29 + <el-option :value="2" label="按照平均分"> </el-option>
  30 + </el-select>
  31 +
  32 + <el-select style="width:18%;margin-right:1%" v-model="row.StartFormula" placeholder="规则" clearable>
  33 + <el-option v-for="item in ruleOptions" :key="item.value" :label="item.label" :value="item.value">
  34 + </el-option>
  35 + </el-select>
  36 + <el-input style="width:20%;margin-right:1%" type="number" v-model="row.StartScore"
  37 + :placeholder="'开始分值'">
  38 + </el-input>
  39 + <el-select style="width:18%;margin-right:1%" v-model="row.EndFormula" placeholder="规则" clearable>
  40 + <el-option v-for="item in ruleOptions" :key="item.value" :label="item.label" :value="item.value">
  41 + </el-option>
  42 + </el-select>
  43 + <el-input style="width:22%" v-model="row.EndScore" type="number" :placeholder="'结束分值'"></el-input>
  44 +
  45 +
  46 +
  47 + </template>
  48 + </el-table-column>
  49 + <el-table-column align="center" width="50" label="排序">
  50 + <template slot-scope="{row}">
  51 + <el-button v-if="row.sort > 0" type="text" size="small" icon="el-icon-top"
  52 + @click="tablesort(0,row.sort,data)">
  53 + </el-button>
  54 + <el-button v-if="row.sort < (data.rules.length-1) && data.rules.length >1" type="text" size="small"
  55 + icon="el-icon-bottom" @click="tablesort(1,row.sort,data)"></el-button>
  56 + </template>
  57 + </el-table-column>
  58 + </el-table>
  59 +
  60 + <div>
  61 + <el-collapse v-model="activeName" accordion>
  62 + <el-collapse-item v-for="(citem,index) in data.rules" :title="citem.DimensionTitle" :name="index"
  63 + :key="index">
  64 +
  65 + <div>
  66 + <div style="width:100%;margin-top:10px;color:#409EFF;">
  67 + 分值解析
  68 + </div>
  69 + <div style="display: flex;">
  70 + <div style="width:50%">
  71 +
  72 + <tinymce ref="content" v-model="citem.DimensionContent" :height="650" />
  73 + </div>
  74 + <div style="width:50%;padding:0px 20px" v-html="citem.DimensionContent">
  75 +
  76 + </div>
  77 + </div>
  78 + </div>
  79 +
  80 + </el-collapse-item>
  81 + </el-collapse>
  82 +
  83 + </div>
  84 + </div>
15 85 </el-form-item>
16 86 </el-form>
17 87 <div slot="footer" class="dialog-footer">
18 88 <el-button @click="dialogFormVisible = false">取 消</el-button>
19   - <el-button type="primary" @click="dialogFormVisible = false"
20   - >确 定</el-button
21   - >
  89 + <el-button type="primary" @click="handleSave">确 定</el-button>
22 90 </div>
23 91 </el-dialog>
24 92 </template>
25 93 <script>
26   -export default {
27   - props:{
28   - model:{
29   - type:Object,
30   - default(){
31   - return {};
32   - }
  94 +
  95 + import Tinymce from '@/components/Tinymce'
  96 +
  97 + import {
  98 + EditQuestionClass,
  99 + getQuestionClass,
  100 +
  101 + } from "@/api/QuestionClass";
  102 +
  103 +
  104 + export default {
  105 + components: {
  106 + Tinymce
  107 + },
  108 + props: {
  109 + model: {
  110 + type: Object,
  111 + default() {
  112 + return {};
  113 + }
  114 + },
  115 + },
  116 +
  117 + data() {
  118 + return {
  119 + data: {
  120 + scoring_type: 0
33 121 },
  122 + activeName: '',
  123 + dialogFormVisible: false,
  124 + form: {},
  125 + ruleOptions: [
  126 + { label: '大于', value: '>' },
  127 + { label: '小于', value: '<' },
  128 + { label: '大于等于', value: '>=' },
  129 + { label: '小于等于', value: '<=' },
  130 + { label: '等于', value: '=' },
  131 + ],
  132 + evalutionRules: [
  133 + {
  134 + id: '',
  135 + QuestionClassId: 0,
  136 + DimensionTitle: '',
  137 + DimensionContent: '',
  138 + StartScore: '',
  139 + StartFormula: '',
  140 + EndScore: '',
  141 + EndFormula: '',
  142 + ScoreType: 1
  143 + }
  144 + ],
  145 + };
34 146 },
35   - data(){
36   - return {
37   - dialogFormVisible:false,
38   - form:{},
39   - evalutionRules:[
  147 + watch: {
  148 + model: {
  149 + deep: true,
  150 + handler(val) {
  151 + this.form = val;
  152 + }
  153 + }
  154 +
  155 + },
  156 + created() {
  157 + // this.show();
  158 + },
  159 + methods: {
  160 + handleSave() {
  161 + if (!this.data.ClassificationName) {
  162 + this.$message.warning('请填写名称!', "消息");
  163 + return;
  164 + }
  165 + this.data.ClassType = 2;//默认维度
  166 + EditQuestionClass(this.data).then(res => {
  167 + if (res.data.code == 200) {
  168 + this.$message.success('保存成功!', "消息");
  169 + this.dialogFormVisible = false;
  170 + this.data = {
  171 + rules: [
40 172 {
41   - id:'',
42   - QuestionClassId:0,
43   - DimensionTitle:'',
44   - DimensionContent:'',
45   - StartScore:'',
46   - StartFormula:'',
47   - EndScore:'',
48   - EndFormula:'',
49   - ScoreType:''
  173 + QuestionClassId: 0,
  174 + DimensionTitle: '',
  175 + DimensionContent: '',
  176 + StartScore: '',
  177 + StartFormula: '',
  178 + EndScore: '',
  179 + EndFormula: '',
  180 + ScoreType: 1,
  181 + sort: 0
50 182 }
51   - ],
52   - };
53   - },
54   - watch:{
55   - model:{
56   - deep:true,
57   - handler(val){
58   - this.form = val;
  183 + ]
  184 + };
  185 + }
  186 + else {
  187 + this.$message.error('保存失败!', "消息");
  188 + }
  189 + });
  190 +
  191 + },
  192 + addtablerow(index, row) {
  193 + row.rules.splice(index + 1, 0, { sort: index + 1, id: (new Date().valueOf() + 1).toString(), ScoreType: 1 })
  194 + this.sortdata(index + 1)
  195 + },
  196 + deltablerow(index, row) {
  197 + if (row.rules.length <= 1) return;
  198 +
  199 + row.rules.splice(index, 1)
  200 + var sort = index - 1;
  201 + if (sort < 0) sort = 0;
  202 +
  203 + this.sortdata(sort)
  204 +
  205 + },
  206 + tablesort(type, index, row) {
  207 + if (type == 0) { //-
  208 + var prevsort = row.rules[index - 1].sort;
  209 + row.rules[index - 1].sort = row.rules[index].sort;
  210 + row.rules[index].sort = prevsort;
  211 + row.rules = row.rules.sort((a, b) => {
  212 + return a.sort - b.sort;
  213 + });
  214 + }
  215 + else { //+
  216 +
  217 + var prevsort = row.rules[index + 1].sort;
  218 + row.rules[index + 1].sort = row.rules[index].sort;
  219 + row.rules[index].sort = prevsort;
  220 + row.rules = row.rules.sort((a, b) => {
  221 + return a.sort - b.sort;
  222 + });
  223 + }
  224 + },
  225 + sortdata(index) {
  226 + try {
  227 +
  228 + var tmp = index;
  229 + var data = this.tableData;
  230 + data = data.forEach((e, itemindex) => {
  231 + if (itemindex > index) {
  232 + tmp++;
  233 + e.sort = tmp;
  234 + }
  235 + });
  236 + this.tableData = tmpdata
  237 + } catch (e) { }
  238 + },
  239 + show(id) {
  240 + if (id) {
  241 + this.data = {
  242 + // id: Date.parse(new Date()) + '_' + Math.ceil(Math.random() * 99999),
  243 + // key: Date.parse(new Date()) + '_' + Math.ceil(Math.random() * 99999),
  244 + rules: [
  245 + {
  246 + QuestionClassId: 0,
  247 + DimensionTitle: '',
  248 + DimensionContent: '',
  249 + StartScore: '',
  250 + StartFormula: '',
  251 + EndScore: '',
  252 + EndFormula: '',
  253 + ScoreType: 1,
  254 + sort: 0
  255 + }
  256 + ]
  257 + };
  258 + this.dialogFormVisible = true;
  259 + getQuestionClass({ id }).then(res => {
  260 +
  261 + if (res) {
  262 + var data = res.data.data;
  263 + if (!data.rules) {
  264 + data.rules = [
  265 + {
  266 + QuestionClassId: 0,
  267 + DimensionTitle: '',
  268 + DimensionContent: '',
  269 + StartScore: '',
  270 + StartFormula: '',
  271 + EndScore: '',
  272 + EndFormula: '',
  273 + ScoreType: 1,
  274 + sort: 0
  275 + }
  276 + ];
  277 + }
  278 +
  279 + this.data = data;
59 280 }
  281 + });
60 282 }
61   - },
62   - methods:{}
63   -}
  283 +
  284 +
  285 + }
  286 + }
  287 + }
64 288 </script>
65 289 \ No newline at end of file
... ...
src/views/QuestionBank/index.vue
... ... @@ -416,7 +416,8 @@ export default {
416 416 //维度编辑
417 417 handleEditDimension(node,data) {
418 418 console.log(data);
419   - this.$refs.editDimensionDialog.dialogFormVisible = true;
  419 + // this.$refs.editDimensionDialog.dialogFormVisible = true;
  420 + this.$refs.editDimensionDialog.show(data.id);
420 421 this.currentEditDimension = data;
421 422 },
422 423 //切换分类
... ...
vue.config.js
... ... @@ -39,6 +39,7 @@ module.exports = {
39 39 proxy: {
40 40 '/development': {
41 41 target: `http://inteview.t1j2.com/`, //后台服务地址
  42 + // target:'https://localhost:44399',
42 43 changeOrigin: true,
43 44 pathRewrite: {
44 45 '^/development': ''
... ...