Commit 2f686237 authored by lixy's avatar lixy

旅游标签

parent 40ae291c
......@@ -72,22 +72,22 @@
<!-- banner modal弹窗 -->
<el-dialog :title="modalTitle" :visible.sync="bannerDialogVisible">
<el-form :model="form" :rules="rules" ref="form" label-width="90px">
<el-form-item label="标签名称" prop="tourTagDTO.name">
<el-input v-model="form.tourTagDTO.name" placeholder="请输入标签名称" @blur="isExistTourTag()"></el-input><span v-if="isExist" style="color:red;">标签名已存在</span>
<el-form-item label="标签名称" prop="name">
<el-input v-model="form.name" placeholder="请输入标签名称" @blur="isExistTourTag()"></el-input><span v-if="isExist" style="color:red;">标签名已存在</span>
</el-form-item>
<!--0-app首页,1-app旅游页;2-租车-->
<el-form-item label="排序" prop="tourTagDTO.rank">
<el-input v-model="form.tourTagDTO.rank" placeholder="请输入排序值" type="number" min="0"></el-input>
<el-form-item label="排序">
<el-input v-model="form.rank" placeholder="请输入排序值" type="number" min="0"></el-input>
</el-form-item>
<!--BASE_API + -->
<el-form-item label="封面图" prop="tourTagDTO.img" :style="{display:'block'}">
<el-form-item label="封面图" :style="{display:'block'}">
<el-upload
class="avatar-uploader"
:action="'https://xxtest.upyuns.com/api/universal/file/app/unauth/admin/upload'"
:show-file-list="false"
:headers="getHeaderWithToken"
:on-success="handleAvatarSuccess">
<img v-if="$utils.isString(form.tourTagDTO.img) && !$utils.isEmpty(form.tourTagDTO.img)" :src="form.tourTagDTO.img" style="width:300px;max-height:300px;">
<img v-if="$utils.isString(form.img) && !$utils.isEmpty(form.img)" :src="form.img" style="width:300px;max-height:300px;">
<i v-else class="el-icon-plus avatar-uploader-icon" style="lineHeight:100px;width:300px;height: 100px;"></i>
</el-upload>
</el-form-item>
......@@ -101,7 +101,7 @@
:on-success="handleBannerSuccess"
list-type="picture">
<div slot="tip" class="el-upload__tip">最多上传5张</div>
<el-button v-if="form.tourTagDTO.bannerNums<5" size="small" type="primary">点击上传</el-button>
<el-button v-if="form.bannerNums<5" size="small" type="primary">点击上传</el-button>
</el-upload>
</el-form-item>
</el-form>
......@@ -176,7 +176,6 @@
showLoadingBody: false,
fileList2: [],//轮播图
form: {
tourTagDTO:{
bannerNums: undefined,
count: undefined,
ctrTime: undefined,
......@@ -188,8 +187,6 @@
name: undefined,
rank: 0
},
tourTagBannerDTOS:{},
},
listQuery: {
pageNo: 1,
pageSize: 20
......@@ -212,6 +209,10 @@
required: true,
message: '请上传封面图',
},
banner:{
required: true,
message: '请上传轮播图',
}
},
list: null,
total: null,
......@@ -256,15 +257,12 @@
* 保存时判断标签名称是否已存在
* */
isExistTagName(type, formName){
this.form.tourTagDTO.name = (this.form.tourTagDTO.name).trim();
if(!this.form.tourTagDTO.name){
return;
}
this.form.name = (this.form.name).trim();
let params = {
name: this.form.tourTagDTO.name
name: this.form.name
};
if(type == 'update'){//编辑
params.id = this.form.tourTagDTO.id;
params.id = this.form.id;
}
existTourTag(params).then(response => {
if (response.status === 200) {
......@@ -293,15 +291,12 @@
* 判断标签名是否已存在
* */
isExistTourTag(){
this.form.tourTagDTO.name = (this.form.tourTagDTO.name).trim();
if(!this.form.tourTagDTO.name){
return;
}
this.form.name = (this.form.name).trim();
let params = {
name: this.form.tourTagDTO.name
name: this.form.name
};
if(this.modalTitle == "编辑"){
params.id = this.form.tourTagDTO.id;
params.id = this.form.id;
}
existTourTag(params).then(response => {
if (response.status === 200) {
......@@ -345,14 +340,17 @@
handleUpdate(row){
this.modalTitle = '编辑';
this.cleanForm();
this.form = row;
this.form = row.tourTagDTO;
this.form.tourTagBannerDTOS = row.tourTagBannerDTOS?row.tourTagBannerDTOS: [];
let fileList2 = [];
if(row.tourTagBannerDTOS){
row.tourTagBannerDTOS.map(function(item){
let p = {
url: item.cover
};
fileList2.push(p);
});
}
this.fileList2 = fileList2;
this.bannerDialogVisible = true;
},
......@@ -368,7 +366,6 @@
* */
cleanForm() {
this.form = {
tourTagDTO:{
bannerNums: 0,
count: undefined,
ctrTime: undefined,
......@@ -379,8 +376,6 @@
isHot: undefined,
name: undefined,
rank: 0
},
tourTagBannerDTOS:[],
};
this.isExist = false;
this.fileList2 = [];//轮播图
......@@ -415,10 +410,27 @@
* */
toCreate(formName){
const set = this.$refs;
// if(!this.form.tourTagBannerDTOS){
// this.$notify({
// title: '警告',
// message: '请上传轮播图',
// type: 'warning',
// duration: 2000
// });
// this.isCreate = false;//点击后确定按钮不可用
// return;
// }
set[formName].validate(valid => {
if (valid && !this.isExist) {
tourTagAdd(this.form)
let tourTagDTO = {
bannerNums: this.form.bannerNums,
img: this.form.img,
name: this.form.name,
rank: this.form.rank
};
tourTagAdd({tourTagDTO: tourTagDTO, tourTagBannerDTOS: this.form.tourTagBannerDTOS})
.then(response => {
this.isCreate = false;//点击后确定按钮不可用
if (response.status === 200) {
this.bannerDialogVisible = false;
this.getList();
......@@ -439,6 +451,7 @@
}
});
} else {
this.isCreate = false;//点击后确定按钮不可用
return false;
}
});
......@@ -447,24 +460,52 @@
* 创建
* */
create(formName) {
const set = this.$refs;
set[formName].validate(valid => {
if (valid) {
this.isCreate = true;//点击后确定按钮不可用
this.isExistTagName("create", formName);
}
});
},
/**
* 编辑-确定按钮
* */
update(formName){
const set = this.$refs;
set[formName].validate(valid => {
if (valid) {
this.isCreate = true;//点击后确定按钮不可用
this.isExistTagName("update", formName);
}
});
},
/**
* 编辑-更新
* */
toUpdate(formName) {
const set = this.$refs;
if(!this.form.tourTagBannerDTOS){
this.$notify({
title: '警告',
message: '请上传轮播图',
type: 'warning',
duration: 2000
});
this.isCreate = false;//点击后确定按钮不可用
return;
}
set[formName].validate(valid => {
if (valid && !this.isExist) {
tourTagUpdate(this.form).then(response => {
let tourTagDTO = {
id: this.form.id,
bannerNums: this.form.bannerNums,
img: this.form.img,
name: this.form.name,
rank: this.form.rank
};
tourTagUpdate({tourTagDTO: tourTagDTO, tourTagBannerDTOS: this.form.tourTagBannerDTOS}).then(response => {
this.isCreate = false;//点击后确定按钮不可用
if (response.status === 200) {
this.bannerDialogVisible = false;
this.getList();
......@@ -485,6 +526,7 @@
}
});
} else {
this.isCreate = false;//点击后确定按钮不可用
return false;
}
});
......@@ -524,7 +566,7 @@
* 封面图上传
* */
handleAvatarSuccess(res, file) {
this.form.tourTagDTO.img = res.data;
this.form.img = res.data;
this.showLoadingBody = false;
},
/**
......@@ -545,7 +587,7 @@
}
});
this.form.tourTagBannerDTOS = arr;
this.form.tourTagDTO.bannerNums = this.fileList2.length;
this.form.bannerNums = this.fileList2.length;
},
/**
* banner上传
......@@ -553,7 +595,7 @@
handleBannerSuccess(res, file){
this.fileList2.push({url:res.data});
this.form.tourTagBannerDTOS.push({cover:res.data});
this.form.tourTagDTO.bannerNums = this.fileList2.length;
this.form.bannerNums = this.fileList2.length;
},
/**
* 操作-删除
......
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