fix: edu.js train.vue 新增线下培训

This commit is contained in:
zty 2024-06-12 15:49:29 +08:00
parent d1844a2104
commit cc20b723fa
2 changed files with 87 additions and 63 deletions

View File

@ -232,15 +232,15 @@ export default {
data
);
}
},
delete: {
name: "删除",
req: async function(id){
return await http.delete(
`${config.API_URL}/edu/training/${id}/`
);
}
},
},
delete: {
name: "删除",
req: async function(id){
return await http.delete(
`${config.API_URL}/edu/training/${id}/`
);
}
},
}
}

View File

@ -34,10 +34,12 @@
label="培训名称"
prop="name"
></el-table-column>
<el-table-column
label="等级"
prop="level"
>
<el-table-column label="等级">
<template v-slot="scope">
<div v-for="(item, index) in levelOptions" :key="index">
<span v-if="item.value == scope.row.level">{{ item.key }}</span>
</div>
</template>
</el-table-column>
<el-table-column
label="时长(h)"
@ -59,10 +61,6 @@
label="内容描述"
prop="description"
></el-table-column>
<el-table-column
label="参与部门"
prop="attend_departs"
></el-table-column>
<el-table-column
label="是否公开"
width="80"
@ -80,21 +78,21 @@
width="150"
>
<template #default="scope">
<!-- <el-button
<el-button
link
size="small"
@click="table_edit(scope.row)"
v-auth="'exam.update'"
v-auth="'train.update'"
type="primary"
>编辑</el-button
> -->
<el-button
>
<!-- <el-button
link
size="small"
@click="row_detail(scope.row)"
type="primary"
>详情</el-button
>
> -->
<el-popconfirm
title="确定删除吗?"
@confirm="table_del(scope.row, scope.$index)"
@ -103,7 +101,7 @@
<el-button
link
size="small"
v-auth="'exam.delete'"
v-auth="'train.delete'"
type="danger"
>删除</el-button
>
@ -122,7 +120,7 @@
<el-form-item label="培训名称" prop="name" required>
<el-input
v-model="trainForm.name"
clearable
style="width: 80%;"
></el-input>
</el-form-item>
<el-row>
@ -144,21 +142,30 @@
/>
</el-form-item>
</el-col>
<el-form-item label="地点" prop="place" required>
<el-input
v-model="trainForm.place"
clearable
></el-input>
</el-form-item>
<el-form-item label="时长(h)" prop="duration" required>
<el-input-number
v-model="trainForm.duration"
controls-position="right"
:step="0.5"
step-strictly="true"
/>
</el-form-item>
<el-form-item label="内容描述" prop="description" required>
<el-input
v-model="trainForm.description"
clearable
autisize
type="textarea"
style="width: 240%;"
></el-input>
</el-form-item>
<el-col :span="8">
<!-- <el-form-item
label="级别"
prop="level"
required
>
<el-input-number
v-model="examForm.chance"
controls-position="right"
:min="1"
style="width: 100%"
></el-input-number>
</el-form-item> -->
</el-col>
<el-col :span="16">
<el-form-item label="级别" prop="level" required>
@ -170,12 +177,14 @@
>
<el-option
v-for="item in levelOptions"
:key="item.id"
:label="item.name"
:value="item.id"
:key="item.key"
:label="item.key"
:value="item.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item
@ -186,13 +195,23 @@
<el-switch v-model="trainForm.is_public"/>
</el-form-item>
</el-col>
<el-form-item label="附件" prop="files">
<sc-upload-file
:multiple="false"
:on-success="handleUpSuccess"
:limit="1"
tip="最多上传10个文件,单个文件不要超过10M"
>
<el-button type="primary" icon="el-icon-upload"> </el-button>
</sc-upload-file>
</el-form-item>
</el-row>
</el-form>
<template #footer>
<el-button
type="primary"
:loading="examSaving"
@click="examSubmit()"
:loading="trainSaving"
@click="TrainSubmit()"
> </el-button
>
</template>
@ -200,12 +219,12 @@
</el-container>
</template>
<script>
const defaultExam = {chance: 1, is_public:false}
const defaultTrain = {chance: 1, is_public:false}
export default {
data() {
return {
paperOptions:[],
examDialog: false,
trainDialog: false,
apiObj: this.$API.edu.training.list,
query: {
search: "",
@ -216,7 +235,7 @@ export default {
{key:'部门',value:30},
{key:'公司',value:40}
],
examForm: Object.assign({}, defaultExam),
trainForm: Object.assign({}, defaultTrain),
};
},
mounted() {
@ -224,7 +243,7 @@ export default {
},
methods: {
getPaperOptions() {
this.$API.edu.paper.list.req({
this.$API.edu.training.list.req({
page: 0
}).then(res => {
this.paperOptions = res;
@ -234,35 +253,40 @@ export default {
this.$refs.table.queryData(this.query);
},
table_add() {
this.examForm = Object.assign({}, defaultExam);
this.examDialog = true;
this.trainForm = Object.assign({}, defaultTrain);
this.trainDialog = true;
},
table_edit(row) {
this.examForm = Object.assign({}, row);
this.examDialog = true;
this.trainForm = Object.assign({}, row);
this.trainDialog = true;
},
table_del(row) {
this.$API.edu.exam.delete.req(row.id).then(() => {
this.$API.edu.training.delete.req(row.id).then(() => {
this.handleQuery();
});
},
examSubmit() {
this.examSaving = true;
if (this.examForm.id){
this.$API.edu.exam.update.req(this.examForm.id, this.examForm).then(res=>{
handleUpSuccess(res, file){
this.trainForm.files = [];
this.trainForm.files.push(res.id)
},
TrainSubmit() {
this.trainSaving = true;
if (this.trainForm.id){
this.$API.edu.training.update.req(this.trainForm.id, this.trainForm).then(res=>{
this.$message.success("更新成功");
this.examSaving = false;
this.examDialog = false;
this.trainSaving = false;
this.trainDialog = false;
this.handleQuery();
}).catch(e=>{this.examSaving=false})
}).catch(e=>{this.trainSaving=false})
}else{
this.$API.edu.exam.create.req(this.examForm).then(res=>{
console.log(this.trainForm)
this.$API.edu.training.create.req(this.trainForm).then(res=>{
this.$message.success("创建成功");
this.examSaving = false;
this.examDialog = false;
this.trainSaving = false;
this.trainDialog = false;
this.handleQuery();
}).catch(err=>{
this.examSaving = false;
this.trainSaving = false;
})
}