518 lines
11 KiB
Vue
Raw Normal View History

2025-04-29 16:36:51 +08:00
<template>
2025-05-13 09:22:55 +08:00
<div style="width: 100vw;">
<scroll-view class="divForm" :style="{height}" scroll-y show-scrollbar>
<uni-forms ref="formRef" :model="formData" :label-width="80">
<uni-forms-item label="站点名称" name="name" required :rules="[{'required': true,errorMessage: '请填写站点名称'}]">
<uni-easyinput v-model="formData.name" />
</uni-forms-item>
2025-05-22 17:36:59 +08:00
<uni-forms-item label="站点类型:" name="zdlx" required
:rules="[{'required': true,errorMessage: '请选择站点类型'}]">
2025-05-13 09:22:55 +08:00
<uni-data-select v-model="formData.zdlx" :localdata="arrZDLX" />
2025-05-22 17:36:59 +08:00
2025-05-13 09:22:55 +08:00
</uni-forms-item>
2025-05-22 17:36:59 +08:00
<uni-forms-item label="站点级别:" name="zdjb" required
:rules="[{'required': true,errorMessage: '请选择站点级别'}]">
2025-05-13 09:22:55 +08:00
<div class="divRow">
<uni-data-checkbox v-model="formData.zdjb" :localdata="arrZDJB" />
</div>
</uni-forms-item>
<!-- <uni-forms-item label="调度投放:" name="ddtf" required :rules="[{'required': true,errorMessage: '请选择调度投放'}]">
<div class="divRow">
<uni-data-checkbox v-model="formData.ddtf" :localdata="arrDDTF" />
</div>
</uni-forms-item>
<uni-forms-item label="用户端显示:" name="zdxs" required :rules="[{'required': true,errorMessage: '请选择用户端显示'}]">
<div class="divRow">
<uni-data-checkbox v-model="formData.zdxs" :localdata="arrZDXS" />
<label style="margin-left: 10px;" @click="showTip('开启后在用户端小程序地图上不会显示站点,但不影响用户在该站点范围内还车')">
<uni-icons type="info" size="20" color="#5892E3" /></label>
</div>
</uni-forms-item>-->
2025-05-22 17:36:59 +08:00
<uni-forms-item label="可停车辆:" name="ktcl" required
:rules="[{'required': true,errorMessage: '请填写可停车辆'}]">
2025-05-13 09:22:55 +08:00
<div class="divRow">
<uni-easyinput v-model="formData.ktcl" />
<label></label>
</div>
</uni-forms-item>
2025-05-22 17:36:59 +08:00
<uni-forms-item label="最大可停:" name="zdkt" required
:rules="[{'required': true,errorMessage: '请填写最大可停'}]">
2025-05-13 09:22:55 +08:00
<div class="divRow">
<uni-easyinput v-model="formData.zdkt" />
<label></label>
</div>
</uni-forms-item>
<!-- <uni-forms-item label="还车半径:">
<div class="divRow">
<uni-easyinput v-model="formData.hcbj" />
<label></label>
</div>
</uni-forms-item> -->
<uni-forms-item label="站点图片:">
<div>
<div class="divFontColor" style="margin: 10px 0px;">最多3张</div>
2025-05-22 17:36:59 +08:00
<uni-file-picker file-mediatype="image" mode="grid" file-extname="png,jpg" :limit="3"
:value="filevalue" @select="uploadfile" @delete="delfile" />
2025-05-13 09:22:55 +08:00
</div>
</uni-forms-item>
<uni-forms-item label="站点描述:">
<uni-easyinput type="textarea" v-model="formData.zdms" />
</uni-forms-item>
<!-- <uni-forms-item label="站点标签:">
<uni-data-checkbox mode="button" multiple v-model="formData.zdbq" :localdata="arrZDBQ" />
</uni-forms-item> -->
</uni-forms>
2025-05-22 17:36:59 +08:00
2025-05-13 09:22:55 +08:00
</scroll-view>
<div class="divBottom">
<div class="b-btn-white divtBtn" v-if="opentype=='edit'" @click="openMap">重新绘制</div>
<div class="b-btn-white divtBtn" v-if="opentype=='add'" @click="openMap">返回绘制</div>
<div class="b-btn-blue divtBtn" style="margin-left: 10px;" @click="SaveData">确认{{opentype=='add'?"新建":"保存"}}
</div>
2025-05-07 16:06:02 +08:00
</div>
2025-04-29 16:36:51 +08:00
</div>
2025-05-22 17:36:59 +08:00
2025-04-29 16:36:51 +08:00
</template>
<script setup>
import {
onLoad
} from "@dcloudio/uni-app";
import {
showModelMessage,
getScreenHeightNoTabBar
} from "@/utils/tools.js";
import {
ref
} from "vue";
import * as map from "@/utils/map.js";
2025-05-22 17:36:59 +08:00
import AMapWX from "@/utils/amap-wx.130.js";
2025-05-07 16:06:02 +08:00
import {
2025-05-09 09:21:05 +08:00
callOperateApi,
fileUploadApi
2025-05-07 16:06:02 +08:00
} from "../../../utils/api";
2025-05-13 09:22:55 +08:00
import config from "../../../utils/config";
2025-05-22 17:36:59 +08:00
import {
findIndex,
lastIndexOf
} from "lodash";
2025-04-29 16:36:51 +08:00
2025-05-22 17:36:59 +08:00
var qqmapsdk = new AMapWX({
2025-04-29 16:36:51 +08:00
key: map.sdkKey
});
const formRef = ref("formRef");
let height = ref("100%");
const opentype = ref("add");
2025-05-09 09:21:05 +08:00
const arrZDLX = ref([]);
2025-04-29 16:36:51 +08:00
2025-05-09 09:21:05 +08:00
const arrZDJB = ref([]);
2025-04-29 16:36:51 +08:00
2025-05-09 09:21:05 +08:00
/* const arrDDTF = ref([{
2025-04-29 16:36:51 +08:00
text: "开启",
value: 1
}, {
text: "关闭",
value: 2
}]);
const arrZDXS = ref([{
text: "隐藏",
value: 1
}, {
text: "显示",
value: 2
}]);
const arrZDBQ = ref([{
text: "早高峰",
value: 1
}, {
text: "午高峰",
value: 2
}, {
text: "晚高峰",
value: 2
2025-05-09 09:21:05 +08:00
}]); */
2025-04-29 16:36:51 +08:00
let arrPoint = [];
let radius = null;
2025-05-07 16:06:02 +08:00
let regionid = null;
2025-05-09 09:21:05 +08:00
let arrFile = [];
2025-05-22 17:36:59 +08:00
const filevalue = ref([]);
2025-04-29 16:36:51 +08:00
const formData = ref({
2025-05-22 17:36:59 +08:00
id: "",
2025-05-13 09:22:55 +08:00
name: "",
2025-05-07 16:06:02 +08:00
address: "",
2025-04-29 16:36:51 +08:00
zdlx: 1,
zdjb: 1,
ktcl: 10,
zdkt: 20,
hcbj: 10,
2025-05-07 16:06:02 +08:00
zdms: "",
2025-04-29 16:36:51 +08:00
zdbq: [1],
zdtf: 1,
zdxs: 1
});
function openMap() {
const type = opentype.value;
if (type == "add") {
uni.navigateBack();
return;
}
if (type == "edit") {
const id = formData.value.id;
2025-05-13 09:22:55 +08:00
const points = JSON.stringify(arrPoint);
2025-04-29 16:36:51 +08:00
uni.navigateTo({
url: `/pages/map/map-bikesite?type=edit&id=${id}&points=${points}&k=${Date.now()}`
})
}
}
function SaveData() {
2025-05-07 16:06:02 +08:00
formRef.value.validate().then(res => {
const {
name,
zdlx,
zdjb,
ktcl,
zdkt,
2025-05-09 09:21:05 +08:00
zdms
2025-05-07 16:06:02 +08:00
} = res;
2025-05-09 09:21:05 +08:00
const {
2025-05-22 17:36:59 +08:00
id,
address
2025-05-09 09:21:05 +08:00
} = formData.value;
2025-05-07 16:06:02 +08:00
let shapeType = 2;
let points = null;
let siteLng = null;
let siteLat = null;
let r = null;
if (arrPoint.length == 1) {
shapeType = 1;
siteLng = arrPoint[0].longitude;
siteLat = arrPoint[0].latitude;
r = radius;
} else {
points = arrPoint;
}
const params = {
2025-05-22 17:36:59 +08:00
siteRegionId: id,
2025-05-07 16:06:02 +08:00
operationRegionId: regionid,
siteName: name,
siteAdress: address,
siteType: zdlx,
siteLevel: zdjb,
allowedParkingNum: ktcl,
allowedParkingMax: zdkt,
radius: r,
shapeType,
points,
siteLng,
2025-05-09 09:21:05 +08:00
siteLat,
2025-05-22 17:36:59 +08:00
imageIds: arrFile,
describe: zdms
2025-05-07 16:06:02 +08:00
}
2025-05-22 17:36:59 +08:00
let url = "ebikeRegion/saveSite"
if (opentype.value == "edit") {
url = "ebikeRegion/updateSite";
2025-05-13 09:22:55 +08:00
}
callOperateApi(url, params, "post").then(res => {
2025-05-09 09:21:05 +08:00
console.log("1111111111111111111", "/ebikeRegion/saveSite", params, res);
2025-05-07 16:06:02 +08:00
const {
code,
data,
message
} = res;
if (code != 200) {
2025-05-09 09:21:05 +08:00
showModelMessage("保存失败!");
console.log("ebikeRegion/saveSite", message);
2025-05-07 16:06:02 +08:00
return;
} else {
showModelMessage("保存成功!");
2025-05-13 09:22:55 +08:00
uni.reLaunch({
2025-05-07 16:06:02 +08:00
url: "/pages/devops/bikesite/bikesite-list"
})
}
})
2025-04-29 16:36:51 +08:00
})
}
function showTip(title) {
showModelMessage(title);
}
2025-05-09 09:21:05 +08:00
//站点类型
function getZDLX() {
callOperateApi("ebikeRegion/siteType", null, "get").then(res => {
const {
code,
data,
message
} = res;
if (code != 200) {
console.log("ebikeRegion/siteType", message)
}
const arrData = [];
data.map(item => {
const {
siteTypeName,
siteTypeValue
} = item;
arrData.push({
text: siteTypeName,
value: siteTypeValue
})
})
arrZDLX.value = arrData;
})
}
//站点级别
2025-05-22 17:36:59 +08:00
function getZDJB() {
callOperateApi("ebikeRegion/siteLevelList", null, "get").then(res => {
2025-05-09 09:21:05 +08:00
const {
code,
data,
message
} = res;
if (code != 200) {
console.log("ebikeRegion/siteLevelList", message)
}
const arrData = [];
data.map(item => {
const {
levelName,
levelValue
} = item;
arrData.push({
text: levelName,
value: levelValue
})
})
arrZDJB.value = arrData;
});
2025-05-22 17:36:59 +08:00
2025-05-09 09:21:05 +08:00
}
2025-05-22 17:36:59 +08:00
2025-05-09 09:21:05 +08:00
function uploadfile(e) {
fileUploadApi("operate/ebikeRegion/siteImagesUpload", e.tempFiles[0]).then(res => {
const {
code,
message,
data
} = res;
if (code != 200) {
console.log("uploadfile", message);
showModelMessage("上传失败!")
}
arrFile.push(data);
})
}
function delfile(e) {
2025-05-22 17:36:59 +08:00
const {
index
} = e;
arrFile.splice(index, 1);
2025-05-09 09:21:05 +08:00
console.log("99999999999999999999999", e);
}
2025-05-22 17:36:59 +08:00
function getSiteInfo(id) {
const params = {
siteRegionId: id
2025-05-09 09:21:05 +08:00
}
2025-05-22 17:36:59 +08:00
callOperateApi("ebikeRegion/siteInfo", params, "get").then(res => {
const {
code,
data,
message
} = res;
if (code != 200) {
2025-05-09 09:21:05 +08:00
showModelMessage("获取数据失败!");
2025-05-22 17:36:59 +08:00
console.log("ebikeRegion/siteInfo", message);
2025-05-09 09:21:05 +08:00
}
2025-05-22 17:36:59 +08:00
const {
siteRegionId: id,
operationRegionId,
siteName,
siteAdress,
siteType,
siteLevel,
siteLng,
siteLat,
shapeType,
radius: r,
points,
allowedParkingNum,
allowedParkingMax,
describe,
images = []
} = data;
regionid = operationRegionId;
radius = r;
const arrFileData = [];
images.map(item => {
const {
imageId,
imageBucket,
imageName
} = item;
const extname = imageName.substring(lastIndexOf(imageName, ".") + 1);
const obj = {
url: `${config.filePath}/${imageBucket}/${imageName}`,
name: imageName,
2025-05-13 09:22:55 +08:00
extname
}
arrFileData.push(obj);
arrFile.push(imageId);
});
2025-05-22 17:36:59 +08:00
if (arrPoint.length == 0) {
if (shapeType == "2") {
arrPoint = points;
} else {
arrPoint = [{
longitude: siteLng,
latitude: siteLat
}]
2025-05-13 09:22:55 +08:00
}
2025-05-09 09:21:05 +08:00
}
2025-05-22 17:36:59 +08:00
filevalue.value = arrFileData;
formData.value = {
2025-05-09 09:21:05 +08:00
id,
2025-05-22 17:36:59 +08:00
name: siteName,
address: siteAdress,
zdlx: siteType,
zdjb: siteLevel,
ktcl: allowedParkingNum,
2025-05-09 09:21:05 +08:00
zdkt: allowedParkingMax,
//hcbj: 10,
zdms: describe,
//zdbq: [1],
// zdtf: 1,
// zdxs: 1
}
2025-05-22 17:36:59 +08:00
2025-05-09 09:21:05 +08:00
})
}
2025-04-29 16:36:51 +08:00
onLoad(options => {
const {
id,
points,
radius: r,
2025-05-07 16:06:02 +08:00
type,
regionid: rid
2025-04-29 16:36:51 +08:00
} = options;
2025-05-07 16:06:02 +08:00
console.log("111111111111111111111", options)
2025-04-29 16:36:51 +08:00
opentype.value = type;
2025-05-07 16:06:02 +08:00
regionid = rid;
2025-04-29 16:36:51 +08:00
let title = "";
switch (type) {
case "add":
title = "新建站点";
break;
case "edit":
title = "编辑站点";
break;
}
uni.setNavigationBarTitle({
title
});
getScreenHeightNoTabBar(res => {
height.value = (res - 60) + "px";
});
2025-05-22 17:36:59 +08:00
arrPoint = [];
2025-04-29 16:36:51 +08:00
if (points) {
2025-05-22 17:36:59 +08:00
2025-04-29 16:36:51 +08:00
arrPoint = JSON.parse(points);
radius = r;
const {
latitude,
longitude
} = arrPoint[0];
if (type == "add") {
map.reverseGeocoder(qqmapsdk, longitude, latitude, (res) => {
const {
2025-05-22 17:36:59 +08:00
name,
formatted_address,
adcode,
province,
city,
district
2025-04-29 16:36:51 +08:00
} = res;
2025-05-22 17:36:59 +08:00
// const {
// address,
// formatted_addresses: {
// recommend
// }
// } = res;
2025-05-07 16:06:02 +08:00
formData.value = {
...formData.value,
2025-05-22 17:36:59 +08:00
name: name,
address: formatted_address
2025-05-07 16:06:02 +08:00
}
2025-04-29 16:36:51 +08:00
}, (res) => {
console.log("fail", res);
})
}
}
2025-05-22 17:36:59 +08:00
if (arrZDLX.value.length == 0) {
2025-05-09 09:21:05 +08:00
getZDLX();
}
2025-05-22 17:36:59 +08:00
if (arrZDJB.value.length == 0) {
2025-05-09 09:21:05 +08:00
getZDJB();
}
2025-05-22 17:36:59 +08:00
if (id) {
2025-05-09 09:21:05 +08:00
getSiteInfo(id);
}
2025-04-29 16:36:51 +08:00
});
</script>
<style scoped>
.divForm {
width: 100vw;
2025-05-07 16:06:02 +08:00
padding: 10px 20px 10px 15px;
2025-04-29 16:36:51 +08:00
}
2025-04-29 18:34:06 +08:00
/* .divForm /deep/ .uni-forms-item {
2025-04-29 16:36:51 +08:00
margin-bottom: 10px !important;
2025-04-29 18:34:06 +08:00
} */
2025-04-29 16:36:51 +08:00
.divFontColor {
color: #606266;
}
.divRow {
display: flex;
align-items: center;
font-size: 14px;
color: #606266;
height: 36px;
}
.divRow label {
margin-left: 10px;
}
.divBottom {
position: absolute;
2025-04-29 18:34:06 +08:00
bottom: 10px;
2025-04-29 16:36:51 +08:00
background-color: white;
padding: 10px;
display: flex;
justify-content: space-evenly;
width: 100vw;
}
.divBottom .divtBtn {
width: 100vw;
text-align: center;
}
</style>