vue-super-crud 1.7.1 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -10
- package/lib/index.css +1 -1
- package/lib/super-crud.min.js +2 -2
- package/package.json +21 -16
- package/src/config/common.js +2 -1
- package/src/config/crud.js +3 -3
- package/src/index.js +4 -0
- package/src/template/formatData.js +75 -87
- package/.browserslistrc +0 -3
- package/.versionrc.json +0 -36
- package/CHANGELOG.md +0 -232
- package/babel.config.js +0 -12
- package/build/alias.js +0 -10
- package/build/build.js +0 -52
- package/build/config.js +0 -70
- package/deploy.bat +0 -14
- package/docs/.vuepress/components/button/base.vue +0 -88
- package/docs/.vuepress/components/common/code-format.vue +0 -331
- package/docs/.vuepress/components/commonConfig/presetCodeTemplate/base.vue +0 -68
- package/docs/.vuepress/components/commonConfig/presetCodeTemplate/customParams.vue +0 -73
- package/docs/.vuepress/components/commonConfig/renderType/component.vue +0 -160
- package/docs/.vuepress/components/commonConfig/renderType/formatter.vue +0 -49
- package/docs/.vuepress/components/commonConfig/renderType/render.vue +0 -91
- package/docs/.vuepress/components/commonConfig/renderType/slot.vue +0 -63
- package/docs/.vuepress/components/crud/baseUse/baseUse.vue +0 -98
- package/docs/.vuepress/components/crud/baseUse/columnAction.vue +0 -72
- package/docs/.vuepress/components/crud/baseUse/columnWidth.vue +0 -107
- package/docs/.vuepress/components/crud/baseUse/handleRow.vue +0 -65
- package/docs/.vuepress/components/crud/baseUse/height.vue +0 -82
- package/docs/.vuepress/components/crud/baseUse/index.vue +0 -54
- package/docs/.vuepress/components/crud/baseUse/loading.vue +0 -70
- package/docs/.vuepress/components/crud/baseUse/pagination.vue +0 -108
- package/docs/.vuepress/components/crud/baseUse/selection.vue +0 -114
- package/docs/.vuepress/components/crud/baseUse/summaryMethod.vue +0 -118
- package/docs/.vuepress/components/crud/baseUse/title.vue +0 -54
- package/docs/.vuepress/components/crud/baseUse/toolbar.vue +0 -69
- package/docs/.vuepress/components/crud/buttons/common.vue +0 -115
- package/docs/.vuepress/components/crud/buttons/fast.vue +0 -82
- package/docs/.vuepress/components/crud/contextMenu/base.vue +0 -72
- package/docs/.vuepress/components/crud/copy.vue +0 -52
- package/docs/.vuepress/components/crud/crudEvents/api.vue +0 -157
- package/docs/.vuepress/components/crud/crudEvents/deleteTip.vue +0 -93
- package/docs/.vuepress/components/crud/crudEvents/events.vue +0 -188
- package/docs/.vuepress/components/crud/dataSort/base.vue +0 -142
- package/docs/.vuepress/components/crud/genDynamicColumns/base.vue +0 -53
- package/docs/.vuepress/components/crud/genDynamicColumns/dynamicAndFixed.vue +0 -111
- package/docs/.vuepress/components/crud/genDynamicColumns/treeDynamic.vue +0 -68
- package/docs/.vuepress/components/crud/handleBar/handleRow.vue +0 -65
- package/docs/.vuepress/components/crud/handleBar/toolbar.vue +0 -69
- package/docs/.vuepress/components/crud/renderType/1.vue +0 -57
- package/docs/.vuepress/components/crud/renderType/2.vue +0 -63
- package/docs/.vuepress/components/crud/renderType/3.vue +0 -105
- package/docs/.vuepress/components/crud/renderType/5.vue +0 -91
- package/docs/.vuepress/components/crud/search/1.vue +0 -90
- package/docs/.vuepress/components/crud/search/2.vue +0 -78
- package/docs/.vuepress/components/crud/search/3.vue +0 -107
- package/docs/.vuepress/components/crud/search/base.vue +0 -123
- package/docs/.vuepress/components/crud/search/localSearch.vue +0 -124
- package/docs/.vuepress/components/crud/search/special.vue +0 -148
- package/docs/.vuepress/components/crud/selection/events.vue +0 -47
- package/docs/.vuepress/components/crud/selection/pagination.vue +0 -94
- package/docs/.vuepress/components/crud/selection/singleSelection.vue +0 -64
- package/docs/.vuepress/components/crud/span/base.vue +0 -69
- package/docs/.vuepress/components/crud/span/special.vue +0 -75
- package/docs/.vuepress/components/crud/summary/base.vue +0 -99
- package/docs/.vuepress/components/crud/tableEdit/addDeleteBtn.vue +0 -174
- package/docs/.vuepress/components/crud/tableEdit/cellEdit.vue +0 -194
- package/docs/.vuepress/components/crud/tableEdit/controlEdit.vue +0 -219
- package/docs/.vuepress/components/crud/tableEdit/dialog.vue +0 -172
- package/docs/.vuepress/components/crud/tableEdit/free.vue +0 -88
- package/docs/.vuepress/components/crud/tableEdit/freeColumn.vue +0 -82
- package/docs/.vuepress/components/crud/tableEdit/methods.vue +0 -154
- package/docs/.vuepress/components/crud/tableEdit/rowAction.vue +0 -107
- package/docs/.vuepress/components/crud/tableEdit/rowBatch.vue +0 -116
- package/docs/.vuepress/components/crud/tableEdit/rowClick.vue +0 -98
- package/docs/.vuepress/components/crud/validate/base.vue +0 -122
- package/docs/.vuepress/components/crud/validate/custom.vue +0 -82
- package/docs/.vuepress/components/crud/validate/regulars.vue +0 -88
- package/docs/.vuepress/components/crud/validate/relation.vue +0 -91
- package/docs/.vuepress/components/crud/validate/tree.vue +0 -82
- package/docs/.vuepress/components/dialog/baseUse/base.vue +0 -92
- package/docs/.vuepress/components/dialog/baseUse/beforeConfirm.vue +0 -78
- package/docs/.vuepress/components/dialog/baseUse/control.vue +0 -79
- package/docs/.vuepress/components/dialog/baseUse/drawer.vue +0 -59
- package/docs/.vuepress/components/dialog/baseUse/footer.vue +0 -87
- package/docs/.vuepress/components/dialog/baseUse/insertSlot.vue +0 -79
- package/docs/.vuepress/components/dict/DictLinkage.vue +0 -91
- package/docs/.vuepress/components/dict/baseUse.vue +0 -72
- package/docs/.vuepress/components/dict/component.vue +0 -82
- package/docs/.vuepress/components/dict/localDict.vue +0 -68
- package/docs/.vuepress/components/form/baseUse/base.vue +0 -48
- package/docs/.vuepress/components/form/baseUse/dataFormat.vue +0 -92
- package/docs/.vuepress/components/form/baseUse/deep.vue +0 -57
- package/docs/.vuepress/components/form/baseUse/gridLayout.vue +0 -47
- package/docs/.vuepress/components/form/baseUse/group.vue +0 -66
- package/docs/.vuepress/components/form/baseUse/hidden.vue +0 -40
- package/docs/.vuepress/components/form/baseUse/inlineLayout.vue +0 -48
- package/docs/.vuepress/components/form/baseUse/label.vue +0 -51
- package/docs/.vuepress/components/form/baseUse/tooltip.vue +0 -40
- package/docs/.vuepress/components/form/baseUse/validate.vue +0 -52
- package/docs/.vuepress/components/form/detail/base.vue +0 -78
- package/docs/.vuepress/components/form/detail/border.vue +0 -90
- package/docs/.vuepress/components/form/detail/singleDetail.vue +0 -72
- package/docs/.vuepress/components/formatData/baseUse.vue +0 -131
- package/docs/.vuepress/components/mock/index.js +0 -347
- package/docs/.vuepress/components/mockData/custom.vue +0 -69
- package/docs/.vuepress/components/mockData/example.vue +0 -290
- package/docs/.vuepress/components/positionSlot/base.vue +0 -24
- package/docs/.vuepress/components/positionSlot/form.vue +0 -71
- package/docs/.vuepress/components/positionSlot/table.vue +0 -85
- package/docs/.vuepress/components/tabs/base.vue +0 -57
- package/docs/.vuepress/components/temp.js +0 -195
- package/docs/.vuepress/config.js +0 -146
- package/docs/.vuepress/enhanceApp.js +0 -142
- package/docs/.vuepress/public/favicon.ico +0 -0
- package/docs/.vuepress/public/super.png +0 -0
- package/docs/.vuepress/styles/index.styl +0 -25
- package/docs/.vuepress/styles/palette.styl +0 -6
- package/docs/README.md +0 -14
- package/docs/guide/button/base.md +0 -31
- package/docs/guide/commonConfig/jsx.md +0 -166
- package/docs/guide/commonConfig/presetCodeTemplate.md +0 -68
- package/docs/guide/commonConfig/renderType.md +0 -181
- package/docs/guide/crud/baseUse.md +0 -120
- package/docs/guide/crud/buttons.md +0 -18
- package/docs/guide/crud/config.md +0 -217
- package/docs/guide/crud/contextMenu.md +0 -18
- package/docs/guide/crud/dataSort.md +0 -66
- package/docs/guide/crud/genDynamicColumns.md +0 -145
- package/docs/guide/crud/handleBar.md +0 -26
- package/docs/guide/crud/renderType.md +0 -4
- package/docs/guide/crud/search.md +0 -150
- package/docs/guide/crud/selection.md +0 -73
- package/docs/guide/crud/span.md +0 -98
- package/docs/guide/crud/summary.md +0 -167
- package/docs/guide/crud/tableEdit.md +0 -377
- package/docs/guide/crud/validate.md +0 -158
- package/docs/guide/dialog/baseUse.md +0 -81
- package/docs/guide/dict/baseUse.md +0 -174
- package/docs/guide/dict/component.md +0 -88
- package/docs/guide/dict/config.md +0 -44
- package/docs/guide/form/baseUse.md +0 -142
- package/docs/guide/form/detail.md +0 -38
- package/docs/guide/formatData/baseUse.md +0 -98
- package/docs/guide/formatData/config.md +0 -142
- package/docs/guide/mockData/base.md +0 -26
- package/docs/guide/positionSlot/base.md +0 -41
- package/docs/guide/question/base.md +0 -44
- package/docs/guide/start/base.md +0 -30
- package/docs/guide/tabs/base.md +0 -63
- package/examples/App.vue +0 -52
- package/examples/Layout/components/AppMain.vue +0 -40
- package/examples/Layout/components/Item.vue +0 -29
- package/examples/Layout/components/Link.vue +0 -44
- package/examples/Layout/components/SidebarItem.vue +0 -93
- package/examples/Layout/index.vue +0 -69
- package/examples/assets/logo.png +0 -0
- package/examples/favicon.ico +0 -0
- package/examples/index.html +0 -18
- package/examples/main.js +0 -54
- package/examples/router/index.js +0 -140
- package/examples/store/index.js +0 -0
- package/examples/styles/index.scss +0 -63
- package/examples/styles/sidebar.scss +0 -226
- package/examples/styles/transition.scss +0 -48
- package/examples/styles/variables.scss +0 -25
- package/examples/views/crud/base.vue +0 -68
- package/examples/views/crud/handleRow.vue +0 -84
- package/examples/views/crud/search.vue +0 -116
- package/examples/views/dashboard/index.vue +0 -244
- package/examples/views/dashboard/index1.vue +0 -234
- package/examples/views/dashboard/test.vue +0 -9
- package/examples/views/formTest/index.vue +0 -168
- package/examples/views/nested/menu1/index.vue +0 -7
- package/examples/views/nested/menu1/menu1-1/index.vue +0 -7
- package/examples/views/nested/menu1/menu1-2/index.vue +0 -7
- package/examples/views/nested/menu1/menu1-2/menu1-2-1/index.vue +0 -5
- package/examples/views/nested/menu1/menu1-2/menu1-2-2/index.vue +0 -5
- package/examples/views/nested/menu1/menu1-3/index.vue +0 -5
- package/examples/views/nested/menu2/index.vue +0 -5
- package/gulpfile.js +0 -84
- package/packages/button/index.vue +0 -189
- package/packages/core/components/comp.vue +0 -223
- package/packages/core/components/position.vue +0 -135
- package/packages/core/components/render.vue +0 -460
- package/packages/core/configManager.js +0 -302
- package/packages/core/create.js +0 -8
- package/packages/core/defaultRender.js +0 -64
- package/packages/core/dict/global.js +0 -10
- package/packages/core/dict/index.js +0 -432
- package/packages/core/dict/mixin.js +0 -94
- package/packages/core/event.js +0 -60
- package/packages/core/index.js +0 -6
- package/packages/core/init.js +0 -122
- package/packages/core/mock/genConfig.js +0 -228
- package/packages/core/mock/genData.js +0 -422
- package/packages/core/mock/index.js +0 -4
- package/packages/core/rules.js +0 -111
- package/packages/crud/column.vue +0 -205
- package/packages/crud/columnAction.vue +0 -207
- package/packages/crud/columnCell.vue +0 -146
- package/packages/crud/defaultColumn.vue +0 -130
- package/packages/crud/drawerColumn.vue +0 -225
- package/packages/crud/form.vue +0 -69
- package/packages/crud/index.vue +0 -564
- package/packages/crud/menuBar.vue +0 -298
- package/packages/crud/mixins/cacheHandler.js +0 -36
- package/packages/crud/mixins/calcColumnWidth.js +0 -79
- package/packages/crud/mixins/calcHeight.js +0 -105
- package/packages/crud/mixins/columnHandler.js +0 -128
- package/packages/crud/mixins/contextMenu.js +0 -98
- package/packages/crud/mixins/dataProcessor.js +0 -202
- package/packages/crud/mixins/dialog.js +0 -109
- package/packages/crud/mixins/excelHandler.js +0 -150
- package/packages/crud/mixins/exposeMethods.js +0 -107
- package/packages/crud/mixins/generateDynamicColumns.js +0 -250
- package/packages/crud/mixins/props.js +0 -38
- package/packages/crud/mixins/searchHandler.js +0 -151
- package/packages/crud/mixins/select.js +0 -359
- package/packages/crud/mixins/spanMethod.js +0 -288
- package/packages/crud/mixins/summary.js +0 -177
- package/packages/crud/mixins/tableEdit.js +0 -547
- package/packages/crud/mixins/validate.js +0 -219
- package/packages/crud/pagination.vue +0 -110
- package/packages/crud/search.vue +0 -119
- package/packages/crud/searchHeader.vue +0 -231
- package/packages/crud/selectBanner.vue +0 -138
- package/packages/crud/utils/EditState.js +0 -319
- package/packages/crud/utils/excelExport.js +0 -112
- package/packages/crud/utils/excelImport.js +0 -112
- package/packages/crud/utils/index.js +0 -98
- package/packages/dialog/dialog.js +0 -233
- package/packages/dialog/dialog.vue +0 -15
- package/packages/dialog/index.js +0 -22
- package/packages/dict/cascadeFormat.vue +0 -179
- package/packages/dict/dateFormat.vue +0 -40
- package/packages/dict/form/cascade.vue +0 -61
- package/packages/dict/form/checkbox.vue +0 -90
- package/packages/dict/form/extendMethod.js +0 -22
- package/packages/dict/form/input-base.js +0 -31
- package/packages/dict/form/input.js +0 -20
- package/packages/dict/form/radio.vue +0 -69
- package/packages/dict/form/select.vue +0 -118
- package/packages/dict/form/switch.vue +0 -75
- package/packages/dict/valueFormat.vue +0 -188
- package/packages/directive/dialog/drag.js +0 -86
- package/packages/directive/dialog/dragSize.js +0 -42
- package/packages/directive/index.js +0 -9
- package/packages/directive/insertSlot.js +0 -10
- package/packages/form/contextMenu.js +0 -192
- package/packages/form/draftDrawer.vue +0 -391
- package/packages/form/formAction.vue +0 -97
- package/packages/form/formItem.vue +0 -259
- package/packages/form/index.vue +0 -451
- package/packages/form/props.js +0 -15
- package/packages/grid/cell.vue +0 -65
- package/packages/grid/index.vue +0 -130
- package/packages/group/index.vue +0 -96
- package/packages/tabs/index.vue +0 -290
- package/packages/tooltip/index.js +0 -9
- package/packages/tooltip/tooltip.vue +0 -32
- package/packages/tooltip/tooltipComponent.js +0 -38
- package/packages/verifyInput/index.vue +0 -131
- package/styles/button.scss +0 -3
- package/styles/crud.scss +0 -425
- package/styles/dialog.scss +0 -95
- package/styles/form.scss +0 -532
- package/styles/group.scss +0 -78
- package/styles/index.scss +0 -94
- package/styles/tabs.scss +0 -139
- package/styles/verifyInput.scss +0 -56
- package/vue-jsx-sync.js +0 -90
- package/vue.config.js +0 -54
@@ -1,223 +0,0 @@
|
|
1
|
-
<script>
|
2
|
-
import { set, omit, isArray, isFunction, isPlainObject } from "lodash-es";
|
3
|
-
import { isVNode } from "utils";
|
4
|
-
import Comp from "./comp.vue";
|
5
|
-
|
6
|
-
// 获取组件名称
|
7
|
-
function getCompName(name, isChildren, children, comp) {
|
8
|
-
if (isChildren || children) return name;
|
9
|
-
const nameMap = {
|
10
|
-
"el-select": "sc-select",
|
11
|
-
"el-checkbox-group": "sc-checkbox",
|
12
|
-
"el-radio-group": "sc-radio",
|
13
|
-
"el-switch": "sc-switch",
|
14
|
-
"el-cascader": "sc-cascader",
|
15
|
-
};
|
16
|
-
if (comp.options && name === "el-input") {
|
17
|
-
return "sc-select";
|
18
|
-
}
|
19
|
-
return nameMap[name] || name;
|
20
|
-
}
|
21
|
-
|
22
|
-
// 获取事件处理函数
|
23
|
-
function getOn(on, comp, scope, parent, props) {
|
24
|
-
const events = {};
|
25
|
-
if (on) {
|
26
|
-
Object.entries(on).forEach(([key, handler]) => {
|
27
|
-
events[key] = (...args) => handler?.(...args, scope);
|
28
|
-
});
|
29
|
-
}
|
30
|
-
|
31
|
-
// 处理以 on 开头的事件配置
|
32
|
-
Object.entries(comp)
|
33
|
-
.filter(([key, value]) => /^on[A-Z]/.test(key) && isFunction(value))
|
34
|
-
.forEach(([key, handler]) => {
|
35
|
-
const eventName = key.slice(2).toLowerCase();
|
36
|
-
events[eventName] = (...args) => handler?.(...args, scope);
|
37
|
-
});
|
38
|
-
|
39
|
-
return {
|
40
|
-
...events,
|
41
|
-
input: (event) => {
|
42
|
-
parent.$value = event;
|
43
|
-
events.input && events.input(event);
|
44
|
-
},
|
45
|
-
change: (event) => {
|
46
|
-
parent.$value = event;
|
47
|
-
events.change && events.change(event);
|
48
|
-
},
|
49
|
-
"hook:mounted": () => {
|
50
|
-
const instance = parent.$vnode.componentInstance.$children[0];
|
51
|
-
if (props.mounted) {
|
52
|
-
props.mounted(scope, instance);
|
53
|
-
}
|
54
|
-
if (props.ref) {
|
55
|
-
props.ref(scope, instance);
|
56
|
-
}
|
57
|
-
},
|
58
|
-
};
|
59
|
-
}
|
60
|
-
|
61
|
-
// 获取插槽
|
62
|
-
function getScopedSlots(scopedSlots, slots, h, scope) {
|
63
|
-
const result = {};
|
64
|
-
const allSlots = { ...scopedSlots, ...slots };
|
65
|
-
|
66
|
-
for (const key in allSlots) {
|
67
|
-
result[key] = () => allSlots[key](h, scope);
|
68
|
-
}
|
69
|
-
|
70
|
-
return result;
|
71
|
-
}
|
72
|
-
|
73
|
-
// 获取placeholder
|
74
|
-
function getPlaceholder(comp, name, scope) {
|
75
|
-
if (comp.placeholder) {
|
76
|
-
return comp.placeholder;
|
77
|
-
}
|
78
|
-
if (name === "el-input") {
|
79
|
-
return "请输入" + scope.item.label;
|
80
|
-
}
|
81
|
-
return "请选择" + scope.item.label;
|
82
|
-
}
|
83
|
-
|
84
|
-
// 获取clearable
|
85
|
-
function getClearable(comp) {
|
86
|
-
if (comp.clearable !== undefined) {
|
87
|
-
return comp.clearable;
|
88
|
-
}
|
89
|
-
return true;
|
90
|
-
}
|
91
|
-
|
92
|
-
// 获取组件尺寸
|
93
|
-
function getCompSize(comp, size, ELEMENT) {
|
94
|
-
return comp.size || size || (ELEMENT || {}).size;
|
95
|
-
}
|
96
|
-
|
97
|
-
// 渲染子元素
|
98
|
-
function renderChildren(children, h, scope) {
|
99
|
-
if (!children) return null;
|
100
|
-
|
101
|
-
if (isFunction(children)) {
|
102
|
-
if (children.length === 2) {
|
103
|
-
children = children(h, scope);
|
104
|
-
if (isVNode(children)) return children;
|
105
|
-
} else {
|
106
|
-
children = children(scope);
|
107
|
-
}
|
108
|
-
}
|
109
|
-
|
110
|
-
if (isArray(children)) {
|
111
|
-
return children.map((child) => {
|
112
|
-
if (isPlainObject(child)) {
|
113
|
-
return h(Comp, {
|
114
|
-
props: { ...child, comp: child, scope, isChildren: true },
|
115
|
-
});
|
116
|
-
}
|
117
|
-
return child;
|
118
|
-
});
|
119
|
-
}
|
120
|
-
|
121
|
-
return children;
|
122
|
-
}
|
123
|
-
|
124
|
-
// 生成假插槽
|
125
|
-
function fakeSlot(h, scopedSlots, slots) {
|
126
|
-
const allSlots = { ...scopedSlots, ...slots };
|
127
|
-
return Object.keys(allSlots).map((slot) => h("i", { slot }));
|
128
|
-
}
|
129
|
-
|
130
|
-
export default {
|
131
|
-
name: "comp",
|
132
|
-
functional: true,
|
133
|
-
props: {
|
134
|
-
value: {},
|
135
|
-
prop: {},
|
136
|
-
name: {
|
137
|
-
default: "el-input",
|
138
|
-
},
|
139
|
-
comp: Object,
|
140
|
-
bind: [Object, Function],
|
141
|
-
on: Object,
|
142
|
-
scopedSlots: Object,
|
143
|
-
slots: Object,
|
144
|
-
children: {},
|
145
|
-
scope: Object,
|
146
|
-
size: {},
|
147
|
-
isChildren: Boolean,
|
148
|
-
nativeOn: Object,
|
149
|
-
directives: {
|
150
|
-
type: Object,
|
151
|
-
default: () => ({}),
|
152
|
-
},
|
153
|
-
created: Function,
|
154
|
-
mounted: Function,
|
155
|
-
},
|
156
|
-
render(h, context) {
|
157
|
-
const { props, data, parent } = context;
|
158
|
-
const { name, comp, scope, isChildren, children, bind } = props;
|
159
|
-
|
160
|
-
// 获取组件props
|
161
|
-
const getComponentProps = (compName) => {
|
162
|
-
const component = parent.$options.components[compName];
|
163
|
-
return component?.options?.props || {};
|
164
|
-
};
|
165
|
-
|
166
|
-
// 处理bind属性
|
167
|
-
let processedComp = comp;
|
168
|
-
if (isFunction(bind)) {
|
169
|
-
processedComp = { ...comp, ...bind(scope) };
|
170
|
-
} else if (bind) {
|
171
|
-
processedComp = { ...comp, ...bind };
|
172
|
-
}
|
173
|
-
|
174
|
-
// 获取组件名称
|
175
|
-
const compName = getCompName(name, isChildren, children, processedComp);
|
176
|
-
|
177
|
-
// 获取组件声明的props
|
178
|
-
const componentProps = getComponentProps(compName);
|
179
|
-
|
180
|
-
// 分离props和attrs
|
181
|
-
const propsToPass = {};
|
182
|
-
const attrsToPass = {};
|
183
|
-
|
184
|
-
Object.entries(processedComp).forEach(([key, value]) => {
|
185
|
-
if (componentProps[key]) {
|
186
|
-
propsToPass[key] = value;
|
187
|
-
} else if (!(key in props)) {
|
188
|
-
attrsToPass[key] = value;
|
189
|
-
}
|
190
|
-
});
|
191
|
-
|
192
|
-
// 生命周期钩子
|
193
|
-
if (props.created) {
|
194
|
-
props.created(scope);
|
195
|
-
}
|
196
|
-
return h(
|
197
|
-
compName,
|
198
|
-
{
|
199
|
-
props: {
|
200
|
-
...propsToPass,
|
201
|
-
value: props.value || parent.$value,
|
202
|
-
scope,
|
203
|
-
},
|
204
|
-
attrs: {
|
205
|
-
...attrsToPass,
|
206
|
-
size: getCompSize(processedComp, props.size, parent.$ELEMENT),
|
207
|
-
placeholder: getPlaceholder(processedComp, compName, scope),
|
208
|
-
clearable: getClearable(processedComp),
|
209
|
-
disabled: processedComp.disabled ? true : false,
|
210
|
-
},
|
211
|
-
on: getOn(props.on, processedComp, scope, parent, props),
|
212
|
-
nativeOn: props.nativeOn,
|
213
|
-
scopedSlots: getScopedSlots(props.scopedSlots, props.slots, h, scope),
|
214
|
-
directives: props.directives,
|
215
|
-
},
|
216
|
-
[
|
217
|
-
renderChildren(children, h, scope),
|
218
|
-
...fakeSlot(h, props.scopedSlots, props.slots),
|
219
|
-
]
|
220
|
-
);
|
221
|
-
},
|
222
|
-
};
|
223
|
-
</script>
|
@@ -1,135 +0,0 @@
|
|
1
|
-
<script>
|
2
|
-
import create from "core/create";
|
3
|
-
import { resolveRender } from "utils";
|
4
|
-
export default create({
|
5
|
-
name: "position",
|
6
|
-
props: {
|
7
|
-
inline: {
|
8
|
-
type: Boolean,
|
9
|
-
default: true,
|
10
|
-
},
|
11
|
-
slotName: String,
|
12
|
-
slotSuffixes: {
|
13
|
-
type: Array,
|
14
|
-
default: () => [],
|
15
|
-
},
|
16
|
-
render: Function,
|
17
|
-
slots: {
|
18
|
-
type: Object,
|
19
|
-
default() {
|
20
|
-
return {};
|
21
|
-
},
|
22
|
-
},
|
23
|
-
scope: {},
|
24
|
-
ellipsis: Boolean,
|
25
|
-
},
|
26
|
-
computed: {
|
27
|
-
slotNames() {
|
28
|
-
if (!this.slotName) return;
|
29
|
-
// 如果没有后缀,直接返回原始slotName
|
30
|
-
if (!this.slotSuffixes.length) return this.slotName;
|
31
|
-
|
32
|
-
// 将所有后缀用'-'连接
|
33
|
-
const suffix = this.slotSuffixes
|
34
|
-
.filter(Boolean) // 过滤掉空值
|
35
|
-
.join("-");
|
36
|
-
|
37
|
-
// 如果有后缀,返回 slotName-suffix 格式
|
38
|
-
return suffix ? `${this.slotName}-${suffix}` : this.slotName;
|
39
|
-
},
|
40
|
-
leftSlot() {
|
41
|
-
return this.slots[`${this.slotNames}-left`] || this.$scopedSlots.left;
|
42
|
-
},
|
43
|
-
rightSlot() {
|
44
|
-
return this.slots[`${this.slotNames}-right`] || this.$scopedSlots.right;
|
45
|
-
},
|
46
|
-
topSlot() {
|
47
|
-
return this.slots[`${this.slotNames}-top`] || this.$scopedSlots.top;
|
48
|
-
},
|
49
|
-
bottomSlot() {
|
50
|
-
return this.slots[`${this.slotNames}-bottom`] || this.$scopedSlots.bottom;
|
51
|
-
},
|
52
|
-
hasPosition() {
|
53
|
-
return this.topSlot || this.bottomSlot || this.leftSlot || this.rightSlot;
|
54
|
-
},
|
55
|
-
contentStyle() {
|
56
|
-
if (!this.ellipsis) return {};
|
57
|
-
return {
|
58
|
-
"white-space": "nowrap",
|
59
|
-
overflow: "hidden",
|
60
|
-
"text-overflow": "ellipsis",
|
61
|
-
};
|
62
|
-
},
|
63
|
-
// 动态计算grid布局样式
|
64
|
-
gridStyle() {
|
65
|
-
const areas = [];
|
66
|
-
if (this.topSlot) {
|
67
|
-
areas.push('"top top top"');
|
68
|
-
}
|
69
|
-
const middleRow = [
|
70
|
-
this.leftSlot ? "left" : ".",
|
71
|
-
"content",
|
72
|
-
this.rightSlot ? "right" : ".",
|
73
|
-
].join(" ");
|
74
|
-
areas.push(`"${middleRow}"`);
|
75
|
-
|
76
|
-
if (this.bottomSlot) {
|
77
|
-
areas.push('"bottom bottom bottom"');
|
78
|
-
}
|
79
|
-
const columns = [
|
80
|
-
this.leftSlot ? "auto" : "0",
|
81
|
-
"1fr",
|
82
|
-
this.rightSlot ? "auto" : "0",
|
83
|
-
].join(" ");
|
84
|
-
return {
|
85
|
-
display: this.inline ? "inline-grid" : "grid",
|
86
|
-
"grid-template-areas": areas.join("\n"),
|
87
|
-
"grid-template-columns": columns,
|
88
|
-
"align-items": "center",
|
89
|
-
};
|
90
|
-
},
|
91
|
-
},
|
92
|
-
render(h) {
|
93
|
-
const renderContent = () => {
|
94
|
-
if (this.slots[`${this.slotNames}`]) {
|
95
|
-
return this.slots[`${this.slotNames}`](this.scope);
|
96
|
-
}
|
97
|
-
if (this.render) {
|
98
|
-
return resolveRender(this.render, h, this.scope);
|
99
|
-
}
|
100
|
-
if (this.$scopedSlots.default) {
|
101
|
-
return this.$scopedSlots.default(this.scope);
|
102
|
-
}
|
103
|
-
};
|
104
|
-
const content = renderContent();
|
105
|
-
if (
|
106
|
-
!content &&
|
107
|
-
!this.topSlot &&
|
108
|
-
!this.leftSlot &&
|
109
|
-
!this.rightSlot &&
|
110
|
-
!this.bottomSlot
|
111
|
-
)
|
112
|
-
return null;
|
113
|
-
return (
|
114
|
-
<div
|
115
|
-
class={[this.b([this.slotNames || "position"])]}
|
116
|
-
style={this.gridStyle}
|
117
|
-
>
|
118
|
-
{this.topSlot && <div class="top">{this.topSlot(this.scope)}</div>}
|
119
|
-
{this.leftSlot && <div class="left">{this.leftSlot(this.scope)}</div>}
|
120
|
-
{content && (
|
121
|
-
<div class="content" style={this.contentStyle}>
|
122
|
-
{content}
|
123
|
-
</div>
|
124
|
-
)}
|
125
|
-
{this.rightSlot && (
|
126
|
-
<div class="right">{this.rightSlot(this.scope)}</div>
|
127
|
-
)}
|
128
|
-
{this.bottomSlot && (
|
129
|
-
<div class="bottom">{this.bottomSlot(this.scope)}</div>
|
130
|
-
)}
|
131
|
-
</div>
|
132
|
-
);
|
133
|
-
},
|
134
|
-
});
|
135
|
-
</script>
|