This commit is contained in:
小小 2025-04-24 13:54:48 +08:00
commit f414712b37
17 changed files with 891 additions and 149 deletions

View File

@ -357,6 +357,14 @@
"navigationBarTitleText": "审核用户报障"
}
}]
}, {
"root": "pages/warehouse/vehicledispatch",
"pages": [{
"path": "vehicledispatch",
"style": {
"navigationBarTitleText": "车辆调度"
}
}]
}
],

View File

@ -45,7 +45,8 @@
const data = ref({
site: "",
reason: ""
reason: "",
zoneName:""
});
let oUser = null;
@ -77,11 +78,15 @@
location: {
lat,
lng
},
ad_info:{
district
}
} = res;
data.value = {
...data.value,
site: address,
zoneName: district,
lat,
lng
};
@ -104,7 +109,8 @@
site,
reason,
lat,
lng
lng,
zoneName
} = data.value;
if(!reason){
showModelMessage("请填写原因!");
@ -125,7 +131,8 @@
applyNickname: nickname,
applyPhone: mobile,
applyReason: reason,
dealState: '0'
dealState: '0',
zoneName
}
uni.showLoading({
title:"提交中"

View File

@ -192,11 +192,11 @@
const statusBarHeight = systemInfo.statusBarHeight;
//
usableHeight.value = screenHeight - statusBarHeight - 170;
let userZone = uni.getStorageSync('userZone');
userZone.forEach(res => {
let userOperation = uni.getStorageSync('userOperation');
userOperation.forEach(res => {
let quyuemap = {
"text": res.name,
"value": res.id
"text": res.regionName,
"value": res.regionId
};
regindata.value.push(quyuemap);
});
@ -240,7 +240,7 @@
const params = {
"bikeCode": customFormData.value.deviceValues, //
"status": statusZT.value, // 2025-03-21
"regionId":customFormData.reginvalue
"reginId":customFormData.value.reginvalue
}
api.callEbikeInfo("vehicleLeaveWarehouse", params).then((res) => {
if (res.code == 200) {

View File

@ -83,7 +83,7 @@
<view class="popup-content" :class="{ 'popup-height': typepopup === 'left' || typepopup === 'right' }">
<view class="padding plcrk">
<uni-forms ref="customForm" :rules="customRules" :modelValue="customFormData">
<uni-section title="站点" type="line">
<uni-section v-if="statusZT==2" title="站点" type="line">
<uni-forms-item required name="reginvalue">
<uni-data-select v-model="customFormData.reginvalue" :localdata="regindata"
@change="changeZT"></uni-data-select>
@ -189,19 +189,20 @@
// getUserRegionInfo();
let userDefultOperation = uni.getStorageSync('userDefultOperation');
//
api.callOperateApi("ebikeRegion/getRegion?regionId="+userDefultOperation.regionId,{} ,"get").then(res=>{
if(res.code==200){
res.data.forEach(res => {
let quyuemap = {
"text": res.regionName,
"value": res.regionId
};
regindata.value.push(quyuemap);
});
}
})
api.callOperateApi("ebikeRegion/getRegion?regionId=" + userDefultOperation.regionId, {}, "get").then(
res => {
if (res.code == 200) {
res.data.forEach(res => {
let quyuemap = {
"text": res.regionName,
"value": res.regionId
};
regindata.value.push(quyuemap);
});
}
})
});
const getUserRegionInfo = () => {
@ -243,37 +244,78 @@
});
};
const submit = (ref) => {
customForm.value.validate().then(res => {
const params = {
"bikeCode": customFormData.value.deviceValues, //
"status": statusZT.value, // 2025-03-21
}
api.callEbikeInfo("vehicleLeaveWarehouse", params).then((res) => {
if (res.code == 200) {
popup.value.close("center")
uni.showToast({
title: '操作成功',
icon: 'success',
duration: 2000
});
searchInfo();
} else {
uni.showToast({
title: '操作失败',
icon: 'error',
duration: 2000
});
}
if (statusZT.value == 0) { //
handleLeaveWarehouse();
} else { //
uni.navigateTo({
url:"/pages/warehouse/vehicledispatch/vehicledispatch?orderId=272553556257517568"
})
// handleLaunch();
}
}).catch(err => {
console.log('err', err);
});
}
//
const handleLeaveWarehouse = () => {
const params = {
"bikeCode": customFormData.value.deviceValues, //
"status": statusZT.value,
"reginId": ""
}
api.callEbikeInfo("vehicleLeaveWarehouse", params).then((res) => {
if (res.code == 200) {
popup.value.close("center");
uni.showToast({
title: '操作成功',
icon: 'success',
duration: 2000
});
searchInfo();
} else {
uni.showToast({
title: '操作失败',
icon: 'error',
duration: 2000
});
}
})
}
//
const handleLaunch = () => {
//
console.log('投放逻辑执行');
const params={
"bikeCodes": customFormData.value.deviceValues, //
"status": statusZT.value,
"siteId": customFormData.value.reginvalue,
"DispatchType":"仓库车调度"
}
// API
api.callEbikeInfo("createWorkOrderDispatch",params).then((res) => {
if (res.code == 200) {
popup.value.close("center");
uni.showToast({
title: '操作成功',
icon: 'success',
duration: 2000
});
} else {
uni.showToast({
title: '操作失败',
icon: 'error',
duration: 2000
});
}
})
}
const onPullDownRefresh = () => {
console.log('onPullDownRefresh')

View File

@ -0,0 +1,75 @@
<template>
<view class="container">
<view class="cu-btn bg-blue" @click="getInfoList">
调度
</view>
</view>
</template>
<script setup>
import {
ref
} from 'vue';
import * as api from '@/utils/api.js';
import {onLoad} from '@dcloudio/uni-app';
const orderId=ref("");
onLoad((options)=>{
debugger;
orderId.value=options.orderId;;
})
const getInfoList =()=>{
debugger;
api.callEbikeInfo("getDispatchVehicleByOrderId?orderId="+orderId.value, {}, "get").then(
res => {
if (res.code == 200) {
debugger;
}
})
}
</script>
<style scoped>
.dispatch-container {
text-align: center;
margin-top: 20px;
}
.dispatch-button {
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
.dispatch-button:hover {
background-color: #45a049;
}
.loading {
margin-top: 10px;
font-size: 18px;
color: #888;
}
.data-display {
margin-top: 20px;
background-color: #f4f4f4;
padding: 15px;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.error-message {
margin-top: 10px;
color: red;
}
</style>

View File

@ -71,8 +71,8 @@ const pages = [
path: '/SysManage',
name: '系统管理',
children: [{
path: '/UserTree',
name: '用户管理',
path: '/OrgManage',
name: '品牌商管理',
isMenu: true
}
]

View File

@ -12,5 +12,6 @@ const config = {
pageSize: 10,
pageSizeOptions: ['10', '5']
}
,imgPath:"https://attiya.fun/ebike-file/cdn-bucket/operate/"
}
export default config;

View File

@ -49,14 +49,13 @@
{{ record.dealState == '0' ? '未处理' : record.dealState == '1' ? '处理中' : record.dealState == '2' ? '已处理' : '' }}
</template>
<template v-if="column.key === 'action'">
<a @click="handleDeal(record)">处理</a>
<a-space v-if="record.dealState == '0'">
<a @click="handleDeal(record)">处理</a>
</a-space>
<a-space v-if="record.dealState == '1'">
<a @click="handleDeal(record)">完成处理</a>
</a-space>
<a-divider type="vertical" />
<!-- <a-divider type="vertical" /> -->
</template>
</template>
</a-table>
@ -66,6 +65,7 @@
v-model:open="open"
:title="openTitle"
@ok="handleOkModal"
@cancel="handleCancelModal"
width="800px"
:maskClosable="false"
>
@ -78,6 +78,7 @@
import { message } from 'ant-design-vue'
import config from '@/utils/config.js'
import { dataFormat } from '@/utils/tools'
import { getCache } from '@/utils/authority';
import BackSiteForm from '@/views/form/backsite/BackSiteForm.vue'
const activeKey = ref('');
@ -92,6 +93,7 @@
const data = ref([])
//
const queryform = ref({
regionId: '',
state: '',
startTime: '',
endTime: '',
@ -118,7 +120,7 @@
//
const columns = ref([
{
title: '号',
title: '号',
key: 'index',
width: 70,
align: 'center',
@ -207,6 +209,9 @@
queryparams.endTime = dataFormat(queryparams.backTime[1], 'yyyy-MM-dd HH:mm:ss');
}
delete queryparams.backTime;
//
const userdefultoperation = getCache('ebike-userdefultoperation');
queryparams.regionId = userdefultoperation.regionId;
const res = await callOrder("/ebikeUserBacksite/page", queryparams);
spinning.value = false;
if (res.code != 200) {
@ -248,7 +253,7 @@
open.value = true;
nextTick(() => {
if (formModel.value) {
formModel.value.openForm({ backsiteid: record['id'] });
formModel.value.openForm({ ...record });
} else {
console.log('formModel is not ready yet');
}
@ -259,8 +264,17 @@
* 处理停车点申请modal确定
*/
const handleOkModal = () => {
formModel.value.formSave((data => {
formModel.value.formSave(bres => {
open.value = false;
}));
if(bres){
getData()
}
});
}
</script>
const handleCancelModal = () => {
formModel.value.resetAll(bres => {
if(bres) open.value = false;
});
}
</script>

View File

@ -51,11 +51,13 @@
</a-button> -->
<!-- 登录 -->
<div class="topAvatar">
<a>
当前区域{{ userdfrname }} <DownOutlined />
</a>
<a-divider type="vertical" />
<UserOutlined style="margin: 0px 5px;" />
<template v-if="userdfrname != ''">
<a>
当前区域{{ userdfrname }} <DownOutlined />
</a>
<a-divider type="vertical" />
<UserOutlined style="margin: 0px 5px;" />
</template>
<a-dropdown>
<a
class="ant-dropdown-link"
@ -137,7 +139,9 @@ onMounted(() => {
//
const userdefultoperation = getCache('ebike-userdefultoperation');
userdfrname.value = userdefultoperation.regionName ? userdefultoperation.regionName : '';
if(userdefultoperation){
userdfrname.value = userdefultoperation.regionName ? userdefultoperation.regionName : '';
}
const menus = getMenus()
items.value = menus

View File

@ -142,7 +142,7 @@
align: 'center'
},
{
title: '号',
title: '号',
key: 'index',
width: 70,
align: 'center',

View File

@ -145,7 +145,7 @@
align: 'center'
},
{
title: '号',
title: '号',
key: 'index',
width: 70,
align: 'center',

View File

@ -164,7 +164,7 @@ let pagination = reactive({
//
const columns = ref([
{
title: '号',
title: '号',
key: 'index',
width: 70,
align: 'center',

View File

@ -142,7 +142,7 @@
align: 'center'
},
{
title: '号',
title: '号',
key: 'index',
width: 70,
align: 'center',

View File

@ -0,0 +1,158 @@
<template>
<!-- 数据操作 -->
<a-space style="margin-bottom: 10px">
<a-button style="background-color: #5cc750" type="primary" class="ele-btn-icon" @click="handleAdd">
<template #icon>
<plus-outlined />
</template>
<span>新增</span>
</a-button>
</a-space>
<a-table :pagination="pagination"
@change="handleTableChange"
bordered
:columns="columns"
:dataSource="dataSource"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action' && record['orgId'] != '258106438092689000'">
<a @click="handleDeal(record)">编辑</a>
</template>
</template>
</a-table>
<!-- 编辑品牌商信息 -->
<a-modal
v-model:open="open"
:title="openTitle"
@ok="handleOkModal"
@cancel="handleCancelModal"
width="800px"
:maskClosable="false"
>
<OrgForm ref="formModel"></OrgForm>
</a-modal>
</template>
<script setup>
import { ref, reactive, onMounted, nextTick } from 'vue';
import { message } from 'ant-design-vue'
import { callUser } from '@/apis/call.js'
import config from '@/utils/config.js'
import OrgForm from '@/views/form/orgmanage/orgform.vue'
const open = ref(false);
const openTitle = ref('品牌商信息');
const formModel = ref(null);
const columns = [
{
title: '序号',
key: 'index',
width: 70,
align: 'center',
dataIndex: 'index'
},
{
title: '品牌商名称',
dataIndex: 'orgName',
key: 'orgName',
},
{
title: '操作',
key: 'action',
width: 200,
align: 'center'
}
];
//
const dataSource = ref([])
const data = ref([])
//
const queryform = ref({
pageParam: {
pageNum: config.pageParam.pageNum,
pageSize: config.pageParam.pageSize
}
})
//
let pagination = reactive({
total: dataSource.value.length,
current: queryform.value.pageParam.pageNum,
pageSize: queryform.value.pageParam.pageSize,
showSizeChanger: true,
pageSizeOptions: config.pageParam.pageSizeOptions,
showQuickJumper: true
})
onMounted(() => {
getData();
})
//
let handleTableChange = (pagina) => {
pagination.current = pagina.current
pagination.pageSize = pagina.pageSize
queryform.value.pageParam.pageNum = pagina.current
queryform.value.pageParam.pageSize = pagina.pageSize
getData();
}
const getData = async () => {
callUser("/organizations/page?pageNum=" + queryform.value.pageParam.pageNum + "&pageSize=" + queryform.value.pageParam.pageSize, {},"get").then((res) => {
if (res.code != 200) {
message.error(res.message)
dataSource.value = []
data.value = []
pagination.total = 0
return
}
data.value = res.data.records
data.value = data.value.map((item, index) => {
index++
return { ...item, index }
})
dataSource.value = data.value
pagination.total = res.data.totalRow
});
}
const handleAdd = async () => {
open.value = true;
nextTick(() => {
if (formModel.value) {
formModel.value.openForm({});
} else {
console.log('formModel is not ready yet');
}
});
}
const handleDeal = async (record) => {
open.value = true;
nextTick(() => {
if (formModel.value) {
formModel.value.openForm({ ...record });
} else {
console.log('formModel is not ready yet');
}
});
}
/**
* 处理停车点申请modal确定
*/
const handleOkModal = () => {
formModel.value.formSave(bres => {
open.value = false;
if(bres){
getData()
}
});
}
const handleCancelModal = () => {
formModel.value.resetAll(bres => {
if(bres) open.value = false;
});
}
</script>

View File

@ -77,8 +77,6 @@
:options="options"
@map_inited="onMapInited"
>
<tlbs-multi-polygon v-if="polygonGeometries.length > 0" ref="polygonRef" :geometries="polygonGeometries" />
<tlbs-multi-circle v-if="circleGeometries.length > 0" ref="circleRef" :geometries="circleGeometries" />
</tlbs-map>
</div>
</a-col>
@ -106,9 +104,9 @@
label="备注"
:label-col="{ span: 3 }"
:wrapper-col="{ span: 21 }"
name="dealNotes"
name="dealNote"
>
<a-textarea v-model:value="form.dealNotes" placeholder="请输入备注"/>
<a-textarea v-model:value="form.dealNote" placeholder="请输入备注"/>
</a-form-item>
</a-col>
</a-row>
@ -119,7 +117,9 @@
import { ref } from 'vue'
import { callOrder, callOperate } from '@/apis/call.js'
import { message } from 'ant-design-vue'
import config from '@/utils/config.js'
import config from '@/utils/config.js'
import { dataFormat } from '@/utils/tools'
import { getCache } from '@/utils/authority';
const formRef = ref();
const formData = () => ({
@ -132,12 +132,13 @@
applyPhone: "",
applyTime: "",
applyReason: "",
regionId: "267781609627852800",
regionId: "",
regionName: "",
dealId: "",
dealState: "",
dealUser: "",
dealTime: "",
dealNotes: ""
dealNote: ""
});
const form = ref(formData());
@ -161,37 +162,53 @@
};
const openForm = (params = {}) => {
Object.assign(form.value, formData());
formRef.value.resetFields();
if (params['backsiteid']) {
form.value.id = params['backsiteid']
callOrder("/ebikeUserBacksite/getInfo?id="+ params['backsiteid'], {}, "get").then(res => {
if (res.code == 200) {
if (res.data) {
form.value = {
id: res.data.id,
applySource: res.data.applySource,
applyPosition: res.data.applyPosition,
applyLng: res.data.applyLng,
applyLat: res.data.applyLat,
applyNickname: res.data.applyNickname,
applyPhone: res.data.applyPhone,
applyTime: res.data.applyTime,
applyReason: res.data.applyReason,
};
}
} else {
message.error(res.message);
}
});
// Object.assign(form.value, formData());
// formRef.value.resetFields();
form.value = {
...formData(),
...params,
}
if(form.value.regionId != ""){
callOperate("/ebikeRegion/getRegionInfo/" + form.value.regionId, {}, "get").then((res) => {
form.value.dealState = params['dealState'] == '0'? '' : params['dealState']
loadMarker();
// if (params['id']) {
// form.value.id = params['id']
// callOrder("/ebikeUserBacksite/getInfo?id="+ params['id'], {}, "get").then(res => {
// if (res.code == 200) {
// if (res.data) {
// form.value = {
// ...form.value,
// id: res.data.id,
// applySource: res.data.applySource,
// applyPosition: res.data.applyPosition,
// applyLng: res.data.applyLng,
// applyLat: res.data.applyLat,
// applyNickname: res.data.applyNickname,
// applyPhone: res.data.applyPhone,
// applyTime: res.data.applyTime,
// applyReason: res.data.applyReason,
// };
// loadMarker();
// }
// } else {
// message.error(res.message);
// }
// });
// }
// if (params['dealId']) {
// form.value.dealId = params['dealId']
// form.value.dealNote = params['dealNote']
// form.value.dealState = params['dealState'] == '0'? '' : params['dealState']
// form.value.dealTime = params['dealTime']
// form.value.dealUser = params['dealUser']
// }
if(params['regionId'] != ""){
form.value.regionId = params['regionId']
callOperate("/ebikeRegion/getRegionInfo/" + params['regionId'], {}, "get").then((res) => {
if (res.code != 200) {
message.error(res.message)
return
}
form.value.regionName = res.data.regionName;
dataRegion.value = res.data;
loadMap();
});
@ -200,11 +217,10 @@
const polygonRef = ref(null);
const circleRef = ref(null);
const polygonGeometries = ref([]);
const circleGeometries = ref([]);
const markerRef = ref(null);
let timer = null;
const loadMap = () => {
if (mapRef.value && typeof(TMap) !== 'undefined') {
if (mapRef.value && mapRef.value.map && typeof(TMap) !== 'undefined') {
clearTimeout(timer);
if (dataRegion.value) {
const { regionId ,points, shapeType, radius } = dataRegion.value;
@ -214,35 +230,63 @@
}
if (points) {
if(shapeType == 1){
//
circleGeometries.value = [];
circleGeometries.value.push({
id: shapeId, //
styleId: 'circle', // id
radius: radius, //
center: new TMap.LatLng(points[0].latitude, points[0].longitude),
properties: {
//
title: 'circle',
},
//
if (circleRef.value) {
circleRef.value.setMap(null); //
}
circleRef.value = new TMap.MultiCircle({
id: 'circle-layer', // id
geometries: [
{
id: shapeId, //
styleId: 'circle', // id
center: new TMap.LatLng(points[0].latitude, points[0].longitude), //
radius: radius, //
properties: {
//
title: 'circle',
},
}
]
});
circleRef.value.setMap(mapRef.value.map);
// //
// const mycircle = circleRef.value.getGeometryById(shapeId);
// const boundary = TMap.geometry.computeBoundingRectangle(mycircle.paths);
// mapRef.value.map.fitBounds(boundary,{
// padding: 100, //
// });
}
else if(shapeType == 2){
const paths = [];
points.forEach((point) => {
paths.push(new TMap.LatLng(point.latitude, point.longitude));
});
//
polygonGeometries.value = [];
polygonGeometries.value.push({
id: shapeId, //
styleId: 'polygon', // id
paths, //
properties: {
//
if (polygonRef.value) {
polygonRef.value.setMap(null); //
}
polygonRef.value = new TMap.MultiPolygon({
id: 'polygon-layer', // id
geometries: [
{
id: shapeId, //
styleId: 'polygon', // id
paths, //
properties: {
//
title: 'polygon',
},
},
],
});
polygonRef.value.setMap(mapRef.value.map);
// //
// const mypolygon = polygonRef.value.getGeometryById(shapeId);
// const boundary = TMap.geometry.computeBoundingRectangle(mypolygon.paths);
// mapRef.value.map.fitBounds(boundary,{
// padding: 100, //
// });
}
}
}
@ -250,33 +294,101 @@
else
{
timer = setTimeout(() => {
loadMap(dataRegion);
loadMap();
}, 1000)
}
};
let timer1 = null;
const loadMarker = () => {
if (mapRef.value && mapRef.value.map && typeof(TMap)!== 'undefined') {
clearTimeout(timer1);
if (form.value.applyLng && form.value.applyLat) {
//
if (markerRef.value) {
markerRef.value.setMap(null); //
}
markerRef.value = new TMap.MultiMarker({
id: 'marker-layer', // id
styles: {
"marker": new TMap.MarkerStyle({
"width": 25,
"height": 35,
"anchor": { x: 16, y: 32 },
"src": config.imgPath + 'assets/map/point.png'
})
},
geometries: [
//
{
// ()
position: new TMap.LatLng(form.value.applyLat, form.value.applyLng),
id: 'marker' + form.value.id,
styleId: 'marker',
properties: {
//
title: '反馈位置',
}
},
],
});
markerRef.value.setMap(mapRef.value.map);
//
var ne = new TMap.LatLng(form.value.applyLat, form.value.applyLng);//
var sw = new TMap.LatLng(form.value.applyLat, form.value.applyLng);//西
var latLngBounds = new TMap.LatLngBounds(sw, ne);
mapRef.value.map.fitBounds(latLngBounds,{
padding: 50, //
});
}
}
else
{
timer1 = setTimeout(() => {
loadMarker();
}, 1000)
}
}
const formSave = (callBack) => {
// formRef.value.validate().then(() => {
// callOperate("/ebikeRegion/saveOperation", form.value).then(res => {
// if (res.code != 200) {
// message.error(res.message);
// if (callBack) {
// callBack(false, res);
// }
// return;
// }
// if (callBack) {
// callBack(true, res);
// }
// formRef.value.resetFields()
// })
// }).catch(error => {
// if (callBack) {
// callBack(false, error);
// }
// });
formRef.value.validate().then(() => {
const userinfo = getCache('ebike-userinfo');
const params = {
id: form.value.dealId,
dealUser: userinfo.username,
dealTime: dataFormat(new Date(),'yyyy-MM-dd HH:mm:ss'),
dealNote: form.value.dealNote,
dealState: form.value.dealState,
}
callOrder("/ebikeUserBacksite/updateDeal", params).then(res => {
if (res.code != 200) {
message.error(res.message);
if (callBack) {
callBack(false, res);
}
return;
}
if (callBack) {
callBack(true, res);
}
resetAll();
})
}).catch(error => {
if (callBack) {
callBack(false, error);
}
});
};
defineExpose({ openForm, formSave });
const resetAll = (callBack) => {
Object.assign(form.value, formData());
formRef.value.resetFields();
if (callBack) {
callBack(true, form.value);
}
}
defineExpose({ openForm, formSave, resetAll });
</script>

View File

@ -17,7 +17,10 @@
name="zoneId"
:rules="[{ required: true, message: '请选择行政区划' }]"
>
<a-input
<a-select v-model:value="form.zoneId" placeholder="请选择行政区划" style="width: 85%;">
<a-select-option v-for="(item) in zoneList" :key="item.id" :value="item.zoneId">{{ item.zoneName }}</a-select-option>
</a-select>
<!-- <a-input
style="display: none;"
v-model:value="form.zoneId"
/>
@ -28,7 +31,7 @@
change-on-select
placeholder="请选择行政区划"
@change="changeZone"
/>
/> -->
</a-form-item>
</a-col>
</a-row>
@ -111,6 +114,7 @@ import { ref, defineProps, onMounted } from 'vue'
import operateRegionMap from '../../Urban/OperateRegion/operateRegionMap.vue'
import { callOperate } from '@/apis/call.js'
import { message } from 'ant-design-vue'
import { getCache } from '@/utils/authority';
const props = defineProps({
@ -128,12 +132,13 @@ const openORMapTitle = ref("");
const zoneOptions = ref([])
const zoneList = ref([])
const form = ref({
regionId: "",
regionName: "",
simpleName: "",
zoneId: "",
zoneId: undefined,
points: [],
shapeType: 2,
radius: 0
@ -141,15 +146,26 @@ const form = ref({
onMounted(() => {
callOperate("/ebikeOperateSystem/ebikeAdministrationZone", {}, "get").then(res => {
if (res.code == 200) {
let opt = []
res.data.map(item => {
opt.push({ label: item['name'], value: item['id'], isLeaf: item['isLeaf'] })
})
zoneOptions.value = opt;
const userinfo = getCache('ebike-userinfo');
callOperate("/ebikeOrgZone/list?orgId=" + userinfo.orgId, {}, "get").then((res) => {
if (res.code!= 200) {
message.error(res.message)
return
}
})
if (res.data) {
zoneList.value = res.data
}
})
// callOperate("/ebikeOperateSystem/ebikeAdministrationZone", {}, "get").then(res => {
// if (res.code == 200) {
// let opt = []
// res.data.map(item => {
// opt.push({ label: item['name'], value: item['id'], isLeaf: item['isLeaf'] })
// })
// zoneOptions.value = opt;
// }
// })
})
const loadZoneData = (data) => {

View File

@ -0,0 +1,305 @@
<template>
<a-form
:model="form"
ref="formRef"
label-align="left"
:label-col="{ span: 6 }"
:wrapper-col="{ span: 18 }"
>
<a-row>
<a-col :span="24">
<a-form-item
label="品牌商名称"
:label-col="{ span: 3 }"
:wrapper-col="{ span: 21 }"
name="orgName"
required
:rules="[{ required: true, message: '请输入品牌商名称' }]"
>
<a-input v-model:value="form.orgName" placeholder="请输入品牌商名称" />
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col :span="24">
<a-form-item
label="品牌商编码"
:label-col="{ span: 3 }"
:wrapper-col="{ span: 21 }"
name="orgName"
required
:rules="[{ required: true, message: '请输入品牌商编码' }]"
>
<a-input v-model:value="form.orgCode" placeholder="请输入品牌商编码" />
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col :span="24">
<a-card size="small">
<template #title>
<span>已授权区域</span>
<a-cascader
:options="zoneOptions"
:load-data="loadZoneData"
placeholder="请选择行政区划"
@change="addOrgZone"
>
<a-button type="primary" size="small" style="margin-left: 15px;">
授权
</a-button>
</a-cascader>
</template>
<!-- 表格 -->
<a-table
:pagination="false"
:columns="columns"
:dataSource="dataSource"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<a @click="removeOrgZone(record)">移除</a>
</template>
</template>
</a-table>
</a-card>
</a-col>
</a-row>
</a-form>
</template>
<script setup>
import { ref } from 'vue'
import { callUser, callOperate } from '@/apis/call.js'
import { message } from 'ant-design-vue'
import { dataFormat } from '@/utils/tools'
import { getCache } from '@/utils/authority';
const formRef = ref();
const formData = () => ({
orgId: "",
orgName: "",
createdTime: ""
});
const form = ref(formData());
//
const dataSource = ref([])
const data = ref([])
//
const columns = ref([
{
title: '序号',
key: 'index',
width: 70,
align: 'center',
dataIndex: 'index'
},
{
key: 'zoneName',
title: '区域名称',
dataIndex: 'zoneName',
align: 'center'
},
{
key: 'assignedTime',
title: '授权时间',
align: 'center',
dataIndex: 'assignedTime'
},
{
title: '操作',
key: 'action',
width: 320,
align: 'center'
}
])
const zoneOptions = ref([])
const openForm = (params = {}) => {
form.value = {
...formData()
}
if (params['orgId']) {
callUser("/organizations/getInfo/"+ params['orgId'], {}, "get").then(res => {
if (res.code == 200) {
if (res.data) {
form.value = {
...res.data
};
}
} else {
message.error(res.message);
}
});
getOrgZoneList(params['orgId']);
}
loadFristZoneData();
};
/**
* 加载区域数据
*/
const loadFristZoneData = () => {
zoneOptions.value = [];
callOperate("/ebikeOperateSystem/ebikeAdministrationZone", {}, "get").then(res => {
if (res.code == 200) {
let opt = []
res.data.map(item => {
opt.push({ label: item['name'], value: item['id'], isLeaf: item['isLeaf'] })
})
zoneOptions.value = opt;
}
})
}
const loadZoneData = (data) => {
if (data) {
let pindex = 0;
let parentId = data[0].value;
if (data.length > 0) {
pindex = data.length - 1;
parentId = data[pindex].value;
}
callOperate("/ebikeOperateSystem/ebikeAdministrationZone?parent_id=" + parentId, {}, "get").then(res => {
if (res.code == 200) {
let opt = []
res.data.map(item => {
opt.push({ label: item['name'], value: item['id'], isLeaf: item['isLeaf'] })
})
setZoneData(zoneOptions.value,'value', parentId,'children',opt);
}
})
}
}
const setZoneData = (arr,keyname,keyvalue,name,value) => {
arr.map(item => {
if (item[keyname] == keyvalue) {
item[name] = value;
}
if (item['children']) {
setZoneData(item['children'],keyname,keyvalue,name,value)
}
})
}
const getOrgZoneList = (orgId) => {
callOperate("/ebikeOrgZone/list?orgId=" + orgId, {}, "get").then((res) => {
if (res.code!= 200) {
message.error(res.message)
return
}
if (res.data) {
data.value = res.data
data.value = data.value.map((item, index) => {
index++
return { ...item, index }
})
dataSource.value = data.value
}
})
}
const removeOrgZone = (record) => {
callOperate("/ebikeOrgZone/remove?id=" + record.id, { }, "post").then((res) => {
if (res.code!= 200) {
message.error(res.message)
return
}
getOrgZoneList(form.value.orgId);
})
}
const addOrgZone = (data) => {
let zoneId = "";
if (data.length > 0) {
zoneId = data[data.length - 1];
} else {
zoneId = "";
}
if (!zoneId) {
message.error('请选择行政区划')
}
const userinfo = getCache('ebike-userinfo');
const params = {
orgId: form.value.orgId,
zoneId: zoneId,
staffId: userinfo.username,
assignedTime: dataFormat(new Date(),'yyyy-MM-dd HH:mm:ss')
}
callOperate("/ebikeOrgZone/save", params, "post").then((res) => {
if (res.code!= 200) {
message.error(res.message)
return
}
getOrgZoneList(form.value.orgId);
loadFristZoneData();
})
}
const formSave = (callBack) => {
formRef.value.validate().then(() => {
let params = {
orgId: "",
orgName: "",
orgCode: "",
createdTime: dataFormat(new Date(),'yyyy-MM-dd HH:mm:ss'),
}
if (form.value.orgId) {
params = {
...form.value
}
callUser("/organizations/update", params).then(res => {
if (res.code != 200) {
message.error(res.message);
if (callBack) {
callBack(false, res);
}
return;
}
if (callBack) {
callBack(true, res);
}
resetAll();
}).catch(error => {
if (callBack) {
callBack(false, error);
}
});
}
else {
callUser("/organizations/save", params).then(res => {
if (res.code!= 200) {
message.error(res.message);
if (callBack) {
callBack(false, res);
}
return;
}
if (callBack) {
callBack(true, res);
}
resetAll();
}).catch(error => {
if (callBack) {
callBack(false, error);
}
});
}
});
};
const resetAll = (callBack) => {
Object.assign(form.value, formData());
data.value = [];
dataSource.value = [];
formRef.value.resetFields();
if (callBack) {
callBack(true, form.value);
}
}
defineExpose({ openForm, formSave, resetAll });
</script>