Commit fddd23bb authored by jingnan's avatar jingnan 👀

合并产品代码【6961】 界面配置无法加载 dee-doc下的组件,控制台报错

parent 5e84d711
import Vue from 'vue'
import _get from 'lodash.get'
let resultComps = []
const requireComponent = require.context(
'./', // 在当前目录下查找
......@@ -13,6 +15,7 @@ function findKey(data) {
data.forEach(el => {
const comp = requireComponent(el)
const item = comp.default
item.modelRelationObjs = getModelRelationObjs(item)
if (!(item.modelRelationObjs.length === 0 || (item.modelRelationObjs.length === 1 && item.modelRelationObjs[0] === ''))) {
item.modelRelationObjs.forEach(key => {
if (allkey.indexOf(key) <= -1) {
......@@ -35,6 +38,7 @@ function handleData(data) {
const item = comp.default
const mfileName = el.split('/')[el.split('/').length - 1]
Vue.component(mfileName.slice(0, -4), comp.default)
item.modelRelationObjs = getModelRelationObjs(item)
if (item.modelRelationObjs.length === 0 || (item.modelRelationObjs.length === 1 && item.modelRelationObjs[0] === '')) {
if (!obj['commonComponent']) {
obj['commonComponent'] = []
......@@ -62,4 +66,12 @@ function handleData(data) {
})
return obj
}
function getModelRelationObjs(item) {
let modelRelationObjs = _get(item, 'modelRelationObjs')
modelRelationObjs = Array.isArray(modelRelationObjs) ? modelRelationObjs : []
modelRelationObjs = modelRelationObjs.filter(name => !!(name || '').trim())
return modelRelationObjs
}
export default resultComps
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment