型号只能选择已绑定的版本功能完善

This commit is contained in:
SjS 2025-04-11 14:54:45 +08:00
parent d46df2ebd9
commit 8d4432c265

View File

@ -260,15 +260,14 @@ export default {
methods: { methods: {
/** 查询版本号 */ /** 查询版本号 */
getVersionByModel(modelId) { getVersionByModel(modelId) {
listVersion({ modelId: modelId }) // modelId return new Promise((resolve, reject) => {
.then(response => { listVersion({ modelId })
this.versionOptions = response.rows; .then(response => {
// this.versionOptions = response.rows;
if (this.form.versionId && resolve();
!this.versionOptions.some(v => v.versionId === this.form.versionId)) { })
this.form.versionId = null; .catch(error => reject(error));
} });
});
}, },
/** 查询型号列表列表 */ /** 查询型号列表列表 */
getList() { getList() {
@ -336,16 +335,23 @@ export default {
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { async handleUpdate(row) {
this.reset(); this.reset();
const modelId = row.modelId || this.ids; const modelId = row.modelId || this.ids;
getModel(modelId).then(response => { try {
this.form = response.data; 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.open = true;
this.title = "修改型号"; this.title = "修改型号";
} catch (error) {
this.getVersionByModel(modelId); // console.error('数据加载失败:', error);
}); }
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {