Compare commits

...

7 Commits

Author SHA1 Message Date
tao
674c1c715d 调整SSE心跳时间
优化全局环境配置
2025-11-03 17:16:30 +08:00
tao
2107dfa261 调整首页初始参数 2025-09-30 15:47:51 +08:00
tao
4fd2c32cd7 优化L1、L4数据展示界面样式 2025-09-30 15:47:41 +08:00
tao
5d0d653b11 优化SSE链接配置 2025-09-30 15:47:21 +08:00
tao
39f0d1e126 优化切换LMS状态功能:请求失败不允许切换 2025-09-30 15:46:20 +08:00
tao
c8f50782af 修改查询结构类型 2025-09-30 15:45:39 +08:00
tao
27835e73ac 优化全局配置 2025-09-30 15:44:56 +08:00
11 changed files with 157 additions and 229 deletions

View File

@@ -1,2 +1,5 @@
# 开发环境 # 开发环境
VITE_APP_BASE_API = '/api' VITE_APP_BASE_API=/api
VITE_APP_BASE_URL=http://192.168.1.38:18081

View File

@@ -1,2 +1,4 @@
# 生产环境 # 生产环境
VITE_APP_BASE_API = '/prod-api' VITE_APP_BASE_API=/prod-api
VITE_APP_BASE_URL=http://127.0.0.1:18081

1
global.d.ts vendored
View File

@@ -2,4 +2,3 @@
declare module '@/components/*'; declare module '@/components/*';
declare module '@/views/*'; declare module '@/views/*';
declare module '@/api/*'; declare module '@/api/*';
declare module '@/App.vue';

View File

@@ -2,7 +2,7 @@ export interface QueryParams {
pageNum?: number; pageNum?: number;
pageSize?: number; pageSize?: number;
orderByColumn?: string; orderByColumn?: string;
isAsc?: boolean; isAsc?: string;
qrCode?: string; qrCode?: string;
createTimeBegin?: string; createTimeBegin?: string;
createTimeEnd?: string; createTimeEnd?: string;

View File

@@ -13,7 +13,7 @@ const errCodeMap: { [key: string]: string } = {
// 创建axios实例 // 创建axios实例
const service = axios.create({ const service = axios.create({
baseURL: import.meta.env.VITE_APP_BASE_API as string, baseURL: import.meta.env.VITE_APP_BASE_API,
timeout: 10000, timeout: 10000,
}); });
@@ -37,7 +37,7 @@ service.interceptors.request.use(
// 响应拦截器 // 响应拦截器
service.interceptors.response.use( service.interceptors.response.use(
response => { response => {
console.log(response) // console.log(response);
const code = response.data.code || 200; const code = response.data.code || 200;
const data = response.data; const data = response.data;

View File

@@ -10,7 +10,7 @@
<a-row :gutter="[0, 12]"> <a-row :gutter="[0, 12]">
<a-col :span="8" class="modal-label">LMS 状态</a-col> <a-col :span="8" class="modal-label">LMS 状态</a-col>
<a-col :span="16" class="modal-value"> <a-col :span="16" class="modal-value">
<a-switch v-model:checked="isOnline" checked-children="在线" un-checked-children="离线" @change="handleToggleOnline" /> <a-switch v-model:checked="isOnline" checked-children="在线" un-checked-children="离线" :loading="loading" @click="handleToggleOnline" />
</a-col> </a-col>
</a-row> </a-row>
<a-row :gutter="[0, 12]"> <a-row :gutter="[0, 12]">
@@ -37,6 +37,7 @@ import { message } from 'ant-design-vue';
const { visible: dialogVisible, show, hide } = useDialog(); const { visible: dialogVisible, show, hide } = useDialog();
const isOnline = ref(false); const isOnline = ref(false);
const loading = ref(false);
const lmsStatus = computed(() => isOnline.value ? '在线' : '离线'); const lmsStatus = computed(() => isOnline.value ? '在线' : '离线');
const onlineStatusClass = computed(() => { const onlineStatusClass = computed(() => {
@@ -45,12 +46,19 @@ const onlineStatusClass = computed(() => {
// 当请求发送成功后才切换状态 // 当请求发送成功后才切换状态
async function handleToggleOnline(checked: boolean | string | number) { async function handleToggleOnline(checked: boolean | string | number) {
await updateLmsWorkMode(checked ? 1 : 0).then(() => { console.log('checked', checked);
loading.value = true;
try {
await updateLmsWorkMode(checked ? 1 : 0);
isOnline.value = Boolean(checked); isOnline.value = Boolean(checked);
message.success('切换成功'); message.success('切换成功');
}).catch((error) => { } catch (e) {
isOnline.value = !Boolean(checked);
message.error('切换失败'); message.error('切换失败');
}); } finally {
loading.value = false;
}
} }
const modalTitle = ref('LMS 状态'); const modalTitle = ref('LMS 状态');

View File

@@ -3,8 +3,7 @@ import { EventSourcePolyfill } from 'event-source-polyfill';
import { generateUUID } from './uuidUtils'; import { generateUUID } from './uuidUtils';
import { getToken } from '@/utils/auth'; import { getToken } from '@/utils/auth';
// const defaultServerUrl = 'http://192.168.1.38:18081/sse'; const defaultServerUrl = import.meta.env.VITE_APP_BASE_URL + '/sse';
const defaultServerUrl = 'http://127.0.0.1:18081/sse';
interface EventData { interface EventData {
timestamp: string; timestamp: string;
@@ -13,7 +12,7 @@ interface EventData {
code: 200 | 201 | 300 | 400 | 500; code: 200 | 201 | 300 | 400 | 500;
} }
interface logItem { export interface logItem {
message: string; message: string;
type?: "success" | "error" | "log"; type?: "success" | "error" | "log";
} }
@@ -129,8 +128,9 @@ export function useSSE(options: SSEOptions) {
// 创建EventSource // 创建EventSource
const eventSourceOptions = { const eventSourceOptions = {
headers: { headers: {
'Authorization': `Bearer ${getToken()}`, Authorization: `Bearer ${getToken()}`,
} },
heartbeatTimeout: 90 * 60 * 1000,
}; };
eventSource = new EventSourcePolyfill(connectUrl, eventSourceOptions); eventSource = new EventSourcePolyfill(connectUrl, eventSourceOptions);

View File

@@ -9,7 +9,7 @@
<a-form layout="inline" :model="formData"> <a-form layout="inline" :model="formData">
<a-form-item label="日期范围"> <a-form-item label="日期范围">
<a-range-picker v-model:value="formData.dateRange" :placeholder="['开始日期', '结束日期']" <a-range-picker v-model:value="formData.dateRange" :placeholder="['开始日期', '结束日期']"
format="YYYY-MM-DD hh:mm:ss" class="date-range-picker" show-time /> format="YYYY-MM-DD hh:mm:ss" show-time />
</a-form-item> </a-form-item>
<a-form-item> <a-form-item>
<a-space> <a-space>
@@ -237,111 +237,54 @@ onMounted(() => {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@use "@/assets/styles/variables" as *; .l1-data-container {
padding: 20px;
.wrapper { background: #f5f5f5;
width: 100%; min-height: 100vh;
height: 100%;
overflow: hidden;
} }
.l1-data-container { .page-header {
display: flex; margin-bottom: 20px;
flex-direction: column;
height: 100vh;
padding: $spacing-lg;
.page-header {
margin-bottom: $spacing-lg;
flex-shrink: 0;
.page-title { .page-title {
font-size: $title-font-size; font-size: 24px;
color: $text-dark;
margin: 0;
font-weight: 600; font-weight: 600;
} color: #1f2937;
} margin: 0;
.filter-section {
background: $bg-light;
padding: $spacing-lg;
border-radius: $border-radius-lg;
margin-bottom: $spacing-lg;
flex-shrink: 0;
.filter-label {
font-weight: 500;
color: $text-dark;
font-size: $content-font-size;
}
}
.table-section {
overflow: hidden;
display: flex;
flex-direction: column;
:deep(.ant-table-wrapper) {
height: 100%;
display: flex;
flex-direction: column;
.ant-spin-container,
.ant-table {
flex-grow: 1;
display: flex;
flex-direction: column;
}
.ant-table-container {
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
}
.ant-table-body {
overflow-y: auto !important;
}
}
}
.detail-content {
.ant-descriptions {
margin-top: $spacing-md;
}
} }
} }
:deep(.ant-btn-primary) { .filter-section {
background: $primary-color; background: white;
border-color: $primary-color; padding: 20px;
border-radius: 8px;
&:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
background: $primary-light; margin-bottom: 20px;
border-color: $primary-light;
}
} }
@media (max-width: 768px) { .table-section {
.l1-data-container { background: white;
padding: $spacing-md; padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.filter-section { .detail-content {
.ant-row { max-height: 500px;
flex-direction: column; overflow-y: auto;
gap: $spacing-md; }
.ant-col { :deep(.ant-table-thead > tr > th) {
width: 100% !important; background: #f8fafc;
} font-weight: 600;
} }
.date-range-picker { :deep(.ant-table-tbody > tr:hover > td) {
width: 100%; background: #f0f9ff;
} }
}
} :deep(.ant-descriptions-item-label) {
font-weight: 600;
background: #f8fafc;
} }
</style> </style>

View File

@@ -8,13 +8,8 @@
<div class="filter-section"> <div class="filter-section">
<a-form layout="inline" :model="formData"> <a-form layout="inline" :model="formData">
<a-form-item label="日期范围"> <a-form-item label="日期范围">
<a-range-picker <a-range-picker v-model:value="formData.dateRange" :placeholder="['开始日期', '结束日期']"
v-model:value="formData.dateRange" format="YYYY-MM-DD hh:mm:ss" show-time />
:placeholder="['开始日期', '结束日期']"
format="YYYY-MM-DD hh:mm:ss"
class="date-range-picker"
show-time
/>
</a-form-item> </a-form-item>
<a-form-item> <a-form-item>
<a-space> <a-space>
@@ -37,17 +32,10 @@
<!-- 数据表格 --> <!-- 数据表格 -->
<div class="table-section"> <div class="table-section">
<a-table <a-table :columns="columns" :data-source="tableData" :loading="loading" :pagination="pagination"
:columns="columns" @change="handleTableChange" row-key="id" size="middle" :scroll="{ x: 1200 }">
:data-source="tableData" <template #bodyCell="{ column, record, index }">
:loading="loading" <template v-if="column.key === 'index'">{{ index + 1 }}</template>
:pagination="pagination"
@change="handleTableChange"
row-key="id"
size="middle"
:scroll="{ x: 1200 }"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'createTime'"> <template v-if="column.key === 'createTime'">
{{ formatDateTime(record.createTime) }} {{ formatDateTime(record.createTime) }}
</template> </template>
@@ -86,24 +74,19 @@
查看详情 查看详情
</a-button> </a-button>
</template> </template>
<template v-else>
{{ record[column.key as string] }}
</template>
</template> </template>
</a-table> </a-table>
</div> </div>
<!-- 详情弹窗 --> <!-- 详情弹窗 -->
<a-modal <a-modal v-model:open="detailModalVisible" title="L4数据详情" width="800px" :footer="null">
v-model:open="detailModalVisible"
title="L4数据详情"
width="800px"
:footer="null"
>
<div v-if="selectedRecord" class="detail-content"> <div v-if="selectedRecord" class="detail-content">
<a-descriptions :column="2" bordered> <a-descriptions :column="2" bordered>
<a-descriptions-item <a-descriptions-item v-for="(value, key) in selectedRecord" :key="key"
v-for="(value, key) in selectedRecord" :label="columns.find((col) => col.key === key)?.title || key">
:key="key"
:label="columns.find((col) => col.key === key)?.title || key"
>
<template v-if="key === 'createTime'"> <template v-if="key === 'createTime'">
{{ formatDateTime(value) }} {{ formatDateTime(value) }}
</template> </template>
@@ -148,13 +131,14 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, computed, onMounted } from 'vue'; import { ref, reactive, onMounted } from 'vue';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import { getL4Data } from '@/api/data'; import { getL4Data } from '@/api/data';
import { columns } from './data'; import { columns } from './data';
import type { QueryParams } from '@/api/data/model'; import type { QueryParams } from '@/api/data/model';
import type { L4Data } from './types'; import type { L4Data } from './types';
import type { Dayjs } from 'dayjs'; import type { Dayjs } from 'dayjs';
import { idText } from 'typescript';
type DateRangeType = [Dayjs, Dayjs] | undefined; type DateRangeType = [Dayjs, Dayjs] | undefined;
@@ -209,6 +193,8 @@ const fetchData = async () => {
const params: QueryParams = { const params: QueryParams = {
pageNum: pagination.current, pageNum: pagination.current,
pageSize: pagination.pageSize, pageSize: pagination.pageSize,
orderByColumn: 'id',
isAsc: 'desc'
}; };
// 添加日期范围筛选 // 添加日期范围筛选
@@ -278,7 +264,7 @@ onMounted(() => {
}); });
</script> </script>
<style scoped> <style scoped lang="scss">
.l4-data-container { .l4-data-container {
padding: 20px; padding: 20px;
background: #f5f5f5; background: #f5f5f5;
@@ -287,13 +273,13 @@ onMounted(() => {
.page-header { .page-header {
margin-bottom: 20px; margin-bottom: 20px;
}
.page-title { .page-title {
font-size: 24px; font-size: 24px;
font-weight: 600; font-weight: 600;
color: #1f2937; color: #1f2937;
margin: 0; margin: 0;
}
} }
.filter-section { .filter-section {
@@ -304,10 +290,6 @@ onMounted(() => {
margin-bottom: 20px; margin-bottom: 20px;
} }
.date-range-picker {
width: 300px;
}
.table-section { .table-section {
background: white; background: white;
padding: 20px; padding: 20px;

View File

@@ -182,17 +182,15 @@ const handleSseMessage = (data: string) => {
console.log('收到SSE消息:', data); console.log('收到SSE消息:', data);
}; };
// Status handlers are now managed by individual modal components
// 检测设备表单数据 // 检测设备表单数据
const detectForm = reactive({ const detectForm = reactive({
workOrderCode: 'SKT202507220001', workOrderCode: '',
productCode: 'JH1008611', productCode: '',
employeeCode: 'ZDXTEST', employeeCode: '',
processName: 'T-自动组装测试', processName: '',
resourceName: 'T-A自动组装测试', resourceName: '',
equipmentCode: 'JH.02.101.13-219', equipmentCode: '',
fixtureCode: 'JH0001', fixtureCode: '',
confirmSequence: '', confirmSequence: '',
detectionData: '', detectionData: '',
sequenceCount: 1 sequenceCount: 1
@@ -200,18 +198,18 @@ const detectForm = reactive({
// 包装设备表单数据 // 包装设备表单数据
const packageForm = reactive({ const packageForm = reactive({
customerSelection: '上海电子科技有限公司', customerSelection: '',
productModel: 'A538-09-高精度传感器', productModel: '',
employeeCode: 'OP-7853', employeeCode: '',
processName: '自动包装', processName: '',
resourceName: '包装台2号', resourceName: '',
equipmentCode: 'EQ-PK-002', equipmentCode: '',
fixtureCode: 'FX-PK-002-B', fixtureCode: '',
packingResult: '正常', packingResult: '',
sequenceNumber: 'SN-A538-09-2023-00018', sequenceNumber: '',
passStationCount: 18, passStationCount: '',
fullBoxCount: 25, fullBoxCount: '',
passStationSequence: 'SN-A538-09-2023-00018' passStationSequence: ''
}); });
// 编辑模式切换 // 编辑模式切换
@@ -476,19 +474,7 @@ onBeforeUnmount(() => {
hideRequiredMark :labelCol="{ span: 4 }" :wrapperCol="{ span: 20 }"> hideRequiredMark :labelCol="{ span: 4 }" :wrapperCol="{ span: 20 }">
<a-row :gutter="32"> <a-row :gutter="32">
<a-col :span="12"> <a-col :span="12">
<a-form-item label="客户选择" name="customerSelection"> <a-form-item label="员工工号" name="employeeCode">
<a-input v-model:value="packageForm.customerSelection" class="edit-input"
:disabled="!isPackageEditMode" />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="产品型号" name="productModel">
<a-input v-model:value="packageForm.productModel" class="edit-input"
:disabled="!isPackageEditMode" />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="工号" name="employeeCode">
<a-input v-model:value="packageForm.employeeCode" class="edit-input" <a-input v-model:value="packageForm.employeeCode" class="edit-input"
:disabled="!isPackageEditMode" /> :disabled="!isPackageEditMode" />
</a-form-item> </a-form-item>

View File

@@ -1,4 +1,4 @@
import { defineConfig } from 'vite'; import { defineConfig, loadEnv } from 'vite';
import Components from "unplugin-vue-components/vite"; // 按需组件自动导入 import Components from "unplugin-vue-components/vite"; // 按需组件自动导入
import { AntDesignVueResolver } from "unplugin-vue-components/resolvers"; import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
import vue from '@vitejs/plugin-vue'; import vue from '@vitejs/plugin-vue';
@@ -7,7 +7,11 @@ import IconsResolver from 'unplugin-icons/resolver';
import path from 'path'; import path from 'path';
// https://vite.dev/config/ // https://vite.dev/config/
export default defineConfig({ export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
return {
resolve: { resolve: {
alias: { alias: {
"@": path.resolve(__dirname, "src"), "@": path.resolve(__dirname, "src"),
@@ -16,12 +20,12 @@ export default defineConfig({
server: { server: {
proxy: { proxy: {
"/api": { "/api": {
target: "http://192.168.1.38:18081", target: env.VITE_APP_BASE_URL,
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ""), rewrite: (path) => path.replace(/^\/api/, ""),
}, },
"/prod-api": { "/prod-api": {
target: "http://127.0.0.1:18081", target: env.VITE_APP_BASE_URL,
changeOrigin: true, changeOrigin: true,
}, },
}, },
@@ -47,4 +51,5 @@ export default defineConfig({
autoInstall: true, // 没安装的图标库会自动下载 autoInstall: true, // 没安装的图标库会自动下载
}), }),
], ],
}
}); });