75 lines
1.6 KiB
JavaScript
75 lines
1.6 KiB
JavaScript
/**
|
|
* 页面工具类
|
|
* @author john
|
|
*/
|
|
|
|
// 表单组件
|
|
export const formComponentList = [
|
|
// 基础组件
|
|
'mf-input',
|
|
'mf-input-number',
|
|
'mf-textarea',
|
|
'mf-radio',
|
|
'mf-checkbox',
|
|
'mf-select',
|
|
'mf-month-picker',
|
|
'mf-date-picker',
|
|
'mf-date-range-picker',
|
|
'mf-switch',
|
|
'mf-image-upload',
|
|
'mf-idcard-upload',
|
|
'mf-upload',
|
|
'mf-remote-select',
|
|
'mf-transfer',
|
|
'dynamic-component',
|
|
'mf-permission-check'
|
|
]
|
|
|
|
// 容器组件
|
|
export const wrapComponentList = [
|
|
'mf-pane',
|
|
'mf-panel',
|
|
'mf-dialog',
|
|
'mf-search',
|
|
'mf-form',
|
|
'mf-drawer',
|
|
'mf-step',
|
|
'mf-tabs'
|
|
]
|
|
|
|
// 媒体组件
|
|
export const mediaComponentList = []
|
|
|
|
/**
|
|
* 渲染插槽节点
|
|
* @param {Object} node 组件
|
|
*/
|
|
export const renderSlotNode = (node, scope) => {
|
|
let { componentOptions = {} } = node
|
|
return {
|
|
...node,
|
|
componentOptions: {
|
|
...componentOptions,
|
|
propsData: {
|
|
...componentOptions.propsData,
|
|
// 表格渲染时,将行号传给单元格内的组件
|
|
__index: scope.$index
|
|
},
|
|
listeners: dealListeners(node, { props: componentOptions, scope })
|
|
}
|
|
}
|
|
}
|
|
|
|
// 获取父组件的实例
|
|
export const getParent = (instance, componentName) => {
|
|
var parent = instance.$parent || instance.$root
|
|
var name = parent.$options.name
|
|
while (parent && (!name || name !== componentName)) {
|
|
parent = parent.$parent
|
|
if (parent) {
|
|
name = parent.$options.name
|
|
}
|
|
}
|
|
return parent
|
|
}
|