2022-02-14 12:27:33 +08:00
|
|
|
|
export function getItemType(dimensionData, quotaData, item) {
|
2022-04-26 13:33:39 +08:00
|
|
|
|
// Check whether the current view is in template status
|
|
|
|
|
// ( dimensionData and quotaData have no data). If yes, return 'success' directly
|
|
|
|
|
if (dimensionData.length === 0 && quotaData.length === 0) {
|
|
|
|
|
return 'success'
|
|
|
|
|
}
|
2022-02-14 12:27:33 +08:00
|
|
|
|
// 将item的字段在数据集维度、指标字段中查询一遍,如果遇到id不存在、字段类型不一致、维度指标不一致,则提示
|
|
|
|
|
const status = item.groupType
|
|
|
|
|
let checked = false
|
|
|
|
|
if (status === 'd') {
|
|
|
|
|
for (let i = 0; i < dimensionData.length; i++) {
|
|
|
|
|
const ele = dimensionData[i]
|
|
|
|
|
if (ele.id === item.id && ele.deType === item.deType && ele.groupType === item.groupType) {
|
|
|
|
|
checked = true
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (status === 'q') {
|
|
|
|
|
for (let i = 0; i < quotaData.length; i++) {
|
|
|
|
|
const ele = quotaData[i]
|
|
|
|
|
if (ele.id === item.id && ele.deType === item.deType && ele.groupType === item.groupType) {
|
|
|
|
|
checked = true
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (checked) {
|
|
|
|
|
if (status === 'd') {
|
|
|
|
|
return ''
|
|
|
|
|
} else if (status === 'q') {
|
|
|
|
|
return 'success'
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return 'danger'
|
|
|
|
|
}
|
|
|
|
|
}
|