店铺相关模块完善

This commit is contained in:
SjS 2025-04-23 10:51:53 +08:00
parent baaae1cbce
commit b5546c748f
9 changed files with 970 additions and 4 deletions

View File

@ -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
View 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'
})
}

View 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
// arealevel
filterAreaByLevel(area, level) {
this.pcaTextArr = this.filterAreaByDepth(area, level);
},
onChange(val) {
this.$emit('change', val);
}
}
}
</script>
<style scoped>
</style>

View 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>

View 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, // WebKey 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>

View File

@ -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
View 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]);
}
}

View 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>

View File

@ -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;