Commit f1227342 authored by lixy's avatar lixy

旅游标签

parent 244a1b07
...@@ -122,3 +122,27 @@ export function deleteTourTag(id) { ...@@ -122,3 +122,27 @@ export function deleteTourTag(id) {
method: 'delete' method: 'delete'
}); });
} }
/**
* 判断标签是否已存在
* @param id
*/
export function existTourTag(query) {
return fetch({
url: '/api/tour/admin/tourTag/exist',
method: 'get',
params: query
});
}
/**
* 获取全部旅游标签
* @param query
*/
export function getAllTourTag(query) {
return fetch({
url: '/api/tour/admin/tourTag/tags',
method: 'get',
params: query
});
}
<template> <template>
<div> <div>
<!-- 图片上传组件辅助--> <!-- 图片上传组件辅助-->
<!--<el-upload-->
<!--class="avatar-uploader"-->
<!--name="img"-->
<!--:headers="getHeaderWithToken"-->
<!--action="https://xxtest.upyuns.com/api/universal/file/app/unauth/admin/upload"-->
<!--:show-file-list="false"-->
<!--:on-success="uploadSuccess"-->
<!--:on-error="uploadError"-->
<!--:before-upload="beforeUpload">-->
<!--</el-upload>-->
<el-upload <el-upload
class="avatar-uploader" class="avatar-uploader"
:action="serverUrl" :action="'https://xxtest.upyuns.com/api/universal/file/app/unauth/admin/upload'"
name="img"
:headers="header"
:show-file-list="false" :show-file-list="false"
:on-success="uploadSuccess" :headers="getHeaderWithToken"
:on-error="uploadError" :before-upload="beforeUpload"
:before-upload="beforeUpload"> :on-success="uploadSuccess">
</el-upload> </el-upload>
<quill-editor <quill-editor
...@@ -40,13 +48,16 @@ ...@@ -40,13 +48,16 @@
[{ align: [] }], // 对齐方式 [{ align: [] }], // 对齐方式
["clean"], // 清除文本格式 ["clean"], // 清除文本格式
//["link", "image","video"] // 链接、图片、视频 //["link", "image","video"] // 链接、图片、视频
// ["link", "image"] // 链接、图片 ["link", "image"] // 链接、图片
]; ];
import { quillEditor } from "vue-quill-editor"; import { quillEditor } from "vue-quill-editor";
import "quill/dist/quill.core.css"; import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css"; import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css"; import "quill/dist/quill.bubble.css";
import {
getToken
} from '../../utils/auth';
export default { export default {
props: { props: {
...@@ -64,6 +75,11 @@ ...@@ -64,6 +75,11 @@
components: { components: {
quillEditor quillEditor
}, },
computed: {
getHeaderWithToken() {
return {Authorization: getToken()};
},
},
data() { data() {
return { return {
...@@ -132,13 +148,14 @@ ...@@ -132,13 +148,14 @@
console.log(file) console.log(file)
// res为图片服务器返回的数据 // res为图片服务器返回的数据
// 获取富文本组件实例 // 获取富文本组件实例
debugger
let quill = this.$refs.myQuillEditor.quill; let quill = this.$refs.myQuillEditor.quill;
// 如果上传成功 // 如果上传成功
if (res.code == 1) { if (res.status == 200) {
// 获取光标所在位置 // 获取光标所在位置
let length = quill.getSelection().index; let length = quill.getSelection().index;
// 插入图片 res.url为服务器返回的图片地址 // 插入图片 res.url为服务器返回的图片地址
quill.insertEmbed(length, "image", res.url); quill.insertEmbed(length, "image", res.data);
// 调整光标到最后 // 调整光标到最后
quill.setSelection(length + 1); quill.setSelection(length + 1);
} else { } else {
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
<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="tourTagDTO.name">
<el-input v-model="form.tourTagDTO.name" placeholder="请输入标签名称"></el-input> <el-input v-model="form.tourTagDTO.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="排序" prop="tourTagDTO.rank">
...@@ -141,7 +141,8 @@ ...@@ -141,7 +141,8 @@
tourTagUpdate, tourTagUpdate,
tourTagAdd, tourTagAdd,
tourTagHot, tourTagHot,
deleteTourTag deleteTourTag,
existTourTag
} from 'api/tourManage'; } from 'api/tourManage';
import rsCode from '../../utils/rsCode'; import rsCode from '../../utils/rsCode';
...@@ -166,6 +167,7 @@ ...@@ -166,6 +167,7 @@
}, },
data() { data() {
return { return {
isExist: false,//标签是否已存在
tableKey:0, tableKey:0,
modalTitle: "创建", modalTitle: "创建",
BASE_API: process.env.BASE_API, BASE_API: process.env.BASE_API,
...@@ -249,6 +251,40 @@ ...@@ -249,6 +251,40 @@
this.modalTitle = '创建'; this.modalTitle = '创建';
this.bannerDialogVisible = true; this.bannerDialogVisible = true;
}, },
/**
* 判断标签名是否已存在
* */
isExistTourTag(){
if(!this.form.tourTagDTO.name){
return;
}
let params = {
name: this.form.tourTagDTO.name
};
if(this.modalTitle == "编辑"){
params.id = this.form.tourTagDTO.id;
}
existTourTag(params).then(response => {
if (response.status === 200) {
this.isExist = response.data;
// if(response.data){
// this.$notify({
// title: '失败',
// message: '标签已存在',
// type: 'error',
// duration: 2000
// });
// }
} else {
this.$notify({
title: '失败',
message: rsCode.msg[response.code] ? rsCode.msg[response.code] : '操作失败!',
type: 'error',
duration: 2000
});
}
});
},
/** /**
* 删除 * 删除
* */ * */
...@@ -316,6 +352,7 @@ ...@@ -316,6 +352,7 @@
}, },
tourTagBannerDTOS:[], tourTagBannerDTOS:[],
}; };
this.isExist = false;
this.fileList2 = [];//轮播图 this.fileList2 = [];//轮播图
}, },
showImgDialog(drivingLicensePath) { showImgDialog(drivingLicensePath) {
...@@ -333,7 +370,7 @@ ...@@ -333,7 +370,7 @@
if (!this.$utils.isEmpty(response.data.data) && this.$utils.isInteger(response.data.totalCount)) { if (!this.$utils.isEmpty(response.data.data) && this.$utils.isInteger(response.data.totalCount)) {
listRs = response.data.data; listRs = response.data.data;
response.data.data.map(function(item){ response.data.data.map(function(item){
item.type = item.type+""; // item.type = item.type+"";
item.visible2 = false; item.visible2 = false;
}); });
totalCountRs = response.data.totalCount; totalCountRs = response.data.totalCount;
...@@ -349,7 +386,7 @@ ...@@ -349,7 +386,7 @@
create(formName) { create(formName) {
const set = this.$refs; const set = this.$refs;
set[formName].validate(valid => { set[formName].validate(valid => {
if (valid) { if (valid && !this.isExist) {
tourTagAdd(this.form) tourTagAdd(this.form)
.then(response => { .then(response => {
if (response.status === 200) { if (response.status === 200) {
...@@ -385,7 +422,7 @@ ...@@ -385,7 +422,7 @@
// console.log(this.form.tourTagBannerDTOS); // console.log(this.form.tourTagBannerDTOS);
// debugger; // debugger;
set[formName].validate(valid => { set[formName].validate(valid => {
if (valid) { if (valid && !this.isExist) {
tourTagUpdate(this.form).then(response => { tourTagUpdate(this.form).then(response => {
if (response.status === 200) { if (response.status === 200) {
this.bannerDialogVisible = false; this.bannerDialogVisible = false;
......
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