实训列表接口调整

This commit is contained in:
fan 2023-01-04 16:45:33 +08:00
parent 8084698cd8
commit b1cec0839d
5 changed files with 318 additions and 322 deletions

View File

@ -206,6 +206,14 @@ export function getPublishTrainingListInOrg(data) {
data
});
}
/** 查询组织已发布的实训列表 */
export function getManageTrainingListInOrg(data) {
return request({
url: `/api/v2/training/published/manage/infos`,
method: 'post',
data
});
}
/** 根据实训id查该已发布实训的所有信息 */
export function getPublishTrainingDetail(trainingId) {
return request({

View File

@ -10,7 +10,7 @@ import { createSimulation } from '@/api/simulation';
import ConstConfig from '@/scripts/ConstConfig';
import { getSessionStorage } from '@/utils/auth';
import { launchFullscreen } from '@/utils/screen';
import { getAllPublishTrainingList, getPublishTrainingListInOrg, publishTrainingPutOn, publishTrainingPutOff, publishTrainingDelete } from '@/api/jmap/training';
import { getAllPublishTrainingList, getManageTrainingListInOrg, publishTrainingPutOn, publishTrainingPutOff, publishTrainingDelete } from '@/api/jmap/training';
export default {
name:'TrainingManage',
data() {
@ -173,7 +173,8 @@ export default {
if (this.hasTeachingDataManage()) {
return getAllPublishTrainingList(param);
} else {
return getPublishTrainingListInOrg(param);
if (!param.type) { delete param.type; }
return getManageTrainingListInOrg(param);
}
},
getLabelJson(row) {
@ -203,11 +204,11 @@ export default {
loadScript(index, row) {
// mapSystem terminal
// row.mapSystem
let memberId = '1';
if (row.playerIdJson) {
memberId = JSON.parse(row.playerIdJson)[0];
}
const data = {mapId: row.mapId, type:row.mapSystem || 'METRO', itemMap:{DEFAULT_MEMBER:memberId} };
// let memberId = '1';
// if (row.playerIdJson) {
// memberId = JSON.parse(row.playerIdJson)[0];
// }
// const data = {mapId: row.mapId, type:row.mapSystem || 'METRO', itemMap:{DEFAULT_MEMBER:memberId} };
// domConfig: Object
// hasExam: false
// hasTraining: false

View File

@ -139,12 +139,6 @@ export default {
return this.isEditMode ? this.$t('publish.modifyRules') : this.$t('publish.addRules');
}
},
created() {
// getLabelList().then(resp => {
// this.labels = [{ label: '', value: '' }, ...resp.data.map(item => ({ label: item, value: item }))];
// });
},
mounted() {},
methods: {
show(detail) {
this.dialogShow = true;
@ -170,14 +164,7 @@ export default {
isDuplicated() {
const isDuplicated =
this.ruleList.length > 0 &&
this.ruleList.some(
rule =>
rule.type === this.form.type &&
rule.subtype === this.form.subtype &&
rule.tags &&
this.form.tags &&
rule.tags.includes(this.form.tags)
);
this.ruleList.some(rule => rule.type === this.form.type && rule.subtype === this.form.subtype && rule.tags && this.form.tags && rule.tags.includes(this.form.tags));
return isDuplicated;
},
subTypesChange(val) {

View File

@ -8,9 +8,9 @@
<div class="joylink-card forms">
<exam-from v-show="currentStep === 1" ref="exam" :exam-data="examData" />
<rule-from
:is-edit-mode="isEditMode"
v-show="currentStep === 2"
ref="rule"
:is-edit-mode="isEditMode"
:rule-list="ruleList"
:exam-data="examData"
/>
@ -32,18 +32,18 @@
</template>
<script>
import RuleFrom from './rule'
import ExamFrom from './examFrom'
import { getPaperDetail } from '@/api/management/exam'
import { UrlConfig } from '@/scripts/ConstDic'
import RuleFrom from './rule';
import ExamFrom from './examFrom';
import { getPaperDetail } from '@/api/management/exam';
import { UrlConfig } from '@/scripts/ConstDic';
import { createPaper, editPaper } from '@/api/management/exam'
import { createPaper, editPaper } from '@/api/management/exam';
export default {
name: 'ExamRule',
components: {
ExamFrom,
RuleFrom,
RuleFrom
},
data() {
return {
@ -56,24 +56,24 @@ export default {
validDuration: 30,
fullScore: 100,
passScore: 60,
mapId: '',
mapId: ''
},
ruleList: [],
}
ruleList: []
};
},
computed: {
orgId() {
return this.$store.state.user.companyId
return this.$store.state.user.companyId;
},
showPrevStep() {
return this.currentStep == 2
return this.currentStep == 2;
},
showNextStep() {
return this.currentStep == 1
return this.currentStep == 1;
},
isEditMode() {
return this.$route.params.mode == 'edit'
},
return this.$route.params.mode == 'edit';
}
},
created() {
if (this.isEditMode) {
@ -86,69 +86,69 @@ export default {
endTime: res.data.endTime,
validDuration: Number(res.data.validDuration),
fullScore: res.data.fullScore,
passScore: res.data.passScore,
}
this.ruleList = res.data.ruleList
passScore: res.data.passScore
};
this.ruleList = res.data.ruleList;
this.$nextTick(() => {
this.$refs.exam.haveDate = !!this.examData.startTime
})
})
this.$refs.exam.haveDate = !!this.examData.startTime;
});
});
}
},
methods: {
prevStep() {
this.currentStep = 1
this.currentStep = 1;
},
nextStep() {
this.$refs.exam
.checkForm()
.then(() => {
this.currentStep = 2
this.currentStep = 2;
})
.catch(() => {})
.catch(() => {});
},
submit() {
const scoreValid = this.$refs.rule.checkTotolScores()
const scoreValid = this.$refs.rule.checkTotalScores();
if (!scoreValid) {
this.$message.warning('规则满分与试题定义不匹配')
return
this.$message.warning('规则满分与试题定义不匹配');
return;
}
const examData = { ...this.examData, ...{ orgId: this.orgId } }
const ruleData = this.ruleList
const uploadData = { ...examData, ruleList: ruleData }
console.log(JSON.stringify(uploadData))
const examData = { ...this.examData, ...{ orgId: this.orgId } };
const ruleData = this.ruleList;
const uploadData = { ...examData, ruleList: ruleData };
console.log(JSON.stringify(uploadData));
const uploadMethodMap = {
add: createPaper,
edit: editPaper,
}
edit: editPaper
};
if (this.isEditMode) {
uploadData.id = this.$route.params.paperId
uploadData.id = this.$route.params.paperId;
}
uploadMethodMap[this.$route.params.mode](uploadData).then(resp => {
if (resp.code === 200) {
this.$message.success(`${this.isEditMode ? '修改' : '创建'}成功`)
this.turnback()
this.$message.success(`${this.isEditMode ? '修改' : '创建'}成功`);
this.turnback();
} else {
this.$message.error(resp.message)
console.log(uploadData)
console.log(resp)
this.$message.error(resp.message);
console.log(uploadData);
console.log(resp);
}
})
});
},
turnback() {
const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleManage}`
const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleManage}`;
if (this.$route.query.source === 'org') {
this.$router.go(-1)
this.$router.go(-1);
} else {
this.$router.replace({
path: `${path}`,
query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout },
})
query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout }
});
}
},
},
}
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.joylink-card {

View File

@ -52,32 +52,32 @@
</template>
</el-table-column>
</el-table>
<edit-rule @submit="handleRuleSubmit" :ruleList="ruleList" ref="addRule" />
<edit-rule ref="addRule" :rule-list="ruleList" @submit="handleRuleSubmit" />
</div>
</template>
<script>
import editRule from './editRule'
import editRule from './editRule';
export default {
name: 'Rule',
components: {
editRule,
editRule
},
props: {
examData: {
type: Object,
default: null,
default: null
},
ruleList: {
type: Array,
default() {
return []
},
return [];
}
},
isEditMode: {
type: Boolean,
},
type: Boolean
}
},
data() {
return {
@ -86,21 +86,21 @@ export default {
trainingOperateTypeMap: {},
trainingTypeNums: {}, //
operationTypeNums: {}, //
trainingTypeList: [], //
}
trainingTypeList: [] //
};
},
computed: {
types() {
return ['', '理论题', '实训题']
return ['', '理论题', '实训题'];
},
subtypes() {
return ['', '单选题', '多选题', '判断题', '单操实训', '场景实训']
},
return ['', '单选题', '多选题', '判断题', '单操实训', '场景实训'];
}
},
created() {},
methods: {
handleAdd() {
this.$refs.addRule.show()
this.$refs.addRule.show();
},
handleRuleSubmit(formData, isEdit) {
const data = {
@ -109,60 +109,60 @@ export default {
amount: formData.amount,
score: formData.score,
topicNum: formData.topicNum,
tags: [formData.tags],
}
tags: [formData.tags]
};
if (isEdit) {
this.$set(this.ruleList, this.editingIndex, data)
this.$set(this.ruleList, this.editingIndex, data);
} else {
this.ruleList.push(data)
this.ruleList.push(data);
}
},
deleteRule(data) {
const index = data.$index
this.ruleList.splice(index, 1)
const index = data.$index;
this.ruleList.splice(index, 1);
},
checkTotolScores() {
return this.currentTotalScore === this.examData.fullScore
checkTotalScores() {
return this.currentTotalScore === this.examData.fullScore;
},
editRow(data) {
this.editingIndex = data.$index
const list = JSON.stringify(data.row)
const detail = JSON.parse(list)
this.$refs.addRule.show({ ...detail, index: data.$index })
this.editingIndex = data.$index;
const list = JSON.stringify(data.row);
const detail = JSON.parse(list);
this.$refs.addRule.show({ ...detail, index: data.$index });
},
getSummaries({ columns, data }) {
const sums = []
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '合计'
return
sums[index] = '合计';
return;
} else if (index === 2) {
const values = data.map(item => Number(item.amount))
const values = data.map(item => Number(item.amount));
sums[2] = values.reduce((prev, curr) => {
const value = Number(curr)
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr
return prev + curr;
} else {
return prev
return prev;
}
}, 0)
}, 0);
} else if (index === 3) {
const values = data.map(item => Number(item.amount) * Number(item.score))
const values = data.map(item => Number(item.amount) * Number(item.score));
this.currentTotalScore = sums[3] = values.reduce((prev, curr) => {
const value = Number(curr)
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr
return prev + curr;
} else {
return prev
return prev;
}
}, 0)
}, 0);
}
})
return sums
},
},
}
});
return sums;
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.exam-rule {