async showTabList() {
console.log('tablist');
var params = {
userId: this.userId,
}
if (this.userId !== -100) {
try {
const res = await getProducBingingtList(params);
var bingList = res.data.bindingList;
console.log(bingList, '返回的产品列表');
let projectLis = [];
for (let item of bingList) {
if (item === 11) {
projectLis.push({ id: 1, name: '安全云盒' });
} else if (item === 12) {
projectLis.push({ id: 2, name: '安全猫' });
} else if (item === 13) {
projectLis.push({ id: 3, name: '安全大脑' });
}
}
projectLis.sort((a, b) => a.id - b.id);
this.projectList = projectLis;
} catch (error) {
// 处理错误
}
} else {
console.log('超级管理员');
this.projectList = [
{ id: 1, name: "安全云盒" },
{ id: 2, name: "安全猫" },
{ id: 3, name: "安全大脑" }
];
}
this.currentProjectId = this.projectList[0].id;
console.log(this.projectList, 'this.projectList');
if (this.projectList && this.projectList.length > 0) {
// 在 $nextTick 中访问 safetySearchForm 的操作
this.$nextTick(() => {
this.changeTableHeader(); // 查询设备
console.log('查询this.$refs["safetySearchForm"]', this.$refs["safetySearchForm"]);
});
// 执行 changeTableHeader() 方法
} else {
console.error('this.projectList 未初始化或为空');
}
// this.changeTableHeader(); // 查询设备
},
根据返回的数据列表转换成想要的数据结构
最新推荐文章于 2024-06-03 09:20:03 发布