feat:新增生产管理模块

This commit is contained in:
5g0Wp7Zy 2025-09-16 14:12:07 +08:00
parent e1bd45f0e1
commit 3ce33157c5
10 changed files with 385 additions and 13 deletions

View File

@ -9,4 +9,4 @@ VITE_ROUTER_MODE = hash
VITE_PUBLIC_PATH = './'
# 请求路径 管理系统/开发环境
VITE_APP_BASE_URL = 'http://192.168.2.110:10010'
VITE_APP_BASE_URL = 'http://192.168.2.92:10010'

View File

@ -0,0 +1,20 @@
import axios from "@/api";
import {} from "./types";
//分页查询中控基本信息
export const getCentralControlBasicInfoByPageAPI = (params: any) => {
return axios({
url: "/operations/ebikeEcuInfo/page",
method: "get",
params
});
};
// 新增中控入库
export const addCentralControlInfoAPI = (data: any) => {
return axios({
url: "/operations/ebikeEcuInfo/save",
method: "post",
data
});
};

View File

@ -0,0 +1,18 @@
interface ListType {
pageNum: number;
pageSize: number;
}
// 运营商列表查询参数
export interface OperatorListParams extends ListType {
operatorName?: string;
}
// 新增中控入库参数
export interface AddCentralControlInfoParams {
ecuId?: string; // 中控ID
operatorId: string; // 运营商ID
ecuCode: string; // 中控编码
ecuSn: string; // 中控SN
ecuBrand: string; // 中控品牌
}

View File

@ -267,3 +267,17 @@ export function formatTreeData(treeData: any[]) {
return treeData;
}
}
/**
*
* @param {Array} list -
* @param {string} key -
* @param {string|number|boolean} value -
* @param {string} valueKey - "dicValueName"
* @returns {any}
*/
export function dictTranslate(list: any[], key: string, value: string | number, valueKey: string = "dicValueName"): any {
if (!Array.isArray(list) || list.length === 0) return value;
let item = list.find(i => i[key] === value.toString());
return item ? item[valueKey] : value;
}

View File

@ -85,7 +85,6 @@ const rules = ref({
]
});
const verifyCode = ref("");
const verifyCodeChange = (code: string) => (verifyCode.value = code);
//
const onSubmit = async ({ errors }: any) => {
@ -113,14 +112,12 @@ const onLogin = async () => {
//
let foundItem = null;
for (const item of routeStore.routeList) {
if (item.meta.type === 2) {
foundItem = item;
break; //
}
}
router.replace(foundItem.path || "/");
//

View File

@ -0,0 +1,9 @@
<template>
<div class="snow-page">
<div class="snow-inner">asdas</div>
</div>
</template>
<script setup lang="ts"></script>
<style lang="scss" scoped></style>

View File

@ -0,0 +1,223 @@
<template>
<div class="snow-page">
<div class="snow-inner">
<s-layout-tools>
<template #right>
<a-space wrap>
<a-button type="primary" @click="onAdd">
<template #icon><icon-plus /></template>
<span>新增</span>
</a-button>
</a-space>
</template>
</s-layout-tools>
<a-table
row-key="id"
:data="moduleList"
:bordered="{ cell: true }"
:loading="loading"
:scroll="{ x: '100%', y: '100%', minWidth: 1000 }"
:pagination="pagination"
>
<template #columns>
<a-table-column title="中控SN码" data-index="ecuSn" align="center"></a-table-column>
<a-table-column title="中控编号" data-index="ecuCode" align="center"></a-table-column>
<a-table-column title="运营商" data-index="operatorId" align="center">
<template #cell="{ record }">
<span>{{ dictFormat(operatorAllList, "operatorId", record.operatorId, "operatorName") }}</span>
</template>
</a-table-column>
<a-table-column title="中控品牌" data-index="ecuBrand" align="center">
<template #cell="{ record }">
<span>{{ dictFormat(ecuBrandList, "dicValue", record.ecuBrand) }}</span>
</template>
</a-table-column>
<a-table-column title="创建时间" data-index="createdAt" :width="180" align="center"></a-table-column>
<!-- TUDO: 暂时不做操作功能 -->
<!-- <a-table-column title="操作" :width="280" align="center" :fixed="'right'">
<template #cell="{ record }">
<a-space>
<a-button type="primary" size="mini" :disabled="record.sysRole">
<template #icon><icon-edit /></template>
<span>修改</span>
</a-button>
</a-space>
</template>
</a-table-column> -->
</template>
</a-table>
</div>
<!-- 模态框 -->
<a-modal v-model:visible="open" @close="afterClose" @before-ok="handleOk" @cancel="afterClose">
<template #title> {{ title }} </template>
<a-form ref="addFormRef" :model="addForm" :rules="rules">
<a-form-item field="ecuCode" label="中控编号" validate-trigger="blur">
<a-input v-model="addForm.ecuCode" placeholder="请输入中控编号" />
</a-form-item>
<a-form-item field="ecuSn" label="中控SN码" validate-trigger="blur">
<a-input v-model="addForm.ecuSn" placeholder="请输入中控SN码" />
</a-form-item>
<a-form-item field="operatorId" label="运营商">
<a-select v-model="addForm.operatorId" placeholder="请选择运营商" validate-trigger="change">
<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="ecuBrand" label="中控品牌">
<a-select v-model="addForm.ecuBrand" placeholder="请选择中控品牌" validate-trigger="change">
<a-option v-for="it in ecuBrandList" :key="it.dicId" :value="it.dicValue">{{ it.dicValueName }}</a-option>
</a-select>
</a-form-item>
</a-form>
</a-modal>
</div>
</template>
<script setup lang="ts">
import { getOperatorAllListAPI } from "@/api/modules/system";
import { useSystemStore } from "@/store/modules/system";
import { getCentralControlBasicInfoByPageAPI, addCentralControlInfoAPI } from "@/api/modules/productionManagement";
import { AddCentralControlInfoParams } from "@/api/modules/productionManagement/types";
import { deepClone, dictTranslate } from "@/utils";
//
const moduleList = ref([]);
const loading = ref(false);
const pagination = ref({
pageNum: 1,
pageSize: 10,
showPageSize: true,
showTotal: true
});
//
const open = ref<boolean>(false);
const system = useSystemStore();
const title = ref<string>("");
const operatorAllList = ref<any>([]);
const ecuBrandList = ref<any>([]);
const addFormRef = ref();
const addForm = ref<AddCentralControlInfoParams>({
operatorId: "",
ecuCode: "",
ecuSn: "",
ecuBrand: ""
});
const rules = {
ecuCode: [{ required: true, message: "请输入中控编号", trigger: "blur" }],
ecuSn: [{ required: true, message: "请输入中控SN码", trigger: "blur" }],
operatorId: [{ required: true, message: "请选择运营商", trigger: "change" }],
ecuBrand: [{ required: true, message: "请选择中控品牌", trigger: "change" }]
};
const onAdd = () => {
title.value = "新增组件";
open.value = true;
};
const reset = () => {};
const search = () => {};
const afterClose = () => {};
const resetForm = () => {
addForm.value = {
operatorId: "",
ecuCode: "",
ecuSn: "",
ecuBrand: ""
};
if (addFormRef.value) {
addFormRef.value.resetFields();
}
};
const handleOk = async () => {
let state = await addFormRef.value.validate();
if (state) return false; //
if (addForm.value.ecuId) {
try {
let res: any = await addCentralControlInfoAPI(addForm.value);
if (res.code === 200) {
arcoMessage("success", "修改成功");
resetForm();
getCentralControlBasicInfoByPage();
return true;
}
} catch (error: any) {
console.error(error);
return false;
}
} else {
try {
let res: any = await addCentralControlInfoAPI(addForm.value);
if (res.code === 200) {
arcoMessage("success", "新增成功");
resetForm();
getCentralControlBasicInfoByPage();
return true;
}
} catch (error: any) {
console.error(error);
return false;
}
}
};
//
const dictFormat = (list: any[], key: string, value: string | number, valueKey: string = "dicValueName") => {
return dictTranslate(list, key, value, valueKey);
};
const onDelete = (record: any) => {
console.log("删除", record);
};
//
const getAllOperatorList = async () => {
return new Promise<void>(async resolve => {
try {
ecuBrandList.value = deepClone(system.getDictByCode("ecuBrandCode"));
const res: any = await getOperatorAllListAPI();
if (res.code === 200) {
operatorAllList.value = res.data;
resolve();
}
} catch (error) {
console.error("获取运营商列表失败:", error);
resolve();
}
});
};
//
const getCentralControlBasicInfoByPage = async () => {
loading.value = true;
try {
const res: any = await getCentralControlBasicInfoByPageAPI({
pageNum: pagination.value.pageNum,
pageSize: pagination.value.pageSize
});
loading.value = false;
if (res.code !== 200) {
return;
}
const { records, pageNumber, pageSize } = res.data;
pagination.value.pageNum = pageNumber;
pagination.value.pageSize = pageSize;
moduleList.value = records;
} catch (error) {
console.error("获取员工列表失败:", error);
} finally {
loading.value = false;
}
};
onMounted(() => {
getCentralControlBasicInfoByPage();
});
onBeforeMount(async () => {
await getAllOperatorList();
});
</script>
<style lang="scss" scoped></style>

View File

@ -0,0 +1,98 @@
<template>
<div class="snow-page">
<div class="snow-inner">
<s-layout-tools>
<template #left>
<a-space wrap>
<a-input v-model="form.username" placeholder="请输入用户名" allow-clear />
<a-input v-model="form.contactPhone" placeholder="请输入联系电话" allow-clear />
<a-button type="primary" @click="search">
<template #icon><icon-search /></template>
<span>查询</span>
</a-button>
<a-button @click="reset">
<template #icon><icon-refresh /></template>
<span>重置</span>
</a-button>
</a-space>
</template>
<template #right>
<a-space wrap>
<a-button type="primary" @click="onAdd">
<template #icon><icon-plus /></template>
<span>新增</span>
</a-button>
</a-space>
</template>
</s-layout-tools>
<a-table
row-key="id"
:data="moduleList"
:bordered="{ cell: true }"
:loading="loading"
:scroll="{ x: '100%', y: '100%', minWidth: 1000 }"
:pagination="pagination"
>
<template #columns>
<a-table-column title="用户名" data-index="username" align="center"></a-table-column>
</template>
</a-table>
</div>
<!-- 模态框 -->
<a-modal v-model:visible="open" @close="afterClose" @before-ok="handleOk" @cancel="afterClose">
<template #title> {{ title }} </template>
<a-form ref="addFormRef" :model="addForm" :rules="rules">
<a-form-item field="username" label="用户名" validate-trigger="blur">
<a-input v-model="addForm.username" placeholder="请输入用户名" />
</a-form-item>
<a-form-item field="password" label="登录密码" validate-trigger="blur">
<a-input-password v-model="addForm.password" placeholder="请输入登录密码" />
</a-form-item>
</a-form>
</a-modal>
</div>
</template>
<script setup lang="ts">
import { AddStaffFromType } from "@/api/modules/system/types";
import { deepClone } from "@/utils";
const form = ref({
username: "",
contactPhone: ""
});
//
const moduleList = ref([]);
const loading = ref(false);
const pagination = ref({
pageNum: 1,
pageSize: 10,
showPageSize: true,
showTotal: true
});
//
const open = ref<boolean>(false);
const title = ref<string>("");
const operatorAllList = ref<any>([]);
const staffRoleAllList = ref<any>([]);
const addFormRef = ref();
const addForm = ref({
username: "",
password: ""
});
const rules = {};
const onAdd = () => {
title.value = "新增组件";
open.value = true;
};
const reset = () => {};
const search = () => {};
const afterClose = () => {};
const handleOk = () => {};
</script>
<style lang="scss" scoped></style>

View File

@ -112,13 +112,6 @@
<template #unchecked> </template>
</a-switch>
</a-col>
<a-col :span="8">
<a-tooltip
content="权限树的父子节点独立因为若节点关联父节点会存在半选情况半选节点的ID不会返回会导致菜单无法渲染"
>
<span>父子关联 <icon-question-circle-fill /></span>
</a-tooltip>
</a-col>
</a-row>
</a-card>
</div>

View File

@ -232,6 +232,7 @@ const onAdd = async () => {
open.value = true;
title.value = "新增员工";
};
//
const select = (list: []) => {
selectedKeys.value = list;
@ -249,13 +250,12 @@ const onUpdate = async (record: any) => {
let res: any = await getStaffByIdAPI(record.staffId);
if (res.code === 200) {
console.log(filterIds(res.data.roles, "roleId"));
addForm.value = {
staffId: res.data.staffId,
username: res.data.username,
contactPhone: res.data.contactPhone,
password: "",
status: res.data.status,
status: res.data.status ? res.data.status.toString() : 1,
roleIds: filterIds(res.data.roles, "roleId"),
operatorId: res.data.operatorId
};