|
@@ -4,7 +4,7 @@
|
|
<Button type="success" icon="md-add" @click="toAdd">新增</Button>
|
|
<Button type="success" icon="md-add" @click="toAdd">新增</Button>
|
|
</div>
|
|
</div>
|
|
<div class="part-box">
|
|
<div class="part-box">
|
|
- <table class="table">
|
|
|
|
|
|
+ <table class="table table-noborder">
|
|
<tr>
|
|
<tr>
|
|
<th>档位</th>
|
|
<th>档位</th>
|
|
<th>最低分</th>
|
|
<th>最低分</th>
|
|
@@ -17,75 +17,121 @@
|
|
<th>占比阀值%</th>
|
|
<th>占比阀值%</th>
|
|
<th>操作</th>
|
|
<th>操作</th>
|
|
</tr>
|
|
</tr>
|
|
- <tr v-for="(level, index) in levels" :key="index">
|
|
|
|
- <td>
|
|
|
|
- <Input
|
|
|
|
- v-model="level.code"
|
|
|
|
- style="width: 60px"
|
|
|
|
- @on-blur="codeChange"
|
|
|
|
- ></Input>
|
|
|
|
- </td>
|
|
|
|
- <td>
|
|
|
|
- <InputNumber
|
|
|
|
- v-model="level.minScore"
|
|
|
|
- :min="0"
|
|
|
|
- :max="200"
|
|
|
|
- ></InputNumber>
|
|
|
|
- </td>
|
|
|
|
- <td>
|
|
|
|
- <InputNumber
|
|
|
|
- v-model="level.maxScore"
|
|
|
|
- :min="level.minScore + 1"
|
|
|
|
- :max="200"
|
|
|
|
- ></InputNumber>
|
|
|
|
- </td>
|
|
|
|
- <td style="min-width: 100px">
|
|
|
|
- <InputNumber
|
|
|
|
- v-model="level.intervalScore"
|
|
|
|
- :min="1"
|
|
|
|
- :max="100"
|
|
|
|
- v-if="level.levelType === 'ADMITED'"
|
|
|
|
- ></InputNumber>
|
|
|
|
- </td>
|
|
|
|
- <td>
|
|
|
|
- <InputNumber
|
|
|
|
- v-model="level.weight"
|
|
|
|
- :min="1"
|
|
|
|
- :max="100"
|
|
|
|
- ></InputNumber>
|
|
|
|
- </td>
|
|
|
|
- <td>
|
|
|
|
- <Select
|
|
|
|
- v-model="level.levelType"
|
|
|
|
- @on-change="levelTypeChange(level)"
|
|
|
|
- style="width: 120px"
|
|
|
|
- >
|
|
|
|
- <Option
|
|
|
|
- v-for="(val, key) in LEVEL_TYPE"
|
|
|
|
- :key="key"
|
|
|
|
- :value="key"
|
|
|
|
- >{{ val }}</Option
|
|
|
|
|
|
+ <template v-for="(level, index) in levels">
|
|
|
|
+ <tr :key="index">
|
|
|
|
+ <td>
|
|
|
|
+ <Input
|
|
|
|
+ v-model="level.code"
|
|
|
|
+ style="width: 60px"
|
|
|
|
+ @on-blur="codeChange(level)"
|
|
|
|
+ ></Input>
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ <InputNumber
|
|
|
|
+ v-model="level.minScore"
|
|
|
|
+ :min="0"
|
|
|
|
+ :max="200"
|
|
|
|
+ @on-blur="checkLevelValidate(level)"
|
|
|
|
+ ></InputNumber>
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ <InputNumber
|
|
|
|
+ v-model="level.maxScore"
|
|
|
|
+ :min="1"
|
|
|
|
+ :max="200"
|
|
|
|
+ @on-blur="checkLevelValidate(level)"
|
|
|
|
+ ></InputNumber>
|
|
|
|
+ </td>
|
|
|
|
+ <td style="min-width: 100px">
|
|
|
|
+ <InputNumber
|
|
|
|
+ v-model="level.intervalScore"
|
|
|
|
+ :min="1"
|
|
|
|
+ :max="100"
|
|
|
|
+ :precision="0"
|
|
|
|
+ @on-blur="checkLevelValidate(level)"
|
|
|
|
+ v-if="level.levelType === 'ADMITED'"
|
|
|
|
+ ></InputNumber>
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ <InputNumber
|
|
|
|
+ v-model="level.weight"
|
|
|
|
+ :min="1"
|
|
|
|
+ :max="100"
|
|
|
|
+ @on-blur="checkLevelValidate(level)"
|
|
|
|
+ ></InputNumber>
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ <Select
|
|
|
|
+ v-model="level.levelType"
|
|
|
|
+ @on-change="levelTypeChange(level)"
|
|
|
|
+ style="width: 120px"
|
|
>
|
|
>
|
|
- </Select>
|
|
|
|
- </td>
|
|
|
|
- <td style="min-width: 140px">
|
|
|
|
- <Input
|
|
|
|
- v-model="level.scoreList"
|
|
|
|
- v-if="level.levelType === 'UNADMIT'"
|
|
|
|
- ></Input>
|
|
|
|
- </td>
|
|
|
|
- <td>
|
|
|
|
- <Input v-model="level.kdpt" :min="1" :max="100"></Input>
|
|
|
|
- </td>
|
|
|
|
- <td>
|
|
|
|
- <Input v-model="level.pt" :min="1" :max="100"></Input>
|
|
|
|
- </td>
|
|
|
|
- <td>
|
|
|
|
- <Button size="small" type="error" @click="toDelete(index)"
|
|
|
|
- >删除</Button
|
|
|
|
- >
|
|
|
|
- </td>
|
|
|
|
- </tr>
|
|
|
|
|
|
+ <Option
|
|
|
|
+ v-for="(val, key) in LEVEL_TYPE"
|
|
|
|
+ :key="key"
|
|
|
|
+ :value="key"
|
|
|
|
+ >{{ val }}</Option
|
|
|
|
+ >
|
|
|
|
+ </Select>
|
|
|
|
+ </td>
|
|
|
|
+ <td style="min-width: 140px">
|
|
|
|
+ <Input
|
|
|
|
+ v-model="level.scoreList"
|
|
|
|
+ @on-blur="checkLevelValidate(level)"
|
|
|
|
+ v-if="level.levelType === 'UNADMIT'"
|
|
|
|
+ ></Input>
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ <InputNumber
|
|
|
|
+ v-model="level.kdpt"
|
|
|
|
+ :min="1"
|
|
|
|
+ :max="100"
|
|
|
|
+ @on-blur="checkLevelValidate(level)"
|
|
|
|
+ ></InputNumber>
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ <InputNumber
|
|
|
|
+ v-model="level.pt"
|
|
|
|
+ :min="1"
|
|
|
|
+ :max="100"
|
|
|
|
+ @on-blur="checkLevelValidate(level)"
|
|
|
|
+ ></InputNumber>
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ <Button size="small" type="error" @click="toDelete(index)"
|
|
|
|
+ >删除</Button
|
|
|
|
+ >
|
|
|
|
+ </td>
|
|
|
|
+ </tr>
|
|
|
|
+ <tr class="tr-tips-error" v-if="level.errors" :key="index + '1'">
|
|
|
|
+ <td>
|
|
|
|
+ {{ level.errors.code }}
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ {{ level.errors.minScore }}
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ {{ level.errors.maxScore }}
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ {{ level.errors.intervalScore }}
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ {{ level.errors.weight }}
|
|
|
|
+ </td>
|
|
|
|
+ <td></td>
|
|
|
|
+ <td>
|
|
|
|
+ {{ level.errors.scoreList }}
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ {{ level.errors.kdpt }}
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ {{ level.errors.pt }}
|
|
|
|
+ </td>
|
|
|
|
+ <td></td>
|
|
|
|
+ </tr>
|
|
|
|
+ </template>
|
|
</table>
|
|
</table>
|
|
|
|
|
|
<div class="text-center">
|
|
<div class="text-center">
|
|
@@ -98,8 +144,10 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import { levelList, uploadLevel } from "@/api";
|
|
|
|
|
|
+import { levelList, updateLevel } from "@/api";
|
|
import { LEVEL_TYPE } from "@/constants/enumerate";
|
|
import { LEVEL_TYPE } from "@/constants/enumerate";
|
|
|
|
+import schema from "async-validator";
|
|
|
|
+schema.warning = function() {};
|
|
|
|
|
|
const initLevel = {
|
|
const initLevel = {
|
|
id: null,
|
|
id: null,
|
|
@@ -171,7 +219,8 @@ export default {
|
|
level.intervalScore = null;
|
|
level.intervalScore = null;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- codeChange() {
|
|
|
|
|
|
+ codeChange(level) {
|
|
|
|
+ level.code = level.code.toUpperCase();
|
|
this.levels.sort((a, b) => {
|
|
this.levels.sort((a, b) => {
|
|
if (
|
|
if (
|
|
!a.code ||
|
|
!a.code ||
|
|
@@ -185,6 +234,7 @@ export default {
|
|
this.letterRelateNumber[a.code] - this.letterRelateNumber[b.code]
|
|
this.letterRelateNumber[a.code] - this.letterRelateNumber[b.code]
|
|
);
|
|
);
|
|
});
|
|
});
|
|
|
|
+ this.checkLevelValidate(level);
|
|
},
|
|
},
|
|
getNextLevelCode() {
|
|
getNextLevelCode() {
|
|
const codeNumbers = this.levels.map(
|
|
const codeNumbers = this.levels.map(
|
|
@@ -207,7 +257,106 @@ export default {
|
|
toDelete(index) {
|
|
toDelete(index) {
|
|
this.levels.splice(index, 1);
|
|
this.levels.splice(index, 1);
|
|
},
|
|
},
|
|
|
|
+ checkLevelValidate(level) {
|
|
|
|
+ const descriptor = {
|
|
|
|
+ code: {
|
|
|
|
+ type: "string",
|
|
|
|
+ required: true,
|
|
|
|
+ pattern: /^[A-Z]{1}$/,
|
|
|
|
+ message: "请输入单个大写字母"
|
|
|
|
+ },
|
|
|
|
+ minScore: {
|
|
|
|
+ type: "number",
|
|
|
|
+ required: true,
|
|
|
|
+ message: "请输入最低分"
|
|
|
|
+ },
|
|
|
|
+ maxScore: {
|
|
|
|
+ type: "number",
|
|
|
|
+ required: true,
|
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
|
+ if (!value || value < level.minScore) {
|
|
|
|
+ callback(new Error("最高分不得小于最低分"));
|
|
|
|
+ } else {
|
|
|
|
+ callback();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ intervalScore: {
|
|
|
|
+ type: "number",
|
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
|
+ if (level.levelType === "ADMITED" && !value) {
|
|
|
|
+ callback(new Error("请输入给分间隔"));
|
|
|
|
+ } else {
|
|
|
|
+ callback();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ weight: {
|
|
|
|
+ type: "number",
|
|
|
|
+ required: true,
|
|
|
|
+ message: "请输入典型值"
|
|
|
|
+ },
|
|
|
|
+ scoreList: {
|
|
|
|
+ type: "string",
|
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
|
+ if (level.levelType !== "UNADMIT") return callback();
|
|
|
|
+
|
|
|
|
+ if (level.levelType === "UNADMIT" && !value) {
|
|
|
|
+ return callback(new Error("请输入给分项"));
|
|
|
|
+ }
|
|
|
|
+ if (!value.match(/^[0-9,]+$/)) {
|
|
|
|
+ return callback(new Error("给分项只能包含数字和英文逗号"));
|
|
|
|
+ }
|
|
|
|
+ const unvalid = value
|
|
|
|
+ .split(",")
|
|
|
|
+ .filter(item => item)
|
|
|
|
+ .some(item => {
|
|
|
|
+ const num = item * 1;
|
|
|
|
+ return num < level.minScore || num > level.maxScore;
|
|
|
|
+ });
|
|
|
|
+ if (unvalid) {
|
|
|
|
+ return callback(
|
|
|
|
+ new Error("给分项包含的分值只能介于最低分和最高分之间")
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ callback();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ pt: {
|
|
|
|
+ type: "number",
|
|
|
|
+ required: true,
|
|
|
|
+ message: "请输入占比阀值"
|
|
|
|
+ },
|
|
|
|
+ kdpt: {
|
|
|
|
+ type: "number",
|
|
|
|
+ required: true,
|
|
|
|
+ message: "请输入考点阀值"
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ return new schema(descriptor)
|
|
|
|
+ .validate(level)
|
|
|
|
+ .then(() => {
|
|
|
|
+ if (level.errors) level.errors = null;
|
|
|
|
+ })
|
|
|
|
+ .catch(({ errors, fields }) => {
|
|
|
|
+ let errorMsgs = {};
|
|
|
|
+ errors.map(error => {
|
|
|
|
+ errorMsgs[error.field] = error.message;
|
|
|
|
+ });
|
|
|
|
+ this.$set(level, "errors", errorMsgs);
|
|
|
|
+ return { errors };
|
|
|
|
+ });
|
|
|
|
+ },
|
|
async toSubmit() {
|
|
async toSubmit() {
|
|
|
|
+ const validatorAll = this.levels.map(level =>
|
|
|
|
+ this.checkLevelValidate(level)
|
|
|
|
+ );
|
|
|
|
+ const result = await Promise.all(validatorAll);
|
|
|
|
+ const hasUnvalidate = result.some(item => !!item);
|
|
|
|
+
|
|
|
|
+ if (hasUnvalidate) return;
|
|
|
|
+
|
|
if (!this.checkLevelCodeIsContinuous()) {
|
|
if (!this.checkLevelCodeIsContinuous()) {
|
|
this.$Message.error("请保持档位连续!");
|
|
this.$Message.error("请保持档位连续!");
|
|
return;
|
|
return;
|
|
@@ -215,7 +364,7 @@ export default {
|
|
|
|
|
|
if (this.isSubmit) return;
|
|
if (this.isSubmit) return;
|
|
this.isSubmit = true;
|
|
this.isSubmit = true;
|
|
- const data = await uploadLevel(this.worKDetail).catch(() => {
|
|
|
|
|
|
+ const data = await updateLevel(this.worKDetail).catch(() => {
|
|
this.isSubmit = false;
|
|
this.isSubmit = false;
|
|
});
|
|
});
|
|
|
|
|