This commit is contained in:
@fawn-nine
2024-08-12 16:35:27 +08:00

View File

@@ -1,7 +1,16 @@
<template> <template>
<el-dialog :title="!dataForm.id ? '新增' : '修改'" :close-on-click-modal="false" :visible.sync="visible" <el-dialog
@close="handlereset"> :title="!dataForm.id ? '新增' : '修改'"
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="80px"> :close-on-click-modal="false"
:visible.sync="visible"
@close="handlereset"
>
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
label-width="80px"
>
<el-form-item label="课程名" prop="title"> <el-form-item label="课程名" prop="title">
<el-input v-model="dataForm.title" placeholder="课程名"></el-input> <el-input v-model="dataForm.title" placeholder="课程名"></el-input>
</el-form-item> </el-form-item>
@@ -9,32 +18,60 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="类型" prop="type"> <el-form-item label="类型" prop="type">
<el-select v-model="dataForm.type" filterable <el-select
placeholder="请选择类型"> v-model="dataForm.type"
filterable
placeholder="请选择类型"
>
<!-- <el-option :key="0" label="无" :value="0"></el-option> --> <!-- <el-option :key="0" label="无" :value="0"></el-option> -->
<el-option v-for="item in typeList" :key="item.dictType" :label="item.dictValue" :value="item.dictType"> <el-option
v-for="item in typeList"
:key="item.dictType"
:label="item.dictValue"
:value="item.dictType"
>
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12" v-if='!this.dataForm.id'> <el-col :span="12" v-if="!this.dataForm.id">
<el-form-item label="是否同步创建商品" prop="needCreate" label-width="140px"> <el-form-item
<el-select v-model="dataForm.needCreate" filterable label="是否同步创建商品"
placeholder="请选择是否"> prop="needCreate"
label-width="140px"
>
<el-select
v-model="dataForm.needCreate"
filterable
placeholder="请选择是否"
>
<!-- <el-option :key="0" label="无" :value="0"></el-option> --> <!-- <el-option :key="0" label="无" :value="0"></el-option> -->
<el-option v-for="item in needCreateList" :key="item.dictType" :label="item.dictValue" :value="item.dictType"> <el-option
v-for="item in needCreateList"
:key="item.dictType"
:label="item.dictValue"
:value="item.dictType"
>
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-form-item label="半年价格" prop="halfFee"> <el-form-item label="半年价格" prop="halfFee">
<el-input v-model="dataForm.halfFee" placeholder="半年价格" :disabled='this.dataForm.id'></el-input> <el-input
v-model="dataForm.halfFee"
placeholder="半年价格"
:disabled="this.dataForm.id"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="全年价格" prop="fee"> <el-form-item label="全年价格" prop="fee">
<el-input v-model="dataForm.fee" placeholder="全年价格" :disabled='this.dataForm.id'></el-input> <el-input
v-model="dataForm.fee"
placeholder="全年价格"
:disabled="this.dataForm.id"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="排序" prop="sort"> <el-form-item label="排序" prop="sort">
<el-input v-model="dataForm.sort" placeholder="排序"></el-input> <el-input v-model="dataForm.sort" placeholder="排序"></el-input>
</el-form-item> </el-form-item>
@@ -167,260 +204,254 @@
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import global from '../../common/common.vue' //引入共用组间 import debounce from "lodash/debounce"; //导入lodash中的debounce
export default { import global from "../../common/common.vue"; //引入共用组间
data() { export default {
return { data() {
baseUrl: global.baseUrl, return {
visible: false, baseUrl: global.baseUrl,
typeList: [{ //类型0免费1普通收费2超v课程 visible: false,
dictType: 0, typeList: [
dictValue: "免费" {
}, //类型0免费1普通收费2超v课程
{ dictType: 0,
dictType: 1, dictValue: "免费"
dictValue: "普通收费"
},
{
dictType: 2,
dictValue: "超v课程"
}
],
needCreateList: [{ ////是否同步创建商品0否1是
dictType: 0,
dictValue: "否"
},
{
dictType: 1,
dictValue: "是"
}
],
medicaldesBookTypeList: [{
dictType: 1,
dictValue: "中医基础"
},
{
dictType: 2,
dictValue: "中医经典"
},
{
dictType: 3,
dictValue: "各家学说"
},
{
dictType: 4,
dictValue: "中医临床"
},
{
dictType: 5,
dictValue: "文学"
},
{
dictType: 6,
dictValue: "哲学"
},
],
props: {
dictType: '',
dictValue: ''
}, },
gushuList:[], {
authorList: [], dictType: 1,
restaurants: [], dictValue: "普通收费"
author: '',
publisherList: [],
fileList: [],
fileListNovel: [],
dialogImageUrl: '',
dialogVisible: false,
dataForm: {
"id": 0,
"courseId": 0,
"type": 0, //类型0免费1普通收费2超v课程
"title": "",
"halfFee": 0, //半年价格
"fee": 0, //全年价格
"sort": 1,
"needCreate": 0 //是否同步创建商品0否1是
}, },
splitsTypeList: [], {
dataRule: { dictType: 2,
dictValue: "超v课程"
} }
],
needCreateList: [
{
////是否同步创建商品0否1是
dictType: 0,
dictValue: "否"
},
{
dictType: 1,
dictValue: "是"
}
],
medicaldesBookTypeList: [
{
dictType: 1,
dictValue: "中医基础"
},
{
dictType: 2,
dictValue: "中医经典"
},
{
dictType: 3,
dictValue: "各家学说"
},
{
dictType: 4,
dictValue: "中医临床"
},
{
dictType: 5,
dictValue: "文学"
},
{
dictType: 6,
dictValue: "哲学"
}
],
props: {
dictType: "",
dictValue: ""
},
gushuList: [],
authorList: [],
restaurants: [],
author: "",
publisherList: [],
fileList: [],
fileListNovel: [],
dialogImageUrl: "",
dialogVisible: false,
dataForm: {
id: 0,
courseId: 0,
type: 0, //类型0免费1普通收费2超v课程
title: "",
halfFee: 0, //半年价格
fee: 0, //全年价格
sort: 1,
needCreate: 0 //是否同步创建商品0否1是
},
splitsTypeList: [],
dataRule: {}
};
},
created() {
this.getBookList();
this.loadAll();
},
mounted() {
// this.restaurants = this.loadAll();
},
methods: {
init(row, courseid) {
console.log("row2", row);
this.dataForm = row || {};
this.dataForm.courseId = courseid || "";
this.visible = true;
},
dataFormSubmit: debounce(async function() {
console.log("11111", this.dataForm.medicaldesBookType);
// if (this.dataForm.medicaldesBookType.length == 0) {
// this.$message.error("请选择图书类型");
// return
// }
this.$refs["dataForm"].validate(valid => {
if (valid) {
this.$http({
url: this.$http.adornUrl(
`${
!this.dataForm.id
? "/master/course/addCourseCatalogue"
: "/master/course/editCourseCatalogue"
}`
),
method: "post",
data: this.$http.adornData({
courseId: this.dataForm.courseId || undefined,
id: this.dataForm.id || undefined,
title: this.dataForm.title,
type: this.dataForm.type, //类型0免费1普通收费2超v课程
halfFee: this.dataForm.halfFee, //半年价格
fee: this.dataForm.fee, //全年价格
sort: this.dataForm.sort,
needCreate: this.dataForm.needCreate //是否同步创建商品0否1是
})
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message({
message: "操作成功",
type: "success",
duration: 1500,
onClose: () => {
this.visible = false;
this.$emit("refreshDataList");
}
});
} else {
this.$message.error(data.msg);
}
});
}
});
}, 200),
// 表单提交
handlePicSuccess(res, file) {
if (res.msg == "success") {
this.dataForm.images = res.url;
this.$message.success("上传成功");
} else {
this.$message.error("上传失败");
} }
}, },
created() { //图书分类
this.getBookList() getBookList() {
this.loadAll() this.$http({
url: this.$http.adornUrl("/book/sysdictdata/selectByType/book_type"),
method: "get"
// params: this.$http.adornParams({
// 'type': 'book_type',
// })
}).then(({ data }) => {
console.log(data);
// this.bookList = data.dataList
});
// 获取图书拆分类型
this.$http({
url: this.$http.adornUrl("/book/sysdictdata/selectByType/splitsType"),
method: "get"
}).then(({ data }) => {
this.splitsTypeList = data.dataList;
});
// 获取古书
this.$http({
url: this.$http.adornUrl("/book/book/getAncientBooks"),
method: "post"
}).then(({ data }) => {
this.gushuList = data.books;
});
}, },
mounted() { handleRemove(file) {
// this.restaurants = this.loadAll(); this.dataForm.images = "";
}, },
methods: { handlePictureCardPreview(file) {
init(row, courseid) { this.dataForm.images = file.url;
console.log('row2', row) this.dialogVisible = true;
this.dataForm = row || {} },
this.dataForm.courseId = courseid || '' handleDownload(file) {
this.visible = true console.log(file);
},
}, handlereset() {
// 表单提交 (this.fileList = []), (this.fileListNovel = []), (this.visible = false);
dataFormSubmit() { },
console.log('11111', this.dataForm.medicaldesBookType) handlePreview(file) {
// if (this.dataForm.medicaldesBookType.length == 0) { console.log(file);
// this.$message.error("请选择图书类型"); },
// return handleExceed(files, fileList) {
// } this.$message.warning(
this.$refs['dataForm'].validate((valid) => { `当前限制选择 3 个文件,本次选择了 ${
if (valid) { files.length
this.$http({ } 个文件,共选择了 ${files.length + fileList.length} 个文件`
url: this.$http.adornUrl(`${!this.dataForm.id ? '/master/course/addCourseCatalogue' : '/master/course/editCourseCatalogue'}`), );
method: 'post', },
data: this.$http.adornData({ beforeRemove(file, fileList) {
'courseId': this.dataForm.courseId || undefined, return this.$confirm(`确定移除 ${file.name}`);
'id': this.dataForm.id || undefined, },
'title': this.dataForm.title, handleRemoveNovel(file) {
"type": this.dataForm.type, //类型0免费1普通收费2超v课程 this.dataForm.novel = "";
"halfFee": this.dataForm.halfFee, //半年价格 },
"fee": this.dataForm.fee, //全年价格 handleNovelSuccess(file) {
"sort": this.dataForm.sort, this.dataForm.novel = file.url;
"needCreate": this.dataForm.needCreate //是否同步创建商品0否1是 },
}) // querySearch(queryString, cb) {
}).then(({ // var restaurants = this.restaurants;
data // var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
}) => { // // 调用 callback 返回建议列表的数据
if (data && data.code === 0) { // console.log(results)
this.$message({ // cb(results);
message: '操作成功', // },
type: 'success', // createFilter(queryString) {
duration: 1500, // return (restaurant) => {
onClose: () => { // return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
this.visible = false // };
this.$emit('refreshDataList') // },
} loadAll() {
}) this.$http({
} else { url: this.$http.adornUrl("/book/author/bookAuthorList"),
this.$message.error(data.msg) method: "get"
} }).then(({ data }) => {
}) this.authorList = data.list;
} });
}) this.$http({
}, url: this.$http.adornUrl("/book/publisher/publisherList"),
handlePicSuccess(res, file) { method: "get"
if (res.msg == "success") { }).then(({ data }) => {
this.dataForm.images = res.url; this.publisherList = data.list;
this.$message.success("上传成功"); });
} else {
this.$message.error("上传失败");
}
},
//图书分类
getBookList() {
this.$http({
url: this.$http.adornUrl('/book/sysdictdata/selectByType/book_type'),
method: 'get',
// params: this.$http.adornParams({
// 'type': 'book_type',
// })
}).then(({
data
}) => {
console.log(data)
// this.bookList = data.dataList
})
// 获取图书拆分类型
this.$http({
url: this.$http.adornUrl('/book/sysdictdata/selectByType/splitsType'),
method: 'get',
}).then(({
data
}) => {
this.splitsTypeList = data.dataList
})
// 获取古书
this.$http({
url: this.$http.adornUrl('/book/book/getAncientBooks'),
method: 'post',
}).then(({
data
}) => {
this.gushuList= data.books
})
},
handleRemove(file) {
this.dataForm.images = '';
},
handlePictureCardPreview(file) {
this.dataForm.images = file.url;
this.dialogVisible = true;
},
handleDownload(file) {
console.log(file)
},
handlereset() {
this.fileList = [],
this.fileListNovel = [],
this.visible = false
},
handlePreview(file) {
console.log(file);
},
handleExceed(files, fileList) {
this.$message.warning(`当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
},
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${ file.name }`);
},
handleRemoveNovel(file) {
this.dataForm.novel = '';
},
handleNovelSuccess(file) {
this.dataForm.novel = file.url
},
// querySearch(queryString, cb) {
// var restaurants = this.restaurants;
// var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
// // 调用 callback 返回建议列表的数据
// console.log(results)
// cb(results);
// },
// createFilter(queryString) {
// return (restaurant) => {
// return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
// };
// },
loadAll() {
this.$http({
url: this.$http.adornUrl('/book/author/bookAuthorList'),
method: 'get',
}).then(({
data
}) => {
this.authorList = data.list
})
this.$http({
url: this.$http.adornUrl('/book/publisher/publisherList'),
method: 'get',
}).then(({
data
}) => {
this.publisherList = data.list
})
},
// handleSelect(item) {
// this.dataForm.authorId = item.id
// console.log(item);
// }
} }
// handleSelect(item) {
// this.dataForm.authorId = item.id
// console.log(item);
// }
} }
};
</script> </script>