Commit 418cd47c authored by 王's avatar

期数管理

parent a8e54c23
<template>
<el-dialog
:title="title"
center
append-to-body
:visible.sync="show"
width="800px">
<div v-loading="loading">
<el-form ref="form" :model="form" :rules="rules" >
<el-row>
<el-col :span="4"><label>不上课日期</label></el-col>
<el-col :span="8">
<el-form-item>
<el-date-picker
type="dates"
v-model="list"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
placeholder="选择一个或多个日期">
</el-date-picker>
<!--<el-input v-model="form.desc" type="textarea"></el-input>-->
</el-form-item>
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="show = false">取 消</el-button>
<el-button type="primary" @click="save">确 定</el-button>
</span>
</div>
</el-dialog>
</template>
<script>
import {updateConfigApi,saveConfigApi} from "../../service/api";
import {TEACHERTYPE} from "../../util/wordbook";
import page from '../framework/page'
export default {
name: "dialogObj",
props:[
'dialogObj'
],
data(){
return{
show:false,
id: '',
title: '',
loading:true,
form:{
key:'noLesson',
value:'noLesson',
desc:''
},
list: [],
rules:{
desc:[
{ required: true, message: '请选择日期', trigger: 'change' }
]
}
}
},
components:{
page
},
methods:{
save(){
if(this.list.length === 0){
this.$message({
type: 'error',
message: '请选择不上课时间!'
});
return;
}
this.form.desc = this.list.join(',');
if(this.dialogObj.id){
updateConfigApi(this.id,this.form).then(res=>{
this.$message({
type: 'success',
message: '修改成功!'
});
this.$emit("reflash");
this.show = false;
})
}else{
this.form.desc = this.list.join(',');
saveConfigApi(this.form).then(res=>{
this.$message({
type: 'success',
message: '新增成功!'
});
this.$emit("reflash");
this.show = false;
})
}
},
initDialog(){
this.show = this.dialogObj.show;
if (this.dialogObj.id) {
this.id = this.dialogObj.id;
}
this.title = this.dialogObj.title;
this.form.desc = this.dialogObj.desc;
this.loading = false
}
},
watch:{
dialogObj:{
handler: function () {
this.loading = true;
this.initDialog()
},
deep: true
},
show(value){
this.$emit("changeShow",value);
}
}
}
</script>
<style scoped lang="less">
@import "../../util/public";
/*.el-col {*/
/*height: 50px;*/
/*text-align: center;*/
/*margin-bottom: 20px;*/
/*line-height: 40px;*/
/*.el-select{*/
/*width: 100%;*/
/*}*/
/*img{*/
/*width: 50px;*/
/*border-radius: 100px;*/
/*}*/
/*label{*/
/*color: #5982e6;*/
/*}*/
/*}*/
.dialog-footer{
display: block;
text-align: center;
margin-top: 30px;
}
.msg_sender_wrp {
display: flex;
flex-flow: row wrap;
justify-content: flex-start;
align-items: center;
/*position: absolute;*/
/*left: 100%;*/
/*top: 50%;*/
width: 500px;
/*z-index: 500;*/
/*-ms-transform: translateY(-50%);*/
/*transform: translateY(-50%);*/
/*background: #FFFFFF;*/
/*box-shadow: 0 1px 20px 0 #E4E8EB;*/
/*border-radius: 2px;*/
}
.el-icon-circle-plus-outline {
font-size: 28px;
}
.weui-desktop-msg-sender__tabs {
line-height: 38px;
background-color: #FFFFFF;
}
ul, ol {
padding-left: 0;
list-style-type: none;
}
.weui-desktop-msg-sender__tab {
padding: 0 15px;
float: left;
cursor: pointer;
}
.weui-desktop-msg-sender__tab_appmsg:before {
background: transparent url(https://mp.weixin.qq.com/mpres/en_US/htmledition/pages/modules/msg_sender/svg/default/sender_appmsg3f92fe.svg) no-repeat 0 0;
}
.weui-desktop-msg-sender__tab:before {
content: " ";
display: inline-block;
width: 22px;
height: 20px;
vertical-align: middle;
margin: -0.2em 5px 0 0;
}
.weui-desktop-msg-sender__tab_text:before {
background: transparent url(https://mp.weixin.qq.com/mpres/en_US/htmledition/pages/modules/msg_sender/svg/default/sender_text3f92fe.svg) no-repeat 0 0;
}
.weui-desktop-msg-sender__tab_img:before {
background: transparent url(https://mp.weixin.qq.com/mpres/en_US/htmledition/pages/modules/msg_sender/svg/default/sender_img3f92fe.svg) no-repeat 0 0;
}
.weui-desktop-msg-sender__tab_audio:before {
background: transparent url(https://mp.weixin.qq.com/mpres/en_US/htmledition/pages/modules/msg_sender/svg/default/sender_audio3f92fe.svg) no-repeat 0 0;
}
.weui-desktop-msg-sender__tab_video:before {
background: transparent url(https://mp.weixin.qq.com/mpres/en_US/htmledition/pages/modules/msg_sender/svg/default/sender_video3f92fe.svg) no-repeat 0 0;
}
</style>
<template>
<div>
<el-row type="flex" class="add-btn" justify="end">
<el-col :span="6">
<el-button type="success" plain @click="add">添加不上课日期</el-button>
</el-col>
</el-row>
<el-table
:data="list"
style="width: 100%">
<el-table-column type="expand">
<template slot-scope="props">
<el-form label-position="left" class="demo-table-expand">
<el-form-item label="不上课日期">
<span>{{ props.row.desc }}</span>
</el-form-item>
</el-form>
</template>
</el-table-column>
<el-table-column
label="ID"
prop="id">
</el-table-column>
<el-table-column
label="Key"
prop="key">
</el-table-column>
<el-table-column
label="关键词"
prop="value">
</el-table-column>
<el-table-column
prop="created_at"
label="创建时间">
</el-table-column>
<el-table-column
width="250"
label="操作">
<template slot-scope="scope">
<el-button size="mini" plain type="warning" @click="edit(scope.row)">
编辑
</el-button>
<el-button size="mini" plain type="danger" @click="del(scope.row)">
删除
</el-button>
</template>
</el-table-column>
</el-table>
<dialog-com :dialogObj="dialogObj" @changeShow="changeShow" @reflash="getList"/>
</div>
</template>
<script>
import dialogCom from './dialog'
import {getConfigListApi,deleteConfigApi,getConfigDetailApi} from "../../service/api";
export default {
name: "index"
name: "index",
data() {
return {
dialogObj:{
value:'',
desc:'',
show:false,
id:''
},
list: []
}
},
components:{
dialogCom
},
mounted(){
this.getList()
},
methods: {
changeShow(data){
this.dialogObj.show=data
},
getList(){
let json = {
key:'noLesson'
};
getConfigListApi(json).then(res => {
this.list = res.list
})
},
add(){
this.dialogObj.title = '添加不上课日期';
this.dialogObj.desc = '';
this.dialogObj.show = true
},
edit(data){
getConfigDetailApi(data.id).then((res) => {
this.dialogObj.title = '修改不上课日期';
this.dialogObj.desc = res.desc;
this.dialogObj.show = true
});
},
del(data){
this.$confirm('此操作将删除该记录?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteConfigApi(data.id).then(res=>{
this.getList()
this.$message({
type: 'success',
message: '删除成功!'
});
});
});
}
}
}
</script>
<style scoped>
<style scoped lang="less">
@import "../../util/public";
.add-btn {
margin: 10px 0;
}
</style>
<template>
<div>
<el-dialog
:title="dialogObj.title"
:visible.sync="dialogObj.show"
>
<el-table
:data="goodList"
style="width: 100%"
row-key="id"
highlight-current-row
@current-change="handleCurrentChange">
<el-table-column
prop="id"
label="商品ID">
</el-table-column>
<el-table-column
prop="name"
label="名称">
</el-table-column>
<el-table-column
label="商品类型">
<template slot-scope="scope">
{{scope.row.goods_type | goodsType}}
</template>
</el-table-column>
<el-table-column
label="现价">
<template slot-scope="scope">
{{scope.row.current_price/100}}
</template>
</el-table-column>
<el-table-column
label="课程类别">
<template slot-scope="scope">
{{scope.row.course_type | lessonType}}
</template>
</el-table-column>
<el-table-column
label="是否有实物">
<template slot-scope="scope">
{{scope.row.is_real | isOrNot}}
</template>
</el-table-column>
<el-table-column
label="状态">
<template slot-scope="scope">
{{scope.row.status | goodsStatus}}
</template>
</el-table-column>
</el-table>
<page :nowPage="nowPage" :total="total"/>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogObj.show = false">取 消</el-button>
<el-button type="primary" @click="onConfirm">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {getGoodsListApi} from "../../service/api";
import {ISORNOT,GOODSTYPE,LESSONTYPE,GOODSSTATUS} from "../../util/wordbook";
import page from '../framework/page'
export default {
props:[
'dialogObj'
],
data(){
return{
nowPage : 1,
total: 0,
goodList:[],
currentRow: null
}
},
components:{
page
},
filters: {
isOrNot(value){
return ISORNOT[value]
},
goodsType(value){
return GOODSTYPE[value]
},
lessonType(value){
return LESSONTYPE[value]
},
goodsStatus(value){
return GOODSSTATUS[value]
}
},
methods:{
initPage(){
getGoodsListApi().then(res=>{
this.goodList = res.list;
this.total = res.total
});
},
handleCurrentChange(val){
this.currentRow = val;
},
onConfirm(){
this.$emit("reflash",this.currentRow);
}
},
mounted(){
this.initPage()
}
// watch:{
// 'dialogObj'(value){
// console.log('dialogObj value', value)
// this.initPage()
// }
// }
}
</script>
<style scoped>
</style>
<template>
<div>
<div class="form-block">
<el-form label-width="90px" inline>
<el-form-item label="期数标题">
<el-input v-model="title" placeholder="请输入内容" clearable></el-input>
</el-form-item>
<el-form-item label="商品ID">
<el-input v-model="goodsId" placeholder="请输入内容" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button @click="onChoose" type="success">选择商品</el-button>
</el-form-item>
<el-form-item style="float: right">
<el-button @click="onSearch" type="primary">查询</el-button>
</el-form-item>
<el-form-item style="float: right">
<el-button @click="onAdd" type="primary">添加期数</el-button>
</el-form-item>
</el-form>
</div>
<el-table
:data="periodList"
style="width: 100%">
<el-table-column
prop="id"
label="期数ID">
</el-table-column>
<el-table-column
prop="title"
label="期数标题">
</el-table-column>
<el-table-column
prop="goods_id"
label="关联的商品ID">
</el-table-column>
<el-table-column
prop="course_id"
label="课程ID">
</el-table-column>
<el-table-column
prop="start_num"
label="开始的主题/歌ID">
</el-table-column>
<el-table-column
prop="start_at"
label="期数开始时间">
</el-table-column>
<el-table-column
prop="watch_num"
label="可看课包数">
</el-table-column>
<el-table-column
prop="duration_num"
label="续看课包数">
</el-table-column>
<el-table-column
prop="has_watch_num"
label="已看课包数">
</el-table-column>
<el-table-column
prop="has_duration_num"
label="已续看课包数">
</el-table-column>
<el-table-column
prop="current_category_id"
label="当前看的课包ID">
</el-table-column>
<el-table-column
prop="rest_week_day"
label="周几不上课">
</el-table-column>
<el-table-column
label="操作">
<template slot-scope="scope">
<el-button size="mini" plain type="primary" @click="onEdit(scope.row)">
编辑
</el-button>
<el-button size="mini" type="danger" plain @click="del(scope.row)">
删除
</el-button>
</template>
</el-table-column>
</el-table>
<page :nowPage="nowPage" :total="total"/>
<good-dialog v-if="dialogObj.show" :dialogObj="dialogObj" @reflash="getChooseGood"></good-dialog>
<new-dialog v-if="newDialog.show" :dialogObj="newDialog" @reflash="onSave"></new-dialog>
</div>
</template>
<script>
import goodDialog from './dialog'
import newDialog from './newDialog'
import page from '../framework/page'
import {getPeriodsApi,delPeriodApi} from "../../service/api";
export default {
name: "index"
name: "index",
data(){
return {
nowPage: 1,
total: 0,
title: '',
goodsId: null,
periodList: [],
dialogObj:{
show:false,
title:'选择商品',
},
newDialog: {
form: {
id: 0,
title: '',
start_num: 0,
start_at: '',
rest_week_day: [],
goods_id:''
},
show: false,
title: ''
}
}
},
components:{
goodDialog,
newDialog,
page
},
methods: {
onChoose(){
this.dialogObj.show = true;
},
getChooseGood(val){
this.goodsId = val.id;
this.dialogObj.show = false;
},
onSearch(){
let json={
}
if(this.title){
json.title = this.title;
}
if(this.goodsId){
json.goods_id = this.goodsId;
}
getPeriodsApi(json).then(res=>{
this.periodList = res.list;
this.total = res.total
});
},
onAdd(){
this.newDialog.form.id = '';
this.newDialog.start_num = '';
this.newDialog.form.start_at = '';
this.newDialog.form.rest_week_day = [];
this.newDialog.form.teacher_ids = [];
this.newDialog.title = '添加期数';
this.newDialog.show = true;
},
onEdit(row){
this.newDialog.form.id = row.id;
this.newDialog.form.start_num = row.start_num;
this.newDialog.form.start_at = row.start_at;
this.newDialog.form.title = row.title;
this.newDialog.form.goods_id = row.goods_id;
console.log('row', row)
let weekList = [];
if(row.rest_week_day){
row.rest_week_day.split(',').forEach((val)=>{
weekList.push(parseInt(val));
})
}
this.newDialog.form.rest_week_day = weekList;
let teacherList = [];
if(row.teacher_ids){
row.teacher_ids.split(',').forEach((val)=>{
teacherList.push(parseInt(val));
})
}
this.newDialog.form.teacher_ids = teacherList;
this.newDialog.title = '编辑期数';
this.newDialog.show = true;
},
onSave(val){
this.newDialog.show = false;
this.onSearch();
},
del(row){
this.$confirm('此操作将删除该期数?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delPeriodApi(row.id).then(res=>{
this.$message({
type: 'success',
message: '删除成功!'
});
this.onSearch()
});
});
}
},
mounted(){
this.onSearch();
}
}
</script>
<style scoped>
.form-block {
margin-top: 10px;
}
</style>
<template>
<div>
<el-dialog
:title="dialogObj.title"
center
append-to-body
:visible.sync="dialogObj.show"
width="800px">
<div v-loading="loading">
<el-form ref="form" :model="form" label-width="120px" :rules="rules">
<el-row>
<el-col :span="10">
<el-form-item label="商品ID" prop="goods_id">
<el-input v-model="form.goods_id" placeholder="请输入内容" clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="10">
<el-form-item>
<el-button @click="onChoose" type="success">选择商品</el-button>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="期数名称" prop="title">
<el-input v-model="form.title"></el-input>
</el-form-item>
<el-form-item label="开始主题" prop="start_num">
<el-select v-model="form.start_num" placeholder="请选择">
<el-option
v-for="item in itemOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="开始上课时间" prop="start_at">
<el-date-picker
v-model="form.start_at"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
type="date"
placeholder="选择日期">
</el-date-picker>
</el-form-item>
<el-form-item label="老师IDs">
<el-select v-model="teacherList" multiple placeholder="请选择">
<el-option
v-for="item in teacherOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="周几不上课" prop="rest_week_day">
<el-select v-model="form.rest_week_day" multiple placeholder="请选择">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogObj.show = false">取 消</el-button>
<el-button type="primary" @click="sub">确 定</el-button>
</span>
</div>
</el-dialog>
<good-dialog v-if="goodDialogObj.show" :dialogObj="goodDialogObj" @reflash="getChooseGood"></good-dialog>
</div>
</template>
<script>
import {getGoodsListApi,getAddPeriodsApi,getTeacherListApi,getEditPeriodsApi,getLessonDetailApi} from "../../service/api";
import {ISORNOT,GOODSTYPE,LESSONTYPE,GOODSSTATUS} from "../../util/wordbook";
import goodDialog from './dialog'
export default {
props:[
'dialogObj'
],
data(){
return{
loading: false,
form: {},
teacherList: [],
goodDialogObj:{
show:false,
title:'选择商品',
},
options: [
{
value: 0,
label: '周日'
},
{
value: 1,
label: '周一'
},
{
value: 2,
label: '周二'
},
{
value: 3,
label: '周三'
},
{
value: 4,
label: '周四'
},
{
value: 5,
label: '周五'
},
{
value: 6,
label: '周六'
}
],
teacherOptions: [],
itemOptions: [],
rules:{
title:[
{ required: true, message: '请输入名称', trigger: 'change' }
],
start_num:[
{ required: true, message: '请输入开始主题', trigger: 'change' }
],
start_at:[
{ required: true, message: '请选择开始上课时间', trigger: 'change' }
],
rest_week_day:[
{ required: true, message: '请选择周几不上课', trigger: 'change' }
],
teacher_ids:[
{ required: true, message: '请选择老师ID', trigger: 'change' }
],
goods_id: [
{ required: true, message: '商品ID不能为空', trigger: 'change' }
]
}
}
},
components:{
goodDialog
},
filters: {
isOrNot(value){
return ISORNOT[value]
},
goodsType(value){
return GOODSTYPE[value]
},
lessonType(value){
return LESSONTYPE[value]
},
goodsStatus(value){
return GOODSSTATUS[value]
}
},
methods:{
initPage(){
getGoodsListApi().then(res=>{
this.goodList = res.list;
this.total = res.total
});
},
handleCurrentChange(val){
this.currentRow = val;
},
onConfirm(){
this.$emit("reflash",this.currentRow);
},
sub(){
if (!this.teacherList) {
this.$message.error('请选择老师ID');
return;
}
this.$refs['form'].validate((valid) => {
if(valid){
let _id = this.form.goods_id;
let json = {
title: this.form.title,
start_num: this.form.start_num,
start_at: this.form.start_at,
rest_week_day: this.form.rest_week_day.join(','),
teacher_ids: this.teacherList.join(',')
}
if (this.form.id) {
getEditPeriodsApi(this.form.id,json).then(res=>{
this.$message({
type: 'success',
message: '添加成功!'
});
this.$emit("reflash");
})
} else {
getAddPeriodsApi(_id,json).then(res=>{
this.$message({
type: 'success',
message: '添加成功!'
});
this.$emit("reflash");
})
}
}
});
},
onChoose(){
this.goodDialogObj.show = true;
},
getChooseGood(val){
this.form.goods_id = val.id;
this.getLessonDetail(val.course_id);
this.goodDialogObj.show = false;
},
getTeachers(){
getTeacherListApi().then((res)=>{
this.teacherOptions = res.list;
})
},
getLessonDetail(id){
getLessonDetailApi(id,{}).then((res) => {
this.itemOptions = res.detail[res.type]
})
}
},
mounted(){
// this.initPage()
this.getTeachers();
this.form = this.dialogObj.form;
this.teacherList = this.dialogObj.form.teacher_ids;
}
}
</script>
<style scoped>
</style>
......@@ -362,6 +362,21 @@ const getPeriodsUrl = `${_baseUrl}api/admin/periods/list`;
export const getPeriodsApi = function (json) {
return Vue.prototype.$fetch(getPeriodsUrl,json)
};
// 添加期数
const getAddPeriodsUrl = `${_baseUrl}api/admin/periods/add/`;
export const getAddPeriodsApi = function (id,json) {
return Vue.prototype.$post(`${getAddPeriodsUrl}${id}`,json)
};
// 编辑期数
const getEditPeriodsUrl = `${_baseUrl}api/admin/periods/info/`;
export const getEditPeriodsApi = function (id,json) {
return Vue.prototype.$put(`${getEditPeriodsUrl}${id}`,json)
};
// 删除期数
const getDelPeriodUrl = `${_baseUrl}api/admin/periods/`;
export const delPeriodApi = function (id) {
return Vue.prototype.$del(`${getDelPeriodUrl}${id}`)
};
// 获取班级列表
const getClassListUrl = `${_baseUrl}api/admin/periods/class/list/`;
export const getClassListApi = function (id,json) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment