Commit 8f88fe2d authored by lixy's avatar lixy

营地标签-车型

parent 956f08d4
import fetch from 'utils/fetch';
/**
* 获取营地标签List
*/
export function campsiteTagList(query) {
return fetch({
url: '/api/campsite/admin/campsiteTag/pages',
method: 'get',
params: query
});
}
/**
* 是否是筛选条件
* */
export function setSearchById(query) {
return fetch({
url: '/api/campsite/admin/campsiteTag/searchStatus?id=' + query.id + '&status=' + query.status,
method: 'put'
});
}
/**
* 删除营地标签
*/
export function delCampsiteTag(id) {
return fetch({
url: '/api/campsite/admin/campsiteTag/' + id,
method: 'delete'
});
}
/**
* 编辑营地标签
* */
export function editCampsiteTag(query) {
return fetch({
url: '/api/campsite/admin/campsiteTag/' + query.id,
method: 'put',
data: query
});
}
/**
* 创建营地标签
* */
export function addCampsiteTag(params) {
return fetch({
url: '/api/campsite/admin/campsiteTag',
method: 'post',
data: params
});
}
/**
* 判断标签是否已存在
* @param id
*/
export function existTag(query) {
return fetch({
url: '/api/campsite/admin/campsiteTag/exist',
method: 'get',
params: query
});
}
/**
* 获取营地List
*/
export function getCampsiteList(query) {
return fetch({
url: '/api/campsite/admin/campsiteShop/pages',
method: 'post',
params: 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'
});
}
/**
* 获取全部旅游标签
* @param query
*/
export function getAllTourTag(query) {
return fetch({
url: '/api/tour/admin/tourTag/tags',
method: 'get',
params: query
});
}
/**
* 获取全部旅游标签
* @param query
*/
export function goodDel(id) {
return fetch({
url: '/api/tour/good/admin/goodDel/' + id,
method: 'get'
});
}
/**
* 上架、下架
* */
export function upStatusChange(query) {
return fetch({
url: '/api/tour/good/admin/upStatus',
method: 'get',
params: query
});
}
...@@ -121,3 +121,13 @@ export function addVehicleModel(params) { ...@@ -121,3 +121,13 @@ export function addVehicleModel(params) {
data: params data: params
}); });
} }
/*
* 删除一条车型数据
* */
export function delVehicleModel(id) {
return fetch({
url: '/vehicle/vehicleModel/app/' + id,
method: 'delete'
});
}
<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: 867px">
<el-table-column
type="index"
align="center" label="序号" width="65">
</el-table-column>
<el-table-column width="200" align="center" label="类型名称">
<template scope="scope">
<span>{{scope.row.name}}</span>
</template>
</el-table-column>
<el-table-column width="200" align="center" label="标签底图">
<template scope="scope">
<img :src="scope.row.tagUrl" style="width: 130px;"/>
</template>
</el-table-column>
<el-table-column width="200" align="center" label="筛选条件">
<template scope="scope">
<el-button size="mini" type="text" @click="isSearchChange(scope.row)" v-if="scope.row.isSearch==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="isSearchChange(scope.row)" v-else ><i style="font-size:24px;" class="el-icon-star-off el-icon--right"></i></el-button>
</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.page" :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit"
layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>
</div>
<!-- 编辑、创建标签弹窗 -->
<el-dialog :title="modalTitle" :visible.sync="dialogVisible">
<el-form :model="form" ref="form" :rules="rules" label-width="90px">
<el-form-item label="标签名称" prop="name">
<el-input v-model="form.name" placeholder="请输入标签名称" @blur="isExistTag()"></el-input><span v-if="isExist" style="color:red;">标签名已存在</span>
</el-form-item>
<!--0-app首页,1-app旅游页;2-租车-->
<el-form-item label="排序">
<el-input v-model="form.rank" placeholder="请输入排序值"></el-input>
</el-form-item>
<!--BASE_API + -->
<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.tagUrl) && !$utils.isEmpty(form.tagUrl)" :src="form.tagUrl" 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>
<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>
<script>
import 'static/css/uploadImg.css';// 引入图片上传组件对话框
import {
formatDate
} from 'utils/dateFormattor';
import {
toEast8Date,
deepCopyDate,
newEast8Date,
convertDate2Str
} from 'utils/dateUtils';
import rsCode from '../../utils/rsCode';
import {mapGetters} from 'vuex';
import {
getToken
} from 'utils/auth';
import {
campsiteTagList,
setSearchById,
delCampsiteTag,
editCampsiteTag,
existTag,
addCampsiteTag
} from 'api/campsiteManage';
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";
export default {
name: 'tourManage',
components: {
ElCol,
ElRow,
Element1
},
data() {
return {
modalTitle: "创建",
BASE_API: process.env.BASE_API,
dialogVisible: false,//添加、编辑弹框
showLoadingBody: false,
isExist: false,//标签是否已存在
form: {
name: undefined,//标签名称
rank: 0,//排序
tagUrl: "",//标签底图
isSearch: 0,//是否是筛选条件
},
rules:{
name: {
type: "string",
message: '请输入名称',
required: true,
trigger: 'blur'
}
},
list: null,
total: null,
listLoading: true,
listQuery: {
page: 1,
limit: 20,
},
inline: true,
tableKey: 0,
}
},
created() {
this.getList();
this.tourManage_btn_edit = true;//this.elements['tourManage:btn_edit'];
this.tourManage_btn_add = true;//this.elements['tourManage:btn_add'];
},
computed: {
...mapGetters([
'elements',
'belong2Type'
]),
getHeaderWithToken() {
return {Authorization: getToken()};
},
},
methods: {
/**
* 判断标签名是否已存在
* */
isExistTag(){
if(!this.form.name){
return;
}
let params = {
name: this.form.name
};
if(this.modalTitle == "编辑"){
params.id = this.form.id;
}
existTag(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
});
}
});
},
/**
* 添加
* */
handleCreate() {
this.resetTemp();
this.modalTitle = '创建';
this.isExist = false;
this.dialogVisible = true;
},
cancelHandel(){
this.dialogVisible = false;
},
/**
* 底图上传
* */
handleAvatarSuccess(res, file) {
this.form.tagUrl = res.data;
this.showLoadingBody = false;
},
/**
* 新建标签
* */
create(formName){
const set = this.$refs;
set[formName].validate(valid => {
if (valid && !this.isExist) {
this.form.visible2 = undefined;
addCampsiteTag(this.form).then(response => {
if (response.status === 200) {
this.dialogVisible = 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;
}
});
},
/**
* 删除
* */
deleteHandler(row) {
delCampsiteTag(row.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
});
}
});
},
/**
* 编辑-更新
* */
update(formName) {
const set = this.$refs;
set[formName].validate(valid => {
if (valid && !this.isExist) {
this.form.visible2 = undefined;
editCampsiteTag(this.form).then(response => {
if (response.status === 200) {
this.dialogVisible = 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;
}
});
},
/**
* 深拷贝
*/
objDeepCopy (source) {
var sourceCopy = source instanceof Array ? [] : {};
for (var item in source) {
sourceCopy[item] = typeof source[item] === 'object' ? objDeepCopy(source[item]) : source[item];
}
return sourceCopy;
},
/**
* 编辑
* */
handleUpdate(row) {
this.modalTitle = '编辑';
this.form = this.objDeepCopy(row);
this.dialogVisible = true;
},
/**
* 筛选条件
* */
isSearchChange(row){
let params={
id: row.id,
status: row.isSearch==0?1:0
};
setSearchById(params).then(response => {
if (response.status === 200) {
this.getList();
}
});
},
/**
* 获取营地标签列表
* */
getList() {
this.listLoading = true;
campsiteTagList(this.listQuery).then(response => {
let totalCountRs = undefined;
let listRs = undefined;
if (!this.$utils.isEmpty(response.data.data) && this.$utils.isInteger(response.data.totalCount)) {
response.data.data.map(function(item){
item.visible2 = false;
});
listRs = response.data.data;
totalCountRs = response.data.totalCount;
}
this.listLoading = false;
this.list = listRs;
this.total = totalCountRs;
})
},
handleSizeChange(val) {
this.listQuery.limit = val;
this.getList();
},
handleCurrentChange(val) {
this.listQuery.page = val;
this.getList();
},
/**
* 重置标签
* */
resetTemp() {
this.form = {
name: undefined,//标签名称
rank: 0,//排序
tagUrl: "",//标签底图
isSearch: 0,//是否是筛选条件
};
},
}
}
</script>
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
import { import {
page, page,
getOneGoodsById, getOneGoodsById,
deleteVehicleType, delVehicleModel,
getLabelList, getLabelList,
getLabelByParentId, getLabelByParentId,
} from 'api/vehicleType'; } from 'api/vehicleType';
...@@ -211,7 +211,7 @@ ...@@ -211,7 +211,7 @@
* 删除 * 删除
* */ * */
deleteHandler(row) { deleteHandler(row) {
deleteVehicleType(row.id).then(response => { delVehicleModel(row.id).then(response => {
if (response.status === 200) { if (response.status === 200) {
this.$notify({ this.$notify({
title: '成功', title: '成功',
......
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