-
-
-
-
-
@@ -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 = `