店铺相关模块完善
This commit is contained in:
parent
baaae1cbce
commit
b5546c748f
|
@ -40,6 +40,7 @@
|
|||
"@pansy/watermark": "^2.3.0",
|
||||
"@riophae/vue-treeselect": "0.4.0",
|
||||
"axios": "0.28.1",
|
||||
"element-china-area-data": "^6.1.0",
|
||||
"clipboard": "2.0.8",
|
||||
"core-js": "3.37.1",
|
||||
"decimal.js": "^10.4.3",
|
||||
|
|
44
src/api/bst/floor.js
Normal file
44
src/api/bst/floor.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 查询楼层列表列表
|
||||
export function listFloor(query) {
|
||||
return request({
|
||||
url: '/bst/floor/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询楼层列表详细
|
||||
export function getFloor(floorId) {
|
||||
return request({
|
||||
url: '/bst/floor/' + floorId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增楼层列表
|
||||
export function addFloor(data) {
|
||||
return request({
|
||||
url: '/bst/floor',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改楼层列表
|
||||
export function updateFloor(data) {
|
||||
return request({
|
||||
url: '/bst/floor',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除楼层列表
|
||||
export function delFloor(floorId) {
|
||||
return request({
|
||||
url: '/bst/floor/' + floorId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
107
src/components/AreaTextSelect/index.vue
Normal file
107
src/components/AreaTextSelect/index.vue
Normal file
|
@ -0,0 +1,107 @@
|
|||
<template>
|
||||
<el-cascader
|
||||
style="width: 100%"
|
||||
:options="pcaTextArr"
|
||||
v-model="selectOptions"
|
||||
@change="onChange"
|
||||
:props="{ checkStrictly: checkStrictly }"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {pcaTextArr} from "element-china-area-data";
|
||||
|
||||
export default {
|
||||
name: "AreaTextSelect",
|
||||
props: {
|
||||
// 省
|
||||
province: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
// 市
|
||||
city: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
// 区
|
||||
county: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
// 是否可选任意一级
|
||||
checkStrictly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
// 级别,从0开始
|
||||
level: {
|
||||
type: Number,
|
||||
default: 2,
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
pcaTextArr: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
selectOptions: {
|
||||
set(val) {
|
||||
this.$emit('update:province', val.length > 0 ? val[0] : null);
|
||||
this.$emit('update:city', val.length > 1 ? val[1] : null);
|
||||
this.$emit('update:county', val.length > 2 ? val[2] : null);
|
||||
},
|
||||
get() {
|
||||
let list = [];
|
||||
if (this.province != null) {
|
||||
list.push(this.province);
|
||||
}
|
||||
if (this.city != null) {
|
||||
list.push(this.city);
|
||||
}
|
||||
if (this.county != null) {
|
||||
list.push(this.county);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.filterAreaByLevel(pcaTextArr, this.level);
|
||||
},
|
||||
methods: {
|
||||
filterAreaByDepth(areaList, targetDepth, currentDepth = 0, maxDepth = targetDepth + 1) {
|
||||
return areaList.reduce((filteredAreas, area) => {
|
||||
const depth = currentDepth + 1;
|
||||
|
||||
if (depth <= maxDepth) {
|
||||
filteredAreas.push(area); // 匹配当前深度或下一层深度,保留此区域
|
||||
|
||||
if (depth < maxDepth && Array.isArray(area.children) && area.children.length > 0) {
|
||||
// 当前节点不是最深节点,且有子节点,递归过滤子节点
|
||||
area.children = this.filterAreaByDepth(area.children, targetDepth, depth, maxDepth);
|
||||
} else {
|
||||
// 当前节点是最深节点或无子节点,清除其 children 属性
|
||||
delete area.children;
|
||||
}
|
||||
}
|
||||
|
||||
return filteredAreas;
|
||||
}, []);
|
||||
},
|
||||
// 将地区列表按照层级过滤出来,子列表:children
|
||||
// area地区列表,level层级
|
||||
filterAreaByLevel(area, level) {
|
||||
this.pcaTextArr = this.filterAreaByDepth(area, level);
|
||||
},
|
||||
onChange(val) {
|
||||
this.$emit('change', val);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
108
src/components/Map/PlaceSearch/PlaceSearchDialog.vue
Normal file
108
src/components/Map/PlaceSearch/PlaceSearchDialog.vue
Normal file
|
@ -0,0 +1,108 @@
|
|||
<template>
|
||||
<el-dialog :title="title" :visible="show" width="70%" top="2vh" @close="close" :append-to-body="true">
|
||||
<el-row v-if="selected != null" style="margin-bottom: 0.5em">
|
||||
当前选择: {{selected.address}}, {{selected.lng}}, {{selected.lat}}
|
||||
</el-row>
|
||||
|
||||
<place-search-map
|
||||
v-if="show"
|
||||
ref="map"
|
||||
height="800px"
|
||||
@select-changed="onSelectChange"
|
||||
@map-geo="onMapGeo"
|
||||
:init-lat="initLat"
|
||||
:init-lng="initLng"
|
||||
:enable-geo="true"
|
||||
:enable-geo-click="true"
|
||||
:enable-poi="true"
|
||||
:marker-type="markerType"
|
||||
/>
|
||||
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="onSubmit()">确定</el-button>
|
||||
<el-button @click="onCancel()">取消</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import PlaceSearchMap from '@/components/Map/PlaceSearch/PlaceSearchMap.vue'
|
||||
|
||||
export default {
|
||||
name: "PlaceSearchDialog",
|
||||
components: { PlaceSearchMap },
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
default: '选择定位'
|
||||
},
|
||||
show: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
initLng: {
|
||||
type: Number,
|
||||
default: 120.250452
|
||||
},
|
||||
initLat: {
|
||||
type: Number,
|
||||
default: 27.101745
|
||||
},
|
||||
markerType: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
selected: null,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onMapGeo(data, lat, lng) {
|
||||
console.log("onMapGeo", data)
|
||||
let component = data.regeocode.addressComponent;
|
||||
this.selected = {
|
||||
address: data.regeocode.formattedAddress,
|
||||
lng: lat,
|
||||
lat: lng,
|
||||
province: component.province,
|
||||
city: component.city === '' ? '市辖区' : component.city,
|
||||
county: component.district,
|
||||
name: component.street + component.streetNumber
|
||||
}
|
||||
},
|
||||
onSelectChange(addr) {
|
||||
console.log("onSelectChange", addr)
|
||||
let data = addr.selected.data;
|
||||
this.selected = {
|
||||
address: data.pname + (data.cityname === data.pname ? '' : data.cityname) + data.adname + data.address + data.name,
|
||||
lng: data.location.lng,
|
||||
lat: data.location.lat,
|
||||
province: data.pname,
|
||||
city: data.cityname === data.pname ? '市辖区' : data.cityname,
|
||||
county: data.adname,
|
||||
name: data.address + data.name,
|
||||
}
|
||||
},
|
||||
// 确定
|
||||
onSubmit() {
|
||||
this.$emit('submit', this.selected);
|
||||
this.close();
|
||||
},
|
||||
// 取消
|
||||
onCancel() {
|
||||
this.close();
|
||||
},
|
||||
// 关闭弹窗
|
||||
close() {
|
||||
this.selected = null;
|
||||
this.$emit('update:show', false);
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
297
src/components/Map/PlaceSearch/PlaceSearchMap.vue
Normal file
297
src/components/Map/PlaceSearch/PlaceSearchMap.vue
Normal file
|
@ -0,0 +1,297 @@
|
|||
<template>
|
||||
<div class="place-search-map" :style="{width: width, height: height}" v-loading="loading">
|
||||
<div id="container"></div>
|
||||
<el-row class="search-row" :gutter="8" type="flex" v-if="enablePoi">
|
||||
<el-col :span="6">
|
||||
<area-text-select
|
||||
:level="1"
|
||||
:province.sync="area.province"
|
||||
:city.sync="area.city"
|
||||
@change="onChangeArea"/>
|
||||
</el-col>
|
||||
<el-col :span="10">
|
||||
<el-input v-model="keyword" placeholder="请输入地址关键词" />
|
||||
</el-col>
|
||||
<el-col>
|
||||
<el-button type="primary" icon="el-icon-search" @click="doPlaceSearch(keyword)">搜索</el-button>
|
||||
<el-button @click="doSearchNearByCenter(keyword)" >周边搜索</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<div id="panel"></div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import AMapLoader from "@amap/amap-jsapi-loader";
|
||||
import globalConfig from '@/utils/config/globalConfig'
|
||||
import { debounce } from '@/utils'
|
||||
import AreaTextSelect from '@/components/AreaTextSelect/index.vue'
|
||||
import { makerFactory } from '@/utils/map'
|
||||
|
||||
export default {
|
||||
name: "PlaceSearchMap",
|
||||
components: { AreaTextSelect },
|
||||
props: {
|
||||
width: {
|
||||
type: String,
|
||||
default: "100%"
|
||||
},
|
||||
height: {
|
||||
type: String,
|
||||
default: "100%"
|
||||
},
|
||||
initLng: {
|
||||
type: Number,
|
||||
default: 120.250452
|
||||
},
|
||||
initLat: {
|
||||
type: Number,
|
||||
default: 27.101745
|
||||
},
|
||||
// 开启逆地理编码
|
||||
enableGeo: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
// 开启点击逆地理编码
|
||||
enableGeoClick: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
// 开启地址搜索
|
||||
enablePoi: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
// 图标类型
|
||||
markerType: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
// 默认地图中心点坐标
|
||||
defaultCenter: {
|
||||
type: Array,
|
||||
default: () => [120.250452, 27.101745]
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
AMap: null,
|
||||
map: null, // 地图实例
|
||||
placeSearch: null, // POI查询
|
||||
geocoder: null, // 逆地理编码
|
||||
loading: false,
|
||||
keyword: null,
|
||||
markers: [],
|
||||
area: {
|
||||
province: '福建省',
|
||||
city: '宁德市',
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.initAMap();
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.destroyMap();
|
||||
},
|
||||
methods: {
|
||||
destroyMap() {
|
||||
this.map?.destroy();
|
||||
},
|
||||
onChangeArea() {
|
||||
this.loadPlaceSearch(this.area.province, this.area.city);
|
||||
if (this.keyword != null) {
|
||||
this.doPlaceSearch(this.keyword);
|
||||
} else {
|
||||
let city = this.area.city === '市辖区' ? this.area.province : this.area.city;
|
||||
this.doPlaceSearch(city + '人民政府');
|
||||
}
|
||||
},
|
||||
initAMap() {
|
||||
AMapLoader.load({
|
||||
key: globalConfig.aMap.key, // 申请好的Web端开发者Key,首次调用 load 时必填
|
||||
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
|
||||
plugins: ["AMap.PlaceSearch"], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
|
||||
}).then((AMap) => {
|
||||
this.AMap = AMap;
|
||||
this.map = new AMap.Map("container", {
|
||||
// 设置地图容器id
|
||||
viewMode: "3D", // 是否为3D地图模式
|
||||
zoom: 16, // 初始化地图级别
|
||||
center: [this.initLng == null ? this.defaultCenter[0] : this.initLng, this.initLat == null ? this.defaultCenter[1] : this.initLat], // 初始化地图中心点位置
|
||||
});
|
||||
if (this.enableGeoClick) {
|
||||
this.map.on('click', this.onClickMap);
|
||||
}
|
||||
|
||||
// POI
|
||||
if (this.enablePoi) {
|
||||
this.loadPlaceSearch(this.area.province, this.area.city);
|
||||
}
|
||||
|
||||
// 逆地理编码
|
||||
if (this.enableGeo) {
|
||||
this.loadGeoCoder();
|
||||
}
|
||||
|
||||
// 加载初始地址
|
||||
this.initMarker();
|
||||
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
},
|
||||
getMarker(lng, lat) {
|
||||
return makerFactory.createMaker(lng, lat, this.markerType);
|
||||
},
|
||||
async initMarker() {
|
||||
this.removeAllMarker();
|
||||
if (this.initLng != null && this.initLat != null) {
|
||||
this.addMarker(this.initLng, this.initLat);
|
||||
this.getGeoAddress(this.initLng, this.initLat).then(res => {
|
||||
// 标点
|
||||
this.$emit('map-geo', res, this.initLng, this.initLat);
|
||||
// 地区
|
||||
let component = res.regeocode.addressComponent;
|
||||
this.area = {
|
||||
province: component.province,
|
||||
city: component.city === '' ? '市辖区' : component.city,
|
||||
}
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
})
|
||||
}
|
||||
},
|
||||
addMarker(lng, lat) {
|
||||
let marker = this.getMarker(lng, lat);
|
||||
this.map.add(marker);
|
||||
this.markers.push(marker);
|
||||
},
|
||||
// 删除所有的标记点
|
||||
removeAllMarker() {
|
||||
this.map.remove(this.markers);
|
||||
this.markers = [];
|
||||
},
|
||||
// 点击地图事件
|
||||
onClickMap(e) {
|
||||
console.log('clickMap', e);
|
||||
let lng = e.lnglat.lng;
|
||||
let lat = e.lnglat.lat;
|
||||
this.changeMarker(lng, lat);
|
||||
},
|
||||
// 逆地理编码,并标点
|
||||
changeMarker(lng, lat) {
|
||||
this.loading = true;
|
||||
this.getGeoAddress(lng, lat).then(res => {
|
||||
this.removeAllMarker();
|
||||
this.addMarker(lng, lat);
|
||||
this.$emit('map-geo', res, lng, lat);
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
})
|
||||
},
|
||||
// 获取逆地理编码
|
||||
getGeoAddress(lng, lat) {
|
||||
return new Promise((resolve, reject) =>{
|
||||
this.geocoder.getAddress([lng, lat], (status, result) => {
|
||||
if (status === 'complete' && result.info === 'OK') {
|
||||
resolve(result);
|
||||
} else {
|
||||
reject(status);
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
// 加载逆地理编码
|
||||
loadGeoCoder() {
|
||||
AMap.plugin('AMap.Geocoder', () => {
|
||||
this.geocoder = new AMap.Geocoder({
|
||||
city: '全国' // city 指定进行编码查询的城市,支持传入城市名、adcode 和 citycode
|
||||
})
|
||||
})
|
||||
},
|
||||
// 加载POI
|
||||
loadPlaceSearch(province, city) {
|
||||
if (city == null) {
|
||||
city = '北京市';
|
||||
}
|
||||
if (city === '市辖区') {
|
||||
city = province;
|
||||
}
|
||||
AMap.plugin(["AMap.PlaceSearch"], () => {
|
||||
//构造地点查询类
|
||||
this.placeSearch = new AMap.PlaceSearch({
|
||||
pageSize: 5, // 单页显示结果条数
|
||||
pageIndex: 1, // 页码
|
||||
city: city, // 兴趣点城市
|
||||
citylimit: true, //是否强制限制在设置的城市内搜索
|
||||
map: this.map, // 展现结果的地图实例
|
||||
panel: "panel", // 结果列表将在此容器中进行展示。
|
||||
autoFitView: true, // 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围
|
||||
});
|
||||
});
|
||||
// 事件绑定
|
||||
this.placeSearch.on('selectChanged', (data) => {
|
||||
this.$emit('select-changed', data);
|
||||
})
|
||||
},
|
||||
//关键字查询
|
||||
doPlaceSearch(keyword) {
|
||||
if (keyword == null) {
|
||||
return this.$message.warning("请输入关键词");
|
||||
}
|
||||
this.loading = true;
|
||||
this.placeSearch.search(keyword, (status, result) => {
|
||||
this.loading = false;
|
||||
console.log("POI", status, result);
|
||||
});
|
||||
},
|
||||
// 周边搜索
|
||||
doSearchNearBy(keyword, lng, lat, radius = 200) {
|
||||
if (keyword == null) {
|
||||
return this.$message.warning("请输入关键词");
|
||||
}
|
||||
this.loading = true;
|
||||
this.placeSearch.searchNearBy(keyword, [lng, lat], radius, (status, result) => {
|
||||
this.loading = false;
|
||||
console.log("POI NearBy", status, result);
|
||||
})
|
||||
},
|
||||
// 根据地图中心点查询周边
|
||||
doSearchNearByCenter(keyword) {
|
||||
let center = this.map.getCenter();
|
||||
this.doSearchNearBy(keyword, center.lng, center.lat, 1000);
|
||||
},
|
||||
// 监听输入事件
|
||||
onInputSearch: debounce(function () {
|
||||
this.doPlaceSearch(this.keyword)
|
||||
}, 600)
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.place-search-map {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
.search-row {
|
||||
margin: 0.5em;
|
||||
}
|
||||
#container {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
#panel {
|
||||
position: absolute;
|
||||
background-color: white;
|
||||
max-height: 90%;
|
||||
overflow-y: auto;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
width: 280px;
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -43,6 +43,7 @@ import DictData from '@/components/DictData';
|
|||
import filter from '@/utils/filter';
|
||||
// 行内表单组件
|
||||
import FormCol from '@/components/FormCol';
|
||||
import globalConfig from "@/utils/config/globalConfig";
|
||||
|
||||
filter(Vue);
|
||||
|
||||
|
@ -214,3 +215,8 @@ Vue.directive('tableMove', {
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
// 高德地图
|
||||
window._AMapSecurityConfig = {
|
||||
securityJsCode: globalConfig.aMap.secret,
|
||||
};
|
||||
|
|
59
src/utils/map.js
Normal file
59
src/utils/map.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
|
||||
|
||||
/**
|
||||
* 创建并获取一个点标记
|
||||
* @param lng 经度
|
||||
* @param lat 纬度
|
||||
* @param icon 图片路径
|
||||
* @param offset 偏移量
|
||||
*/
|
||||
export function createMaker(lng, lat, icon = null, offset = null, size = null) {
|
||||
let option = {
|
||||
position: [lng, lat],
|
||||
}
|
||||
if (icon != null) {
|
||||
option.icon = icon;
|
||||
}
|
||||
if (offset != null) {
|
||||
option.offset = new AMap.Pixel(offset[0], offset[1]);
|
||||
}
|
||||
if (size != null) {
|
||||
option.size = new AMap.Size(size[0], size[1]);
|
||||
}
|
||||
return new AMap.Marker(option);
|
||||
}
|
||||
|
||||
|
||||
export function createIcon(image, size, imageSize, offset) {
|
||||
// 创建一个 icon
|
||||
return new AMap.Icon({
|
||||
size: new AMap.Size(size[0], size[1]),
|
||||
image: '//a.amap.com/jsapi_demos/static/demo-center/icons/dir-marker.png',
|
||||
imageSize: new AMap.Size(imageSize[0], imageSize[1]),
|
||||
imageOffset: new AMap.Pixel(offset[0], offset[1])
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 点标记工厂
|
||||
* 用于创造各种类型的点标记
|
||||
*/
|
||||
export const makerFactory = {
|
||||
/// 创建指定类型点标记
|
||||
createMaker(lng, lat, type) {
|
||||
switch(type) {
|
||||
case 'store': return this.createStoreMaker(lng, lat);
|
||||
default: return createMaker(lng, lat);
|
||||
}
|
||||
},
|
||||
// 创建店铺点标记
|
||||
createStoreMaker(lng, lat) {
|
||||
let icon = new AMap.Icon({
|
||||
size: new AMap.Size(36, 43),
|
||||
image: 'https://api.ccttiot.com/Fofy3sTm5cYkYGcQDCFsMzcxkcF8',
|
||||
imageSize: new AMap.Size(36, 43),
|
||||
imageOffset: new AMap.Pixel(0, 0)
|
||||
});
|
||||
return createMaker(lng, lat, icon, [-18, -43]);
|
||||
}
|
||||
}
|
344
src/views/bst/floor/index.vue
Normal file
344
src/views/bst/floor/index.vue
Normal file
|
@ -0,0 +1,344 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="所属店铺" prop="storeName">
|
||||
<el-input
|
||||
v-model="queryParams.storeName"
|
||||
placeholder="请输入所属店铺"
|
||||
clearable
|
||||
@change="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="楼层名称" prop="floorName">
|
||||
<el-input
|
||||
v-model="queryParams.floorName"
|
||||
placeholder="请输入楼层名称"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-has-permi="['bst:floor:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-has-permi="['bst:floor:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-has-permi="['bst:floor:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="floorList" @selection-change="handleSelectionChange" :default-sort="defaultSort" @sort-change="onSortChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<template v-for="column of showColumns">
|
||||
<el-table-column
|
||||
:key="column.key"
|
||||
:label="column.label"
|
||||
:prop="column.key"
|
||||
:align="column.align"
|
||||
:min-width="column.minWidth"
|
||||
:sort-orders="orderSorts"
|
||||
:sortable="column.sortable"
|
||||
:show-overflow-tooltip="column.overflow"
|
||||
:width="column.width"
|
||||
>
|
||||
</el-table-column>
|
||||
</template>
|
||||
<!-- <el-table-column label="楼层ID" align="center" prop="partId" />-->
|
||||
<el-table-column label="楼层名称" align="center" prop="floorName" />
|
||||
<el-table-column label="楼层图片" align="center" prop="picture" >
|
||||
<image-preview slot-scope="d" :src="d.row.picture" :width="50" :height="50"/>
|
||||
</el-table-column>
|
||||
<el-table-column label="所属店铺" align="center" prop="storeName" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-has-permi="['bst:floor:edit']"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-has-permi="['bst:floor:remove']"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改楼层列表对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body :close-on-click-modal="false">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-row>
|
||||
<el-form-item label="选择店铺" prop="storeId">
|
||||
<el-select
|
||||
v-model="form.storeId"
|
||||
placeholder="请选择店铺"
|
||||
clearable
|
||||
filterable
|
||||
:loading="loading"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in storeOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<form-col :span="span" label="楼层名称" prop="floorName">
|
||||
<el-input v-model="form.floorName" placeholder="请输入楼层名称" />
|
||||
</form-col>
|
||||
<form-col :span="span" label="楼层图片" prop="picture">
|
||||
<image-upload v-model="form.picture"/>
|
||||
</form-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listFloor, getFloor, delFloor, addFloor, updateFloor } from "@/api/bst/floor";
|
||||
import { $showColumns } from '@/utils/mixins';
|
||||
import FormCol from "@/components/FormCol/index.vue";
|
||||
import {listStore} from "@/api/bst/store";
|
||||
|
||||
// 默认排序字段
|
||||
const defaultSort = {
|
||||
prop: "createTime",
|
||||
order: "descending"
|
||||
}
|
||||
|
||||
export default {
|
||||
name: "Floor",
|
||||
mixins: [$showColumns],
|
||||
components: {FormCol},
|
||||
data() {
|
||||
return {
|
||||
span: 24,
|
||||
// 字段列表
|
||||
columns: [
|
||||
// {key: 'floorId', visible: true, label: '楼层ID', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
|
||||
// {key: 'storeId', visible: true, label: '店铺ID', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
|
||||
// {key: 'floorName', visible: true, label: '楼层名称', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
|
||||
// {key: 'picture', visible: true, label: '楼层图片', minWidth: null, sortable: true, overflow: false, align: 'center', width: null},
|
||||
],
|
||||
// 排序方式
|
||||
orderSorts: ['ascending', 'descending', null],
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 楼层列表表格数据
|
||||
floorList: [],
|
||||
// 店铺选项
|
||||
storeOptions: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
defaultSort,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
orderByColumn: defaultSort.prop,
|
||||
isAsc: defaultSort.order,
|
||||
storeId: null,
|
||||
floorName: null,
|
||||
picture: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
createTime: [
|
||||
{ required: true, message: "创建时间不能为空", trigger: "blur" }
|
||||
],
|
||||
storeId: [
|
||||
{ required: true, message: "所属店铺不能为空", trigger: "blur" }
|
||||
],
|
||||
floorName: [
|
||||
{ required: true, message: "楼层名称不能为空", trigger: "blur" }
|
||||
],
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getStoreList();
|
||||
},
|
||||
methods: {
|
||||
/** 当排序按钮被点击时触发 **/
|
||||
onSortChange(column) {
|
||||
if (column.order == null) {
|
||||
this.queryParams.orderByColumn = defaultSort.prop;
|
||||
this.queryParams.isAsc = defaultSort.order;
|
||||
} else {
|
||||
this.queryParams.orderByColumn = column.prop;
|
||||
this.queryParams.isAsc = column.order;
|
||||
}
|
||||
this.getList();
|
||||
},
|
||||
/** 查询楼层列表列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listFloor(this.queryParams).then(response => {
|
||||
this.floorList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 查询店铺列表 */
|
||||
getStoreList() {
|
||||
this.loading = true;
|
||||
listStore().then(response => {
|
||||
this.storeOptions = (response.rows || []).map(item => ({
|
||||
value: item.storeId,
|
||||
label: item.storeName
|
||||
}))
|
||||
this.loading = false
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
floorId: null,
|
||||
storeId: null,
|
||||
floorName: null,
|
||||
picture: null,
|
||||
createTime: null
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.floorId)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加楼层列表";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const floorId = row.floorId || this.ids
|
||||
getFloor(floorId).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改楼层列表";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.floorId != null) {
|
||||
updateFloor(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addFloor(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const floorIds = row.floorId || this.ids;
|
||||
this.$modal.confirm('是否确认删除楼层列表编号为"' + floorIds + '"的数据项?').then(function() {
|
||||
return delFloor(floorIds);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('bst/floor/export', {
|
||||
...this.queryParams
|
||||
}, `floor_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -224,8 +224,8 @@
|
|||
|
||||
<place-search-dialog
|
||||
:show.sync="showPlaceSearchMap"
|
||||
:init-lat="form.lat"
|
||||
:init-lng="form.lng"
|
||||
:init-lat="form.latitude"
|
||||
:init-lng="form.longitude"
|
||||
@submit="onSubmitAddress"
|
||||
marker-type="store"
|
||||
/>
|
||||
|
@ -343,8 +343,8 @@ export default {
|
|||
methods: {
|
||||
onSubmitAddress(addr) {
|
||||
this.form.address = addr.name;
|
||||
this.form.lat = addr.lat;
|
||||
this.form.lng = addr.lng;
|
||||
this.form.latitude = addr.lat;
|
||||
this.form.longitude = addr.lng;
|
||||
this.form.province = addr.province;
|
||||
this.form.city = addr.city;
|
||||
this.form.county = addr.county;
|
||||
|
|
Loading…
Reference in New Issue
Block a user