vue-super-crud 1.7.1 → 1.7.2
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/.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,42 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* v-dialogDragWidth 可拖动弹窗高度(右下角)
|
3
|
-
* Copyright (c) 2019 ruoyi
|
4
|
-
*/
|
5
|
-
|
6
|
-
export default {
|
7
|
-
bind(el, binding) {
|
8
|
-
const value = binding.value;
|
9
|
-
if (value == false) return;
|
10
|
-
const dragDom = el.querySelector(".el-dialog");
|
11
|
-
const lineEl = document.createElement("div");
|
12
|
-
lineEl.style =
|
13
|
-
"width: 6px; background: inherit; height: 10px; position: absolute; right: 0; bottom: 0; margin: auto; z-index: 1; cursor: nwse-resize;";
|
14
|
-
lineEl.addEventListener(
|
15
|
-
"mousedown",
|
16
|
-
function (e) {
|
17
|
-
// 鼠标按下,计算当前元素距离可视区的距离
|
18
|
-
const disX = e.clientX - el.offsetLeft;
|
19
|
-
const disY = e.clientY - el.offsetTop;
|
20
|
-
// 当前宽度 高度
|
21
|
-
const curWidth = dragDom.offsetWidth;
|
22
|
-
const curHeight = dragDom.offsetHeight;
|
23
|
-
document.onmousemove = function (e) {
|
24
|
-
dragDom.style["user-select"] = "none";
|
25
|
-
e.preventDefault(); // 移动时禁用默认事件
|
26
|
-
// 通过事件委托,计算移动的距离
|
27
|
-
const xl = e.clientX - disX;
|
28
|
-
const yl = e.clientY - disY;
|
29
|
-
dragDom.style.width = `${curWidth + xl}px`;
|
30
|
-
dragDom.style.height = `${curHeight + yl}px`;
|
31
|
-
};
|
32
|
-
document.onmouseup = function (e) {
|
33
|
-
dragDom.style["user-select"] = "auto";
|
34
|
-
document.onmousemove = null;
|
35
|
-
document.onmouseup = null;
|
36
|
-
};
|
37
|
-
},
|
38
|
-
false
|
39
|
-
);
|
40
|
-
dragDom.appendChild(lineEl);
|
41
|
-
},
|
42
|
-
};
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import insertSlot from "./insertSlot";
|
2
|
-
import dialogDrag from "./dialog/drag";
|
3
|
-
import dialogDragSize from "./dialog/dragSize";
|
4
|
-
|
5
|
-
export default function (Vue) {
|
6
|
-
Vue.directive("insertSlot", insertSlot);
|
7
|
-
Vue.directive("scDialogDrag", dialogDrag);
|
8
|
-
Vue.directive("scDialogDragHeight", dialogDragSize);
|
9
|
-
}
|
@@ -1,192 +0,0 @@
|
|
1
|
-
import { batchMerge } from "utils/mergeTemp";
|
2
|
-
import { checkVisibility, filterButtons } from "utils";
|
3
|
-
export default {
|
4
|
-
methods: {
|
5
|
-
contextMenuTemps() {
|
6
|
-
return {
|
7
|
-
mock: {
|
8
|
-
label: "生成测试数据",
|
9
|
-
icon: "el-icon-magic-stick",
|
10
|
-
onClick: () => {
|
11
|
-
this.$emit("mockData");
|
12
|
-
},
|
13
|
-
},
|
14
|
-
reset: {
|
15
|
-
label: "重置表单",
|
16
|
-
icon: "el-icon-refresh",
|
17
|
-
onClick: () => {
|
18
|
-
this.$emit("handleChild", "resetField", null, true);
|
19
|
-
},
|
20
|
-
},
|
21
|
-
copy: {
|
22
|
-
label: "复制数据",
|
23
|
-
icon: "el-icon-document-copy",
|
24
|
-
onClick: async () => {
|
25
|
-
try {
|
26
|
-
// 只获取显示的字段数据
|
27
|
-
const visibleData = this.trueRenderColumns.reduce(
|
28
|
-
(acc, column) => {
|
29
|
-
if (!column.hidden && this.value[column.prop] !== undefined) {
|
30
|
-
acc[column.prop] = this.value[column.prop];
|
31
|
-
}
|
32
|
-
return acc;
|
33
|
-
},
|
34
|
-
{}
|
35
|
-
);
|
36
|
-
|
37
|
-
const jsonStr = JSON.stringify(visibleData, null, 2);
|
38
|
-
await navigator.clipboard.writeText(jsonStr);
|
39
|
-
this.$message.success("表单数据已复制到剪贴板");
|
40
|
-
this.$emit("copy", jsonStr);
|
41
|
-
} catch (error) {
|
42
|
-
this.$message.error("复制失败:" + error.message);
|
43
|
-
}
|
44
|
-
},
|
45
|
-
},
|
46
|
-
paste: {
|
47
|
-
label: "粘贴数据",
|
48
|
-
icon: "el-icon-document-add",
|
49
|
-
children: [
|
50
|
-
{
|
51
|
-
label: "粘贴当前",
|
52
|
-
onClick: async () => {
|
53
|
-
try {
|
54
|
-
await this.handlePasteData();
|
55
|
-
} catch (error) {
|
56
|
-
this.$message.error("导入失败:" + error.message);
|
57
|
-
}
|
58
|
-
},
|
59
|
-
},
|
60
|
-
{
|
61
|
-
label: "粘贴全部",
|
62
|
-
onClick: async () => {
|
63
|
-
try {
|
64
|
-
await this.handlePasteData(true);
|
65
|
-
} catch (error) {
|
66
|
-
this.$message.error("导入失败:" + error.message);
|
67
|
-
}
|
68
|
-
},
|
69
|
-
},
|
70
|
-
],
|
71
|
-
},
|
72
|
-
saveDraft: {
|
73
|
-
label: `保存为草稿`,
|
74
|
-
icon: "el-icon-plus",
|
75
|
-
onClick: () => {
|
76
|
-
this.$refs.draftDrawer.handleSaveDraft();
|
77
|
-
},
|
78
|
-
},
|
79
|
-
loadDraft: {
|
80
|
-
label: `加载最新草稿`,
|
81
|
-
icon: "el-icon-bottom",
|
82
|
-
children: [
|
83
|
-
{
|
84
|
-
label: "加载当前",
|
85
|
-
onClick: () => {
|
86
|
-
this.$refs.draftDrawer.handleLoadDraft();
|
87
|
-
},
|
88
|
-
},
|
89
|
-
{
|
90
|
-
label: "完整加载",
|
91
|
-
onClick: () => {
|
92
|
-
this.$refs.draftDrawer.handleLoadDraft(null, true);
|
93
|
-
},
|
94
|
-
},
|
95
|
-
],
|
96
|
-
},
|
97
|
-
draft: {
|
98
|
-
label: `草稿箱 (${this.$refs.draftDrawer.draftNumber})`,
|
99
|
-
icon: "el-icon-notebook-2",
|
100
|
-
onClick: () => {
|
101
|
-
this.$refs.draftDrawer.handleDraft();
|
102
|
-
},
|
103
|
-
},
|
104
|
-
};
|
105
|
-
},
|
106
|
-
handleContextMenu(event) {
|
107
|
-
if (checkVisibility(this.formOptions.contextMenu) === false) return;
|
108
|
-
|
109
|
-
const isFormElement =
|
110
|
-
["INPUT", "TEXTAREA", "SELECT"].includes(event.target.tagName) ||
|
111
|
-
event.target.contentEditable === "true";
|
112
|
-
// 如果是表单元素则不拦截右键菜单
|
113
|
-
if (isFormElement) return;
|
114
|
-
event.preventDefault();
|
115
|
-
// 创建右键菜单项
|
116
|
-
const menuItems = batchMerge(
|
117
|
-
"btn.form.contextMenu",
|
118
|
-
this.formOptions.contextMenu,
|
119
|
-
this.formScope,
|
120
|
-
this.contextMenuTemps()
|
121
|
-
);
|
122
|
-
// 显示右键菜单
|
123
|
-
this.$contextmenu({
|
124
|
-
items: filterButtons(
|
125
|
-
menuItems,
|
126
|
-
this.formOptions,
|
127
|
-
this.formScope,
|
128
|
-
"contextMenu"
|
129
|
-
),
|
130
|
-
event,
|
131
|
-
customClass: "sc-form-contextmenu",
|
132
|
-
zIndex: 3000,
|
133
|
-
minWidth: 180,
|
134
|
-
});
|
135
|
-
},
|
136
|
-
|
137
|
-
// 验证粘贴的数据是否符合表单结构
|
138
|
-
validatePasteData(data) {
|
139
|
-
if (!data || typeof data !== "object") {
|
140
|
-
return false;
|
141
|
-
}
|
142
|
-
return this.trueRenderColumns.some(
|
143
|
-
(column) => data[column.prop] !== undefined
|
144
|
-
);
|
145
|
-
},
|
146
|
-
async filterDisabledData(data) {
|
147
|
-
const updates = {};
|
148
|
-
if (this.isDisabled) {
|
149
|
-
return updates;
|
150
|
-
}
|
151
|
-
|
152
|
-
const updatePromises = this.trueRenderColumns.map(async (column) => {
|
153
|
-
if (data[column.prop] === undefined) return;
|
154
|
-
|
155
|
-
// 获取字段配置
|
156
|
-
const config = await new Promise((resolve) => {
|
157
|
-
this.$emit("handleChild", "getComponentConfig", column.prop, resolve);
|
158
|
-
});
|
159
|
-
|
160
|
-
// 如果字段未禁用,则更新值
|
161
|
-
if (!config?.disabled && !column.disabled && !column.detail) {
|
162
|
-
updates[column.prop] = data[column.prop];
|
163
|
-
}
|
164
|
-
});
|
165
|
-
|
166
|
-
await Promise.all(updatePromises);
|
167
|
-
return updates;
|
168
|
-
}, // 处理粘贴数据
|
169
|
-
async handlePasteData(loadAll = false) {
|
170
|
-
const text = await navigator.clipboard.readText();
|
171
|
-
let pasteData = JSON.parse(text);
|
172
|
-
|
173
|
-
// 验证数据结构
|
174
|
-
if (!this.validatePasteData(pasteData)) {
|
175
|
-
this.$message.error("数据结构不匹配,请检查字段");
|
176
|
-
return;
|
177
|
-
}
|
178
|
-
|
179
|
-
// 更新表单数据
|
180
|
-
const newFormData = { ...this.value };
|
181
|
-
const updates = loadAll
|
182
|
-
? pasteData
|
183
|
-
: await this.filterDisabledData(pasteData);
|
184
|
-
Object.assign(newFormData, updates);
|
185
|
-
|
186
|
-
this.$emit("input", newFormData);
|
187
|
-
this.$emit("paste", newFormData);
|
188
|
-
this.$message.success("数据导入成功");
|
189
|
-
this.clearValidate();
|
190
|
-
},
|
191
|
-
},
|
192
|
-
};
|
@@ -1,391 +0,0 @@
|
|
1
|
-
<template>
|
2
|
-
<el-drawer
|
3
|
-
title="草稿箱"
|
4
|
-
:visible.sync="draftVisible"
|
5
|
-
direction="rtl"
|
6
|
-
size="600"
|
7
|
-
:append-to-body="true"
|
8
|
-
:destroy-on-close="false"
|
9
|
-
>
|
10
|
-
<div :class="b()">
|
11
|
-
<!-- 顶部操作区 -->
|
12
|
-
<div class="draft-header">
|
13
|
-
<div class="draft-header__left">
|
14
|
-
<el-tooltip content="清空草稿箱" placement="top">
|
15
|
-
<el-button
|
16
|
-
type="danger"
|
17
|
-
size="small"
|
18
|
-
icon="el-icon-delete"
|
19
|
-
@click="handleClearDraft"
|
20
|
-
>
|
21
|
-
</el-button>
|
22
|
-
</el-tooltip>
|
23
|
-
</div>
|
24
|
-
<div class="draft-header__right">
|
25
|
-
<el-input
|
26
|
-
v-model="searchKeyword"
|
27
|
-
placeholder="搜索草稿"
|
28
|
-
prefix-icon="el-icon-search"
|
29
|
-
clearable
|
30
|
-
size="small"
|
31
|
-
/>
|
32
|
-
</div>
|
33
|
-
</div>
|
34
|
-
|
35
|
-
<!-- 草稿列表 -->
|
36
|
-
<div class="draft-list">
|
37
|
-
<el-empty
|
38
|
-
v-if="!filteredDraftList.length"
|
39
|
-
description="暂无草稿"
|
40
|
-
></el-empty>
|
41
|
-
|
42
|
-
<div
|
43
|
-
v-else
|
44
|
-
v-for="draft in filteredDraftList"
|
45
|
-
:key="draft.id"
|
46
|
-
class="draft-item"
|
47
|
-
>
|
48
|
-
<div class="draft-item__header">
|
49
|
-
<span class="draft-item__name">{{ draft.name }}</span>
|
50
|
-
<span class="draft-item__time">{{
|
51
|
-
formatTime(draft.updateTime)
|
52
|
-
}}</span>
|
53
|
-
</div>
|
54
|
-
|
55
|
-
<div class="draft-item__footer">
|
56
|
-
<el-button type="text" size="mini" @click="handleLoadDraft(draft)">
|
57
|
-
加载当前
|
58
|
-
</el-button>
|
59
|
-
<el-button
|
60
|
-
type="text"
|
61
|
-
size="mini"
|
62
|
-
@click="handleLoadDraft(draft, true)"
|
63
|
-
>
|
64
|
-
完整加载
|
65
|
-
</el-button>
|
66
|
-
<el-button
|
67
|
-
type="text"
|
68
|
-
size="mini"
|
69
|
-
@click="handlePreviewDraft(draft)"
|
70
|
-
>
|
71
|
-
预览
|
72
|
-
</el-button>
|
73
|
-
<el-button
|
74
|
-
type="text"
|
75
|
-
size="mini"
|
76
|
-
@click="handleDeleteDraft(draft.id)"
|
77
|
-
>
|
78
|
-
删除
|
79
|
-
</el-button>
|
80
|
-
</div>
|
81
|
-
</div>
|
82
|
-
</div>
|
83
|
-
</div>
|
84
|
-
</el-drawer>
|
85
|
-
</template>
|
86
|
-
|
87
|
-
<script>
|
88
|
-
import cache from "utils/cache.js";
|
89
|
-
import { create } from "core";
|
90
|
-
export default create({
|
91
|
-
name: "form-draft",
|
92
|
-
inject: ["formCtx"],
|
93
|
-
props: {
|
94
|
-
// 添加尺寸属性
|
95
|
-
size: {
|
96
|
-
type: String,
|
97
|
-
default: "medium",
|
98
|
-
validator: (value) =>
|
99
|
-
["default", "medium", "small", "mini"].includes(value),
|
100
|
-
},
|
101
|
-
},
|
102
|
-
data() {
|
103
|
-
return {
|
104
|
-
isExpanded: false,
|
105
|
-
shouldExpandHorizontal: false,
|
106
|
-
hideTimer: null,
|
107
|
-
draftList: [],
|
108
|
-
draftVisible: false,
|
109
|
-
searchKeyword: "",
|
110
|
-
};
|
111
|
-
},
|
112
|
-
|
113
|
-
created() {
|
114
|
-
this.loadDraftsFromStorage();
|
115
|
-
},
|
116
|
-
|
117
|
-
computed: {
|
118
|
-
filteredDraftList() {
|
119
|
-
if (!this.searchKeyword) {
|
120
|
-
return this.draftList;
|
121
|
-
}
|
122
|
-
const keyword = this.searchKeyword.toLowerCase();
|
123
|
-
return this.draftList.filter((draft) =>
|
124
|
-
draft.name.toLowerCase().includes(keyword)
|
125
|
-
);
|
126
|
-
},
|
127
|
-
draftNumber() {
|
128
|
-
return this.draftList.length;
|
129
|
-
},
|
130
|
-
},
|
131
|
-
|
132
|
-
methods: {
|
133
|
-
handleMouseEnter() {
|
134
|
-
if (this.hideTimer) {
|
135
|
-
clearTimeout(this.hideTimer);
|
136
|
-
}
|
137
|
-
this.isExpanded = true;
|
138
|
-
},
|
139
|
-
handleMouseLeave() {
|
140
|
-
this.hideTimer = setTimeout(() => {
|
141
|
-
this.isExpanded = false;
|
142
|
-
}, 200);
|
143
|
-
},
|
144
|
-
handleDraft() {
|
145
|
-
this.draftVisible = true;
|
146
|
-
},
|
147
|
-
|
148
|
-
handleSaveDraft() {
|
149
|
-
this.$prompt("请输入草稿名称", "保存草稿", {
|
150
|
-
confirmButtonText: "确定",
|
151
|
-
cancelButtonText: "取消",
|
152
|
-
inputPattern: /\S+/, // 不允许空白字符
|
153
|
-
inputErrorMessage: "草稿名称不能为空",
|
154
|
-
inputValue: `草稿_${new Date().toLocaleString()}`, // 默认名称
|
155
|
-
}).then(({ value: draftName }) => {
|
156
|
-
try {
|
157
|
-
// 创建新的草稿对象
|
158
|
-
const draft = {
|
159
|
-
id: `draft_${Date.now()}`, // 使用时间戳生成唯一ID
|
160
|
-
name: draftName.trim(),
|
161
|
-
formData: JSON.parse(JSON.stringify(this.formCtx.value)), // 深拷贝表单数据
|
162
|
-
createTime: new Date().toISOString(),
|
163
|
-
updateTime: new Date().toISOString(),
|
164
|
-
};
|
165
|
-
|
166
|
-
// 获取现有草稿列表
|
167
|
-
const drafts = [...this.draftList];
|
168
|
-
|
169
|
-
// 检查是否存在同名草稿
|
170
|
-
const existingIndex = drafts.findIndex(
|
171
|
-
(item) => item.name === draft.name
|
172
|
-
);
|
173
|
-
|
174
|
-
if (existingIndex !== -1) {
|
175
|
-
// 如果存在同名草稿,提示用户是否覆盖
|
176
|
-
return this.$confirm("已存在同名草稿,是否覆盖?", "提示", {
|
177
|
-
type: "warning",
|
178
|
-
confirmButtonText: "覆盖",
|
179
|
-
cancelButtonText: "取消",
|
180
|
-
})
|
181
|
-
.then(() => {
|
182
|
-
// 覆盖已有草稿
|
183
|
-
drafts[existingIndex] = draft;
|
184
|
-
this.saveDraftsToStorage(drafts);
|
185
|
-
this.$message.success("草稿已更新");
|
186
|
-
})
|
187
|
-
.catch(() => {
|
188
|
-
// 用户取消覆盖,重新调用保存方法
|
189
|
-
this.handleSaveDraft();
|
190
|
-
});
|
191
|
-
}
|
192
|
-
|
193
|
-
// 添加新草稿到列表开头
|
194
|
-
drafts.unshift(draft);
|
195
|
-
|
196
|
-
// 保存到本地存储
|
197
|
-
this.saveDraftsToStorage(drafts);
|
198
|
-
|
199
|
-
// 更新组件数据
|
200
|
-
this.draftList = drafts;
|
201
|
-
|
202
|
-
this.$message.success("保存成功");
|
203
|
-
} catch (error) {
|
204
|
-
console.error("保存草稿失败:", error);
|
205
|
-
this.$message.error("保存失败:" + error.message);
|
206
|
-
}
|
207
|
-
});
|
208
|
-
},
|
209
|
-
|
210
|
-
// 保存草稿列表到本地存储
|
211
|
-
saveDraftsToStorage(drafts) {
|
212
|
-
try {
|
213
|
-
if (!this.$route) return;
|
214
|
-
let draftsStr = cache.local.getJSON("SC_FORM_DRAFTS") || {};
|
215
|
-
draftsStr[this.$route.path] = drafts;
|
216
|
-
cache.local.setJSON("SC_FORM_DRAFTS", draftsStr);
|
217
|
-
} catch (error) {
|
218
|
-
console.error("保存到本地存储失败:", error);
|
219
|
-
throw new Error("保存到本地存储失败");
|
220
|
-
}
|
221
|
-
},
|
222
|
-
|
223
|
-
// 从本地存储加载草稿列表
|
224
|
-
loadDraftsFromStorage() {
|
225
|
-
try {
|
226
|
-
const cacheData = cache.local.getJSON("SC_FORM_DRAFTS") || {};
|
227
|
-
this.draftList = cacheData[this.$route.path] || [];
|
228
|
-
} catch (error) {
|
229
|
-
console.error("加载草稿列表失败:", error);
|
230
|
-
this.draftList = [];
|
231
|
-
}
|
232
|
-
},
|
233
|
-
|
234
|
-
async handleLoadDraft(draft, loadAll = false) {
|
235
|
-
if (!draft) {
|
236
|
-
draft = this.filteredDraftList[0];
|
237
|
-
}
|
238
|
-
if (!draft) return;
|
239
|
-
try {
|
240
|
-
// 更新表单数据
|
241
|
-
const formData = JSON.parse(JSON.stringify(draft.formData));
|
242
|
-
let newFormData;
|
243
|
-
if (loadAll) {
|
244
|
-
// 加载全部字段
|
245
|
-
newFormData = formData;
|
246
|
-
} else {
|
247
|
-
// 只更新表单中存在的字段
|
248
|
-
const currentFormData = { ...this.formCtx.value };
|
249
|
-
const updates = await this.formCtx.filterDisabledData(formData);
|
250
|
-
newFormData = { ...currentFormData, ...updates };
|
251
|
-
}
|
252
|
-
|
253
|
-
// 更新表单数据
|
254
|
-
this.formCtx.$emit("input", newFormData);
|
255
|
-
|
256
|
-
// 更新草稿的使用时间
|
257
|
-
const updatedDraft = {
|
258
|
-
...draft,
|
259
|
-
updateTime: new Date().toISOString(),
|
260
|
-
};
|
261
|
-
|
262
|
-
// 更新草稿列表中的数据
|
263
|
-
const draftIndex = this.draftList.findIndex(
|
264
|
-
(item) => item.id === draft.id
|
265
|
-
);
|
266
|
-
if (draftIndex !== -1) {
|
267
|
-
this.draftList.splice(draftIndex, 1);
|
268
|
-
this.draftList.unshift(updatedDraft);
|
269
|
-
// 保存更新后的草稿列表
|
270
|
-
this.saveDraftsToStorage(this.draftList);
|
271
|
-
}
|
272
|
-
|
273
|
-
// 关闭草稿箱
|
274
|
-
this.draftVisible = false;
|
275
|
-
|
276
|
-
// 清除表单验证状态
|
277
|
-
this.formCtx.clearValidate();
|
278
|
-
|
279
|
-
// 提示成功
|
280
|
-
this.$message.success("加载成功");
|
281
|
-
|
282
|
-
// 触发加载草稿事件
|
283
|
-
this.formCtx.$emit("draft-loaded", draft);
|
284
|
-
} catch (error) {
|
285
|
-
console.error("加载草稿失败:", error);
|
286
|
-
this.$message.error("加载失败:" + error.message);
|
287
|
-
}
|
288
|
-
},
|
289
|
-
|
290
|
-
// 添加草稿数据验证方法
|
291
|
-
validateDraftData(draftData) {
|
292
|
-
// 检查必要的字段
|
293
|
-
if (!draftData || typeof draftData !== "object") {
|
294
|
-
return false;
|
295
|
-
}
|
296
|
-
|
297
|
-
// 检查是否至少有一个有效字段
|
298
|
-
const hasValidField = this.formCtx.trueRenderColumns.some(
|
299
|
-
(column) => draftData[column.prop] !== undefined
|
300
|
-
);
|
301
|
-
|
302
|
-
return hasValidField;
|
303
|
-
},
|
304
|
-
|
305
|
-
handleDeleteDraft(draftId) {
|
306
|
-
// 确认是否删除草稿
|
307
|
-
this.$confirm("确认删除该草稿?删除后将无法恢复", "提示", {
|
308
|
-
confirmButtonText: "确定",
|
309
|
-
cancelButtonText: "取消",
|
310
|
-
type: "warning",
|
311
|
-
})
|
312
|
-
.then(() => {
|
313
|
-
try {
|
314
|
-
// 获取要删除的草稿
|
315
|
-
const draftIndex = this.draftList.findIndex(
|
316
|
-
(item) => item.id === draftId
|
317
|
-
);
|
318
|
-
if (draftIndex === -1) return;
|
319
|
-
|
320
|
-
// 从列表中移除草稿
|
321
|
-
const deletedDraft = this.draftList[draftIndex];
|
322
|
-
this.draftList.splice(draftIndex, 1);
|
323
|
-
|
324
|
-
// 保存更新后的草稿列表到本地存储
|
325
|
-
this.saveDraftsToStorage(this.draftList);
|
326
|
-
// 触发删除事件
|
327
|
-
this.formCtx.$emit("draft-deleted", deletedDraft);
|
328
|
-
|
329
|
-
// 如果草稿列表为空,可以自动关闭抽屉
|
330
|
-
if (this.draftList.length === 0) {
|
331
|
-
this.draftVisible = false;
|
332
|
-
}
|
333
|
-
} catch (error) {
|
334
|
-
console.error("删除草稿失败:", error);
|
335
|
-
}
|
336
|
-
})
|
337
|
-
.catch(() => {
|
338
|
-
// 用户取消删除,不做处理
|
339
|
-
});
|
340
|
-
},
|
341
|
-
|
342
|
-
handleClearDraft() {
|
343
|
-
this.$confirm("确认清空草稿箱?", "提示", {
|
344
|
-
confirmButtonText: "确定",
|
345
|
-
cancelButtonText: "取消",
|
346
|
-
type: "warning",
|
347
|
-
}).then(() => {
|
348
|
-
this.draftList = [];
|
349
|
-
this.saveDraftsToStorage([]);
|
350
|
-
});
|
351
|
-
},
|
352
|
-
// 格式化时间显示
|
353
|
-
formatTime(time) {
|
354
|
-
return new Date(time).toLocaleString();
|
355
|
-
},
|
356
|
-
// 添加预览草稿方法
|
357
|
-
handlePreviewDraft(draft) {
|
358
|
-
// 创建 prop 到 label 的映射
|
359
|
-
const propToLabelMap = this.formCtx.trueRenderColumns.reduce(
|
360
|
-
(map, col) => {
|
361
|
-
map[col.prop] = col.label || col.prop;
|
362
|
-
return map;
|
363
|
-
},
|
364
|
-
{}
|
365
|
-
);
|
366
|
-
|
367
|
-
// 格式化显示数据
|
368
|
-
const formattedData = Object.entries(draft.formData)
|
369
|
-
.map(([key, value]) => {
|
370
|
-
const label = propToLabelMap[key] || key;
|
371
|
-
// 处理不同类型的值的显示
|
372
|
-
let displayValue = value;
|
373
|
-
if (Array.isArray(value)) {
|
374
|
-
displayValue = JSON.stringify(value);
|
375
|
-
} else if (typeof value === "object" && value !== null) {
|
376
|
-
displayValue = JSON.stringify(value);
|
377
|
-
} else if (value === "" || value === null || value === undefined) {
|
378
|
-
displayValue = "空";
|
379
|
-
}
|
380
|
-
return `${label}: ${displayValue}`;
|
381
|
-
})
|
382
|
-
.join("\n");
|
383
|
-
this.$alert(formattedData, "草稿预览", {
|
384
|
-
confirmButtonText: "关闭",
|
385
|
-
customClass: "sc-form-draft__preview-dialog",
|
386
|
-
callback: () => {},
|
387
|
-
});
|
388
|
-
},
|
389
|
-
},
|
390
|
-
});
|
391
|
-
</script>
|