Commit 16413668 authored by liuyang's avatar liuyang

finished 课程标签管理

parent 59ac4197
/******************
* 课程标签
*****************/
// 导入请求公用方法
import {
request
} from '../../utils/axiosFun';
export const addObj = (obj) => {
return request('post','/api/mgr/courseTag/save',obj)
}
export const putObj = (obj) => {
return request('post','/api/mgr/courseTag/update',obj)
}
export const delObj = (ids) => {
return request('post','/api/mgr/courseTag/delete',ids)
}
export const fetchList = (query) => {
return request('post','/api/mgr/courseTag/list',query)
}
\ No newline at end of file
/******************
* 价格配置
*****************/
// 导入请求公用方法
import {
request
} from '../../utils/axiosFun';
export const getConfig = () => {
return request('get','/api/mgr/priceConfig/get',{})
}
export const updateConfig = (obj) => {
return request('post','/api/mgr/priceConfig/update',obj)
}
\ No newline at end of file
...@@ -132,7 +132,7 @@ export const loadStyle = url => { ...@@ -132,7 +132,7 @@ export const loadStyle = url => {
* @param:{string} data 状态值,必填 * @param:{string} data 状态值,必填
**/ **/
function disposereq(self, data) { function disposereq(self, data) {
console.log(data) // console.log(data)
if (data.message.indexOf('401') != -1) { if (data.message.indexOf('401') != -1) {
self.$message.info("token过期,请重新登录!"); self.$message.info("token过期,请重新登录!");
localStorage.removeItem("token"); localStorage.removeItem("token");
......
...@@ -91,10 +91,10 @@ export default { ...@@ -91,10 +91,10 @@ export default {
] ]
}, },
modalRules: { modalRules: {
oldPwd: [ password: [
{required: true ,message: '原始密码不能为空',trigger: 'blur'} {required: true ,message: '原始密码不能为空',trigger: 'blur'}
], ],
newPwd: [ newPassword: [
{required: true ,message: '新密码不能为空',trigger: 'blur'} {required: true ,message: '新密码不能为空',trigger: 'blur'}
] ]
}, },
......
<template>
<div class="template_content">
<!-- 搜索 -->
<div class="search_box">
<a-form layout="inline">
<a-form-item label="标签名:">
<a-input v-model="searchPage.name" placeholder="请输入标签名" allowClear></a-input>
</a-form-item>
<a-form-item>
<a-button icon="search" type="primary" @click="handleSubmit">查询</a-button>
</a-form-item>
</a-form>
</div>
<!-- 主体内容 -->
<div class="content_box">
<!-- 表格操作 -->
<div class="table_top">
<a-button
icon="plus"
type="primary"
class="btn_right_margin"
@click="showModal('')"
>添加</a-button>
</div>
<a-table
tableLayout="fixed"
:columns="columns"
:dataSource="data"
:loading="loading"
:pagination="pagination"
bordered
size="small"
@change="handleTableChange"
rowKey="id"
>
<!-- 操作 -->
<template slot="action" slot-scope="text, record">
<a-button
icon="edit"
type="primary"
class="btn_margin"
@click="showModal(record)"
>修改</a-button>
<a-button
icon="delete"
type="danger"
class="btn_margin"
@click="deleteRow(record)"
>删除</a-button>
</template>
</a-table>
</div>
<!-- 弹窗 -->
<template>
<a-modal
:visible="modalVisible"
:title="modalTitle"
@ok="onSave"
@cancel="onCancel"
>
<a-form-model
:model="formModel"
:label-col="{span:4}"
:wrapper-col="{span: 8}"
:rules="formRules"
ref="formModelRef"
>
<a-form-model-item
label="标签名称"
ref="nameVal"
prop="name"
>
<a-input v-model="formModel.name" @blur="blurValidate('nameVal')"></a-input>
</a-form-model-item>
</a-form-model>
</a-modal>
</template>
</div>
</template>
<script>
import {fetchList,addObj,putObj,delObj} from '@/api/biz/courseTag'
import {disposereq} from '@/utils/util'
let columns = [
{
title: "标签名",
dataIndex: "name",
align: "center"
},
{
title: '操作',
key: "action",
scopedSlots: { customRender: "action" },
align: "center"
}
]
export default {
data(){
return {
loading: false,
searchPage: {
pageIndex: 1,
pageSize: 10,
name: ""
},
columns: columns,
data: [],
pagination: {
showQuickJumper: true,
showSizeChanger: true
},
modalVisible: false,
modalTitle: '添加',
modalType: '',
rowData: '',
formModel: {
name: ''
},
formRules: {
name: [
{
required: true,
message: '不能为空',
trigger: 'blur'
},
]
}
}
},
created() {
this.getList(this.searchPage)
},
beforeUpdate() {
},
methods: {
getList(query){
this.loading = true;
fetchList(query).then(res => {
if(res.code == 200){
this.loading = false
this.data = res.data;
const pager = { ...this.pagination };
pager.current = query.pageIndex;
pager.total = res.count;
this.pagination = pager;
}else{
this.$message.info(res.resp_msg);
}
}).catch(err => {
this.loading = false
disposereq(this,err)
})
},
blurValidate(prop){
this.$refs[prop].onFieldBlur()
},
// 表格数据变化触发事件
handleTableChange(pagination, filters, sorter) {
const searchPage = { ...this.searchPage };
searchPage.pageIndex = pagination.current;
searchPage.pageSize = pagination.pageSize;
this.loading = true;
this.getList(searchPage);
},
// 搜索事件
handleSubmit() {
const searchPage = { ...this.searchPage };
this.getList(searchPage);
},
// 显示对话框
showModal(row) {
this.modalVisible = true;
// 判断添加或者编辑
if (row == "") {
this.modalTitle = '添加';
this.modalType = "add";
this.formModel.name = ""
this.rowData = ''
} else {
this.modalTitle = '编辑';
this.modalType = "edit";
this.formModel.name = row.name
this.rowData = row;
}
},
// 删除行数据
deleteRow(row) {
delObj([row.id])
.then(res => {
this.loading = false;
if (res.resp_code == 200) {
this.$message.success('删除成功');
const searchPage = { ...this.searchPage };
this.loading = true;
this.getList(searchPage);
} else {
this.$message.info(res.resp_msg);
}
})
.catch(err => {
disposereq(this, err);
});
},
//对话框确定
onSave(){
this.$refs.formModelRef.validate(valid => {
if(valid){
if(this.modalType == 'add'){
let data = {}
data.name = this.formModel.name
addObj(data).then(res => {
if(res.resp_code == 200){
this.modalVisible = false
this.$message.success('保存成功');
const searchPage = { ...this.searchPage };
this.loading = true;
this.getList(searchPage);
}else{
this.$message.info(res.resp_msg);
}
}).catch(err => {
disposereq(this,err)
})
}else if(this.modalType == 'edit'){
let data = {}
data.id = this.rowData.id
data.name = this.formModel.name
putObj(data).then(res => {
if(res.resp_code == 200){
this.modalVisible = false
this.$message.success('保存成功');
const searchPage = { ...this.searchPage };
this.loading = true;
this.getList(searchPage);
}else{
this.$message.info(res.resp_msg)
}
}).catch(err => {
disposereq(this,err)
})
}
}
})
},
//对话框取消
onCancel(){
this.modalVisible = false
this.$refs.formModelRef.resetFields()
}
}
}
</script>
<style>
.template_content {
background-color: #f0f2f5;
width: 100%;
height: 100%;
box-sizing: border-box;
}
.search_box {
width: 100%;
box-sizing: border-box;
padding: 14px;
background-color: #fff;
}
.content_box {
width: 100%;
background-color: #fff;
margin-top: 10px;
padding: 14px;
}
.table_top {
padding-bottom: 14px;
}
.btn_margin {
margin: 0px 5px;
}
.btn_right_margin {
margin-right: 10px;
}
</style>
\ No newline at end of file
<template>
<div>
<a-form-model
:model="formModel"
:label-col="{span:4}"
:wrapper-col="{span: 4}"
:rules="formRules"
ref="formv"
>
<a-form-model-item label="会员价格" ref="vipPriceVal" prop="vipPrice">
<a-input v-model="formModel.vipPrice" prefix="¥" suffix="1个月" @blur="blurValidate('vipPriceVal')"></a-input>
</a-form-model-item>
<a-form-model-item label="折扣配置" ref="discountFor3MonVal" prop="discountFor3Mon">
<a-input v-model="formModel.discountFor3Mon" prefix="¥" suffix="3个月" @blur="blurValidate('discountFor3MonVal')"></a-input>
</a-form-model-item>
<a-form-model-item :wrapper-col="{span:4,offset:4}" ref="discountFor6MonVal" prop="discountFor6Mon">
<a-input v-model="formModel.discountFor6Mon" prefix="¥" suffix="6个月" @blur="blurValidate('discountFor6MonVal')"></a-input>
</a-form-model-item>
<a-form-model-item :wrapper-col="{span:4,offset:4}" ref="discountFor12MonVal" prop="discountFor12Mon">
<a-input v-model="formModel.discountFor12Mon" prefix="¥" suffix="12个月" @blur="blurValidate('discountFor12MonVal')"></a-input>
</a-form-model-item>
<a-form-model-item label="企业会员价格" ref="enterpriceVipPriceVal" prop="enterpriceVipPrice">
<a-input v-model="formModel.enterpriceVipPrice" prefix="¥" suffix="1个月" @blur="blurValidate('enterpriceVipPriceVal')"></a-input>
</a-form-model-item>
<a-form-model-item :wrapper-col="{offset:4}">
<a-button type="primary" @click="onSubmit" :loading="btnLoading">保存</a-button>
</a-form-model-item>
</a-form-model>
</div>
</template>
<script>
import {getConfig,updateConfig} from '@/api/biz/priceConfig'
import {disposereq} from '@/utils/util'
export default {
data(){
return {
formModel: {
vipPrice: 0,
discountFor3Mon: 0,
discountFor6Mon: 0,
discountFor12Mon: 0,
enterpriceVipPrice: 0
},
btnLoading: false,
formRules:{
vipPrice: [
{
required: true,
message: '不能为空',
trigger: 'blur'
},
{
type: 'number',
message: '必须为数字',
trigger: 'blur',
transform: (value)=>{
return Number(value)
}
}
],
discountFor3Mon: [
{
required: true,
message: '不能为空',
trigger: 'blur'
},
{
type: 'number',
message: '必须为数字',
trigger: 'blur',
transform: (value)=>{
return Number(value)
}
}
],
discountFor6Mon: [
{
required: true,
message: '不能为空',
trigger: 'blur'
},
{
type: 'number',
message: '必须为数字',
trigger: 'blur',
transform: (value)=>{
return Number(value)
}
}
],
discountFor12Mon: [
{
required: true,
message: '不能为空',
trigger: 'blur'
},
{
type: 'number',
message: '必须为数字',
trigger: 'blur',
transform: (value)=>{
return Number(value)
}
}
],
enterpriceVipPrice: [
{
required: true,
message: '不能为空',
trigger: 'blur'
},
{
type: 'number',
message: '必须为数字',
trigger: 'blur',
transform: (value)=>{
return Number(value)
}
}
]
}
}
},
created() {
this.getPriceConfig()
},
beforeUpdate() {
},
methods: {
blurValidate(prop){
this.$refs[prop].onFieldBlur()
},
getPriceConfig(){
getConfig().then(res => {
if(res.resp_code == 200){
this.formModel = res.datas
}else{
this.$message.info(res.resp_msg);
}
}).catch(err => {
disposereq(err)
})
},
onSubmit(){
this.btnLoading = true
this.$refs.formv.validate(valid=>{
if(valid){
updateConfig(this.formModel).then(res => {
if(res.resp_code == 200){
this.$message.info('保存成功');
}else{
this.$message.info(res.resp_msg);
}
this.btnLoading = false
}).catch(err => {
this.btnLoading = false
disposereq(err)
})
}else{
this.btnLoading = false
}
})
}
}
}
</script>
<style>
</style>
\ No newline at end of file
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