案例校验、新增

zqqdev
CherrysChang 5 years ago
parent 3607676424
commit 59bfd06560
  1. 2
      src/api/server.js
  2. 47
      src/views/train/case-detail.vue
  3. 2
      src/views/train/case-list.vue

@ -51,7 +51,7 @@ export const Train = new (class {
//添加
insertCase(params) {
return axios
.post(this.insertCaseApi, qs.stringify(params))
.post(this.insertCaseApi, qs.stringify(params,{allowDots: true }))
.then(res => res.data);
}
//修改

@ -48,16 +48,15 @@
<template slot-scope="scope">
<el-row>
<el-col :span="12">
<el-form-item :prop="'taskList.'+scope.$index+'.taskOperate'" :rules="dataRule.score" class="score-input" >
<el-form-item :prop="'taskList.'+scope.$index+'.taskOperate'" :rules="dataRule.taskOperate" class="score-input" >
<el-select v-model="scope.row.taskOperate" size="small" style="width: 100px;">
<el-option label="大于" value="1"></el-option>
<el-option label="等于" value="2"></el-option>
<el-option label="小于" value="3"></el-option>
<el-option label="小于" value="2"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :prop="'taskList.'+scope.$index+'.taskRate'" :rules="dataRule.score" class="score-input" >
<el-form-item :prop="'taskList.'+scope.$index+'.taskRate'" :rules="dataRule.taskRate" class="score-input" >
<el-input size="small" v-model.trim="scope.row.taskRate" :disabled="formAction == 2" style="width: 100px;">
<i slot="suffix">%</i>
</el-input>
@ -66,10 +65,10 @@
</el-row>
</template>
</el-table-column>
<el-table-column prop="score" label="分数" width="120">
<el-table-column prop="taskScore" label="分数" width="120">
<template slot-scope="scope">
<el-form-item :prop="'taskList.'+scope.$index+'.score'" :rules="dataRule.score" class="score-input">
<el-input size="small" v-model.trim="scope.row.score" :disabled="formAction == 2" style="width: 100px;"><i slot="suffix"></i></el-input>
<el-form-item :prop="'taskList.'+scope.$index+'.taskScore'" :rules="dataRule.taskScore" class="score-input">
<el-input size="small" v-model.trim="scope.row.taskScore" :disabled="formAction == 2" style="width: 100px;"><i slot="suffix"></i></el-input>
</el-form-item>
</template>
</el-table-column>
@ -104,17 +103,17 @@
var validateScore = (rule, value, callback) => {
if (!value) {
callback(new Error('请输入分数'));
} else if (!(/^(([1-9][0-9]*)|(([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2})))$/.test(value)) || value > 100) {
callback(new Error('请输入0-100之间最多两位小数的数字'));
} else if (!(/^[1-9][0-9]{0,2}$/.test(value)) || value > 100) {
callback(new Error('请输入1-100之间的正整数'));
} else {
callback();
}
};
var validateContent = (rule, value, callback) => {
if (!value.trim()) {
callback(new Error('请填写案例描述'));
} else if (value.length > 3000) {
callback(new Error('长度在 1 到 3000 个字符'));
var validateTaskRate = (rule, value, callback) => {
if (!value) {
callback(new Error('请输入任务目标'));
} else if (!(/^(([1-9][0-9]*)|(([0]\.\d|[1-9][0-9]*\.\d)))$/.test(value)) || value > 100) {
callback(new Error('请输入100以内最多一位小数的正数'));
} else {
callback();
}
@ -137,10 +136,13 @@
type: [
{ required: true, message: '请选择实训用途', trigger: 'change' }
],
// content: [
// {validator: validateContent, trigger: 'blur'}
// ],
score: [
taskOperate: [
{ required: true, message: '请选择设置项', trigger: 'change' }
],
taskRate: [
{validator: validateTaskRate, trigger: 'blur'}
],
taskScore: [
{validator: validateScore, trigger: 'blur'}
],
},
@ -216,8 +218,8 @@
},
methods: {
goBackList() {
// this.$router.push({name: 'CaseList'});
this.$router.go(-1);
this.$router.push({name: 'CaseList'});
// this.$router.go(-1);
},
initTargetList(searchObj) {
Train.getTargetList(searchObj).then(res => {
@ -247,8 +249,7 @@
item=Object.assign({}, item, {
taskOperate: null,
taskRate: null,
score: null,
taskSeq: null
taskScore: null
})
//
this.rightTargetList.push(item);
@ -303,7 +304,7 @@
return;
}
if (index === 3) { //
values = data.map(item => Number(item['score']));
values = data.map(item => Number(item['taskScore']));
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {

@ -93,7 +93,7 @@
Train.getCaseList(searchObj).then(res => {
if (res.code == 200) {
this.listData = res.data.rows;
this.totalCount = res.totalCount;
this.totalCount = res.data.total;
}
}).catch(error => {
console.info(error)

Loading…
Cancel
Save