Commit f1227342 authored by lixy's avatar lixy

旅游标签

parent 244a1b07
......@@ -122,3 +122,27 @@ export function deleteTourTag(id) {
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>
<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
class="avatar-uploader"
:action="serverUrl"
name="img"
:headers="header"
: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">
:headers="getHeaderWithToken"
:before-upload="beforeUpload"
:on-success="uploadSuccess">
</el-upload>
<quill-editor
......@@ -40,13 +48,16 @@
[{ align: [] }], // 对齐方式
["clean"], // 清除文本格式
//["link", "image","video"] // 链接、图片、视频
// ["link", "image"] // 链接、图片
["link", "image"] // 链接、图片
];
import { quillEditor } from "vue-quill-editor";
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
import {
getToken
} from '../../utils/auth';
export default {
props: {
......@@ -64,6 +75,11 @@
components: {
quillEditor
},
computed: {
getHeaderWithToken() {
return {Authorization: getToken()};
},
},
data() {
return {
......@@ -132,13 +148,14 @@
console.log(file)
// res为图片服务器返回的数据
// 获取富文本组件实例
debugger
let quill = this.$refs.myQuillEditor.quill;
// 如果上传成功
if (res.code == 1) {
if (res.status == 200) {
// 获取光标所在位置
let length = quill.getSelection().index;
// 插入图片 res.url为服务器返回的图片地址
quill.insertEmbed(length, "image", res.url);
quill.insertEmbed(length, "image", res.data);
// 调整光标到最后
quill.setSelection(length + 1);
} else {
......
......@@ -73,7 +73,7 @@
<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="请输入标签名称"></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>
<!--0-app首页,1-app旅游页;2-租车-->
<el-form-item label="排序" prop="tourTagDTO.rank">
......@@ -141,7 +141,8 @@
tourTagUpdate,
tourTagAdd,
tourTagHot,
deleteTourTag
deleteTourTag,
existTourTag
} from 'api/tourManage';
import rsCode from '../../utils/rsCode';
......@@ -166,6 +167,7 @@
},
data() {
return {
isExist: false,//标签是否已存在
tableKey:0,
modalTitle: "创建",
BASE_API: process.env.BASE_API,
......@@ -249,6 +251,40 @@
this.modalTitle = '创建';
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 @@
},
tourTagBannerDTOS:[],
};
this.isExist = false;
this.fileList2 = [];//轮播图
},
showImgDialog(drivingLicensePath) {
......@@ -333,7 +370,7 @@
if (!this.$utils.isEmpty(response.data.data) && this.$utils.isInteger(response.data.totalCount)) {
listRs = response.data.data;
response.data.data.map(function(item){
item.type = item.type+"";
// item.type = item.type+"";
item.visible2 = false;
});
totalCountRs = response.data.totalCount;
......@@ -349,7 +386,7 @@
create(formName) {
const set = this.$refs;
set[formName].validate(valid => {
if (valid) {
if (valid && !this.isExist) {
tourTagAdd(this.form)
.then(response => {
if (response.status === 200) {
......@@ -385,7 +422,7 @@
// console.log(this.form.tourTagBannerDTOS);
// debugger;
set[formName].validate(valid => {
if (valid) {
if (valid && !this.isExist) {
tourTagUpdate(this.form).then(response => {
if (response.status === 200) {
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