组件封装
This commit is contained in:
39
src/api/detect/index.ts
Normal file
39
src/api/detect/index.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import request from '../request';
|
||||
import type {
|
||||
CheckOrderNumber,
|
||||
ProcessInfo,
|
||||
} from './model';
|
||||
|
||||
// 验证工单、产品编码关系是否正确
|
||||
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
|
||||
})
|
||||
}
|
||||
|
||||
// 查询 L1 数据
|
||||
export function listL1DataApi() {
|
||||
return request({
|
||||
url: '/jinghua/l1Data/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
// 查询 L4 数据
|
||||
export function listL4DataApi() {
|
||||
return request({
|
||||
url: '/jinghua/l4Data/list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// 验证工单-物料
|
||||
export interface CheckOrderNumber {
|
||||
workOrderCode: string;
|
||||
materialCode: string;
|
||||
productCode: string;
|
||||
}
|
||||
|
||||
// 加工信息
|
||||
@@ -1,5 +1,5 @@
|
||||
import request from '../request';
|
||||
import { type LmsWorkMode } from '../types';
|
||||
import type { LmsWorkMode } from './model';
|
||||
|
||||
// 获取 LMS 工作模式
|
||||
export const fetchLmsWorkMode = () => {
|
||||
@@ -1,23 +0,0 @@
|
||||
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
|
||||
})
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
export * from './user';
|
||||
export * from './laser';
|
||||
export * from './station';
|
||||
export * from './check';
|
||||
export * from './system';
|
||||
@@ -1,32 +0,0 @@
|
||||
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
|
||||
})
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
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
|
||||
})
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
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'
|
||||
})
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
import axios from 'axios';
|
||||
import { notification } from 'ant-design-vue';
|
||||
import { Modal, notification } from 'ant-design-vue';
|
||||
import router from '@/router';
|
||||
import { getToken } from '@/utils/auth';
|
||||
|
||||
interface ErrCodeMap {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
const errCodeMap: ErrCodeMap = {
|
||||
'401': '认证失败,无法访问系统资源',
|
||||
const errCodeMap: { [key: string]: string } = {
|
||||
'403': '当前操作没有权限',
|
||||
'404': '访问资源不存在',
|
||||
'default': '系统未知错误,请反馈给管理员'
|
||||
@@ -23,8 +20,8 @@ service.interceptors.request.use(
|
||||
config => {
|
||||
config.headers = config.headers || {};
|
||||
config.headers['Accept-Language'] = 'zh-CN';
|
||||
// 可选:添加token
|
||||
const token = localStorage.getItem('token');
|
||||
|
||||
const token = getToken();
|
||||
if (token) {
|
||||
config.headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
@@ -38,21 +35,28 @@ service.interceptors.request.use(
|
||||
// 响应拦截器
|
||||
service.interceptors.response.use(
|
||||
response => {
|
||||
// 统一处理后端自定义结构 { code, msg, data }
|
||||
const res = response.data;
|
||||
if (res.code === 200) {
|
||||
// 成功,返回data字段
|
||||
return res.data;
|
||||
console.log(response)
|
||||
// 未设置状态码则默认成功状态
|
||||
const code = response.data.code || 200;
|
||||
|
||||
if (code === 200) {
|
||||
return response.data ?? response;
|
||||
} else if (code === 401) {
|
||||
Modal.error({
|
||||
title: '系统提示',
|
||||
content: '登录状态已过期,请重新登录',
|
||||
onOk: () => {
|
||||
router.push('/login')
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// 优先使用本地错误码映射
|
||||
const codeStr = String(res.code);
|
||||
const errMsg = errCodeMap[codeStr] || res.msg || errCodeMap['default'];
|
||||
const codeStr = String(code);
|
||||
const errMsg = errCodeMap[codeStr] || response.data.msg || errCodeMap['default'];
|
||||
notification.error({
|
||||
message: '请求错误',
|
||||
description: errMsg,
|
||||
});
|
||||
// 可在此处对401等特殊code做处理(如跳转登录)
|
||||
return Promise.reject(res);
|
||||
return Promise.reject(response.data);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
|
||||
19
src/api/system/index.ts
Normal file
19
src/api/system/index.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import request from '../request'
|
||||
import type { LoginInfo } from './model';
|
||||
|
||||
// 用户登录
|
||||
export function login(data: LoginInfo) {
|
||||
return request({
|
||||
url: '/login',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 获取验证码
|
||||
export function getCaptcha() {
|
||||
return request({
|
||||
url: '/captchaImage',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
6
src/api/system/model.d.ts
vendored
Normal file
6
src/api/system/model.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export interface LoginInfo {
|
||||
username: string
|
||||
password: string
|
||||
uuid: string
|
||||
code: string
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
export * from './laser';
|
||||
export * from './station';
|
||||
export * from './check';
|
||||
export * from './system';
|
||||
@@ -1,42 +0,0 @@
|
||||
// 获取 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
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
// 工序过站
|
||||
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';
|
||||
}
|
||||
Reference in New Issue
Block a user