123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <template>
- <el-dialog
- :visible.sync="modalIsShow"
- :title="title"
- top="10vh"
- width="500px"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- append-to-body
- @open="visibleChange"
- >
- <el-form label-width="80px">
- <el-form-item label="评价方式:">
- <el-select
- v-model="selectedEvaluationIds"
- placeholder="请选择评卷方式"
- class="width-full"
- multiple
- @change="selectChange"
- >
- <el-option
- v-for="item in sources"
- :key="item.evaluationId"
- :value="item.evaluationId"
- :label="item.evaluationName"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-form>
- <el-table :data="dataList" border>
- <el-table-column
- prop="evaluationName"
- label="评价方式"
- min-width="120"
- ></el-table-column>
- <el-table-column prop="courseCode" label="权重" width="130">
- <template slot-scope="scope">
- <el-input-number
- v-model="scope.row.weight"
- class="width-80"
- size="small"
- :min="0"
- :max="100"
- :step="1"
- step-strictly
- :controls="false"
- >
- </el-input-number>
- <span style="margin-left: 5px">%</span>
- </template>
- </el-table-column>
- </el-table>
- <div slot="footer">
- <el-button type="primary" @click="submit">确认</el-button>
- <el-button @click="cancel">取消</el-button>
- </div>
- </el-dialog>
- </template>
- <script>
- import { calcSum } from "@/plugins/utils";
- export default {
- name: "modify-target-evaluation",
- props: {
- target: {
- type: Object,
- default() {
- return {};
- },
- },
- sources: {
- type: Array,
- default() {
- return [];
- },
- },
- },
- data() {
- return {
- modalIsShow: false,
- dataList: [],
- selectedEvaluationIds: [],
- };
- },
- computed: {
- title() {
- return `${this.target.courseTargetName}平时成绩组成详情`;
- },
- },
- methods: {
- visibleChange() {
- this.dataList = this.target.evaluationList
- .slice(0, -1)
- .filter((item) => item.enable)
- .map((item) => {
- return { ...item };
- });
- this.selectedEvaluationIds = this.dataList.map(
- (item) => item.evaluationId
- );
- },
- cancel() {
- this.modalIsShow = false;
- },
- open() {
- this.modalIsShow = true;
- },
- selectChange() {
- const selectData = this.sources.filter((item) =>
- this.selectedEvaluationIds.includes(item.evaluationId)
- );
- const count = selectData.length;
- const weight = Math.floor(100 / count);
- const sData = 100 % count;
- this.dataList = selectData.map((item, index) => {
- return {
- ...item,
- weight: index === count - 1 ? weight + sData : weight,
- };
- });
- },
- async submit() {
- if (!this.dataList.length) {
- this.$message.error("请选择评价方式");
- return;
- }
- if (calcSum(this.dataList.map((item) => item.weight)) !== 100) {
- this.$message.error("权重综合不等于100%");
- return;
- }
- this.$emit("modified", this.dataList);
- this.cancel();
- },
- },
- };
- </script>
|