From c493779a8504fe1eb548c865ff268a7f7436ec01 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期四, 19 三月 2026 11:43:36 +0800
Subject: [PATCH] feat: 集成机械手客户端并重构模拟器前端工作台
---
Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Web/src/views/EditView.vue | 130 ++++++++++++++++++++++++------------------
1 files changed, 74 insertions(+), 56 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Web/src/views/EditView.vue b/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Web/src/views/EditView.vue
index 043fe13..ecc26b1 100644
--- a/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Web/src/views/EditView.vue
+++ b/Code/WCS/WIDESEAWCS_S7Simulator/WIDESEAWCS_S7Simulator.Web/src/views/EditView.vue
@@ -1,5 +1,5 @@
-<template>
- <div>
+锘�<template>
+ <div class="admin-page">
<div v-if="loading" class="loading-container">
<el-icon class="loading-icon" :size="40"><Loading /></el-icon>
<p>鍔犺浇涓�...</p>
@@ -40,7 +40,7 @@
<el-row justify="center">
<el-col :lg="24">
- <el-card shadow="never">
+ <el-card shadow="never" class="panel-card">
<el-form :model="form" :rules="rules" ref="formRef" label-width="120px">
<!-- 鍩烘湰淇℃伅 -->
<el-divider content-position="left">
@@ -98,6 +98,21 @@
</el-col>
</el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="鍗忚妯℃澘" prop="protocolTemplateId">
+ <el-select v-model="form.protocolTemplateId" style="width: 100%">
+ <el-option
+ v-for="tpl in protocolTemplates"
+ :key="tpl.id"
+ :label="`${tpl.name} (${tpl.id})`"
+ :value="tpl.id"
+ />
+ </el-select>
+ </el-form-item>
+ </el-col>
+ </el-row>
+
<!-- 鍐呭瓨閰嶇疆 -->
<el-divider content-position="left">
<h3>鍐呭瓨閰嶇疆</h3>
@@ -105,7 +120,7 @@
<el-row :gutter="20">
<el-col :span="8">
- <el-form-item label="M鍖哄煙澶у皬">
+ <el-form-item label="M鍖哄ぇ灏�">
<el-input-number
v-model="form.mRegionSize"
:min="0"
@@ -114,7 +129,7 @@
</el-form-item>
</el-col>
<el-col :span="8">
- <el-form-item label="I鍖哄煙澶у皬">
+ <el-form-item label="I鍖哄ぇ灏�">
<el-input-number
v-model="form.iRegionSize"
:min="0"
@@ -123,7 +138,7 @@
</el-form-item>
</el-col>
<el-col :span="8">
- <el-form-item label="Q鍖哄煙澶у皬">
+ <el-form-item label="Q鍖哄ぇ灏�">
<el-input-number
v-model="form.qRegionSize"
:min="0"
@@ -135,11 +150,16 @@
<el-row :gutter="20">
<el-col :span="8">
- <el-form-item label="DB鍧楁暟閲�">
- <el-input-number
- v-model="form.dbBlockCount"
- :min="0"
+ <el-form-item label="DB鍧楀垪琛�">
+ <el-select
+ v-model="form.dbBlockNumbers"
+ multiple
+ filterable
+ allow-create
+ default-first-option
+ :reserve-keyword="false"
style="width: 100%"
+ placeholder="杈撳叆鍧楀彿鍚庡洖杞︼紝渚嬪 50銆�900銆�901"
/>
</el-form-item>
</el-col>
@@ -194,7 +214,7 @@
import type { FormInstance, FormRules } from 'element-plus'
import { Edit, Back, Loading } from '@element-plus/icons-vue'
import * as api from '../api'
-import type { InstanceConfig, MemoryRegionConfig, SiemensPLCType } from '../types'
+import type { InstanceConfig, MemoryRegionConfig, ProtocolTemplate, SiemensPLCType } from '../types'
const router = useRouter()
const route = useRoute()
@@ -207,9 +227,11 @@
port: 102,
activationKey: '',
autoStart: false,
+ protocolTemplateId: '',
mRegionSize: 1024,
- dbBlockCount: 100,
- dbBlockSize: 1024,
+ dbBlockCount: 0,
+ dbBlockNumbers: [] as Array<number | string>,
+ dbBlockSize: 65536,
iRegionSize: 256,
qRegionSize: 256,
tRegionCount: 64,
@@ -220,6 +242,7 @@
const errorMsg = ref('')
const submitting = ref(false)
const isRunning = ref(false)
+const protocolTemplates = ref<ProtocolTemplate[]>([])
const id = route.params.id as string
@@ -232,12 +255,17 @@
],
port: [
{ required: true, message: '璇疯緭鍏ョ洃鍚鍙�', trigger: 'blur' },
- { type: 'number', min: 1, max: 65535, message: '绔彛蹇呴』鍦�1-65535涔嬮棿', trigger: 'blur' }
+ { type: 'number', min: 1, max: 65535, message: '绔彛蹇呴』鍦� 1-65535 涔嬮棿', trigger: 'blur' }
+ ],
+ protocolTemplateId: [
+ { required: true, message: '璇烽�夋嫨鍗忚妯℃澘', trigger: 'change' }
]
}
onMounted(async () => {
try {
+ protocolTemplates.value = await api.getProtocolTemplates()
+
// 鑾峰彇瀹炰緥鐘舵��
const state = await api.getInstance(id)
if (!state) {
@@ -263,8 +291,10 @@
port: config.port,
activationKey: config.activationKey,
autoStart: config.autoStart,
+ protocolTemplateId: config.protocolTemplateId || '',
mRegionSize: config.memoryConfig.mRegionSize,
- dbBlockCount: config.memoryConfig.dbBlockCount,
+ dbBlockCount: 0,
+ dbBlockNumbers: toDbBlockNumbers(config.memoryConfig.dbBlockNumbers, config.memoryConfig.dbBlockCount),
dbBlockSize: config.memoryConfig.dbBlockSize,
iRegionSize: config.memoryConfig.iRegionSize,
qRegionSize: config.memoryConfig.qRegionSize,
@@ -288,9 +318,16 @@
submitting.value = true
try {
+ const dbBlockNumbers = normalizeDbBlockNumbers(form.value.dbBlockNumbers)
+ if (dbBlockNumbers.length === 0) {
+ ElMessage.error('璇疯嚦灏戦厤缃竴涓狣B鍧楀彿锛屼緥濡� 50,900,901')
+ return
+ }
+
const memoryConfig: MemoryRegionConfig = {
mRegionSize: form.value.mRegionSize > 0 ? form.value.mRegionSize : 1024,
- dbBlockCount: form.value.dbBlockCount > 0 ? form.value.dbBlockCount : 100,
+ dbBlockCount: 0,
+ dbBlockNumbers,
dbBlockSize: form.value.dbBlockSize > 0 ? form.value.dbBlockSize : 1024,
iRegionSize: form.value.iRegionSize > 0 ? form.value.iRegionSize : 256,
qRegionSize: form.value.qRegionSize > 0 ? form.value.qRegionSize : 256,
@@ -305,6 +342,7 @@
port: form.value.port,
activationKey: form.value.activationKey,
autoStart: form.value.autoStart,
+ protocolTemplateId: form.value.protocolTemplateId,
memoryConfig
}
@@ -324,49 +362,29 @@
}
})
}
+
+function normalizeDbBlockNumbers(input: Array<number | string>): number[] {
+ return Array.from(new Set(
+ input
+ .map(x => Number(String(x).trim()))
+ .filter(x => Number.isInteger(x) && x > 0)
+ )).sort((a, b) => a - b)
+}
+
+function toDbBlockNumbers(dbBlockNumbers: number[] | undefined, dbBlockCount: number): Array<number | string> {
+ if (dbBlockNumbers && dbBlockNumbers.length > 0) {
+ return dbBlockNumbers
+ }
+
+ if (dbBlockCount > 0) {
+ return Array.from({ length: dbBlockCount }, (_, idx) => idx + 1)
+ }
+
+ return []
+}
</script>
<style scoped>
-.page-header {
- display: flex;
- justify-content: space-between;
- align-items: flex-start;
- margin-bottom: 20px;
- flex-wrap: wrap;
- gap: 16px;
-}
-
-.header-left h2 {
- display: flex;
- align-items: center;
- gap: 8px;
- margin: 0 0 8px 0;
-}
-
-.text-muted {
- color: #909399;
- margin: 0;
-}
-
-.loading-container {
- text-align: center;
- padding: 60px 0;
- color: #909399;
-}
-
-.loading-icon {
- animation: spin 1s linear infinite;
-}
-
-@keyframes spin {
- from {
- transform: rotate(0deg);
- }
- to {
- transform: rotate(360deg);
- }
-}
-
.form-tip {
font-size: 12px;
color: #909399;
--
Gitblit v1.9.3