You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

277 lines
9.2 KiB

2 years ago
<template>
<div>
<xy-dialog ref="dialog" :width="70" :is-show.sync="isShow" :type="'form'" :title="type === 'add' ? '新增课程' : '编辑课程'"
:form="form" :rules='rules' @submit="submit">
<template v-slot:name>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>课程名称:
</div>
<div class="xy-table-item-content">
2 years ago
<el-input v-model="form.name" placeholder="请输入课程名称" clearable style="width: 100%;"></el-input>
2 years ago
</div>
</div>
</template>
<template v-slot:type>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>课程类别:
</div>
<div class="xy-table-item-content">
2 years ago
<el-select v-model="form.type" placeholder="请选择类别" clearable style="width: 100%;">
2 years ago
<el-option v-for="item in type_options" :key="item.id" :label="item.value" :value="item.id">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:menu>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>课程简介:
</div>
<div class="xy-table-item-content">
<my-tinymce :value="form.menu"></my-tinymce>
</div>
</div>
</template>
<template v-slot:level>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>开课日期:
</div>
<div class="xy-table-item-content">
2 years ago
<el-date-picker style="width: 100%;" v-model="form.daterange" type="daterange" range-separator="至"
2 years ago
start-placeholder="开课日期" end-placeholder="结束日期">
</el-date-picker>
</div>
</div>
</template>
<template v-slot:period>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>开课人数:
</div>
<div class="xy-table-item-content">
2 years ago
<el-input style="width: 100%;" v-model="form.period" placeholder="请输入开课人数" clearable></el-input>
2 years ago
</div>
</div>
</template>
<template v-slot:end_time>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>所在班级(地点):
</div>
<div class="xy-table-item-content">
2 years ago
<el-input style="width: 100%;" v-model="form.end_time" placeholder="请输入所在班级(地点)" clearable></el-input>
2 years ago
</div>
</div>
</template>
<template v-slot:content>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>面向学员的企业性质:
</div>
<div class="xy-table-item-content">
2 years ago
<el-select style="width: 100%;" v-model="form.content" placeholder="请选择" clearable>
2 years ago
<el-option v-for="item in type_options" :key="item.id" :label="item.value" :value="item.id">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:require>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>所属行业:
</div>
<div class="xy-table-item-content">
2 years ago
<el-select style="width: 100%;" v-model="form.require" placeholder="请选择" clearable>
2 years ago
<el-option v-for="item in type_options" :key="item.id" :label="item.value" :value="item.id">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:status>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>状态:
</div>
<div class="xy-table-item-content">
2 years ago
<el-select style="width: 100%;" v-model="form.status" placeholder="请选择" clearable>
2 years ago
<el-option v-for="item in type_options" :key="item.id" :label="item.value" :value="item.id">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:settings>
<div class="xy-table-item">
2 years ago
<div class="xy-table-item-label" style="font-weight: bold;display:none">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>
2 years ago
</div>
<div class="xy-table-item-content" style="flex-grow: 1;">
2 years ago
课程设置:<el-button
2 years ago
type="primary"
icon="md-add"
style="margin-bottom: 10px"
@click="form.settings.push({ name: '',desc:''})"
>新增</el-button>
<xy-table
style="width: 100%"
:height="260"
:is-page="false"
:list="form.settings"
:table-item="settings_Table"
>
<template v-slot:btns>
<el-table-column
label="操作"
width="90"
header-align="center"
align="center"
>
<template v-slot:default="scope">
<el-button
size="small"
type="danger"
2 years ago
plain
2 years ago
@click="form.settings.splice(scope.$index, 1)"
>删除</el-button>
</template>
</el-table-column>
</template>
</xy-table>
</div>
</div>
</template>
<template v-slot:footerContent>
<el-button type="primary" style='margin-left:5px;margin-bottom:5px;' @click="submit">确认</el-button>
2 years ago
<el-button type="primary" plain style='margin-left:5px;margin-bottom:5px;' @click="isShow=false">取消</el-button>
2 years ago
</template>
</xy-dialog>
</div>
</template>
<script>
export default {
components: {
},
data() {
return {
isShow: false,
type: 'add',
id: '',
type_options: [{
id: 0,
value: '常规课程'
}, {
id: 1,
value: '短期课程'
}],
form: {
name: '',
type: '',
menu: '',
level: '',
period: '',
end_time: '',
content: '',
require: '',
status: '',
settings: [],
},
settings_Table:[{
label: "课时名称",
width: 180,
customFn: (row) => {
return ( <el-input placeholder = "请输入课时名称"
type = "text"
v-model = {
row.name
} >
</el-input>
);
},
},{
label: "课时简介",
customFn: (row) => {
return ( <el-input placeholder = "请输入课时简介"
type = "text"
v-model = {
row.desc
} >
</el-input>
);
},
},],
rules: {
}
}
},
created() {},
methods: {
clickSubmit() {
this.$refs.dialog.submit()
},
submit() {
if (this.id) {
this.form.id = this.id
}
if (this.type == 'add') {
this.form.id = ''
}
save({
table_name: 'new_plans',
...this.form
}).then(res => {
Message({
type: 'success',
message: this.type === 'add' ? '新增课程成功' : '编辑课程成功'
})
this.isShow = false
this.$emit('refresh')
})
},
getDetail() {
show({
id: this.id,
table_name: 'new_plans',
}).then(res => {
})
}
},
watch: {
isShow(newVal) {
if (newVal) {
if (this.type === 'editor') {
// this.getDetail()
}
} else {
this.id = ''
this.$refs['dialog'].reset()
}
},
}
}
</script>
<style scoped lang="scss">
::v-deep .menu,
::v-deep .settings{
flex-basis: 100%;
}
</style>