From 8d4432c265ae683b9495896e3fcaaec1ba193270 Mon Sep 17 00:00:00 2001 From: SjS Date: Fri, 11 Apr 2025 14:54:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9E=8B=E5=8F=B7=E5=8F=AA=E8=83=BD=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=B7=B2=E7=BB=91=E5=AE=9A=E7=9A=84=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/device/model/index.vue | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/AutoSprout-ui/src/views/device/model/index.vue b/AutoSprout-ui/src/views/device/model/index.vue index e759bd1..23e6f17 100644 --- a/AutoSprout-ui/src/views/device/model/index.vue +++ b/AutoSprout-ui/src/views/device/model/index.vue @@ -260,15 +260,14 @@ export default { methods: { /** 查询版本号 */ getVersionByModel(modelId) { - listVersion({ modelId: modelId }) // 假设后端支持modelId参数过滤 - .then(response => { - this.versionOptions = response.rows; - // 保持当前选择的版本有效性 - if (this.form.versionId && - !this.versionOptions.some(v => v.versionId === this.form.versionId)) { - this.form.versionId = null; - } - }); + return new Promise((resolve, reject) => { + listVersion({ modelId }) + .then(response => { + this.versionOptions = response.rows; + resolve(); + }) + .catch(error => reject(error)); + }); }, /** 查询型号列表列表 */ getList() { @@ -336,16 +335,23 @@ export default { }, /** 修改按钮操作 */ - handleUpdate(row) { + async handleUpdate(row) { this.reset(); const modelId = row.modelId || this.ids; - getModel(modelId).then(response => { - this.form = response.data; + try { + await this.getVersionByModel(modelId); + const res = await getModel(modelId); + this.form = { + ...res.data, + versionId: this.versionOptions.some(v => v.versionId === res.data.versionId) + ? res.data.versionId + : null + }; this.open = true; this.title = "修改型号"; - - this.getVersionByModel(modelId); // 关键代码 - }); + } catch (error) { + console.error('数据加载失败:', error); + } }, /** 提交按钮 */ submitForm() {