feat:新增运营商配置功能
This commit is contained in:
parent
7d92d5e722
commit
261fd5d17f
20
src/api/modules/serviceConfiguration/index.ts
Normal file
20
src/api/modules/serviceConfiguration/index.ts
Normal 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 }
|
||||
});
|
||||
};
|
||||
8
src/api/modules/serviceConfiguration/types.ts
Normal file
8
src/api/modules/serviceConfiguration/types.ts
Normal file
@ -0,0 +1,8 @@
|
||||
//运营商配置添加更新配置
|
||||
export interface OperatorConfigFormType {
|
||||
operatorId: string; //运营商id
|
||||
dispatchDuration: number | undefined; //配置项时长
|
||||
rideDuration: number | undefined; //配置项骑行时长
|
||||
inspectionIntervalDuration: number | undefined; //巡检间隔时长(日)
|
||||
operatorPhone: string; //运营商手机号
|
||||
}
|
||||
@ -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>
|
||||
|
||||
@ -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>
|
||||
|
||||
152
src/views/serviceConfiguration/servicePhone/servicePhone.vue
Normal file
152
src/views/serviceConfiguration/servicePhone/servicePhone.vue
Normal 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>
|
||||
Loading…
x
Reference in New Issue
Block a user