diff --git a/Release/database/XNSim.db b/Release/database/XNSim.db index 8cd7cc0..3b232e4 100644 Binary files a/Release/database/XNSim.db and b/Release/database/XNSim.db differ diff --git a/XNSimHtml/components/header-tools.js b/XNSimHtml/components/header-tools.js index 09c9f12..a8642f5 100644 --- a/XNSimHtml/components/header-tools.js +++ b/XNSimHtml/components/header-tools.js @@ -11,15 +11,15 @@ class HeaderTools extends HTMLElement { return this.shadowRoot.getElementById('planeSelect').value; } - get selectedProduct() { - return this.shadowRoot.getElementById('productSelect').value; + get selectedConfiguration() { + return this.shadowRoot.getElementById('configurationSelect').value; } // 保存选择到localStorage saveSelection() { const selection = { plane: this.selectedPlane, - product: this.selectedProduct + configurationId: this.selectedConfiguration }; localStorage.setItem('xnsim-selection', JSON.stringify(selection)); } @@ -30,16 +30,16 @@ class HeaderTools extends HTMLElement { if (savedSelection) { const selection = JSON.parse(savedSelection); const planeSelect = this.shadowRoot.getElementById('planeSelect'); - const productSelect = this.shadowRoot.getElementById('productSelect'); + const configurationSelect = this.shadowRoot.getElementById('configurationSelect'); // 先加载机型列表 this.loadPlanes().then(() => { if (selection.plane) { planeSelect.value = selection.plane; // 加载该机型下的构型列表 - this.loadProducts(selection.plane).then(() => { - if (selection.product) { - productSelect.value = selection.product; + this.loadConfigurations(selection.plane).then(() => { + if (selection.configurationId) { + configurationSelect.value = selection.configurationId; } }); } @@ -88,7 +88,7 @@ class HeaderTools extends HTMLElement { color: #666; } - .plane-select, .product-select { + .plane-select, .configuration-select { min-width: 120px; height: 32px; padding: 0 8px; @@ -130,7 +130,7 @@ class HeaderTools extends HTMLElement {
构型: -
@@ -157,7 +157,7 @@ class HeaderTools extends HTMLElement { // 加载机型列表 this.loadPlanes(); // 加载构型列表 - this.loadProducts(); + this.loadConfigurations(); // 恢复上次的选择 this.restoreSelection(); @@ -187,15 +187,19 @@ class HeaderTools extends HTMLElement { detail: { plane: e.target.value } })); // 当机型改变时,重新加载该机型下的构型列表 - this.loadProducts(e.target.value); + this.loadConfigurations(e.target.value); // 保存选择 this.saveSelection(); }); // 构型选择 - this.shadowRoot.getElementById('productSelect').addEventListener('change', (e) => { - this.dispatchEvent(new CustomEvent('product-change', { - detail: { product: e.target.value } + this.shadowRoot.getElementById('configurationSelect').addEventListener('change', (e) => { + const selectedOption = e.target.options[e.target.selectedIndex]; + this.dispatchEvent(new CustomEvent('configuration-change', { + detail: { + configurationId: e.target.value, + configurationName: selectedOption.textContent + } })); // 保存选择 this.saveSelection(); @@ -225,23 +229,23 @@ class HeaderTools extends HTMLElement { } } - async loadProducts(planeName = '') { + async loadConfigurations(planeName = '') { try { const url = planeName ? `/api/configurations?plane=${planeName}` : '/api/configurations'; const response = await fetch(url); if (!response.ok) { throw new Error('获取构型列表失败'); } - const products = await response.json(); - const select = this.shadowRoot.getElementById('productSelect'); + const configurations = await response.json(); + const select = this.shadowRoot.getElementById('configurationSelect'); // 清空现有选项 select.innerHTML = ''; - products.forEach(product => { + configurations.forEach(config => { const option = document.createElement('option'); - option.value = product.ConfName; - option.textContent = product.ConfName; + option.value = config.ConfID; + option.textContent = config.ConfName; select.appendChild(option); }); } catch (error) { diff --git a/XNSimHtml/components/interface-config.js b/XNSimHtml/components/interface-config.js index e33be2c..0401a07 100644 --- a/XNSimHtml/components/interface-config.js +++ b/XNSimHtml/components/interface-config.js @@ -8,7 +8,7 @@ class InterfaceConfig extends HTMLElement { super(); this.attachShadow({ mode: 'open' }); this.data = []; - this.products = []; // 存储构型列表 + this.planes = []; // 存储构型列表 this.atas = []; // 存储ATA章节列表 } @@ -39,16 +39,25 @@ class InterfaceConfig extends HTMLElement { } if (!confirm(`确定要删除选中的 ${selectedRows.length} 个接口吗?`)) { - return; - } + return; + } - try { + try { + const savedSelection = localStorage.getItem('xnsim-selection'); + if (!savedSelection) { + throw new Error('请先选择构型'); + } + const selection = JSON.parse(savedSelection); + if (!selection.configurationId) { + throw new Error('请先选择构型'); + } + const deletePromises = selectedRows.map(row => { - const { SystemName, ProductName, ATAName, ModelStructName, InterfaceName } = row; - return fetch(`/api/interface/delete?systemName=${SystemName}&productName=${ProductName}&ataName=${ATAName}&modelStructName=${ModelStructName}&interfaceName=${InterfaceName}`, { + const { InterfaceName } = row; + return fetch(`/api/interface/delete?interfaceName=${InterfaceName}&confID=${selection.configurationId}`, { method: 'DELETE' - }); - }); + }); + }); const results = await Promise.all(deletePromises); const failed = results.some(result => !result.ok); @@ -61,30 +70,7 @@ class InterfaceConfig extends HTMLElement { alert('删除成功'); } catch (error) { console.error('删除接口时出错:', error); - alert('删除接口失败'); - } - }); - - // 下载模板事件 - toolbar.addEventListener('download-template', async () => { - try { - const response = await fetch('/api/interface/template'); - if (!response.ok) { - throw new Error('下载模板失败'); - } - - const blob = await response.blob(); - const url = window.URL.createObjectURL(blob); - const a = document.createElement('a'); - a.href = url; - a.download = '接口变量模板.xlsx'; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - window.URL.revokeObjectURL(url); - } catch (error) { - console.error('下载模板时出错:', error); - alert('下载模板失败'); + alert(error.message || '删除接口失败'); } }); @@ -123,14 +109,29 @@ class InterfaceConfig extends HTMLElement { importDialog.addEventListener('confirm-import', async (e) => { const importData = e.detail; try { - console.log('准备导入的数据:', importData); + const savedSelection = localStorage.getItem('xnsim-selection'); + if (!savedSelection) { + throw new Error('请先选择构型'); + } + const selection = JSON.parse(savedSelection); + if (!selection.configurationId) { + throw new Error('请先选择构型'); + } + + // 为每个导入项添加 confID + const importDataWithConfID = importData.map(item => ({ + ...item, + ConfID: selection.configurationId + })); + + console.log('准备导入的数据:', importDataWithConfID); const response = await fetch('/api/interface/import', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(importData) + body: JSON.stringify(importDataWithConfID) }); if (!response.ok) { @@ -147,7 +148,7 @@ class InterfaceConfig extends HTMLElement { } } catch (error) { console.error('保存导入数据时出错:', error); - alert('保存导入数据失败: ' + error.message); + alert(error.message || '保存导入数据失败'); } }); @@ -156,7 +157,7 @@ class InterfaceConfig extends HTMLElement { const variableForm = this.shadowRoot.querySelector('variable-form'); if (variableForm) { // 确保在设置编辑数据之前先设置选项 - variableForm.setOptions(this.products, this.atas); + variableForm.setOptions(this.planes, this.atas); // 先显示表单,再设置模式和数据 variableForm.show(); variableForm.setMode('edit', e.detail); @@ -165,10 +166,19 @@ class InterfaceConfig extends HTMLElement { // 表格删除按钮事件 dataTable.addEventListener('delete', async (e) => { - const { SystemName, ProductName, ATAName, ModelStructName, InterfaceName } = e.detail; + const { InterfaceName } = e.detail; try { - const response = await fetch(`/api/interface/delete?systemName=${SystemName}&productName=${ProductName}&ataName=${ATAName}&modelStructName=${ModelStructName}&interfaceName=${InterfaceName}`, { + const savedSelection = localStorage.getItem('xnsim-selection'); + if (!savedSelection) { + throw new Error('请先选择构型'); + } + const selection = JSON.parse(savedSelection); + if (!selection.configurationId) { + throw new Error('请先选择构型'); + } + + const response = await fetch(`/api/interface/delete?interfaceName=${InterfaceName}&confID=${selection.configurationId}`, { method: 'DELETE' }); @@ -180,7 +190,7 @@ class InterfaceConfig extends HTMLElement { alert('删除成功'); } catch (error) { console.error('删除接口时出错:', error); - alert('删除接口失败'); + alert(error.message || '删除接口失败'); } }); @@ -195,7 +205,7 @@ class InterfaceConfig extends HTMLElement { const requestData = interfaceData.mode === 'edit' ? { currentData: { SystemName: 'XNSim', - ProductName: interfaceData.ProductName, + PlaneName: interfaceData.PlaneName, ATAName: interfaceData.ATAName, ModelStructName: interfaceData.ModelStructName, InterfaceName: interfaceData.InterfaceName, @@ -204,18 +214,19 @@ class InterfaceConfig extends HTMLElement { InterfaceIsArray: interfaceData.InterfaceIsArray, InterfaceArraySize_1: interfaceData.InterfaceArraySize_1, InterfaceArraySize_2: interfaceData.InterfaceArraySize_2, - InterfaceNotes: interfaceData.InterfaceNotes + InterfaceNotes: interfaceData.InterfaceNotes, + ConfID: interfaceData.ConfID }, originalData: { SystemName: 'XNSim', - ProductName: interfaceData.originalProductName || interfaceData.ProductName, + PlaneName: interfaceData.originalPlaneName || interfaceData.PlaneName, ATAName: interfaceData.originalATAName || interfaceData.ATAName, ModelStructName: interfaceData.originalModelStructName || interfaceData.ModelStructName, InterfaceName: interfaceData.originalInterfaceName || interfaceData.InterfaceName } } : { SystemName: 'XNSim', - ProductName: interfaceData.ProductName, + PlaneName: interfaceData.PlaneName, ATAName: interfaceData.ATAName, ModelStructName: interfaceData.ModelStructName, InterfaceName: interfaceData.InterfaceName, @@ -224,7 +235,8 @@ class InterfaceConfig extends HTMLElement { InterfaceIsArray: interfaceData.InterfaceIsArray, InterfaceArraySize_1: interfaceData.InterfaceArraySize_1, InterfaceArraySize_2: interfaceData.InterfaceArraySize_2, - InterfaceNotes: interfaceData.InterfaceNotes + InterfaceNotes: interfaceData.InterfaceNotes, + ConfID: interfaceData.ConfID }; const response = await fetch(url, { @@ -288,14 +300,24 @@ class InterfaceConfig extends HTMLElement { async loadData() { try { - const response = await fetch('/api/interface/list'); + // 从 localStorage 获取选择 + const savedSelection = localStorage.getItem('xnsim-selection'); + if (!savedSelection) { + throw new Error('请先选择构型'); + } + const selection = JSON.parse(savedSelection); + if (!selection.configurationId) { + throw new Error('请先选择构型'); + } + + const response = await fetch(`/api/interface/list?systemName=XNSim&confID=${selection.configurationId}`); if (!response.ok) { throw new Error('获取数据失败'); } this.data = await response.json(); - // 从接口数据中提取构型和ATA章节列表 - this.products = [...new Set(this.data.map(item => item.ProductName))]; + // 从接口数据中提取机型和ATA章节列表 + this.planes = [...new Set(this.data.map(item => item.PlaneName))]; this.atas = [...new Set(this.data.map(item => item.ATAName))]; this.updateTable(); @@ -304,16 +326,16 @@ class InterfaceConfig extends HTMLElement { // 通知所有子组件数据已更新 const importDialog = this.shadowRoot.querySelector('import-dialog'); if (importDialog) { - importDialog.setOptions(this.products, this.atas); + importDialog.setOptions(this.planes, this.atas); } const variableForm = this.shadowRoot.querySelector('variable-form'); if (variableForm) { - variableForm.setOptions(this.products, this.atas); + variableForm.setOptions(this.planes, this.atas); } } catch (error) { console.error('加载数据时出错:', error); - alert('加载数据失败'); + alert(error.message || '加载数据失败'); } } @@ -333,7 +355,7 @@ class InterfaceConfig extends HTMLElement { // 更新下拉选项 toolbar.updateFilterOptions({ - products: this.products, + planes: this.planes, atas: this.atas, structs }); diff --git a/XNSimHtml/components/interface-config/data-table.js b/XNSimHtml/components/interface-config/data-table.js index 2b81579..4a488e3 100644 --- a/XNSimHtml/components/interface-config/data-table.js +++ b/XNSimHtml/components/interface-config/data-table.js @@ -7,7 +7,7 @@ class InterfaceDataTable extends HTMLElement { this.selectedRows = new Set(); this.searchKeyword = ''; this.filters = { - productName: '', + planeName: '', ataName: '', structName: '' }; @@ -92,7 +92,7 @@ class InterfaceDataTable extends HTMLElement { // 重置所有筛选条件 this.searchKeyword = ''; this.filters = { - productName: '', + planeName: '', ataName: '', structName: '' }; @@ -164,9 +164,9 @@ class InterfaceDataTable extends HTMLElement { // 首先根据高级搜索条件过滤 let filtered = [...this.data]; - if (this.filters.productName) { + if (this.filters.planeName) { filtered = filtered.filter(item => - item.ProductName === this.filters.productName + item.PlaneName === this.filters.planeName ); } if (this.filters.ataName) { @@ -209,8 +209,11 @@ class InterfaceDataTable extends HTMLElement { this.selectedRows.clear(); // 设置新数据 - this.data = data; - this.filteredData = [...data]; + this.data = data.map((item, index) => ({ + ...item, + _displayIndex: index + })); + this.filteredData = [...this.data]; this.currentPage = 1; this.render(); } finally { @@ -238,11 +241,7 @@ class InterfaceDataTable extends HTMLElement { getCurrentPageData() { const start = (this.currentPage - 1) * this.pageSize; - const end = start + this.pageSize; - return this.filteredData.slice(start, end).map((item, index) => ({ - ...item, - _displayIndex: start + index - })); + return this.filteredData.slice(start, start + this.pageSize); } setPage(page) { @@ -323,7 +322,7 @@ class InterfaceDataTable extends HTMLElement { text-align: center; } - .product-cell { + .plane-cell { width: 60px; } @@ -435,7 +434,7 @@ class InterfaceDataTable extends HTMLElement { - 构型 + 机型 ATA章节 接口结构体名 接口名称 @@ -451,16 +450,16 @@ class InterfaceDataTable extends HTMLElement { - ${item.ProductName || ''} + ${item.PlaneName || ''} ${item.ATAName || ''} ${item.ModelStructName || ''} ${item.InterfaceName || ''} ${item.InterfaceType || ''} ${this.formatArraySize(item)} ${item.InterfaceNotes || ''} - - - + + + `).join('')} @@ -471,19 +470,19 @@ class InterfaceDataTable extends HTMLElement {
` : ''} - - `; this.bindEventListeners(); @@ -607,7 +606,7 @@ class InterfaceDataTable extends HTMLElement { const resetSearchHandler = async () => { this.searchKeyword = ''; this.filters = { - productName: '', + planeName: '', ataName: '', structName: '' }; diff --git a/XNSimHtml/components/interface-config/import-dialog.js b/XNSimHtml/components/interface-config/import-dialog.js index 300606e..94f9a28 100644 --- a/XNSimHtml/components/interface-config/import-dialog.js +++ b/XNSimHtml/components/interface-config/import-dialog.js @@ -3,7 +3,7 @@ class ImportDialog extends HTMLElement { super(); this.attachShadow({ mode: 'open' }); this.data = []; - this.products = []; + this.planes = []; this.atas = []; } @@ -13,31 +13,22 @@ class ImportDialog extends HTMLElement { } // 接收父组件传递的选项数据 - setOptions(products, atas) { - this.products = products; + setOptions(planes, atas) { + this.planes = planes; this.atas = atas; - this.updateProductOptions(); this.updateAtaOptions(); } - updateProductOptions() { - const select = this.shadowRoot.querySelector('#product-select'); - select.innerHTML = ` - - ${this.products.map(product => ` - - `).join('')} - `; - } - updateAtaOptions() { const select = this.shadowRoot.querySelector('#ata-select'); - select.innerHTML = ` - - ${this.atas.map(ata => ` - - `).join('')} - `; + if (select) { + select.innerHTML = ` + + ${this.atas.map(ata => ` + + `).join('')} + `; + } } show(data) { @@ -83,14 +74,21 @@ class ImportDialog extends HTMLElement { }); confirmBtn.addEventListener('click', () => { - const productSelect = this.shadowRoot.querySelector('#product-select'); const ataSelect = this.shadowRoot.querySelector('#ata-select'); const modelInput = this.shadowRoot.querySelector('#model-input'); - if (!productSelect.value) { - alert('请选择构型'); + // 从 localStorage 获取机型信息 + const savedSelection = localStorage.getItem('xnsim-selection'); + if (!savedSelection) { + alert('请先选择机型'); return; } + const selection = JSON.parse(savedSelection); + if (!selection.configurationId) { + alert('请先选择机型'); + return; + } + if (!ataSelect.value) { alert('请选择ATA章节'); return; @@ -105,7 +103,7 @@ class ImportDialog extends HTMLElement { // 处理数据,转换为数据库格式 const processedData = this.data.map(item => ({ SystemName: 'XNSim', // 系统名称固定为XNSim - ProductName: productSelect.value, + PlaneName: selection.plane, ATAName: ataSelect.value, ModelStructName: `${modelName}_${item.structName}`, InterfaceName: lowercaseCheckbox.checked ? item.name.toLowerCase() : item.name, @@ -114,7 +112,8 @@ class ImportDialog extends HTMLElement { InterfaceIsArray: item.isArray ? 1 : 0, // 确保是数字类型 InterfaceArraySize_1: item.arraySize1 || 0, // 确保是数字类型 InterfaceArraySize_2: item.arraySize2 || 0, // 确保是数字类型 - InterfaceNotes: item.description || '' // 确保不是null + InterfaceNotes: item.description || '', // 确保不是null + ConfID: selection.configurationId })); // 验证数据 @@ -138,6 +137,11 @@ class ImportDialog extends HTMLElement { } render() { + // 从 localStorage 获取机型信息 + const savedSelection = localStorage.getItem('xnsim-selection'); + const selection = savedSelection ? JSON.parse(savedSelection) : null; + const planeName = selection?.plane || ''; + this.shadowRoot.innerHTML = `
导入数据预览
+
+ 当前机型:${planeName} +
-
- - -
- - @@ -480,14 +474,9 @@ class InterfaceToolbar extends HTMLElement { } updateFilterOptions(options) { - const productSelect = this.shadowRoot.querySelector('#filterProduct'); const ataSelect = this.shadowRoot.querySelector('#filterAta'); const structSelect = this.shadowRoot.querySelector('#filterStruct'); - // 更新构型选项 - productSelect.innerHTML = '' + - options.products.map(product => ``).join(''); - // 更新ATA章节选项 ataSelect.innerHTML = '' + options.atas.map(ata => ``).join(''); diff --git a/XNSimHtml/components/interface-config/variable-form.js b/XNSimHtml/components/interface-config/variable-form.js index 84b54f9..cc805b4 100644 --- a/XNSimHtml/components/interface-config/variable-form.js +++ b/XNSimHtml/components/interface-config/variable-form.js @@ -4,7 +4,7 @@ class VariableForm extends HTMLElement { this.attachShadow({ mode: 'open' }); this.mode = 'add'; this.interfaceData = null; - this.products = []; + this.planes = []; this.ataChapters = []; this.modelStructs = []; } @@ -15,21 +15,21 @@ class VariableForm extends HTMLElement { } // 接收父组件传递的选项数据 - setOptions(products, atas) { - this.products = products; + setOptions(planes, atas) { + this.planes = planes; this.ataChapters = atas; - this.updateProductOptions(); + this.updatePlaneOptions(); this.updateAtaOptions(); } - updateProductOptions() { - const select = this.shadowRoot.querySelector('#productName'); + updatePlaneOptions() { + const select = this.shadowRoot.querySelector('#planeName'); if (select) { select.innerHTML = ` - - ${this.products.map(product => ` - + ${this.planes.map(plane => ` + `).join('')} `; @@ -50,9 +50,18 @@ class VariableForm extends HTMLElement { } } - async loadModelStructs(productName, ataName) { + async loadModelStructs(planeName, ataName) { try { - const response = await fetch(`/api/interface/struct/list?systemName=XNSim&productName=${productName}&ataName=${ataName}`); + const savedSelection = localStorage.getItem('xnsim-selection'); + if (!savedSelection) { + throw new Error('请先选择构型'); + } + const selection = JSON.parse(savedSelection); + if (!selection.configurationId) { + throw new Error('请先选择构型'); + } + + const response = await fetch(`/api/interface/struct/list?systemName=XNSim&planeName=${planeName}&ataName=${ataName}&confID=${selection.configurationId}`); if (!response.ok) { throw new Error('获取模型结构体列表失败'); } @@ -61,7 +70,7 @@ class VariableForm extends HTMLElement { this.updateModelStructSelect(); } catch (error) { console.error('加载模型结构体列表失败:', error); - alert('加载模型结构体列表失败'); + alert(error.message || '加载模型结构体列表失败'); } } @@ -85,13 +94,13 @@ class VariableForm extends HTMLElement { if (data) { // 保存原始数据 this.originalData = { - ProductName: data.ProductName, + PlaneName: data.PlaneName, ATAName: data.ATAName, ModelStructName: data.ModelStructName, InterfaceName: data.InterfaceName }; // 如果是在编辑模式下,需要先加载模型结构体列表 - this.loadModelStructs(data.ProductName, data.ATAName).then(() => { + this.loadModelStructs(data.PlaneName, data.ATAName).then(() => { this.render(); this.addEventListeners(); this.show(); @@ -120,7 +129,7 @@ class VariableForm extends HTMLElement { addEventListeners() { const form = this.shadowRoot.querySelector('form'); const cancelBtn = this.shadowRoot.querySelector('.cancel-btn'); - const productSelect = this.shadowRoot.querySelector('#productName'); + const planeSelect = this.shadowRoot.querySelector('#planeName'); const ataSelect = this.shadowRoot.querySelector('#ataName'); const interfaceNameInput = this.shadowRoot.querySelector('#interfaceName'); const isArrayCheckbox = this.shadowRoot.querySelector('#interfaceIsArray'); @@ -128,19 +137,19 @@ class VariableForm extends HTMLElement { const arraySize2Input = this.shadowRoot.querySelector('#interfaceArraySize_2'); // 监听构型和ATA章节的变化 - productSelect.addEventListener('change', () => { - const productName = productSelect.value; + planeSelect.addEventListener('change', () => { + const planeName = planeSelect.value; const ataName = ataSelect.value; - if (productName && ataName) { - this.loadModelStructs(productName, ataName); + if (planeName && ataName) { + this.loadModelStructs(planeName, ataName); } }); ataSelect.addEventListener('change', () => { - const productName = productSelect.value; + const planeName = planeSelect.value; const ataName = ataSelect.value; - if (productName && ataName) { - this.loadModelStructs(productName, ataName); + if (planeName && ataName) { + this.loadModelStructs(planeName, ataName); } }); @@ -185,7 +194,7 @@ class VariableForm extends HTMLElement { const data = { SystemName: 'XNSim', - ProductName: formData.get('productName'), + PlaneName: formData.get('planeName'), ATAName: formData.get('ataName'), ModelStructName: formData.get('modelStructName'), InterfaceName: formData.get('interfaceName'), @@ -197,9 +206,22 @@ class VariableForm extends HTMLElement { InterfaceNotes: formData.get('interfaceNotes') }; + // 从 localStorage 获取 ConfID + const savedSelection = localStorage.getItem('xnsim-selection'); + if (!savedSelection) { + alert('请先选择机型'); + return; + } + const selection = JSON.parse(savedSelection); + if (!selection.configurationId) { + alert('请先选择机型'); + return; + } + data.ConfID = selection.configurationId; + // 如果是编辑模式,添加原始数据 if (this.mode === 'edit' && this.originalData) { - data.originalProductName = this.originalData.ProductName; + data.originalPlaneName = this.originalData.PlaneName; data.originalATAName = this.originalData.ATAName; data.originalModelStructName = this.originalData.ModelStructName; data.originalInterfaceName = this.originalData.InterfaceName; @@ -208,11 +230,12 @@ class VariableForm extends HTMLElement { // 验证必填字段 const requiredFields = [ 'SystemName', - 'ProductName', + 'PlaneName', 'ATAName', 'ModelStructName', 'InterfaceName', - 'InterfaceType' + 'InterfaceType', + 'ConfID' ]; const missingFields = requiredFields.filter(field => !data[field]); @@ -261,6 +284,11 @@ class VariableForm extends HTMLElement { 'float', 'double', 'long double', 'boolean' ]; + // 从 localStorage 获取机型信息 + const savedSelection = localStorage.getItem('xnsim-selection'); + const selection = savedSelection ? JSON.parse(savedSelection) : null; + const planeName = selection?.plane || ''; + this.shadowRoot.innerHTML = `

${this.mode === 'add' ? '添加接口' : '编辑接口'}

+
+ 当前机型:${planeName} +
-
- - -
- +