Commit de3d4ef4 authored by 王's avatar

优化

parent ecbafa04
......@@ -16,7 +16,8 @@
<el-col :span="24">
<el-form-item prop="title" label="盒子首图">
<el-upload
action="/api/public/upload"
action="/api/public/upload/zone"
:http-request="uploadFile"
:class="{disabled:!uploadShow}"
:before-upload="beforeAvatarUpload"
list-type="picture-card"
......@@ -80,7 +81,7 @@
</template>
<script>
import {getSingleListApi,addBoxApi,getBoxDetailApi,editBoxApi} from "../../service/api";
import {getSingleListApi,addBoxApi,getBoxDetailApi,editBoxApi,uploadFileApi} from "../../service/api";
export default {
name: "boxDialog",
props:[
......@@ -199,6 +200,21 @@
handleAvatarSuccess(res) {
this.imageList = [{name:res.data.url,url:process.env.IMAGE_URL_HEAD + res.data.url}]
},
uploadFile(a) {
this.loading = true;
this.$store.dispatch('setProgress',{type:'new',id:a.file.uid});
this.fileUid = a.file.uid;
uploadFileApi({file:a.file,type:'local'}).then(res=>{
this.imageList = [{name:res.url,url:process.env.IMAGE_URL_HEAD + res.url}]
this.loading = false;
this.$message({
type: 'success',
message: '上传成功!'
});
}).catch(()=>{
this.loading = false;
})
}
},
watch:{
'boxDialogObj'(value){
......
......@@ -4,6 +4,15 @@
:visible.sync="dialogObj.show"
>
<el-form ref="form" :model="form" label-width="120px">
<el-form-item label="期数" v-if="this.dialogObj.type !==1">
<el-cascader
:options="goodsList"
:props="{value:'id',label:'name'}"
@active-item-change="handleItemChange"
@change="changePeriods"
>
</el-cascader>
</el-form-item>
<el-form-item label="老师">
<el-select v-model="form.teacher_id" placeholder="请选择">
<el-option
......@@ -26,7 +35,7 @@
</template>
<script>
import {getTeacherListApi,getClassDetailApi,editClassApi,addClassApi} from "../../service/api";
import {getTeacherListApi,getClassDetailApi,editClassApi,addClassApi,getPeriodsApi,getGoodsListApi} from "../../service/api";
export default {
props:[
'dialogObj'
......@@ -37,7 +46,9 @@
teacher_id:'',
max_join_num:''
},
teacherList:[]
teacherList:[],
goodsList: [],
periods: {}
}
},
methods:{
......@@ -47,6 +58,7 @@
});
switch (this.dialogObj.type) {
case 0:
this.getPeriodList();
this.form = {
teacher_id:'',
max_join_num:''
......@@ -61,10 +73,25 @@
})
}
},
getPeriodList(){
getGoodsListApi().then(res=>{
res.list.forEach(i=>{
i.children = [];
});
this.goodsList = res.list;
if(!this.periods) {
getPeriodsApi({goods_id:this.goodsList[0].id}).then(res=>{
res.list.forEach(i=>{i.name = i.title});
this.goodsList[0].children = res.list;
this.periods = res.list[0]
})
}
});
},
onSave(){
switch (this.dialogObj.type) {
case 0:
addClassApi(this.dialogObj.periodsId,this.form).then(res=>{
addClassApi(this.periods.id,this.form).then(res=>{
this.$message({
type: 'success',
message: '添加成功!'
......@@ -83,6 +110,19 @@
this.dialogObj.show = false;
})
}
},
handleItemChange(val){
getPeriodsApi({goods_id:val[0]}).then(res=>{
res.list.forEach(i=>{i.name = i.title});
this.goodsList.find(i=>{return i.id === val[0]}).children = res.list
})
},
changePeriods(data){
if(data.length>1){
let nowGoods = this.goodsList.find(i=>{return i.id === data[0]});
this.periods = nowGoods.children.find(i=>{return i.id === data[1]});
this.getTeacher()
}
}
},
watch:{
......
......@@ -13,6 +13,7 @@
<el-form-item label="课程封面">
<el-upload
action="/api/public/upload"
:http-request="uploadFileMain"
:class="{disabled:!uploadShow}"
:before-upload="beforeAvatarUpload"
list-type="picture-card"
......@@ -79,7 +80,7 @@
</template>
<script>
import {getCategoryApi,getBoxTypeListApi,addLessonApi,getLessonDetailApi,editLessonApi} from "../../service/api";
import {getCategoryApi,getBoxTypeListApi,addLessonApi,getLessonDetailApi,editLessonApi,uploadFileApi} from "../../service/api";
export default {
name: "dialogObj",
props:[
......@@ -218,6 +219,7 @@
cover:'',
};
this.imageList = [{name:res.cover,url:process.env.IMAGE_URL_HEAD + res.cover}];
this.uploadShow = false;
this.selectedLessonList = [];
this.selectedBoxList = [];
if(res.type === 0){
......@@ -263,6 +265,19 @@
handleAvatarSuccess(res) {
this.imageList = [{name:res.data.url,url:process.env.IMAGE_URL_HEAD + res.data.url}]
},
uploadFileMain(a){
this.$store.dispatch('setProgress',{type:'new',id:a.file.uid});
this.fileUid = a.file.uid;
uploadFileApi({file:a.file,type:'local'}).then(res=>{
if(this.form.goods_desc.img){
this.form.goods_desc.img[0] = {name:res.url,url:process.env.IMAGE_URL_HEAD + res.url,title:'',lable:''}
}else{
this.form.goods_desc.img=[];
this.form.goods_desc.img[0] = {name:res.url,url:process.env.IMAGE_URL_HEAD + res.url,title:'',lable:''}
}
})
}
},
watch:{
dialogObj(){
......@@ -300,3 +315,9 @@
text-align: left;
}
</style>
<style>
.disabled .el-upload--picture-card {
display: none !important;
}
</style>
......@@ -11,7 +11,7 @@
<el-form-item>
<el-button @click="onChoose" type="success">选择商品</el-button>
</el-form-item>
<el-form-item style="float: right">
<el-form-item>
<el-button @click="onSearch" type="primary">查询</el-button>
</el-form-item>
<el-form-item style="float: right">
......
......@@ -6,24 +6,13 @@
:visible.sync="dialogObj.show"
width="800px">
<div v-loading="loading">
<el-form ref="form" :model="form" label-width="120px">
<el-form ref="form" :model="form" label-width="200px" :disabled="dialogObj.type === 2">
<el-form-item label="商品名称">
<el-input v-model="form.name"></el-input>
</el-form-item>
<el-form-item label="商品描述">
<el-input v-model="form.goods_desc.desc"></el-input>
</el-form-item>
<el-form-item label="主图">
<el-upload
list-type="picture-card"
class="upload-demo"
action="/api/public/upload"
:http-request="uploadFileMain"
:file-list="form.goods_desc.img"
>
<i class="el-icon-plus"></i>
</el-upload>
</el-form-item>
<el-form-item label="商品类型">
<el-select v-model="form.goods_type" placeholder="请选择">
<el-option
......@@ -36,6 +25,28 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item label="主图">
<el-upload
list-type="picture-card"
class="upload-demo"
action="/api/public/upload"
:http-request="uploadFileMain"
:file-list="form.goods_desc.img"
>
<i class="el-icon-plus"></i>
</el-upload>
</el-form-item>
<el-form-item label="客服">
<el-upload
list-type="picture-card"
class="upload-demo"
action="/api/public/upload"
:http-request="uploadFileMainService"
:file-list="form.desc.customer_service"
>
<i class="el-icon-plus"></i>
</el-upload>
</el-form-item>
<el-form-item label="课程类型">
<el-select v-model="form.course_type" placeholder="请选择" @change="changeLessonType()">
<el-option
......@@ -69,21 +80,40 @@
v-model="form.is_real"
:active-value="1"
:inactive-value="0">
</el-switch>
</el-switch> <span>打开后提示用户填写具体住址</span>
</el-form-item>
<el-form-item label="是否可以分享">
<template v-if="form.goods_type === 1">
<el-form-item label="是否可以给用户分享">
<el-switch
v-model="form.is_auth_user"
:active-value="1"
:inactive-value="0">
</el-switch>
</el-form-item>
<el-form-item label="原价">
<el-form-item label="是否可以给老师分享">
<el-switch
v-model="form.is_auth_teacher"
:active-value="1"
:inactive-value="0">
</el-switch>
</el-form-item>
<el-form-item label="推荐奖金">
<el-input-number v-model="form.invite_earnings" label="推荐奖金"></el-input-number>
</el-form-item>
</template>
<el-form-item :label="form.goods_type === 1 ? '原价' : '拼团价格'">
<el-input-number v-model="form.original_price" label="原价"></el-input-number>
</el-form-item>
<el-form-item label="现价">
<el-form-item :label="form.goods_type === 1 ? '现价' : '单买价格'">
<el-input-number v-model="form.current_price" label="现价"></el-input-number>
</el-form-item>
<el-form-item label="成团人数" v-if="form.goods_type === 2">
<el-input-number v-model="form.desc.group_number" label="成团人数"></el-input-number>
</el-form-item>
<el-form-item label="团购失效时间" v-if="form.goods_type === 2">
<el-input-number v-model="form.desc.group_continue" label="团购失效时间"></el-input-number>小时
</el-form-item>
<el-form-item label="分享标题">
<el-input v-model="form.share_desc.title" style="width: 200px"></el-input>
</el-form-item>
......@@ -107,8 +137,8 @@
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="show = false">取 消</el-button>
<span slot="footer" class="dialog-footer" v-if="dialogObj.type !== 2">
<el-button @click="dialogObj.show = false">取 消</el-button>
<el-button type="primary" @click="sub">确 定</el-button>
</span>
</div>
......@@ -129,7 +159,7 @@
loading:true,
form:{
name:'',
goods_type:0,
goods_type:1,
goods_desc:{
desc:"",
img:[]
......@@ -149,7 +179,8 @@
},
desc:{
detail:"",
qa:""
qa:"",
customer_service:[]
}
},
lessonList:[]
......@@ -207,6 +238,18 @@
})
},
uploadFileMainService(a){
this.$store.dispatch('setProgress',{type:'new',id:a.file.uid});
this.fileUid = a.file.uid;
uploadFileApi({file:a.file,type:'local'}).then(res=>{
if(this.form.desc.customer_service){
this.form.desc.customer_service[0] = {name:res.url,url:process.env.IMAGE_URL_HEAD + res.url,title:'',lable:''}
}else{
this.form.desc.customer_service=[];
this.form.desc.customer_service[0] = {name:res.url,url:process.env.IMAGE_URL_HEAD + res.url,title:'',lable:''}
}
})
},
uploadFileShare(a){
this.$store.dispatch('setProgress',{type:'new',id:a.file.uid});
this.fileUid = a.file.uid;
......@@ -225,7 +268,7 @@
this.loading = false;
this.form={
name:'',
goods_type:0,
goods_type:1,
goods_desc:{
desc:"",
img:[]
......@@ -245,12 +288,13 @@
},
desc:{
detail:"",
qa:""
qa:"",
customer_service:[]
}
},
this.getLessonList();
break;
case 1:
case 1: case 2:
getGoodsDetailApi(this.dialogObj.id).then(res=>{
this.loading = false;
this.form={
......@@ -266,12 +310,14 @@
is_real:res.is_real,
is_auth_user:res.is_auth_user,
share_desc:JSON.parse(res.share_desc),
desc:JSON.parse(res.desc)
desc:JSON.parse(res.desc),
invite_earnings: res.invite_earnings,
is_auth_teacher: res.is_auth_teacher
};
this.getLessonList()
});
break;
case 2:
case 3:
this.title = '编辑';
this.show = this.dialogObj.show;
this.id = this.dialogObj.id;
......
......@@ -163,7 +163,8 @@
},
detail(data){
this.dialogObj.id = data.id;
this.dialogObj.type = 1;
this.dialogObj.type = 2;
this.dialogObj.title = '查看商品'
this.dialogObj.show = true
},
onDel(data){
......@@ -192,9 +193,9 @@
type: 'success',
message: '操作成功!'
});
});
this.getUser()
});
});
},
onDown(data){
this.$confirm('此操作将下架该商品?', '提示', {
......@@ -207,9 +208,9 @@
type: 'success',
message: '操作成功!'
});
});
this.getUser()
});
});
},
changeShow(data){
this.dialogObj.show=data
......
......@@ -23,6 +23,16 @@
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="4">
<label>分类</label>
</el-col>
<el-col :span="8">
<el-form-item>
<el-input v-model="form.category_name"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="4">
<label>封面图片</label>
......@@ -30,7 +40,8 @@
<el-col :span="20">
<div class="upload-block">
<el-upload
action="/api/public/upload"
action="/api/public/upload/zone"
:http-request="uploadFile"
:class="{disabled:!uploadShow}"
:before-upload="beforeAvatarUpload"
list-type="picture-card"
......@@ -52,7 +63,7 @@
</template>
<script>
import {getSingleDetailApi,addSingleApi,editSingleApi} from "../../service/api";
import {getSingleDetailApi,addSingleApi,editSingleApi,uploadFileApi} from "../../service/api";
export default {
name: "dialogObj",
props:[
......@@ -117,6 +128,21 @@
beforeAvatarUpload(){
this.uploadShow = false
},
uploadFile(a) {
this.loading = true;
this.$store.dispatch('setProgress',{type:'new',id:a.file.uid});
this.fileUid = a.file.uid;
uploadFileApi({file:a.file,type:'local'}).then(res=>{
this.imageList = [{name:res.url,url:process.env.IMAGE_URL_HEAD + res.url}]
this.loading = false;
this.$message({
type: 'success',
message: '上传成功!'
});
}).catch(()=>{
this.loading = false;
})
},
handleRemove(){
this.uploadShow = true
},
......
......@@ -2,6 +2,12 @@
<div class="single">
<el-form ref="searchFrom" :model="searchFrom" label-width="80px">
<el-row>
<el-col :span="4">
<el-form-item label="分类名称">
<el-input v-model="searchFrom.category_name" placeholder="名称"
size="small"></el-input>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="单品名称">
<el-input v-model="searchFrom.name" placeholder="名称"
......@@ -13,6 +19,10 @@
<el-button type="primary" plain size="small" @click="initPage">
搜索
</el-button>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item>
<el-button type="success" plain size="small" @click="onAdd">
添加单品
</el-button>
......@@ -32,6 +42,10 @@
prop="name"
label="名称">
</el-table-column>
<el-table-column
prop="category_name"
label="分类">
</el-table-column>
<el-table-column
prop="num"
sortable
......@@ -85,7 +99,14 @@
},
methods:{
initPage(){
getSingleListApi(this.searchFrom.name).then(res=>{
let json = {}
if (this.searchFrom.name) {
json.name = this.searchFrom.name
}
if (this.searchFrom.category_name) {
json.category_name = this.searchFrom.category_name
}
getSingleListApi(json).then(res=>{
this.tableData = res.list;
this.total = res.total
})
......
......@@ -238,18 +238,15 @@
this.loading = true;
this.$store.dispatch('setProgress',{type:'new',id:a.file.uid});
this.fileUid = a.file.uid;
this.showProgress = true;
uploadFileApi({file:a.file,type:'local'}).then(res=>{
this.imageList = [{name:res.url,url:process.env.IMAGE_URL_HEAD + res.url}]
this.loading = false;
this.showProgress = false;
this.$message({
type: 'success',
message: '上传成功!'
});
}).catch(()=>{
this.loading = false;
this.showProgress = false;
})
}
}
......
......@@ -54,14 +54,31 @@
</el-form-item>
</el-col>
</el-row>
<el-row v-if="type !== 1">
<el-row>
<el-col :span="4"><label>二维码</label></el-col>
<el-col :span="8">
<span v-if="type===1">{{teacherDetail.qr}}</span>
<el-form-item v-if="type !== 1" prop="qr">
<el-input v-model="form.qr"></el-input>
<img class="qr-img" v-if="type===1" :src="teacherDetail.qr"/>
<el-form-item v-if="type !== 1">
<!--<el-input v-model="form.qr"></el-input>-->
<el-upload
action="/api/public/upload/zone"
:http-request="uploadFile"
:class="{disabled:!uploadShow}"
:before-upload="beforeAvatarUpload"
list-type="picture-card"
:file-list="imageList"
:on-success="handleAvatarSuccess"
:on-remove="handleRemove">
<i class="el-icon-plus"></i>
</el-upload>
</el-form-item>
</el-col>
<template v-if="type===1">
<el-col :span="4"><label>邀请码</label></el-col>
<el-col :span="8">
<span v-if="type===1">{{teacherDetail.invite_code}}</span>
</el-col>
</template>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer" v-if="type !== 1">
......@@ -74,7 +91,7 @@
</template>
<script>
import {getTeacherDetailApi,addTeacherApi,editTeacherApi} from "../../service/api";
import {getTeacherDetailApi,addTeacherApi,editTeacherApi,uploadFileApi} from "../../service/api";
import {TEACHERTYPE} from "../../util/wordbook";
export default {
name: "dialogObj",
......@@ -118,7 +135,7 @@
type:0,
qr:'',
alias:'',
status:0,
status:0
},
rules:{
name:[
......@@ -128,11 +145,16 @@
{ required: true, message: '请输入二维码', trigger: 'change' }
]
},
teacherDetail:{}
teacherDetail:{},
imageList: [],
uploadShow: true
}
},
methods:{
sub(){
if(this.imageList.length > 0){
this.form.qr = this.imageList[0].url;
}
switch(this.dialogObj.type){
case 2:
this.$refs['form'].validate((valid) => {
......@@ -164,6 +186,31 @@
break
}
},
beforeAvatarUpload(){
this.uploadShow = false
},
handleRemove(){
this.uploadShow = true
},
handleAvatarSuccess(res) {
this.imageList = [{name:res.data.url,url:process.env.IMAGE_URL_HEAD + res.data.url}]
},
uploadFile(a) {
this.loading = true;
this.$store.dispatch('setProgress',{type:'new',id:a.file.uid});
this.fileUid = a.file.uid;
uploadFileApi({file:a.file,type:'local'}).then(res=>{
this.imageList = [{name:res.url,url:process.env.IMAGE_URL_HEAD + res.url}]
this.uploadShow = false;
this.loading = false;
this.$message({
type: 'success',
message: '上传成功!'
});
}).catch(()=>{
this.loading = false;
})
},
initDialog(){
switch(this.dialogObj.type){
case 0:
......@@ -175,6 +222,7 @@
this.form.qr = "";
this.form.type = 0;
this.form.status = 0;
this.imageList = [];
this.loading = false;
break;
case 1:
......@@ -198,6 +246,8 @@
this.form.qr = res.qr;
this.form.type = res.type;
this.form.status = res.status;
this.imageList = [{name:res.qr,url:res.qr}];
this.uploadShow = !res.qr;
this.loading = false
});
break
......@@ -222,7 +272,7 @@
<style scoped lang="less">
.el-col{
height: 50px;
min-height: 50px;
text-align: center;
margin-bottom: 20px;
line-height: 40px;
......@@ -237,8 +287,18 @@
color: #5982e6;
}
}
.qr-img {
width: 148px !important;
border: none !important;
border-radius: 0 !important;
}
.dialog-footer{
display: block;
text-align: center;
}
</style>
<style>
.disabled .el-upload--picture-card {
display: none !important;
}
</style>
......@@ -36,8 +36,16 @@
label="微信号">
</el-table-column>
<el-table-column
prop="mobile"
prop="invite_code"
label="邀请码">
</el-table-column>
<el-table-column
label="二维码">
<template slot-scope="scope">
<a :href="scope.row.qr">
<img class="shortcut" :src="scope.row.qr"/>
</a>
</template>
</el-table-column>
<el-table-column
label="类别">
......@@ -132,9 +140,9 @@
type: 'success',
message: '删除成功!'
});
});
this.getUser()
});
});
},
changeShow(data){
this.dialogObj.show=data
......@@ -154,4 +162,7 @@
text-align: center;
}
}
.shortcut {
width: 50px;
}
</style>
......@@ -187,8 +187,8 @@ export const delElementApi = function (id) {
}
// 获取单品列表
const getSingleListUrl = `${_baseUrl}api/admin/item/stock/list`;
export const getSingleListApi = function (name) {
return Vue.prototype.$fetch(`${getSingleListUrl}`,{name:name})
export const getSingleListApi = function (json) {
return Vue.prototype.$fetch(`${getSingleListUrl}`,json)
};
// 获取单品详情
const getSingleDetailUrl = `${_baseUrl}api/admin/item/stock/info/`;
......
......@@ -127,6 +127,11 @@ export default [
value:'素材管理',
routerName:'weChatResource',
path:'/weChatResource'
},
{
value:'Banner管理',
routerName:'banner',
path:'/banner'
}
]
},{
......@@ -138,10 +143,6 @@ export default [
value:'账号管理',
routerName:'admin',
path:'/admin'
},{
value:'Banner管理',
routerName:'banner',
path:'/banner'
},{
value:'角色管理',
routerName:'role',
......
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