12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import _ from 'lodash'
- type DragType = 'rows-container' | 'cols-container' | 'col-item' | 'row-item'
- /**
- * 构建所有组件的公共属性
- * @param config 原始config
- * @param dragType 组件模式
- * 不填,代表不能在设计时被拖拽
- * row-container 是一个rows容器
- * col-container 是一个cols容器
- * col-item cols中的一个格子(非容器),比如 textfield / combofield 等等
- * row-item rows中的一行,比如 tree / grid / panel 等等
- */
- export function baseConfig(config, dragType?: DragType) {
- if (config.designMode && dragType) {
- let cc = ''
- switch (dragType) {
- case "cols-container":
- cc = 'design_cols_container'
- break
- case "col-item":
- cc = 'design_col_item'
- break
- case "rows-container":
- cc = 'design_rows_container'
- break
- case "row-item":
- cc = 'design_row_item'
- break
- }
- if (typeof config.cls === 'string') {
- _.extend(config, {
- cls: [config.cls, 'yvan_design', cc]
- })
- } else if (_.isArray(config.cls)) {
- _.extend(config, {
- cls: [...config.cls, 'yvan_design', cc]
- })
- } else {
- _.extend(config, {
- cls: ['yvan_design', cc]
- })
- }
- }
- return config
- }
|