Commit 41a1b884 authored by 王's avatar

单品盒子修改

parent 5d96b1c6
......@@ -44,12 +44,26 @@
<el-row>
<el-col :span="12">
<el-form-item prop="title" label="最小等级">
<el-input-number v-model="form.min_level"></el-input-number>
<el-select v-model="form.min_level" placeholder="请选择" clearable>
<el-option
v-for="item in levelOption"
:key="item"
:label="item"
:value="item">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="title" label="最大等级">
<el-input-number v-model="form.max_level"></el-input-number>
<el-select v-model="form.max_level" placeholder="请选择" clearable>
<el-option
v-for="item in levelOption"
:key="item"
:label="item"
:value="item">
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
......@@ -104,7 +118,8 @@
max_age:0,
min_level:0,
max_level:0
}
},
levelOption: [0,1,2,3,4,5,6,7,8,9]
}
},
mounted(){
......
......@@ -6,8 +6,8 @@
</div>
<el-card class="box-card">
<div slot="header">
<span>盒子类型</span>
<el-button style="float: right; padding: 3px 0;" @click="onAddType" type="text" v-if="!$store.state.readonly">新增类型</el-button>
<span>主题类别</span>
<el-button style="float: right; padding: 3px 0;" @click="onAddType" type="text" v-if="!$store.state.readonly">新增</el-button>
</div>
<el-card v-for="o in list" shadow="hover" :key="o.id" :class="{text:true,'now-card':o.id === nowId}">
<div class="name" @click="changeCateGory(o.id)">
......@@ -20,10 +20,10 @@
</div>
</el-card>
</el-card>
<el-dialog title="新增盒子" :visible.sync="dialogVisible" :modal="false" v-if="!$store.state.readonly">
<el-dialog title="主题类别" :visible.sync="dialogVisible" :modal="false" v-if="!$store.state.readonly">
<el-form label-width="100px">
<el-form-item label="名称">
<el-input v-model="form.name"></el-input>
<el-input v-model="form.name" placeholder="规则:课程类别-主题-教具"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
......
......@@ -6,16 +6,16 @@
:visible.sync="show"
width="800px">
<div v-loading="loading">
<el-form ref="form" :model="form" :rules="rules" >
<el-form ref="form" :model="form">
<el-row>
<el-col :span="4"><label>单品名称</label></el-col>
<el-col :span="8">
<el-form-item prop="name">
<el-input v-model="form.name"></el-input>
<el-form-item>
<el-input v-model="form.name" placeholder="规则:主题名+单品名"></el-input>
</el-form-item>
</el-col>
<el-col :span="4">
<label>数量</label>
<label>库存数量</label>
</el-col>
<el-col :span="8">
<el-form-item>
......@@ -27,9 +27,27 @@
<el-col :span="4">
<label>分类</label>
</el-col>
<el-col :span="8">
<el-col :span="20">
<el-form-item>
<el-input v-model="form.category_name"></el-input>
<el-tag
:key="tagIndex"
v-for="(tag,tagIndex) in form.category_name"
closable
:disable-transitions="false"
@close="handleClose(tag)">
{{tag}}
</el-tag>
<el-input
class="input-new-tag"
v-if="inputVisible"
v-model="inputValue"
ref="saveTagInput"
size="small"
@keyup.enter.native="handleInputConfirm"
@blur="handleInputConfirm"
>
</el-input>
<el-button v-else class="button-new-tag" size="small" @click="showInput">+ 新增</el-button>
</el-form-item>
</el-col>
</el-row>
......@@ -82,19 +100,43 @@
rules: {
},
inputVisible: false,
inputValue: '',
teacherDetail: {}
}
},
methods:{
handleClose(tag) {
this.form.category_name.splice(this.form.category_name.indexOf(tag), 1);
},
showInput() {
this.inputVisible = true;
this.$nextTick(_ => {
this.$refs.saveTagInput.$refs.input.focus();
});
},
handleInputConfirm() {
let inputValue = this.inputValue;
if (inputValue) {
this.form.category_name.push(inputValue);
}
this.inputVisible = false;
this.inputValue = '';
},
sub(){
switch(this.dialogObj.type){
case 0:
this.$refs['form'].validate((valid) => {
if(valid){
if(this.imageList.length >0){
console.log('this.imageList', this.imageList)
this.form.cover = this.imageList[0].name;
}
addSingleApi(this.form).then(()=>{
let json = this.form;
json.category_name = json.category_name.join(',')
addSingleApi(json).then(()=>{
this.$message({
type: 'success',
message: '修改成功!'
......@@ -108,11 +150,16 @@
case 1:
this.$refs['form'].validate((valid) => {
if(valid){
this.form.cover = this.imageList[0].name;
editSingleApi(this.id,this.form).then(()=>{
console.log('this.imageList', this.imageList)
if(this.imageList.length >0){
this.form.cover = this.imageList[0].name;
}
let json = this.form;
json.category_name = json.category_name.join(',')
editSingleApi(this.id,json).then(()=>{
this.$message({
type: 'success',
message: '新增成功!'
message: '修改成功!'
});
this.$emit("reflash");
this.show = false;
......@@ -156,7 +203,8 @@
this.form = {
name: '',
num: 0,
cover: ''
cover: '',
category_name: []
};
this.uploadShow = true;
this.loading = false;
......@@ -172,7 +220,7 @@
name:res.name,
num:res.num,
cover:res.cover,
category_name: res.category_name
category_name: res.category_name ? res.category_name.split(',') : []
};
if(this.form.cover && this.form.cover !== ''){
this.imageList = [{name:res.cover,url:process.env.IMAGE_URL_HEAD + res.cover}];
......@@ -226,5 +274,20 @@
.disabled .el-upload--picture-card {
display: none !important;
}
.el-tag + .el-tag {
margin-left: 10px;
}
.button-new-tag {
margin-left: 10px;
height: 32px;
line-height: 30px;
padding-top: 0;
padding-bottom: 0;
}
.input-new-tag {
width: 90px;
margin-left: 10px;
vertical-align: bottom;
}
</style>
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