feat:新增运营商配置功能

This commit is contained in:
5g0Wp7Zy 2026-03-04 14:25:41 +08:00
parent 7d92d5e722
commit 261fd5d17f
5 changed files with 184 additions and 3 deletions

View File

@ -0,0 +1,20 @@
import axios from "@/api";
import { OperatorConfigFormType } from "./types";
// 运营商配置添加更新
export const addOrUpdateOperatorConfigAPI = (data: OperatorConfigFormType) => {
return axios({
url: "/operations/ebikeCarrierConfiguration/saveOrUpdate",
method: "post",
data
});
};
//根据运营商id查询配置信息
export const getOperatorConfigByOperatorIdAPI = (operatorId: string) => {
return axios({
url: "/operations/ebikeCarrierConfiguration/getByOperatorId",
method: "get",
params: { operatorId }
});
};

View File

@ -0,0 +1,8 @@
//运营商配置添加更新配置
export interface OperatorConfigFormType {
operatorId: string; //运营商id
dispatchDuration: number | undefined; //配置项时长
rideDuration: number | undefined; //配置项骑行时长
inspectionIntervalDuration: number | undefined; //巡检间隔时长(日)
operatorPhone: string; //运营商手机号
}

View File

@ -4,9 +4,9 @@
<div class="login">
<LoginBanner v-if="isPc" />
<div class="login_box">
<div class="login_title">Welcome Back</div>
<div class="login_title_desc">国际化路由配置状态管理应有尽有</div>
<div class="login_title_desc">丰富的的页面模板覆盖大多数典型业务场景</div>
<div class="login_title">欢迎登录电单车管理系统</div>
<div class="login_title_desc">高效管理电单车运营实时掌握车辆动态</div>
<div class="login_title_desc">智能调度助力城市绿色出行</div>
<LoginForm @isLoading="state => (loading = state)" />
</div>
</div>

View File

@ -207,6 +207,7 @@ onBeforeMount(async () => {
<span>{{ record.actualAmount }} </span>
</template>
</a-table-column>
<a-table-column title="订单创建时间" data-index="startTime" align="center"></a-table-column>
<a-table-column title="操作" align="center" :fixed="'right'">
<template #cell="{ record }">
<a-space>

View File

@ -0,0 +1,152 @@
<script setup lang="ts">
import { getOperatorAllListAPI } from "@/api/modules/system";
import { addOrUpdateOperatorConfigAPI, getOperatorConfigByOperatorIdAPI } from "@/api/modules/serviceConfiguration";
import { OperatorConfigFormType } from "@/api/modules/serviceConfiguration/types";
import { deepClone } from "@/utils";
const operatorAllList = ref<any>([]);
const addFormRef = ref<any>(null);
const addForm = ref<OperatorConfigFormType>({
operatorId: "",
dispatchDuration: undefined,
rideDuration: undefined,
inspectionIntervalDuration: undefined,
operatorPhone: ""
});
const rules = {
operatorId: [{ required: true, message: "请选择运营商", trigger: "change" }],
dispatchDuration: [{ required: true, message: "请输入配置项时长", trigger: "change" }],
rideDuration: [{ required: true, message: "请输入配置项骑行时长", trigger: "change" }],
inspectionIntervalDuration: [{ required: true, message: "请输入配置项时长", trigger: "change" }],
operatorPhone: [{ required: true, message: "请输入运营商手机号", trigger: "change" }]
};
const isLoading = ref<boolean>(false);
//
const getAllOperatorList = async () => {
return new Promise<void>(async resolve => {
try {
const res: any = await getOperatorAllListAPI();
if (res.code === 200) {
operatorAllList.value = res.data;
resolve();
}
} catch (error) {
console.error("获取运营商列表失败:", error);
resolve();
}
});
};
//
async function submit() {
let state = await addFormRef.value.validate();
if (state) return false; //
isLoading.value = true;
const params = deepClone(addForm.value);
try {
const res: any = await addOrUpdateOperatorConfigAPI(params);
arcoMessage("success", "保存成功");
} catch (error) {
console.error("保存失败:", error);
} finally {
isLoading.value = false;
}
}
watch(
() => addForm.value.operatorId,
async newOperatorId => {
if (newOperatorId) {
try {
const { data }: any = await getOperatorConfigByOperatorIdAPI(newOperatorId);
if (data) {
addForm.value = { ...addForm.value, ...data };
} else {
addForm.value = {
operatorId: newOperatorId,
dispatchDuration: undefined,
rideDuration: undefined,
inspectionIntervalDuration: undefined,
operatorPhone: ""
};
}
} catch (error) {
console.error("获取运营商配置失败:", error);
}
}
}
);
onMounted(async () => {
await getAllOperatorList();
addForm.value.operatorId = operatorAllList.value.length > 0 ? operatorAllList.value[0].operatorId : "";
});
</script>
<template>
<div class="snow-page">
<div class="snow-inner">
<div class="header">运营商配置</div>
<div class="form_bar">
<a-form ref="addFormRef" :model="addForm" :rules="rules">
<a-form-item field="operatorId" label="运营商:" validate-trigger="blur">
<a-select v-model="addForm.operatorId" :style="{ width: '320px' }" placeholder="请选择">
<a-option v-for="it in operatorAllList" :key="it.operatorId" :value="it.operatorId">{{ it.operatorName }}</a-option>
</a-select>
</a-form-item>
<a-form-item field="dispatchDuration" label="时长配置(h):" validate-trigger="blur">
<a-input-number
v-model="addForm.dispatchDuration"
:style="{ width: '320px' }"
placeholder="请输入配置项时长"
:min="0"
/>
</a-form-item>
<a-form-item field="rideDuration" label="骑行时长配置(h):" validate-trigger="blur">
<a-input-number
v-model="addForm.rideDuration"
:style="{ width: '320px' }"
placeholder="请输入骑行时长配置"
:min="0"
/>
</a-form-item>
<a-form-item field="inspectionIntervalDuration" label="巡检间隔时长(日):" validate-trigger="blur">
<a-input-number
v-model="addForm.inspectionIntervalDuration"
:style="{ width: '320px' }"
placeholder="请输入巡检间隔时长"
:min="0"
/>
</a-form-item>
<a-form-item field="operatorPhone" label="联系电话:" validate-trigger="blur">
<a-input :style="{ width: '320px' }" placeholder="请输入联系电话" allow-clear v-model="addForm.operatorPhone" />
</a-form-item>
</a-form>
</div>
<div class="footer">
<a-button type="primary" :loading="isLoading" @click="submit">{{ isLoading ? "正在保存中..." : "保存" }}</a-button>
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
.header {
width: 100%;
font-size: 22px;
font-weight: bold;
text-align: center;
}
.footer {
width: 100%;
height: 60px;
display: flex;
justify-content: center;
align-items: center;
margin-top: 50px;
}
.form_bar {
margin-top: 20px;
}
</style>