vue-super-crud 1.7.1
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/.browserslistrc +3 -0
- package/.versionrc.json +36 -0
- package/CHANGELOG.md +232 -0
- package/LICENSE +201 -0
- package/README.md +46 -0
- package/babel.config.js +12 -0
- package/build/alias.js +10 -0
- package/build/build.js +52 -0
- package/build/config.js +70 -0
- package/deploy.bat +14 -0
- package/docs/.vuepress/components/button/base.vue +88 -0
- package/docs/.vuepress/components/common/code-format.vue +331 -0
- package/docs/.vuepress/components/commonConfig/presetCodeTemplate/base.vue +68 -0
- package/docs/.vuepress/components/commonConfig/presetCodeTemplate/customParams.vue +73 -0
- package/docs/.vuepress/components/commonConfig/renderType/component.vue +160 -0
- package/docs/.vuepress/components/commonConfig/renderType/formatter.vue +49 -0
- package/docs/.vuepress/components/commonConfig/renderType/render.vue +91 -0
- package/docs/.vuepress/components/commonConfig/renderType/slot.vue +63 -0
- package/docs/.vuepress/components/crud/baseUse/baseUse.vue +98 -0
- package/docs/.vuepress/components/crud/baseUse/columnAction.vue +72 -0
- package/docs/.vuepress/components/crud/baseUse/columnWidth.vue +107 -0
- package/docs/.vuepress/components/crud/baseUse/handleRow.vue +65 -0
- package/docs/.vuepress/components/crud/baseUse/height.vue +82 -0
- package/docs/.vuepress/components/crud/baseUse/index.vue +54 -0
- package/docs/.vuepress/components/crud/baseUse/loading.vue +70 -0
- package/docs/.vuepress/components/crud/baseUse/pagination.vue +108 -0
- package/docs/.vuepress/components/crud/baseUse/selection.vue +114 -0
- package/docs/.vuepress/components/crud/baseUse/summaryMethod.vue +118 -0
- package/docs/.vuepress/components/crud/baseUse/title.vue +54 -0
- package/docs/.vuepress/components/crud/baseUse/toolbar.vue +69 -0
- package/docs/.vuepress/components/crud/buttons/common.vue +115 -0
- package/docs/.vuepress/components/crud/buttons/fast.vue +82 -0
- package/docs/.vuepress/components/crud/contextMenu/base.vue +72 -0
- package/docs/.vuepress/components/crud/copy.vue +52 -0
- package/docs/.vuepress/components/crud/crudEvents/api.vue +157 -0
- package/docs/.vuepress/components/crud/crudEvents/deleteTip.vue +93 -0
- package/docs/.vuepress/components/crud/crudEvents/events.vue +188 -0
- package/docs/.vuepress/components/crud/dataSort/base.vue +142 -0
- package/docs/.vuepress/components/crud/genDynamicColumns/base.vue +53 -0
- package/docs/.vuepress/components/crud/genDynamicColumns/dynamicAndFixed.vue +111 -0
- package/docs/.vuepress/components/crud/genDynamicColumns/treeDynamic.vue +68 -0
- package/docs/.vuepress/components/crud/handleBar/handleRow.vue +65 -0
- package/docs/.vuepress/components/crud/handleBar/toolbar.vue +69 -0
- package/docs/.vuepress/components/crud/renderType/1.vue +57 -0
- package/docs/.vuepress/components/crud/renderType/2.vue +63 -0
- package/docs/.vuepress/components/crud/renderType/3.vue +105 -0
- package/docs/.vuepress/components/crud/renderType/5.vue +91 -0
- package/docs/.vuepress/components/crud/search/1.vue +90 -0
- package/docs/.vuepress/components/crud/search/2.vue +78 -0
- package/docs/.vuepress/components/crud/search/3.vue +107 -0
- package/docs/.vuepress/components/crud/search/base.vue +123 -0
- package/docs/.vuepress/components/crud/search/localSearch.vue +124 -0
- package/docs/.vuepress/components/crud/search/special.vue +148 -0
- package/docs/.vuepress/components/crud/selection/events.vue +47 -0
- package/docs/.vuepress/components/crud/selection/pagination.vue +94 -0
- package/docs/.vuepress/components/crud/selection/singleSelection.vue +64 -0
- package/docs/.vuepress/components/crud/span/base.vue +69 -0
- package/docs/.vuepress/components/crud/span/special.vue +75 -0
- package/docs/.vuepress/components/crud/summary/base.vue +99 -0
- package/docs/.vuepress/components/crud/tableEdit/addDeleteBtn.vue +174 -0
- package/docs/.vuepress/components/crud/tableEdit/cellEdit.vue +194 -0
- package/docs/.vuepress/components/crud/tableEdit/controlEdit.vue +219 -0
- package/docs/.vuepress/components/crud/tableEdit/dialog.vue +172 -0
- package/docs/.vuepress/components/crud/tableEdit/free.vue +88 -0
- package/docs/.vuepress/components/crud/tableEdit/freeColumn.vue +82 -0
- package/docs/.vuepress/components/crud/tableEdit/methods.vue +154 -0
- package/docs/.vuepress/components/crud/tableEdit/rowAction.vue +107 -0
- package/docs/.vuepress/components/crud/tableEdit/rowBatch.vue +116 -0
- package/docs/.vuepress/components/crud/tableEdit/rowClick.vue +98 -0
- package/docs/.vuepress/components/crud/validate/base.vue +122 -0
- package/docs/.vuepress/components/crud/validate/custom.vue +82 -0
- package/docs/.vuepress/components/crud/validate/regulars.vue +88 -0
- package/docs/.vuepress/components/crud/validate/relation.vue +91 -0
- package/docs/.vuepress/components/crud/validate/tree.vue +82 -0
- package/docs/.vuepress/components/dialog/baseUse/base.vue +92 -0
- package/docs/.vuepress/components/dialog/baseUse/beforeConfirm.vue +78 -0
- package/docs/.vuepress/components/dialog/baseUse/control.vue +79 -0
- package/docs/.vuepress/components/dialog/baseUse/drawer.vue +59 -0
- package/docs/.vuepress/components/dialog/baseUse/footer.vue +87 -0
- package/docs/.vuepress/components/dialog/baseUse/insertSlot.vue +79 -0
- package/docs/.vuepress/components/dict/DictLinkage.vue +91 -0
- package/docs/.vuepress/components/dict/baseUse.vue +72 -0
- package/docs/.vuepress/components/dict/component.vue +82 -0
- package/docs/.vuepress/components/dict/localDict.vue +68 -0
- package/docs/.vuepress/components/form/baseUse/base.vue +48 -0
- package/docs/.vuepress/components/form/baseUse/dataFormat.vue +92 -0
- package/docs/.vuepress/components/form/baseUse/deep.vue +57 -0
- package/docs/.vuepress/components/form/baseUse/gridLayout.vue +47 -0
- package/docs/.vuepress/components/form/baseUse/group.vue +66 -0
- package/docs/.vuepress/components/form/baseUse/hidden.vue +40 -0
- package/docs/.vuepress/components/form/baseUse/inlineLayout.vue +48 -0
- package/docs/.vuepress/components/form/baseUse/label.vue +51 -0
- package/docs/.vuepress/components/form/baseUse/tooltip.vue +40 -0
- package/docs/.vuepress/components/form/baseUse/validate.vue +52 -0
- package/docs/.vuepress/components/form/detail/base.vue +78 -0
- package/docs/.vuepress/components/form/detail/border.vue +90 -0
- package/docs/.vuepress/components/form/detail/singleDetail.vue +72 -0
- package/docs/.vuepress/components/formatData/baseUse.vue +131 -0
- package/docs/.vuepress/components/mock/index.js +347 -0
- package/docs/.vuepress/components/mockData/custom.vue +69 -0
- package/docs/.vuepress/components/mockData/example.vue +290 -0
- package/docs/.vuepress/components/positionSlot/base.vue +24 -0
- package/docs/.vuepress/components/positionSlot/form.vue +71 -0
- package/docs/.vuepress/components/positionSlot/table.vue +85 -0
- package/docs/.vuepress/components/tabs/base.vue +57 -0
- package/docs/.vuepress/components/temp.js +195 -0
- package/docs/.vuepress/config.js +146 -0
- package/docs/.vuepress/enhanceApp.js +142 -0
- package/docs/.vuepress/public/favicon.ico +0 -0
- package/docs/.vuepress/public/super.png +0 -0
- package/docs/.vuepress/styles/index.styl +25 -0
- package/docs/.vuepress/styles/palette.styl +6 -0
- package/docs/README.md +14 -0
- package/docs/guide/button/base.md +31 -0
- package/docs/guide/commonConfig/jsx.md +166 -0
- package/docs/guide/commonConfig/presetCodeTemplate.md +68 -0
- package/docs/guide/commonConfig/renderType.md +181 -0
- package/docs/guide/crud/baseUse.md +120 -0
- package/docs/guide/crud/buttons.md +18 -0
- package/docs/guide/crud/config.md +217 -0
- package/docs/guide/crud/contextMenu.md +18 -0
- package/docs/guide/crud/dataSort.md +66 -0
- package/docs/guide/crud/genDynamicColumns.md +145 -0
- package/docs/guide/crud/handleBar.md +26 -0
- package/docs/guide/crud/renderType.md +4 -0
- package/docs/guide/crud/search.md +150 -0
- package/docs/guide/crud/selection.md +73 -0
- package/docs/guide/crud/span.md +98 -0
- package/docs/guide/crud/summary.md +167 -0
- package/docs/guide/crud/tableEdit.md +377 -0
- package/docs/guide/crud/validate.md +158 -0
- package/docs/guide/dialog/baseUse.md +81 -0
- package/docs/guide/dict/baseUse.md +174 -0
- package/docs/guide/dict/component.md +88 -0
- package/docs/guide/dict/config.md +44 -0
- package/docs/guide/form/baseUse.md +142 -0
- package/docs/guide/form/detail.md +38 -0
- package/docs/guide/formatData/baseUse.md +98 -0
- package/docs/guide/formatData/config.md +142 -0
- package/docs/guide/mockData/base.md +26 -0
- package/docs/guide/positionSlot/base.md +41 -0
- package/docs/guide/question/base.md +44 -0
- package/docs/guide/start/base.md +30 -0
- package/docs/guide/tabs/base.md +63 -0
- package/examples/App.vue +52 -0
- package/examples/Layout/components/AppMain.vue +40 -0
- package/examples/Layout/components/Item.vue +29 -0
- package/examples/Layout/components/Link.vue +44 -0
- package/examples/Layout/components/SidebarItem.vue +93 -0
- package/examples/Layout/index.vue +69 -0
- package/examples/assets/logo.png +0 -0
- package/examples/favicon.ico +0 -0
- package/examples/index.html +18 -0
- package/examples/main.js +54 -0
- package/examples/router/index.js +140 -0
- package/examples/store/index.js +0 -0
- package/examples/styles/index.scss +63 -0
- package/examples/styles/sidebar.scss +226 -0
- package/examples/styles/transition.scss +48 -0
- package/examples/styles/variables.scss +25 -0
- package/examples/views/crud/base.vue +68 -0
- package/examples/views/crud/handleRow.vue +84 -0
- package/examples/views/crud/search.vue +116 -0
- package/examples/views/dashboard/index.vue +244 -0
- package/examples/views/dashboard/index1.vue +234 -0
- package/examples/views/dashboard/test.vue +9 -0
- package/examples/views/formTest/index.vue +168 -0
- package/examples/views/nested/menu1/index.vue +7 -0
- package/examples/views/nested/menu1/menu1-1/index.vue +7 -0
- package/examples/views/nested/menu1/menu1-2/index.vue +7 -0
- package/examples/views/nested/menu1/menu1-2/menu1-2-1/index.vue +5 -0
- package/examples/views/nested/menu1/menu1-2/menu1-2-2/index.vue +5 -0
- package/examples/views/nested/menu1/menu1-3/index.vue +5 -0
- package/examples/views/nested/menu2/index.vue +5 -0
- package/gulpfile.js +84 -0
- package/lib/index.css +1 -0
- package/lib/super-crud.min.js +15 -0
- package/package.json +66 -0
- package/packages/button/index.vue +189 -0
- package/packages/core/components/comp.vue +223 -0
- package/packages/core/components/position.vue +135 -0
- package/packages/core/components/render.vue +460 -0
- package/packages/core/configManager.js +302 -0
- package/packages/core/create.js +8 -0
- package/packages/core/defaultRender.js +64 -0
- package/packages/core/dict/global.js +10 -0
- package/packages/core/dict/index.js +432 -0
- package/packages/core/dict/mixin.js +94 -0
- package/packages/core/event.js +60 -0
- package/packages/core/index.js +6 -0
- package/packages/core/init.js +122 -0
- package/packages/core/mock/genConfig.js +228 -0
- package/packages/core/mock/genData.js +422 -0
- package/packages/core/mock/index.js +4 -0
- package/packages/core/rules.js +111 -0
- package/packages/crud/column.vue +205 -0
- package/packages/crud/columnAction.vue +207 -0
- package/packages/crud/columnCell.vue +146 -0
- package/packages/crud/defaultColumn.vue +130 -0
- package/packages/crud/drawerColumn.vue +225 -0
- package/packages/crud/form.vue +69 -0
- package/packages/crud/index.vue +564 -0
- package/packages/crud/menuBar.vue +298 -0
- package/packages/crud/mixins/cacheHandler.js +36 -0
- package/packages/crud/mixins/calcColumnWidth.js +79 -0
- package/packages/crud/mixins/calcHeight.js +105 -0
- package/packages/crud/mixins/columnHandler.js +128 -0
- package/packages/crud/mixins/contextMenu.js +98 -0
- package/packages/crud/mixins/dataProcessor.js +202 -0
- package/packages/crud/mixins/dialog.js +109 -0
- package/packages/crud/mixins/excelHandler.js +150 -0
- package/packages/crud/mixins/exposeMethods.js +107 -0
- package/packages/crud/mixins/generateDynamicColumns.js +250 -0
- package/packages/crud/mixins/props.js +38 -0
- package/packages/crud/mixins/searchHandler.js +151 -0
- package/packages/crud/mixins/select.js +359 -0
- package/packages/crud/mixins/spanMethod.js +288 -0
- package/packages/crud/mixins/summary.js +177 -0
- package/packages/crud/mixins/tableEdit.js +547 -0
- package/packages/crud/mixins/validate.js +219 -0
- package/packages/crud/pagination.vue +110 -0
- package/packages/crud/search.vue +119 -0
- package/packages/crud/searchHeader.vue +231 -0
- package/packages/crud/selectBanner.vue +138 -0
- package/packages/crud/utils/EditState.js +319 -0
- package/packages/crud/utils/excelExport.js +112 -0
- package/packages/crud/utils/excelImport.js +112 -0
- package/packages/crud/utils/index.js +98 -0
- package/packages/dialog/dialog.js +233 -0
- package/packages/dialog/dialog.vue +15 -0
- package/packages/dialog/index.js +22 -0
- package/packages/dict/cascadeFormat.vue +179 -0
- package/packages/dict/dateFormat.vue +40 -0
- package/packages/dict/form/cascade.vue +61 -0
- package/packages/dict/form/checkbox.vue +90 -0
- package/packages/dict/form/extendMethod.js +22 -0
- package/packages/dict/form/input-base.js +31 -0
- package/packages/dict/form/input.js +20 -0
- package/packages/dict/form/radio.vue +69 -0
- package/packages/dict/form/select.vue +118 -0
- package/packages/dict/form/switch.vue +75 -0
- package/packages/dict/valueFormat.vue +188 -0
- package/packages/directive/dialog/drag.js +86 -0
- package/packages/directive/dialog/dragSize.js +42 -0
- package/packages/directive/index.js +9 -0
- package/packages/directive/insertSlot.js +10 -0
- package/packages/form/contextMenu.js +192 -0
- package/packages/form/draftDrawer.vue +391 -0
- package/packages/form/formAction.vue +97 -0
- package/packages/form/formItem.vue +259 -0
- package/packages/form/index.vue +451 -0
- package/packages/form/props.js +15 -0
- package/packages/grid/cell.vue +65 -0
- package/packages/grid/index.vue +130 -0
- package/packages/group/index.vue +96 -0
- package/packages/tabs/index.vue +290 -0
- package/packages/tooltip/index.js +9 -0
- package/packages/tooltip/tooltip.vue +32 -0
- package/packages/tooltip/tooltipComponent.js +38 -0
- package/packages/verifyInput/index.vue +131 -0
- package/src/config/common.js +88 -0
- package/src/config/crud.js +567 -0
- package/src/config/dialog.js +87 -0
- package/src/config/form.js +215 -0
- package/src/config/index.js +9 -0
- package/src/constants/index.js +72 -0
- package/src/index.js +67 -0
- package/src/template/btn/crud.js +6 -0
- package/src/template/btn/dialog.js +1 -0
- package/src/template/btn/form.js +3 -0
- package/src/template/btn/index.js +9 -0
- package/src/template/dicts.js +1 -0
- package/src/template/formatData.js +507 -0
- package/src/template/index.js +19 -0
- package/src/template/render.js +124 -0
- package/src/template/rules.js +53 -0
- package/src/utils/bem.js +49 -0
- package/src/utils/cache.js +77 -0
- package/src/utils/getType.js +34 -0
- package/src/utils/index.js +212 -0
- package/src/utils/mergeTemp.js +124 -0
- package/styles/button.scss +3 -0
- package/styles/crud.scss +425 -0
- package/styles/dialog.scss +95 -0
- package/styles/form.scss +532 -0
- package/styles/group.scss +78 -0
- package/styles/index.scss +94 -0
- package/styles/tabs.scss +139 -0
- package/styles/verifyInput.scss +56 -0
- package/vue-jsx-sync.js +90 -0
- package/vue.config.js +54 -0
@@ -0,0 +1,97 @@
|
|
1
|
+
<template>
|
2
|
+
<component
|
3
|
+
v-if="showAction"
|
4
|
+
:class="b([action.align])"
|
5
|
+
:is="layoutCell"
|
6
|
+
:widthSize="widthSize"
|
7
|
+
>
|
8
|
+
<el-form-item label-width="0px">
|
9
|
+
<button_
|
10
|
+
v-for="(item, index) in formActionButtons"
|
11
|
+
:key="index"
|
12
|
+
:size="formCtx.formOptions.size"
|
13
|
+
:loading="formCtx.loadingStatus"
|
14
|
+
:scope="scope"
|
15
|
+
v-bind="item"
|
16
|
+
></button_>
|
17
|
+
</el-form-item>
|
18
|
+
</component>
|
19
|
+
</template>
|
20
|
+
|
21
|
+
<script>
|
22
|
+
import create from "core/create";
|
23
|
+
import { batchMerge } from "utils/mergeTemp";
|
24
|
+
import Cell from "../grid/cell.vue";
|
25
|
+
import button_ from "pak/button";
|
26
|
+
import { checkVisibility } from "utils";
|
27
|
+
export default create({
|
28
|
+
name: "form-action",
|
29
|
+
inject: ["formCtx"],
|
30
|
+
components: { Cell, button_ },
|
31
|
+
computed: {
|
32
|
+
showAction() {
|
33
|
+
return checkVisibility(
|
34
|
+
this.action,
|
35
|
+
null,
|
36
|
+
this.formActionButtons.length > 0
|
37
|
+
);
|
38
|
+
},
|
39
|
+
action() {
|
40
|
+
return this.formCtx.formOptions.action;
|
41
|
+
},
|
42
|
+
scope() {
|
43
|
+
return {
|
44
|
+
ctx: this.formCtx,
|
45
|
+
row: this.formCtx.value,
|
46
|
+
};
|
47
|
+
},
|
48
|
+
layoutCell() {
|
49
|
+
if (this.formCtx.formOptions.layout === "grid") {
|
50
|
+
return "cell";
|
51
|
+
}
|
52
|
+
if (this.formCtx.formOptions.layout === "el-row") {
|
53
|
+
return "el-col";
|
54
|
+
}
|
55
|
+
},
|
56
|
+
widthSize() {
|
57
|
+
if (this.action.widthSize) {
|
58
|
+
return this.action.widthSize;
|
59
|
+
}
|
60
|
+
if (this.action.fill !== false) {
|
61
|
+
return this.formCtx.formOptions.columns;
|
62
|
+
}
|
63
|
+
return 1;
|
64
|
+
},
|
65
|
+
formActionButtons() {
|
66
|
+
const action = this.action;
|
67
|
+
const buttons = [];
|
68
|
+
const merges = batchMerge(
|
69
|
+
"btn.form",
|
70
|
+
action,
|
71
|
+
{
|
72
|
+
ctx: this.formCtx,
|
73
|
+
row: this.formCtx.value,
|
74
|
+
},
|
75
|
+
this.formActionTemps
|
76
|
+
);
|
77
|
+
buttons.push(...merges);
|
78
|
+
return buttons;
|
79
|
+
},
|
80
|
+
formActionTemps() {
|
81
|
+
return {
|
82
|
+
submit: (item, { ctx }) => ({
|
83
|
+
label: "提交",
|
84
|
+
icon: "el-icon-check",
|
85
|
+
type: "primary",
|
86
|
+
onClick: this.formCtx.submit,
|
87
|
+
}),
|
88
|
+
reset: (item, { ctx }) => ({
|
89
|
+
icon: "el-icon-refresh",
|
90
|
+
label: "重置",
|
91
|
+
onClick: this.formCtx.reset,
|
92
|
+
}),
|
93
|
+
};
|
94
|
+
},
|
95
|
+
},
|
96
|
+
});
|
97
|
+
</script>
|
@@ -0,0 +1,259 @@
|
|
1
|
+
<script>
|
2
|
+
import { create } from "core";
|
3
|
+
import { omit } from "lodash-es";
|
4
|
+
import grid from "../grid/index.vue";
|
5
|
+
import cell from "pak/grid/cell.vue";
|
6
|
+
import formItem from "./formItem";
|
7
|
+
import position from "core/components/position";
|
8
|
+
import Render from "core/components/render";
|
9
|
+
import tooltip from "../tooltip/tooltip.vue";
|
10
|
+
import { generateRules } from "core";
|
11
|
+
export default create({
|
12
|
+
name: "form-item",
|
13
|
+
props: {
|
14
|
+
col: Object,
|
15
|
+
isFirstRow: Boolean,
|
16
|
+
},
|
17
|
+
inject: ["formCtx", "elForm"],
|
18
|
+
provide() {
|
19
|
+
return this.provide;
|
20
|
+
},
|
21
|
+
components: {
|
22
|
+
cell,
|
23
|
+
grid,
|
24
|
+
formItem,
|
25
|
+
},
|
26
|
+
data() {
|
27
|
+
return {};
|
28
|
+
},
|
29
|
+
created() {
|
30
|
+
this.formCtx.$on("handleChild", (method, prop, params) => {
|
31
|
+
if (!method) return;
|
32
|
+
if (prop) {
|
33
|
+
if (prop !== this.item.prop) return;
|
34
|
+
if (!this[method])
|
35
|
+
return console.error(`不存在方法${method},prop-${this.item.prop}`);
|
36
|
+
this[method](params);
|
37
|
+
} else {
|
38
|
+
this[method](params);
|
39
|
+
}
|
40
|
+
});
|
41
|
+
},
|
42
|
+
methods: {
|
43
|
+
resetField(isCondition) {
|
44
|
+
const config = this.getComponentConfig();
|
45
|
+
if (isCondition && (config?.disabled || this.disabled)) {
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
this.$refs.formItem?.resetField();
|
49
|
+
},
|
50
|
+
getComponentConfig(callBack) {
|
51
|
+
const config = this.$refs.render?.getComponentConfig();
|
52
|
+
callBack && callBack(config);
|
53
|
+
return config;
|
54
|
+
},
|
55
|
+
},
|
56
|
+
watch: {
|
57
|
+
isDetail() {
|
58
|
+
// 改变模式时,重置form,刷新item组件的provide
|
59
|
+
this.formCtx.refreshForm();
|
60
|
+
},
|
61
|
+
},
|
62
|
+
computed: {
|
63
|
+
provide() {
|
64
|
+
// 控制子组件单个禁用
|
65
|
+
if (this.isDetail) {
|
66
|
+
return {
|
67
|
+
elForm: {
|
68
|
+
...this.elForm,
|
69
|
+
disabled: true,
|
70
|
+
},
|
71
|
+
};
|
72
|
+
}
|
73
|
+
},
|
74
|
+
disabled() {
|
75
|
+
return this.isDetail || this.item.disabled || this.elForm?.disabled;
|
76
|
+
},
|
77
|
+
isDetail() {
|
78
|
+
if (this.col.isDetail === false) return false;
|
79
|
+
return this.formCtx.isDetail || this.col.detail;
|
80
|
+
},
|
81
|
+
item() {
|
82
|
+
if (this.isDetail) {
|
83
|
+
return this.col.detail || this.col;
|
84
|
+
}
|
85
|
+
return this.col;
|
86
|
+
},
|
87
|
+
formOptions() {
|
88
|
+
return this.formCtx.formOptions;
|
89
|
+
},
|
90
|
+
generateRules() {
|
91
|
+
return generateRules(this.item, this.formCtx.formScope);
|
92
|
+
},
|
93
|
+
rules() {
|
94
|
+
return this.generateRules.rules;
|
95
|
+
},
|
96
|
+
rawRules() {
|
97
|
+
return this.generateRules.rawRules;
|
98
|
+
},
|
99
|
+
mode() {
|
100
|
+
return this.item.mode || this.formOptions.mode;
|
101
|
+
},
|
102
|
+
|
103
|
+
labelOverTip() {
|
104
|
+
return (
|
105
|
+
this.formCtx.formOptions.labelOverTip ||
|
106
|
+
this.formCtx.formOptions.labelOverTip === "" ||
|
107
|
+
this.item.labelOverTip
|
108
|
+
);
|
109
|
+
},
|
110
|
+
className() {
|
111
|
+
const names = [];
|
112
|
+
// 标签隐藏
|
113
|
+
if (this.formOptions.hiddenLabel || this.item.hiddenLabel) {
|
114
|
+
names.push("hidden-label");
|
115
|
+
}
|
116
|
+
// 标签粗细
|
117
|
+
if (this.formCtx.isBorder || this.formOptions.shrinkLabel) {
|
118
|
+
names.push("shrink-label");
|
119
|
+
}
|
120
|
+
if (this.hasFormChildren) {
|
121
|
+
names.push("has-form-children");
|
122
|
+
}
|
123
|
+
if (this.item.class) {
|
124
|
+
names.push(this.item.class);
|
125
|
+
}
|
126
|
+
if (this.rules.required) names.push("is-required");
|
127
|
+
if (this.isDetail) names.push("is-detail");
|
128
|
+
if (this.isFirstRow) names.push("is-first-row");
|
129
|
+
return names;
|
130
|
+
},
|
131
|
+
hasFormChildren() {
|
132
|
+
return this.item.formItems && Array.isArray(this.item.formItems);
|
133
|
+
},
|
134
|
+
},
|
135
|
+
render(h) {
|
136
|
+
const cellRender = () => {
|
137
|
+
if (this.hasFormChildren) {
|
138
|
+
return (
|
139
|
+
<this.formOptions.layout
|
140
|
+
columns={this.item.columns || this.item.formItems.length}
|
141
|
+
props={this.item}
|
142
|
+
>
|
143
|
+
{this.item.formItems.map((item) => {
|
144
|
+
item.hiddenLabel = true;
|
145
|
+
return <formItem item={item} props={item} />;
|
146
|
+
})}
|
147
|
+
</this.formOptions.layout>
|
148
|
+
);
|
149
|
+
}
|
150
|
+
return (
|
151
|
+
<tooltip
|
152
|
+
hide={!this.item.contentTip}
|
153
|
+
content={
|
154
|
+
typeof this.item.contentTip === "string"
|
155
|
+
? this.item.contentTip
|
156
|
+
: this.formCtx.value[this.item.prop]
|
157
|
+
}
|
158
|
+
>
|
159
|
+
<Render
|
160
|
+
ref="render"
|
161
|
+
value={this.formCtx.value[this.item.prop]}
|
162
|
+
onInput={(e) => {
|
163
|
+
this.$set(this.formCtx.value, this.item.prop, e);
|
164
|
+
}}
|
165
|
+
props={this.item}
|
166
|
+
item={this.item}
|
167
|
+
slots={this.formCtx.slots}
|
168
|
+
mode={this.formOptions.mode}
|
169
|
+
scope={this.formCtx.formScope}
|
170
|
+
size={this.formOptions.size}
|
171
|
+
rawRules={this.rawRules}
|
172
|
+
defaultRender={this.formOptions.defaultRender}
|
173
|
+
controlDefault={(defaultRender, scope) => {
|
174
|
+
if (
|
175
|
+
this.item.formatter ||
|
176
|
+
this.formCtx.isDetail ||
|
177
|
+
this.item.detail
|
178
|
+
) {
|
179
|
+
return (h, scope) => defaultRender.formatter(h, scope, true);
|
180
|
+
}
|
181
|
+
return defaultRender.input;
|
182
|
+
}}
|
183
|
+
></Render>
|
184
|
+
</tooltip>
|
185
|
+
);
|
186
|
+
};
|
187
|
+
const labelRender = () => {
|
188
|
+
const labelVNode = (
|
189
|
+
<tooltip
|
190
|
+
hide={!this.labelOverTip}
|
191
|
+
content={
|
192
|
+
typeof this.item.labelOverTip === "string"
|
193
|
+
? this.item.labelOverTip
|
194
|
+
: this.item.label
|
195
|
+
}
|
196
|
+
overflow={true}
|
197
|
+
>
|
198
|
+
<position
|
199
|
+
class="form-label"
|
200
|
+
ellipsis={this.labelOverTip ? true : false}
|
201
|
+
slotName={this.item.prop}
|
202
|
+
slotSuffixes={this.mode ? [this.mode, "label"] : ["label"]}
|
203
|
+
render={this.item.labelRender}
|
204
|
+
slots={this.formCtx.slots}
|
205
|
+
scope={this.formCtx.formScope}
|
206
|
+
>
|
207
|
+
{this.item.label}
|
208
|
+
</position>
|
209
|
+
</tooltip>
|
210
|
+
);
|
211
|
+
const hasTooltip =
|
212
|
+
this.item.tooltip ||
|
213
|
+
this.item.tooltipRender ||
|
214
|
+
this.formCtx.slots[`${this.item.prop}-tooltip`];
|
215
|
+
const tooltipVNode = (
|
216
|
+
<el-tooltip effect="dark" placement="top">
|
217
|
+
<position
|
218
|
+
slot="content"
|
219
|
+
slotName={this.item.prop}
|
220
|
+
slotSuffixes={this.mode ? [this.mode, "tooltip"] : ["tooltip"]}
|
221
|
+
render={this.item.tooltipRender}
|
222
|
+
slots={this.formCtx.slots}
|
223
|
+
scope={this.formCtx.formScope}
|
224
|
+
>
|
225
|
+
{this.item.tooltip}
|
226
|
+
</position>
|
227
|
+
<i class="el-icon-question" />
|
228
|
+
</el-tooltip>
|
229
|
+
);
|
230
|
+
return (
|
231
|
+
<span>
|
232
|
+
{labelVNode} {hasTooltip ? tooltipVNode : null}
|
233
|
+
</span>
|
234
|
+
);
|
235
|
+
};
|
236
|
+
return (
|
237
|
+
<this.formCtx.layoutCell props={this.item} attrs={this.item}>
|
238
|
+
<el-form-item
|
239
|
+
class={this.className}
|
240
|
+
style={{
|
241
|
+
"--label-width": this.item.labelWidth,
|
242
|
+
}}
|
243
|
+
ref="formItem"
|
244
|
+
label={this.item.label}
|
245
|
+
label-width={this.item.labelWidth}
|
246
|
+
size={this.formOptions.size}
|
247
|
+
prop={this.item.validateProp || this.item.prop}
|
248
|
+
rules={this.rules}
|
249
|
+
scopedSlots={{
|
250
|
+
label: labelRender,
|
251
|
+
}}
|
252
|
+
>
|
253
|
+
{cellRender()}
|
254
|
+
</el-form-item>
|
255
|
+
</this.formCtx.layoutCell>
|
256
|
+
);
|
257
|
+
},
|
258
|
+
});
|
259
|
+
</script>
|