型号只能选择已绑定的版本功能完善
This commit is contained in:
parent
d46df2ebd9
commit
8d4432c265
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user