Commit 11004b5d authored by lixy's avatar lixy

旅行标签设置

parent 0939dc54
......@@ -29,9 +29,6 @@ export function getOneGoodsById(query) {
params: query
});
}
// api/tour/admin/tourBanner
// api/tour/admin/tourBanner/page?pageNo=0&pageSize=10
/**
* 获取bannerList
*/
......@@ -65,7 +62,7 @@ export function editBanner(params) {
// delBanner
/**
* 修改banner
* 删除banner
*/
export function delBanner(id) {
return fetch({
......@@ -73,3 +70,55 @@ export function delBanner(id) {
method: 'delete'
});
}
/**
* 获取旅游标签List
*/
export function getTourTagList(query) {
return fetch({
url: '/api/tour/admin/tourTag/pages',
method: 'get',
params: query
});
}
/**
* 获取旅游标签List
*/
export function tourTagUpdate(query) {
return fetch({
url: '/api/tour/admin/tourTag/update',
method: 'put',
data: query
});
}
/**
* 获取旅游标签List
*/
export function tourTagAdd(query) {
return fetch({
url: '/api/tour/admin/tourTag/save',
method: 'post',
data: query
});
}
/**
*热门标签状态
*/
export function tourTagHot(query) {
return fetch({
url: '/api/tour/admin/tourTag/update/hot',
method: 'put',
params: query
});
}
/**
*删除旅游标签
*/
export function deleteTourTag(id) {
return fetch({
url: '/api/tour/admin/tourTag/' + id,
method: 'delete'
});
}
......@@ -11,11 +11,16 @@
type="index"
align="center" label="序号" width="98">
</el-table-column>
<el-table-column width="500" align="center" label="标题">
<el-table-column width="300" align="center" label="标题">
<template scope="scope">
<span>{{scope.row.title}}</span>
</template>
</el-table-column>
<el-table-column width="200" align="center" label="类型">
<template scope="scope">
<span>{{scope.row.type==0?"app首页":scope.row.type==1?"app旅游页":"租车"}}</span>
</template>
</el-table-column>
<el-table-column width="300" align="center" label="banner图">
<template scope="scope">
<img :src="scope.row.cover" style="width:100%;max-height:100px;">
......@@ -204,13 +209,6 @@
this.modalTitle = '创建';
this.bannerDialogVisible = true;
},
/**
* 操作-删除
* */
deleteHandler(row) {
this.oneTourRow = row;
this.bannerDialogVisible = true;
},
/**
* 操作-编辑
* */
......@@ -273,7 +271,7 @@
addBanner(this.form)
.then(response => {
if (response.status === 200) {
this.dialogFormVisible = false;
this.bannerDialogVisible = false;
this.getList();
this.$notify({
title: '成功',
......
<template>
<div class="app-container calendar-list-container" v-loading.body="showLoadingBody">
<div class="filter-container" ref="filter-container">
<el-button class="filter-item" style="margin-left: 10px;" @click="handleCreate"
type="primary" icon="edit">添加
</el-button>
</div>
<el-table :key='tableKey' :data="list" border fit highlight-current-row
style="width: 100%">
<el-table-column
type="index"
align="center" label="序号" width="65">
</el-table-column>
<el-table-column width="100" align="center" label="标签名称">
<template scope="scope">
<span>{{scope.row.tourTagDTO.name}}</span>
</template>
</el-table-column>
<el-table-column width="200" align="center" label="封面图">
<template scope="scope">
<img :src="scope.row.tourTagDTO.img" style="width:100%;max-height:100px;">
</template>
</el-table-column>
<el-table-column width="100" align="center" label="轮播图">
<template scope="scope">
<span>{{scope.row.tourTagDTO.bannerNums}}</span>
</template>
</el-table-column>
<el-table-column width="200" align="center" label="旅行数量">
<template scope="scope">
<span>{{scope.row.tourTagDTO.count}}</span>
</template>
</el-table-column>
<el-table-column width="200" align="center" label="排序">
<template scope="scope">
<span>{{scope.row.tourTagDTO.rank}}</span>
</template>
</el-table-column>
<el-table-column width="200" align="center" label="热门标签">
<template scope="scope">
<!--isHot-->
<el-button size="mini" type="text" @click="tourTagHotChange(scope.row)" v-if="scope.row.tourTagDTO.isHot==1" ><i style="color: #208ee1;font-size:24px;" class="el-icon-star-on el-icon--right"></i></el-button>
<el-button size="mini" type="text" @click="tourTagHotChange(scope.row)" v-if="scope.row.tourTagDTO.isHot==0" ><i style="font-size:24px;" class="el-icon-star-off el-icon--right"></i></el-button>
<!--<el-icon v-if="scope.row.tourTagDTO.isHot==1" style="color: #208ee1;" class="el-icon-star-on" @click="tourTagHotChange(scope.row)"></el-icon>-->
<!--<el-icon v-else class="el-icon-star-off" @click="tourTagHotChange(scope.row)"></el-icon>-->
</template>
</el-table-column>
<el-table-column align="center" width="200" label="操作">
<template scope="scope">
<el-button size="small" type="success" @click="handleUpdate(scope.row)">编辑
</el-button>
<el-popover
ref="popover5"
placement="top"
width="160"
v-model="scope.row.visible2">
<p>确定删除吗?</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="scope.row.visible2 = false">取消</el-button>
<el-button type="primary" size="mini" @click="deleteHandler(scope.row)">确定</el-button>
</div>
</el-popover>
<el-button type="danger" size="small" v-popover:popover5>删除</el-button>
</template>
</el-table-column>
</el-table>
<div v-show="!listLoading" class="pagination-container">
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
:current-page.sync="listQuery.pageNo" :page-sizes="[10,20,30, 50]" :page-size="listQuery.pageSize"
layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>
</div>
<!-- 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="请输入标签名称"></el-input>
</el-form-item>
<!--0-app首页,1-app旅游页;2-租车-->
<el-form-item label="排序" prop="tourTagDTO.rank">
<el-input v-model="form.tourTagDTO.rank" placeholder="请输入排序值"></el-input>
</el-form-item>
<!--BASE_API + -->
<el-form-item label="封面图" prop="tourTagDTO.img" :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;">
<i v-else class="el-icon-plus avatar-uploader-icon" style="lineHeight:100px;width:300px;height: 100px;"></i>
</el-upload>
</el-form-item>
<el-form-item label="轮播图" :style="{display:'block'}">
<el-upload
class="upload-demo"
:headers="getHeaderWithToken"
action="https://xxtest.upyuns.com/api/universal/file/app/unauth/admin/upload"
:on-remove="handleRemove"
:file-list="fileList2"
: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-upload>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancelHandel">取 消</el-button>
<el-button v-if="modalTitle=='创建'" type="primary" @click="create('form')">确 定</el-button>
<el-button v-else type="primary" @click="update('form')">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<style>
.el-upload-list{
display: flex;
width: 100px;
}
.el-upload-list li{
margin-left: 10px;
}
</style>
<script>
import 'static/css/uploadImg.css';// 引入图片上传组件对话框
import {
formatDate
} from 'utils/dateFormattor';
import {
toEast8Date,
deepCopyDate,
newEast8Date,
convertDate2Str
} from 'utils/dateUtils';
import {
getTourTagList,
tourTagUpdate,
tourTagAdd,
tourTagHot,
deleteTourTag
} from 'api/tourManage';
import rsCode from '../../utils/rsCode';
import {mapGetters} from 'vuex';
import {
getToken
} from '../../utils/auth';
import Element1 from "../admin/menu/components/element";
import ElRow from "element-ui/packages/row/src/row";
import ElCol from "element-ui/packages/col/src/col";
import ElIcon from "../../../node_modules/element-ui/packages/icon/src/icon.vue";
export default {
name: 'tourManage',
components: {
ElIcon,
ElCol,
ElRow,
Element1
},
data() {
return {
tableKey:0,
modalTitle: "创建",
BASE_API: process.env.BASE_API,
bannerDialogVisible: false,//添加、编辑弹框
showLoadingBody: false,
fileList2: [],//轮播图
form: {
tourTagDTO:{
bannerNums: undefined,
count: undefined,
ctrTime: undefined,
describe: undefined,
id: undefined,
img: undefined,
isDel: undefined,
isHot: undefined,
name: undefined,
rank: undefined
},
tourTagBannerDTOS:{},
},
listQuery: {
pageNo: 1,
pageSize: 20
},
rules: {
name: {
type: 'string',
required: true,
message: '请输入标签名称',
trigger: 'blur'
},
rank:{
type: 'string',
required: true,
message: '请输入排序值',
trigger: 'blur'
},
img: {
type: 'string',
required: true,
message: '请上传封面图',
},
},
list: null,
total: null,
listLoading: true,
inline: true,
banner_btn_edit: false,//编辑
banner_btn_add: false,//添加
}
},
created() {
this.getList();
this.banner_btn_edit = true;//this.elements['tourManage:btn_edit'];
this.banner_btn_add = true;//this.elements['tourManage:btn_add'];
},
computed: {
...mapGetters([
'elements',
'belong2Type'
]),
getHeaderWithToken() {
return {Authorization: getToken()};
},
},
methods: {
handleSizeChange(val) {
this.listQuery.pageSize = val;
this.getList();
},
handleCurrentChange(val) {
this.listQuery.pageNo = val;
this.getList();
},
/**
* 添加
* */
handleCreate() {
this.cleanForm();
this.modalTitle = '创建';
this.bannerDialogVisible = true;
},
/**
* 删除
* */
deleteHandler(row) {
deleteTourTag(row.id).then(response => {
if (response.status === 200) {
this.$notify({
title: '成功',
message: '删除成功',
type: 'success',
duration: 2000
});
this.bannerDialogVisible = false;
this.getList();
} else {
this.$notify({
title: '删除失败',
message: rsCode.msg[response.code] ? rsCode.msg[response.code] : '操作失败!',
type: 'error',
duration: 2000
});
}
});
},
/**
* 操作-编辑
* */
handleUpdate(row){
this.modalTitle = '编辑';
this.cleanForm();
this.form = row;
let fileList2 = [];
row.tourTagBannerDTOS.map(function(item){
let p = {
url: item.cover
};
fileList2.push(p);
});
this.fileList2 = fileList2;
this.bannerDialogVisible = true;
},
/**
* 弹框-取消
* */
cancelHandel(){
this.cleanForm();
this.bannerDialogVisible = false;
},
/**
* 清空表单
* */
cleanForm() {
this.form = {
tourTagDTO:{
bannerNums: 0,
count: undefined,
ctrTime: undefined,
describe: undefined,
id: undefined,
img: undefined,
isDel: undefined,
isHot: undefined,
name: undefined,
rank: undefined
},
tourTagBannerDTOS:[],
};
this.fileList2 = [];//轮播图
},
showImgDialog(drivingLicensePath) {
this.licenceSrcUrl = this.getDrivingLicenseUrl(drivingLicensePath);
this.dialogForm4LicenceVisible = true;
},
/**
* 获取banner列表数据
* */
getList() {
this.listLoading = true;
getTourTagList(this.listQuery).then(response => {
let totalCountRs = undefined;
let listRs = undefined;
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.visible2 = false;
});
totalCountRs = response.data.totalCount;
}
this.listLoading = false;
this.list = listRs;
this.total = totalCountRs;
});
},
/**
* 创建
* */
create(formName) {
const set = this.$refs;
set[formName].validate(valid => {
if (valid) {
tourTagAdd(this.form)
.then(response => {
if (response.status === 200) {
this.bannerDialogVisible = false;
this.getList();
this.$notify({
title: '成功',
message: '创建成功',
type: 'success',
duration: 2000
});
this.getList();
} else {
this.$notify({
title: '失败',
message: rsCode.msg[response.code] ? rsCode.msg[response.code] : '操作失败!',
type: 'error',
duration: 2000
});
}
});
} else {
return false;
}
});
},
/**
* 编辑-更新
* */
update(formName) {
const set = this.$refs;
// console.log(this.fileList2);
// console.log(this.form.tourTagBannerDTOS);
// debugger;
set[formName].validate(valid => {
if (valid) {
tourTagUpdate(this.form).then(response => {
if (response.status === 200) {
this.bannerDialogVisible = false;
this.getList();
this.$notify({
title: '成功',
message: '编辑成功',
type: 'success',
duration: 2000
});
this.getList();
} else {
this.$notify({
title: '失败',
message: rsCode.msg[response.code] ? rsCode.msg[response.code] : '操作失败!',
type: 'error',
duration: 2000
});
}
});
} else {
return false;
}
});
},
/**
* 热门标签
* */
tourTagHotChange(row){
let params={
id: row.tourTagDTO.id,
state: row.tourTagDTO.isHot==0?1:0
};
tourTagHot(params).then(response => {
if (response.status === 200) {
this.getList();
}});
},
/**
* 上传图片
* @param file
* @returns {boolean}
*/
beforeAvatarUpload(file) {
const isJPG = file.type === 'image/jpeg' || file.type === 'image/gif';
const isLt2M = file.size / 1024 / 1024 < 10;
if (!isJPG) {
this.$message.error('上传图片只能是 JPG/GIF 格式!');
}
if (!isLt2M) {
this.$message.error('上传图片大小不能超过 10MB!');
}
this.showLoadingBody = true;
return isJPG && isLt2M;
},
/**
* 封面图上传
* */
handleAvatarSuccess(res, file) {
this.form.tourTagDTO.img = res.data;
this.showLoadingBody = false;
},
/**
* 删除banner
* */
handleRemove(file, fileList){
let list = [];
fileList.map(function(item){
if(item.url != file.url){
list.push(item);
}
});
this.fileList2 = list;
let arr = [];
this.form.tourTagBannerDTOS.map(function(item){
if(item.cover != file.url){
arr.push(item);
}
});
this.form.tourTagBannerDTOS = arr;
this.form.tourTagDTO.bannerNums = this.fileList2.length;
},
/**
* banner上传
* */
handleBannerSuccess(res, file){
this.fileList2.push({url:res.data});
this.form.tourTagBannerDTOS.push({cover:res.data});
this.form.tourTagDTO.bannerNums = this.fileList2.length;
},
/**
* 操作-删除
* */
deleteHandler(row) {
deleteTourTag(row.tourTagDTO.id).then(response => {
if (response.status === 200) {
this.$notify({
title: '成功',
message: '删除成功',
type: 'success',
duration: 2000
});
this.getList();
} else {
this.$notify({
title: '删除失败',
message: rsCode.msg[response.code] ? rsCode.msg[response.code] : '操作失败!',
type: 'error',
duration: 2000
});
}
});
},
getUrl(drivingLicensePath) {
return process.env.BASE_API +
'/vehicle/vehicleInfo/download/drivingLicense?realFileRelPath=' + encodeURI(drivingLicensePath);
},
}
}
</script>
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