Commit 2f686237 authored by lixy's avatar lixy

旅游标签

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