前后端接口对接
This commit is contained in:
23
src/api/modules/check.ts
Normal file
23
src/api/modules/check.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import request from '../request.ts';
|
||||
import {
|
||||
type CheckOrderNumber,
|
||||
type ProcessInfo,
|
||||
} from '../types';
|
||||
|
||||
// 验证工单、产品编码关系是否正确
|
||||
export function checkOrderNumberApi(data: CheckOrderNumber) {
|
||||
return request({
|
||||
url: '/jinghua/mes/work-order-material/verify',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 新增加工信息
|
||||
export function addProcessInfoApi(data: ProcessInfo) {
|
||||
return request({
|
||||
url: '/jinghua/processInfo',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
5
src/api/modules/index.ts
Normal file
5
src/api/modules/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export * from './user';
|
||||
export * from './laser';
|
||||
export * from './station';
|
||||
export * from './check';
|
||||
export * from './system';
|
||||
32
src/api/modules/laser.ts
Normal file
32
src/api/modules/laser.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import request from '../request.ts';
|
||||
import {
|
||||
type LaserCarvingOrderSN,
|
||||
type LaserResult
|
||||
} from '../types';
|
||||
|
||||
// 根据工单、产品编码、拼版数量获取 SN 号码信息
|
||||
export function fetchSNApi(data: LaserCarvingOrderSN) {
|
||||
return request({
|
||||
url: '/laser/carving/getOrderSN',
|
||||
method: 'get',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 测试项目结果上传
|
||||
export function uploadTestResultApi(data: string) {
|
||||
return request({
|
||||
url: '/laser/carving/uploadResult',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 根据工单号、产品编码、接收镭雕结果,更改 SN 状态
|
||||
export function updateSNStatusApi(data: LaserResult) {
|
||||
return request({
|
||||
url: '/laser/carving/updateSNStatus',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
19
src/api/modules/station.ts
Normal file
19
src/api/modules/station.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import request from '../request.ts';
|
||||
|
||||
// 工序过站
|
||||
export function operationStationApi(data: string) {
|
||||
return request({
|
||||
url: '/operationStation',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 包装过站
|
||||
export function packageStationApi(data: string) {
|
||||
return request({
|
||||
url: '/packageStation',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
18
src/api/modules/system.ts
Normal file
18
src/api/modules/system.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import request from '../request';
|
||||
import { type LmsWorkMode } from '../types';
|
||||
|
||||
// 获取 LMS 工作模式
|
||||
export const fetchLmsWorkMode = () => {
|
||||
return request({
|
||||
url: '/jinghua/mes/work-mode',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
// 更新 LMS 工作模式
|
||||
export const updateLmsWorkMode = (workMode: LmsWorkMode) => {
|
||||
return request({
|
||||
url: `/jinghua/mes/work-mode/${workMode}`,
|
||||
method: 'put',
|
||||
})
|
||||
}
|
||||
41
src/api/modules/user.ts
Normal file
41
src/api/modules/user.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import request from '../request'
|
||||
|
||||
export interface LoginInfo {
|
||||
username: string
|
||||
password: string
|
||||
}
|
||||
|
||||
// 用户登录
|
||||
export const login = (data: LoginInfo) => {
|
||||
return request({
|
||||
url: '/user/login',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 获取用户信息
|
||||
export const getUserInfo = (data: any) => {
|
||||
return request({
|
||||
url: '/user/info',
|
||||
method: 'get',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 更新用户信息
|
||||
export const updateUser = (id: string, data: any) => {
|
||||
return request({
|
||||
url: `/user/${id}`,
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除用户
|
||||
export const deleteUser = (id: string) => {
|
||||
return request({
|
||||
url: `/user/${id}`,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
68
src/api/request.ts
Normal file
68
src/api/request.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import axios from 'axios';
|
||||
import { notification } from 'ant-design-vue';
|
||||
|
||||
interface ErrCodeMap {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
const errCodeMap: ErrCodeMap = {
|
||||
'401': '认证失败,无法访问系统资源',
|
||||
'403': '当前操作没有权限',
|
||||
'404': '访问资源不存在',
|
||||
'default': '系统未知错误,请反馈给管理员'
|
||||
};
|
||||
|
||||
// 创建axios实例
|
||||
const service = axios.create({
|
||||
baseURL: import.meta.env.VITE_APP_BASE_API as string,
|
||||
timeout: 10000
|
||||
});
|
||||
|
||||
// 请求拦截器
|
||||
service.interceptors.request.use(
|
||||
config => {
|
||||
config.headers = config.headers || {};
|
||||
config.headers['Accept-Language'] = 'zh-CN';
|
||||
// 可选:添加token
|
||||
const token = localStorage.getItem('token');
|
||||
if (token) {
|
||||
config.headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
return config;
|
||||
},
|
||||
error => {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
// 响应拦截器
|
||||
service.interceptors.response.use(
|
||||
response => {
|
||||
// 统一处理后端自定义结构 { code, msg, data }
|
||||
const res = response.data;
|
||||
if (res.code === 200) {
|
||||
// 成功,返回data字段
|
||||
return res.data;
|
||||
} else {
|
||||
// 优先使用本地错误码映射
|
||||
const codeStr = String(res.code);
|
||||
const errMsg = errCodeMap[codeStr] || res.msg || errCodeMap['default'];
|
||||
notification.error({
|
||||
message: '请求错误',
|
||||
description: errMsg,
|
||||
});
|
||||
// 可在此处对401等特殊code做处理(如跳转登录)
|
||||
return Promise.reject(res);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
// 网络/服务器错误统一处理
|
||||
notification.error({
|
||||
message: '网络错误',
|
||||
description: error.message || '请求失败',
|
||||
});
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
export default service;
|
||||
16
src/api/types/check.ts
Normal file
16
src/api/types/check.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
// 验证工单-物料
|
||||
export interface CheckOrderNumber {
|
||||
workOrderCode: string;
|
||||
materialCode: string;
|
||||
}
|
||||
|
||||
// 加工信息
|
||||
export interface ProcessInfo {
|
||||
workOrderCode: string;
|
||||
productCode: string;
|
||||
employeeCode: string;
|
||||
processName: string;
|
||||
resourceName: string;
|
||||
equipmentCode: string;
|
||||
fixtureCode: string;
|
||||
}
|
||||
4
src/api/types/index.ts
Normal file
4
src/api/types/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from './laser';
|
||||
export * from './station';
|
||||
export * from './check';
|
||||
export * from './system';
|
||||
42
src/api/types/laser.ts
Normal file
42
src/api/types/laser.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
// 获取 SN 号所需参数
|
||||
export interface LaserCarvingOrderSN {
|
||||
orderNumber: string;
|
||||
itemCode: string;
|
||||
qty: number;
|
||||
}
|
||||
|
||||
// 测试项目上传所需参数
|
||||
export interface commandStringItem {
|
||||
number: '04';
|
||||
// 工号
|
||||
empNo: string;
|
||||
// SN 号
|
||||
snNo: string;
|
||||
// 工序名称
|
||||
operationName: string;
|
||||
// 资源名称
|
||||
resName: string;
|
||||
// 设备编码
|
||||
machineNo: string;
|
||||
// 工治具编码
|
||||
fixtureCode: string;
|
||||
// 测试开始时间
|
||||
testStartTime: string;
|
||||
// 检测项(检测项名称:结果值)
|
||||
testItem1: string;
|
||||
testItem2?: string;
|
||||
testItem3?: string;
|
||||
testItem4?: string;
|
||||
testItem5?: string;
|
||||
testItem6?: string;
|
||||
testItem7?: string;
|
||||
// 测试次数
|
||||
testTimes: number;
|
||||
}
|
||||
|
||||
// 上传镭雕结果所需参数,result 代表镭雕结果,例如:{"SN001":"OK}
|
||||
export interface LaserResult {
|
||||
orderNumber: string;
|
||||
itemCode: string;
|
||||
result: any
|
||||
}
|
||||
39
src/api/types/station.ts
Normal file
39
src/api/types/station.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
// 工序过站
|
||||
export interface operationCommandStringItem {
|
||||
number: '05';
|
||||
// 工号
|
||||
empNo: string;
|
||||
// SN 号
|
||||
snNo: string;
|
||||
// 工序名称
|
||||
operationName: string;
|
||||
// 资源名称
|
||||
resName: string;
|
||||
// 设备编码
|
||||
machineNo: string | null;
|
||||
// 工治具编码
|
||||
fixtureCode: string | null;
|
||||
// 测试结果
|
||||
testResult: 'OK' | 'NG';
|
||||
// 不良原因
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
// 包装过站
|
||||
export interface packageCommandStringItem {
|
||||
number: '070';
|
||||
// 工号
|
||||
empNo: string;
|
||||
// SN 号
|
||||
snNo: string | string[];
|
||||
// 工序名称
|
||||
operationName: string;
|
||||
// 资源名称
|
||||
resName: string;
|
||||
// 设备编码
|
||||
machineNo: string | null;
|
||||
// 工治具编码
|
||||
fixtureCode: string | null;
|
||||
// 装箱结果
|
||||
packageResult: 'OK';
|
||||
}
|
||||
1
src/api/types/system.ts
Normal file
1
src/api/types/system.ts
Normal file
@@ -0,0 +1 @@
|
||||
export type LmsWorkMode = 0 | 1
|
||||
Reference in New Issue
Block a user