olp-table 5.3.1 → 5.3.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/.env.build +1 -0
- package/README.md +26 -0
- package/babel.config.js +5 -0
- package/jsconfig.json +22 -0
- package/{olp-table.common.js → olp-table/olp-table.common.js} +5 -5
- package/{olp-table.umd.js → olp-table/olp-table.umd.js} +5 -5
- package/{olp-table.umd.min.js → olp-table/olp-table.umd.min.js} +3 -3
- package/package.json +92 -12
- package/public/favicon.ico +0 -0
- package/public/index.html +17 -0
- package/rmMode.bat +1 -0
- package/src/App.vue +199 -0
- package/src/api/crud.js +22 -0
- package/src/api/dist.js +6 -0
- package/src/assets/iconfont/iconfont.css +20 -0
- package/src/assets/iconfont/iconfont.json +16 -0
- package/src/assets/iconfont/iconfont.ttf +0 -0
- package/src/assets/iconfont/iconfont.woff +0 -0
- package/src/assets/iconfont/iconfont.woff2 +0 -0
- package/src/assets/logo.png +0 -0
- package/src/components/auto-height/index.vue +75 -0
- package/src/components/codemirror-tag.vue +100 -0
- package/src/components/lazy-load-select.vue +107 -0
- package/src/components/ol-dialog-excel.vue +112 -0
- package/src/components/ol-dialog-import.vue +304 -0
- package/src/components/ol-dialog-json.vue +82 -0
- package/src/components/ol-dialog-table.vue +81 -0
- package/src/components/ol-dialog-upload-file.vue +208 -0
- package/src/components/ol-dict-tag.vue +271 -0
- package/src/components/ol-select-dom.vue +71 -0
- package/src/components/ol-table-filter.vue +28 -0
- package/src/components/ol-table-render.vue +44 -0
- package/src/components/ol-table-select.vue +150 -0
- package/src/components/pinia-init.vue +18 -0
- package/src/components/table/model/ModelMixins.js +43 -0
- package/src/components/table/model/model-index.vue +121 -0
- package/src/components/table/model/ot-left-right.vue +18 -0
- package/src/components/table/model/ot-left-tree-right-table.scss +14 -0
- package/src/components/table/model/ot-left-tree-right-table.vue +41 -0
- package/src/components/table/model/ot-top-1-bottom-2.vue +39 -0
- package/src/components/table/model/ot-top-2-bottom-1.vue +38 -0
- package/src/components/table/model/ot-top-2-bottom-2.vue +38 -0
- package/src/components/table/model/ot-top-bottom.vue +18 -0
- package/src/components/table/model/splitpanesModel.css +22 -0
- package/src/components/table/model/splitpanesModel.vue +54 -0
- package/src/components/table/ol-form/index.vue +537 -0
- package/src/components/table/ol-form-v3/index.vue +455 -0
- package/src/components/table/ol-main-form-sub-table/index.vue +601 -0
- package/src/components/table/ol-pager/index.vue +46 -0
- package/src/components/table/ol-table/components/ol-table-column-config/columnIndex.vue +233 -0
- package/src/components/table/ol-table/components/ol-table-column-config/index.vue +145 -0
- package/src/components/table/ol-table/components/ol-table-column-dict-color/index.vue +88 -0
- package/src/components/table/ol-table/index.vue +232 -0
- package/src/components/table/ol-table-operate/index.vue +61 -0
- package/src/components/table/ol-table-search/index.vue +17 -0
- package/src/components/table/ol-table-tool-btn/index.vue +60 -0
- package/src/components/tree/components/o-tree.vue +289 -0
- package/src/components/tree/index.vue +46 -0
- package/src/components/v-component/index.vue +43 -0
- package/src/config/dev-config.js +5 -0
- package/src/config/prod-config.js +5 -0
- package/src/config/shared-config.js +20 -0
- package/src/data.js +9378 -0
- package/src/directives/permission/hasPermi.js +63 -0
- package/src/directives/permission/hasRole.js +30 -0
- package/src/main.js +55 -0
- package/src/mixins/VTMixin/DefaultMethods.js +749 -0
- package/src/mixins/VTMixin/OTMixinBody.js +105 -0
- package/src/mixins/VTMixin/OTMixinBodyFooter.js +93 -0
- package/src/mixins/VTMixin/OTMixinBodyMethods.js +420 -0
- package/src/mixins/VTMixin/OTMixinColumnMethod.js +450 -0
- package/src/mixins/VTMixin/OTMixinInitMethod.js +130 -0
- package/src/mixins/VTMixin/OTMixinPager.js +38 -0
- package/src/mixins/VTMixin/OTMixinSortable.js +43 -0
- package/src/mixins/VTMixin/index.js +18 -0
- package/src/package/index.js +20 -0
- package/src/plugins/axios.js +61 -0
- package/src/store/dict.js +76 -0
- package/src/store/dictType.js +52 -0
- package/src/store/permi.js +45 -0
- package/src/styles/common.scss +37 -0
- package/src/styles/index.scss +48 -0
- package/src/styles/theme.scss +32 -0
- package/src/utils/AESCRUDUtils.js +87 -0
- package/src/utils/DateUtils.js +35 -0
- package/src/utils/ExcelUtil.js +159 -0
- package/src/utils/TableSortUtil.js +91 -0
- package/src/utils/columnProp.js +3 -0
- package/src/utils/groupCompute.js +68 -0
- package/src/utils/http/httpFactory.js +92 -0
- package/src/utils/http/httpFactory2.js +79 -0
- package/src/utils/http/httpUtil.js +123 -0
- package/src/utils/http/httpUtils.js +38 -0
- package/src/utils/loadStyle.js +14 -0
- package/src/utils/message.js +56 -0
- package/src/utils/object.js +80 -0
- package/src/utils/security/TokenUtil.js +19 -0
- package/src/utils/tree.js +54 -0
- package/src/utils/util.js +127 -0
- package/src/views/Test/index.vue +77 -0
- package/src/views/Test/index2.vue +33 -0
- package/src/views/components/btn-config/index.vue +202 -0
- package/src/views/components/option-config/index.vue +192 -0
- package/src/views/db/chineseToEnglish.vue +127 -0
- package/src/views/db/filed.vue +395 -0
- package/src/views/db/index.vue +192 -0
- package/src/views/db/preview/index.vue +139 -0
- package/src/views/db/preview/left.vue +204 -0
- package/src/views/db/preview/right.vue +466 -0
- package/src/views/groupTable/index.vue +137 -0
- package/src/views/groupTable/ol-table-column-config/columnIndex.vue +194 -0
- package/src/views/groupTable/ol-table-column-config/index.vue +92 -0
- package/src/views/table/add-or-edit/config/base-config/index.vue +539 -0
- package/src/views/table/add-or-edit/config/base-config/table-form.vue +333 -0
- package/src/views/table/add-or-edit/config/column-config/header-config.vue +475 -0
- package/src/views/table/add-or-edit/config/column-config/index.vue +790 -0
- package/src/views/table/add-or-edit/config/data/column.js +218 -0
- package/src/views/table/add-or-edit/config/data/crud.js +122 -0
- package/src/views/table/add-or-edit/config/data/events.js +109 -0
- package/src/views/table/add-or-edit/config/data/method.js +127 -0
- package/src/views/table/add-or-edit/config/data/option.js +725 -0
- package/src/views/table/add-or-edit/config/data/page.js +79 -0
- package/src/views/table/add-or-edit/config/field-config/filed-config-table.vue +42 -0
- package/src/views/table/add-or-edit/config/field-config/index.vue +91 -0
- package/src/views/table/add-or-edit/config/form-config/index.vue +1179 -0
- package/src/views/table/add-or-edit/config/index.vue +376 -0
- package/src/views/table/add-or-edit/config/initFormObject.js +25 -0
- package/src/views/table/add-or-edit/config/script-config/LeftMeun.vue +71 -0
- package/src/views/table/add-or-edit/config/script-config/index.vue +70 -0
- package/src/views/table/add-or-edit/config/table-config/btn-config.vue +340 -0
- package/src/views/table/add-or-edit/config/table-config/btn-sort.vue +132 -0
- package/src/views/table/add-or-edit/config/table-config/index.vue +446 -0
- package/src/views/table/add-or-edit/configOld/dataTags/filed-config-table-model.vue +41 -0
- package/src/views/table/add-or-edit/configOld/dataTags/filed-config.vue +74 -0
- package/src/views/table/add-or-edit/configOld/dataTags/index.vue +439 -0
- package/src/views/table/add-or-edit/configOld/dataTags/set-table-sql.vue +79 -0
- package/src/views/table/add-or-edit/configOld/dataTags/table-on-config.vue +74 -0
- package/src/views/table/add-or-edit/configOld/index.vue +127 -0
- package/src/views/table/add-or-edit/configOld/tableTags/columnConfig.js +5 -0
- package/src/views/table/add-or-edit/configOld/tableTags/index.vue +353 -0
- package/src/views/table/add-or-edit/configOld/tableTags/operation-but-config.vue +75 -0
- package/src/views/table/add-or-edit/configOld/tableTags/tool-but-config.vue +92 -0
- package/src/views/table/add-or-edit/index.vue +201 -0
- package/src/views/table/add-or-edit/themeModel/index.vue +53 -0
- package/src/views/table/add-or-edit/themeModel/init-model-table.vue +48 -0
- package/src/views/table/add-or-edit/themeModel/init-model.vue +81 -0
- package/src/views/table/add-or-edit/themeModel/left-right.vue +24 -0
- package/src/views/table/add-or-edit/themeModel/left-tree-right-table.vue +75 -0
- package/src/views/table/add-or-edit/themeModel/olTableSearchModelMixins.js +42 -0
- package/src/views/table/add-or-edit/themeModel/splitpanesThemeModel.vue +49 -0
- package/src/views/table/add-or-edit/themeModel/top-1-bottom-2.vue +29 -0
- package/src/views/table/add-or-edit/themeModel/top-2-bottom-1.vue +32 -0
- package/src/views/table/add-or-edit/themeModel/top-2-bottom-2.vue +32 -0
- package/src/views/table/add-or-edit/themeModel/top-bottom.vue +14 -0
- package/src/views/table/index.vue +43 -0
- package/src/views/table/index2.vue +199 -0
- package/src/views/table/preview/index.vue +29 -0
- package/src/views/tree/components/config-core-data.vue +85 -0
- package/src/views/tree/components/config-core-table.vue +362 -0
- package/src/views/tree/components/config-core-tree/data/events.js +95 -0
- package/src/views/tree/components/config-core-tree/data/option.js +88 -0
- package/src/views/tree/components/config-core-tree/data/prop.js +28 -0
- package/src/views/tree/components/config-core-tree/index.vue +181 -0
- package/src/views/tree/components/config-core.vue +42 -0
- package/src/views/tree/components/form-config/index.vue +967 -0
- package/src/views/tree/index.vue +424 -0
- package/vue.config.js +44 -0
- /package/{demo.html → olp-table/demo.html} +0 -0
- /package/{fonts → olp-table/fonts}/iconfont.1720006583309.7e4906d9.woff +0 -0
- /package/{fonts → olp-table/fonts}/iconfont.1720006583309.947a27f0.ttf +0 -0
- /package/{olp-table.css → olp-table/olp-table.css} +0 -0
|
@@ -0,0 +1,967 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="header">
|
|
4
|
+
<el-form label-width="80">
|
|
5
|
+
<el-row>
|
|
6
|
+
<el-col :span="5">
|
|
7
|
+
<el-form-item label="表单类型">
|
|
8
|
+
<el-radio-group v-model="formType">
|
|
9
|
+
<el-radio :value="0" :label="0" size="large" style="font-size: 20px;">基础表单</el-radio>
|
|
10
|
+
<el-radio :value="1" :label="1" size="large">设计器表单</el-radio>
|
|
11
|
+
</el-radio-group>
|
|
12
|
+
</el-form-item>
|
|
13
|
+
</el-col>
|
|
14
|
+
<el-col :span="5" v-if="formType == 0">
|
|
15
|
+
<el-form-item label="表单设计">
|
|
16
|
+
<!-- 表单设计 -->
|
|
17
|
+
<el-radio-group v-model="formConfig" style="margin-left: 50px;">
|
|
18
|
+
<el-radio :value="0" :label="0" size="large" style="font-size: 20px;">快捷设计</el-radio>
|
|
19
|
+
<el-radio :value="1" :label="1" size="large">编码设计</el-radio>
|
|
20
|
+
</el-radio-group>
|
|
21
|
+
</el-form-item>
|
|
22
|
+
</el-col>
|
|
23
|
+
<el-col :span="4" v-if="formType == 1">
|
|
24
|
+
<el-form-item label="表单名称">
|
|
25
|
+
<olDictTag v-model="customForm" @change="onChangeForm" placeholder="请输入表单名称"
|
|
26
|
+
code="online,form_designer,description,id" like="desc_code"
|
|
27
|
+
></olDictTag>
|
|
28
|
+
</el-form-item>
|
|
29
|
+
</el-col>
|
|
30
|
+
<el-col :span="4" v-if="formType == 2">
|
|
31
|
+
<el-form-item label="表单文件路径">
|
|
32
|
+
<el-input style="margin-left: 20px;width:500px" v-model="customUrl" size="large"
|
|
33
|
+
placeholder="请输入表单文件路径:views/xxx">
|
|
34
|
+
<template #append>
|
|
35
|
+
<el-button :icon="Search" @click="$refs.vComponent.setComponent(customUrl,'init')"/>
|
|
36
|
+
</template>
|
|
37
|
+
</el-input>
|
|
38
|
+
</el-form-item>
|
|
39
|
+
</el-col>
|
|
40
|
+
|
|
41
|
+
<el-col :span="5">
|
|
42
|
+
<el-form-item label="保存路径">
|
|
43
|
+
<el-input v-model="form.saveUrl"
|
|
44
|
+
style="margin-left: 20px;"></el-input>
|
|
45
|
+
</el-form-item>
|
|
46
|
+
</el-col>
|
|
47
|
+
|
|
48
|
+
<el-col :span="4" v-if="type == 'edit' && formType == 0">
|
|
49
|
+
<el-form-item label="更新条件">
|
|
50
|
+
<el-input v-model="form.updateKey"
|
|
51
|
+
style="margin-left: 20px;"></el-input>
|
|
52
|
+
</el-form-item>
|
|
53
|
+
</el-col>
|
|
54
|
+
<el-col :span="4">
|
|
55
|
+
<el-button type="primary" style="margin-left: 40px" @click="showViewForm">表单弹框预览</el-button>
|
|
56
|
+
<vForm ref="vFormViewer" v-if="dialogTableVisible"></vForm>
|
|
57
|
+
</el-col>
|
|
58
|
+
</el-row>
|
|
59
|
+
</el-form>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
<el-row style="height:565px" :gutter="24">
|
|
64
|
+
|
|
65
|
+
<!-- 基础表单 -->
|
|
66
|
+
<el-col :span="12" v-if="formType == 0">
|
|
67
|
+
<el-card class="box-card">
|
|
68
|
+
<el-scrollbar max-height="500px">
|
|
69
|
+
<avue-form v-model="state.baseForm" :option="baseOption"></avue-form>
|
|
70
|
+
</el-scrollbar>
|
|
71
|
+
</el-card>
|
|
72
|
+
</el-col>
|
|
73
|
+
|
|
74
|
+
<!-- 表单设计 -->
|
|
75
|
+
<el-col :span="12" v-if="formType == 0">
|
|
76
|
+
<!-- 快捷设计 -->
|
|
77
|
+
<el-card class="box-card" v-show="formConfig == 0">
|
|
78
|
+
<!-- 表单 -->
|
|
79
|
+
<el-form :inline="true" :model="baseOption" class="demo-form-inline">
|
|
80
|
+
<el-row>
|
|
81
|
+
<el-col :span="12">
|
|
82
|
+
<el-form-item label="每行个数">
|
|
83
|
+
<el-input-number style="width: 240px" v-model="designForm.span" placeholder="请输入每行的个数"
|
|
84
|
+
@change="designFormChange"
|
|
85
|
+
:min="1" :max="4"/>
|
|
86
|
+
</el-form-item>
|
|
87
|
+
</el-col>
|
|
88
|
+
<el-col :span="12">
|
|
89
|
+
<el-form-item label="label宽度">
|
|
90
|
+
<el-input-number style="width: 240px" v-model="baseOption.labelWidth" placeholder="label宽度"
|
|
91
|
+
@change="designFormChange"
|
|
92
|
+
/>
|
|
93
|
+
</el-form-item>
|
|
94
|
+
</el-col>
|
|
95
|
+
<el-col :span="12">
|
|
96
|
+
<el-form-item label="弹窗宽度">
|
|
97
|
+
<el-input-number style="width: 240px" v-model="baseOption.diaLogWidth" placeholder="请输入弹窗宽度"
|
|
98
|
+
@change="designFormChange"
|
|
99
|
+
:min="100" :max="1920"/>
|
|
100
|
+
</el-form-item>
|
|
101
|
+
</el-col>
|
|
102
|
+
<el-col :span="12">
|
|
103
|
+
<el-form-item label="弹窗高度">
|
|
104
|
+
<el-input-number style="width: 240px" v-model="baseOption.diaLogHeight" placeholder="请输入弹窗高度"
|
|
105
|
+
@change="designFormChange"
|
|
106
|
+
:min="50" :max="1080"/>
|
|
107
|
+
</el-form-item>
|
|
108
|
+
</el-col>
|
|
109
|
+
</el-row>
|
|
110
|
+
|
|
111
|
+
</el-form>
|
|
112
|
+
|
|
113
|
+
<!-- 表格 -->
|
|
114
|
+
<vxe-grid
|
|
115
|
+
v-bind="gridOptions"
|
|
116
|
+
ref="vexGridRef"
|
|
117
|
+
:expand-config="{labelField: 'seq'}"
|
|
118
|
+
resizable
|
|
119
|
+
row-key
|
|
120
|
+
>
|
|
121
|
+
<!-- 通用弹窗 -->
|
|
122
|
+
<template #change="{column,row}">
|
|
123
|
+
<olCodemirrorTag v-model="row[column.field]" @confirm="codeMirrorChange(row)"/>
|
|
124
|
+
</template>
|
|
125
|
+
<!-- 通用输入框 -->
|
|
126
|
+
<template #input_default="{column,row}">
|
|
127
|
+
<el-input v-model="row[column.field]" @change="inputChange(row)"></el-input>
|
|
128
|
+
</template>
|
|
129
|
+
<!-- 通用多选框 -->
|
|
130
|
+
<template #checkedBox_header="{ column }">
|
|
131
|
+
<div style="display: flex;align-items: center;">
|
|
132
|
+
<el-checkbox v-model="column.params.all" @change="headerClick(column)"></el-checkbox>
|
|
133
|
+
<span style="margin-left: 5px;">{{ column.title }} </span>
|
|
134
|
+
|
|
135
|
+
</div>
|
|
136
|
+
</template>
|
|
137
|
+
<template #checkedBox_default="{ column, row }">
|
|
138
|
+
<el-checkbox v-model="row[column.field]" @change="checkBoxClick(column, row)" true-value="1"
|
|
139
|
+
:true-label="0" :false-label="1"
|
|
140
|
+
false-value="0"></el-checkbox>
|
|
141
|
+
</template>
|
|
142
|
+
<!-- 通用下拉框 -->
|
|
143
|
+
<template #select_default="{column,row}">
|
|
144
|
+
<olDictTag
|
|
145
|
+
code="select_dom"
|
|
146
|
+
v-model="row[column.field]"
|
|
147
|
+
@change="dictChange(row)"></olDictTag>
|
|
148
|
+
</template>
|
|
149
|
+
<!-- 展开行 -->
|
|
150
|
+
<template #seq="{ rowIndex}">
|
|
151
|
+
<span>{{ rowIndex + 1 }}</span>
|
|
152
|
+
</template>
|
|
153
|
+
<template #content="{ row }">
|
|
154
|
+
<div style="padding:30px 0 12px;display: flex;">
|
|
155
|
+
<avue-form ref="formRef"
|
|
156
|
+
:option="expandForm"
|
|
157
|
+
v-model="row.form"
|
|
158
|
+
@change="refreshForm()"
|
|
159
|
+
>
|
|
160
|
+
<!-- 通用弹窗 -->
|
|
161
|
+
<template #change1>
|
|
162
|
+
<olCodemirrorTag v-model="row.form.change"/>
|
|
163
|
+
</template>
|
|
164
|
+
</avue-form>
|
|
165
|
+
</div>
|
|
166
|
+
</template>
|
|
167
|
+
<template #operate="{ row }">
|
|
168
|
+
<el-button @click="removeRowEvent(row)" type="danger" circle plain>
|
|
169
|
+
<el-icon>
|
|
170
|
+
<Delete/>
|
|
171
|
+
</el-icon>
|
|
172
|
+
</el-button>
|
|
173
|
+
</template>
|
|
174
|
+
</vxe-grid>
|
|
175
|
+
</el-card>
|
|
176
|
+
|
|
177
|
+
<!-- 编码设计 -->
|
|
178
|
+
<div style="width:100%;height:calc(100% - 40px);position: relative;" v-show="formConfig == 1">
|
|
179
|
+
<codemirror
|
|
180
|
+
ref="mycode"
|
|
181
|
+
style="height: 92%;max-height: 510px;text-align: left;"
|
|
182
|
+
v-model="codeForm"
|
|
183
|
+
:autofocus="true"
|
|
184
|
+
:lint="true"
|
|
185
|
+
:indent-with-tab="true"
|
|
186
|
+
:lineWrapping="true"
|
|
187
|
+
:tabSize="2"
|
|
188
|
+
:extensions="state.extensions"
|
|
189
|
+
/>
|
|
190
|
+
<el-button @click="codeToData" type="primary" style="height:40px;width: 100%;">生成</el-button>
|
|
191
|
+
</div>
|
|
192
|
+
|
|
193
|
+
</el-col>
|
|
194
|
+
|
|
195
|
+
<!-- 自定义表单 -->
|
|
196
|
+
<el-col :span="24" v-if="formType == 1 || formType == 2" style="height: 100%;">
|
|
197
|
+
<el-card class="box-card">
|
|
198
|
+
<el-scrollbar max-height="500px">
|
|
199
|
+
<VFormRender v-if="formType == 1" :key="formKey" :form-json="formJson" :form-data="formData"
|
|
200
|
+
:option-data="optionData"
|
|
201
|
+
ref="vFormRef">
|
|
202
|
+
</VFormRender>
|
|
203
|
+
<vComponent ref="vComponent" v-if="formType == 2"/>
|
|
204
|
+
</el-scrollbar>
|
|
205
|
+
</el-card>
|
|
206
|
+
</el-col>
|
|
207
|
+
</el-row>
|
|
208
|
+
|
|
209
|
+
</div>
|
|
210
|
+
</template>
|
|
211
|
+
|
|
212
|
+
<script>
|
|
213
|
+
import vForm from "@/components/table/ol-form"
|
|
214
|
+
import {Delete, Search} from '@element-plus/icons-vue'
|
|
215
|
+
import {reactive, ref, defineExpose, defineEmits, nextTick, onMounted, defineProps, inject} from "vue";
|
|
216
|
+
import vComponent from "@/components/v-component/index.vue";
|
|
217
|
+
import {Codemirror} from "vue-codemirror";
|
|
218
|
+
import {javascript} from "@codemirror/lang-javascript";
|
|
219
|
+
import {oneDark} from "@codemirror/theme-one-dark";
|
|
220
|
+
import {useMessage} from "@/utils/message";
|
|
221
|
+
import {get} from "@/utils/http/httpUtils";
|
|
222
|
+
import Sortable from "sortablejs";
|
|
223
|
+
import {storeDictType} from "@/store/dictType";
|
|
224
|
+
import {storeDict} from "@/store/dict";
|
|
225
|
+
import VXETable from "vxe-table";
|
|
226
|
+
|
|
227
|
+
export default {
|
|
228
|
+
name: 'FormConfig',
|
|
229
|
+
components: {},
|
|
230
|
+
props: {
|
|
231
|
+
type: {}
|
|
232
|
+
},
|
|
233
|
+
inject: ['treeConfigAll', 'addOrEditRootData', 'http'],
|
|
234
|
+
data() {
|
|
235
|
+
return {
|
|
236
|
+
data: [
|
|
237
|
+
{index: "t1", type: "主表", joinTable: "", joinFiled: "/", deleteWhere: 'id=${id}'}
|
|
238
|
+
],
|
|
239
|
+
isHovering: false,
|
|
240
|
+
dict: storeDict(),
|
|
241
|
+
dictType: storeDictType(),
|
|
242
|
+
customUrl: '',
|
|
243
|
+
vexGridRef: '',
|
|
244
|
+
vFormViewer: '',
|
|
245
|
+
dialogTableVisible: false,
|
|
246
|
+
events: ['change'],
|
|
247
|
+
// 基础表单
|
|
248
|
+
baseOption: {
|
|
249
|
+
submitBtn: false,
|
|
250
|
+
emptyBtn: false,
|
|
251
|
+
labelWidth: 125,
|
|
252
|
+
column: []
|
|
253
|
+
},
|
|
254
|
+
//编码设计
|
|
255
|
+
codeForm: {},
|
|
256
|
+
form: {
|
|
257
|
+
updateKey: '',
|
|
258
|
+
saveUrl: '',
|
|
259
|
+
},
|
|
260
|
+
state: {
|
|
261
|
+
show: false,
|
|
262
|
+
extensions: [javascript(), oneDark],
|
|
263
|
+
values: null,
|
|
264
|
+
err: false,
|
|
265
|
+
baseForm: {},
|
|
266
|
+
baseFormRender: {},
|
|
267
|
+
},
|
|
268
|
+
|
|
269
|
+
formMap: {},
|
|
270
|
+
update: true,
|
|
271
|
+
//表单类型
|
|
272
|
+
formType: 0,
|
|
273
|
+
//表单设计
|
|
274
|
+
formConfig: 0,
|
|
275
|
+
//快捷设计表单
|
|
276
|
+
designForm: {
|
|
277
|
+
span: 2,
|
|
278
|
+
},
|
|
279
|
+
//快捷设计表格
|
|
280
|
+
gridOptions: {
|
|
281
|
+
border: true,
|
|
282
|
+
resizable: true,
|
|
283
|
+
showOverflow: true,
|
|
284
|
+
height: 400,
|
|
285
|
+
columns: [
|
|
286
|
+
{
|
|
287
|
+
type: "expand",
|
|
288
|
+
width: 61,
|
|
289
|
+
title: "序号",
|
|
290
|
+
fixed: "left",
|
|
291
|
+
slots: {
|
|
292
|
+
content: 'content',
|
|
293
|
+
default: 'seq'
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
field: 'prop',
|
|
298
|
+
width: 80,
|
|
299
|
+
className: 'move',
|
|
300
|
+
title: "字段名"
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
title: '必填',
|
|
304
|
+
field: 'required',
|
|
305
|
+
params: {
|
|
306
|
+
all: null
|
|
307
|
+
},
|
|
308
|
+
slots: {
|
|
309
|
+
header: 'checkedBox_header',
|
|
310
|
+
default: 'checkedBox_default'
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
field: 'title',
|
|
315
|
+
title: "标题"
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
field: 'showName',
|
|
319
|
+
title: "label",
|
|
320
|
+
slots: {
|
|
321
|
+
default: 'input_default'
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
title: '控件类型',
|
|
326
|
+
field: 'selectDom',
|
|
327
|
+
width: 200,
|
|
328
|
+
slots: {
|
|
329
|
+
default: 'select_default'
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
title: '更新回调',
|
|
334
|
+
field: 'change',
|
|
335
|
+
width: 100,
|
|
336
|
+
slots: {
|
|
337
|
+
default: 'change'
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
title: '操作',
|
|
342
|
+
width: 60,
|
|
343
|
+
fixed: 'right',
|
|
344
|
+
slots: {
|
|
345
|
+
default: 'operate'
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
],
|
|
349
|
+
data: []
|
|
350
|
+
},
|
|
351
|
+
//展开行表单
|
|
352
|
+
expandForm: {
|
|
353
|
+
submitBtn: false,
|
|
354
|
+
emptyBtn: false,
|
|
355
|
+
span: 8,
|
|
356
|
+
column: [
|
|
357
|
+
{
|
|
358
|
+
label: '禁用',
|
|
359
|
+
prop: 'disabled',
|
|
360
|
+
type: 'switch',
|
|
361
|
+
dicData: [{
|
|
362
|
+
label: '关',
|
|
363
|
+
value: 0
|
|
364
|
+
}, {
|
|
365
|
+
label: '开',
|
|
366
|
+
value: 1
|
|
367
|
+
}]
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
label: '标题宽度',
|
|
371
|
+
prop: 'labelWidth',
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
label: '数据字典',
|
|
375
|
+
prop: 'dictCode',
|
|
376
|
+
type: 'select',
|
|
377
|
+
allowCreate: true,
|
|
378
|
+
filterable: true,
|
|
379
|
+
//数据字典属性的配置对象
|
|
380
|
+
props: {
|
|
381
|
+
label: 'dictLabel',
|
|
382
|
+
value: 'dictValue'
|
|
383
|
+
},
|
|
384
|
+
dicData: [],
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
label: '默认值',
|
|
388
|
+
prop: 'value',
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
label: '输入框提示',
|
|
392
|
+
prop: 'placeholder',
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
label: '数据字典表',
|
|
396
|
+
prop: 'dictTable',
|
|
397
|
+
},
|
|
398
|
+
]
|
|
399
|
+
},
|
|
400
|
+
//自定义表单值
|
|
401
|
+
formJson: {},
|
|
402
|
+
formData: {},
|
|
403
|
+
formKey: 0,
|
|
404
|
+
optionData: {},
|
|
405
|
+
vFormRef: null,
|
|
406
|
+
customForm: "",
|
|
407
|
+
customOptions: [],
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
created() {
|
|
411
|
+
this.initConfigDict()
|
|
412
|
+
},
|
|
413
|
+
methods: {
|
|
414
|
+
initConfigDict() {
|
|
415
|
+
for (const col of this.expandForm.column) {
|
|
416
|
+
if (col.prop == 'dictCode') {
|
|
417
|
+
col.dicData = this.dictType.val()
|
|
418
|
+
break
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
showViewForm() {
|
|
423
|
+
this.dialogTableVisible = true;
|
|
424
|
+
this.$nextTick(() => {
|
|
425
|
+
let data = {
|
|
426
|
+
type: this.formType,
|
|
427
|
+
title: "新增",
|
|
428
|
+
theme: 't1'
|
|
429
|
+
}
|
|
430
|
+
data.form = data.type == 0 ? this.baseOption : this.formJson
|
|
431
|
+
this.$ref.vFormViewer.init(data)
|
|
432
|
+
})
|
|
433
|
+
},
|
|
434
|
+
//表头全选框更新
|
|
435
|
+
headerClick(column) {
|
|
436
|
+
this.gridOptions.data.forEach(item => {
|
|
437
|
+
if (column.params.all) {
|
|
438
|
+
item.rules = [{
|
|
439
|
+
required: true,
|
|
440
|
+
message: '请输入' + item.title,
|
|
441
|
+
trigger: 'blur'
|
|
442
|
+
}]
|
|
443
|
+
item[column.field] = '1'
|
|
444
|
+
} else {
|
|
445
|
+
item[column.field] = '0'
|
|
446
|
+
item.rules = null
|
|
447
|
+
}
|
|
448
|
+
this.checkBoxChange(item)
|
|
449
|
+
})
|
|
450
|
+
},
|
|
451
|
+
//表格多选框更新
|
|
452
|
+
checkBoxClick(column, row) {
|
|
453
|
+
if (row.required == '1') {
|
|
454
|
+
row.rules = [{
|
|
455
|
+
required: true,
|
|
456
|
+
message: '请输入' + row.title,
|
|
457
|
+
trigger: 'blur'
|
|
458
|
+
}]
|
|
459
|
+
}
|
|
460
|
+
if (row.required == '0') {
|
|
461
|
+
row.rules = null
|
|
462
|
+
}
|
|
463
|
+
this.checkBoxChange(row)
|
|
464
|
+
},
|
|
465
|
+
|
|
466
|
+
checkBoxChange(row) {
|
|
467
|
+
this.$nextTick(() => {
|
|
468
|
+
this.baseOption.column.forEach(item => {
|
|
469
|
+
if (item.prop == row.prop) {
|
|
470
|
+
item.rules = row.rules
|
|
471
|
+
this.codeForm = this.jsonFormat(this.baseOption)
|
|
472
|
+
return
|
|
473
|
+
}
|
|
474
|
+
})
|
|
475
|
+
})
|
|
476
|
+
},
|
|
477
|
+
//获取数据
|
|
478
|
+
setData(data) {
|
|
479
|
+
if (!data) return
|
|
480
|
+
this.formType = parseInt(data.formMain.designer)
|
|
481
|
+
this.form.updateKey = data.formMain.updateKey
|
|
482
|
+
this.form.saveUrl = data.formMain.saveUrl
|
|
483
|
+
this.customForm = data.formMain.customForm
|
|
484
|
+
//基础表单
|
|
485
|
+
//JSON字符串
|
|
486
|
+
if (data.formJson.optionJson) {
|
|
487
|
+
this.codeForm = data.formJson.optionJson
|
|
488
|
+
this.codeToData()
|
|
489
|
+
}
|
|
490
|
+
if (data.formJson.customJson) {
|
|
491
|
+
//自定义表单
|
|
492
|
+
this.formJson = JSON.parse(data.formJson.customJson)
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
codeToData() {
|
|
496
|
+
try {
|
|
497
|
+
this.getFormatter();
|
|
498
|
+
let value = JSON.parse(this.codeForm);
|
|
499
|
+
|
|
500
|
+
this.setSort(value);
|
|
501
|
+
this.codeForm = this.jsonFormat(value)
|
|
502
|
+
//更新快捷设计表格的数据
|
|
503
|
+
this.setTableData(value)
|
|
504
|
+
if (!value.labelWidth) value.labelWidth = 125
|
|
505
|
+
this.baseOption = value;
|
|
506
|
+
this.setBaseOption(value.column);
|
|
507
|
+
value.span = value.span ? value.span : 12
|
|
508
|
+
//计算表单每行个数
|
|
509
|
+
this.designForm.span = this.parseInt(24 / value.span)
|
|
510
|
+
} catch (e) {
|
|
511
|
+
console.error(e)
|
|
512
|
+
const msg = useMessage() // 消息弹窗
|
|
513
|
+
msg.error('生成失败,请检查对象格式是否正确' + e)
|
|
514
|
+
}
|
|
515
|
+
},
|
|
516
|
+
getFormatter() {
|
|
517
|
+
//正则表达式替换字符串的值
|
|
518
|
+
let v = this.codeForm.replace(/,}/gi, "}").replace(/,]/gi, "]");
|
|
519
|
+
this.codeForm = JSON.stringify(JSON.parse(v), null, 4)
|
|
520
|
+
},
|
|
521
|
+
setSort(value) {
|
|
522
|
+
value.column.sort((a, b) => {
|
|
523
|
+
return a.sort - b.sort
|
|
524
|
+
})
|
|
525
|
+
for (let i = 0; i < value.column.length; i++) {
|
|
526
|
+
value.column.sort = i + 1
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
//JSON格式化
|
|
530
|
+
jsonFormat(val) {
|
|
531
|
+
return JSON.stringify(JSON.parse(JSON.stringify(val)), null, 4)
|
|
532
|
+
},
|
|
533
|
+
//编码设计生成后更新快捷设计表格数据
|
|
534
|
+
setTableData(value) {
|
|
535
|
+
let data = [];
|
|
536
|
+
for (let item of value.column) {
|
|
537
|
+
let tableObj = this.getTableObject(item);
|
|
538
|
+
data.push(tableObj);
|
|
539
|
+
}
|
|
540
|
+
this.$nextTick(() => {
|
|
541
|
+
this.gridOptions.data = data;
|
|
542
|
+
})
|
|
543
|
+
},
|
|
544
|
+
setBaseOption(columns) {
|
|
545
|
+
columns = JSON.parse(JSON.stringify(columns));
|
|
546
|
+
for (let column of columns) {
|
|
547
|
+
try {
|
|
548
|
+
if (column.disabled == 1) {
|
|
549
|
+
column.disabled = true;
|
|
550
|
+
}
|
|
551
|
+
this.setEvents(column);
|
|
552
|
+
this.setDictCode(column)
|
|
553
|
+
} catch (e) {
|
|
554
|
+
console.error(e)
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
this.baseOption.column = columns;
|
|
558
|
+
},
|
|
559
|
+
setDictCode(column) {
|
|
560
|
+
if (column.selectDom != 1 && column.dictCode) {
|
|
561
|
+
this.getDicData(column.dictCode, column)
|
|
562
|
+
}
|
|
563
|
+
},
|
|
564
|
+
setEvents(column) {
|
|
565
|
+
for (let event of this.events) {
|
|
566
|
+
if (column[event] != undefined && column[event] != '') {
|
|
567
|
+
try {
|
|
568
|
+
column[event] = eval("(params)=>{try{" + this.replaceDollarBraces(column[event]) + "}catch (e) {}}");
|
|
569
|
+
} catch (e) {
|
|
570
|
+
console.error(e)
|
|
571
|
+
}
|
|
572
|
+
} else {
|
|
573
|
+
delete column[event];
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
replaceDollarBraces(str) {
|
|
578
|
+
return str.replace(/\$\{?([^{}]+)\}?/g, function (match, innerContent) {
|
|
579
|
+
return innerContent ? `'${innerContent}'` : match;
|
|
580
|
+
});
|
|
581
|
+
},
|
|
582
|
+
getTableObject(item) {
|
|
583
|
+
let obj = {
|
|
584
|
+
prop: item.prop || item.field,
|
|
585
|
+
title: item.title || item.label,
|
|
586
|
+
showName: item.title ? item.label : "",
|
|
587
|
+
required: item.rules ? '1' : '0',
|
|
588
|
+
change: item.change ? item.change : null,
|
|
589
|
+
selectDom: this.getFormType({selectDom: item.type ? item.type : 'input'}),
|
|
590
|
+
//有字典值则赋值否则为空对象
|
|
591
|
+
form: {}
|
|
592
|
+
}
|
|
593
|
+
for (let key of Object.keys(item)) {
|
|
594
|
+
if (!obj[key]) {
|
|
595
|
+
obj.form[key] = item[key]
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
return obj
|
|
599
|
+
},
|
|
600
|
+
//控件类型转换
|
|
601
|
+
getFormType(row) {
|
|
602
|
+
let val = row.selectDom
|
|
603
|
+
if (val != '' || val != undefined || val) {
|
|
604
|
+
let type = ""
|
|
605
|
+
let map = {
|
|
606
|
+
input: '1',
|
|
607
|
+
select: '2',
|
|
608
|
+
time: '3',
|
|
609
|
+
radio: '4',
|
|
610
|
+
checkbox: '5',
|
|
611
|
+
date: '6',
|
|
612
|
+
number: '7',
|
|
613
|
+
}
|
|
614
|
+
if (isNaN(val)) {
|
|
615
|
+
//不是数字,通过健找值
|
|
616
|
+
type = map[val]
|
|
617
|
+
} else {
|
|
618
|
+
//是数字,通过值找健
|
|
619
|
+
// 使用 Object.values() 获取对象的所有值
|
|
620
|
+
const arr = Object.values(map);
|
|
621
|
+
// 使用 Array.prototype.indexOf() 查找指定值在数组中的索引位置
|
|
622
|
+
const index = arr.indexOf(val);
|
|
623
|
+
// 使用 Object.keys()[index] 获取对应索引位置的键名
|
|
624
|
+
type = Object.keys(map)[index];
|
|
625
|
+
|
|
626
|
+
if (type == "") {
|
|
627
|
+
type = 'input'
|
|
628
|
+
} else if (type == "select" || type == "checkbox" || type == "radio") {
|
|
629
|
+
this.getDicData(row.dictCode, row)
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
return type
|
|
633
|
+
}
|
|
634
|
+
},
|
|
635
|
+
//获取字典
|
|
636
|
+
getDicData(code, row) {
|
|
637
|
+
if (code == "" || !code) {
|
|
638
|
+
delete row.dicData
|
|
639
|
+
} else {
|
|
640
|
+
row.dicData = this.dict.val(code)
|
|
641
|
+
this.setDicData(row)
|
|
642
|
+
}
|
|
643
|
+
},
|
|
644
|
+
setDicData(row) {
|
|
645
|
+
this.baseOption.column.forEach(item => {
|
|
646
|
+
if (item.prop == row.prop) {
|
|
647
|
+
item.dicData = row.dicData
|
|
648
|
+
return
|
|
649
|
+
}
|
|
650
|
+
})
|
|
651
|
+
},
|
|
652
|
+
//初始化数据
|
|
653
|
+
init(data) {
|
|
654
|
+
//基础表单
|
|
655
|
+
const option = {
|
|
656
|
+
submitBtn: false,
|
|
657
|
+
emptyBtn: false,
|
|
658
|
+
span: 12,
|
|
659
|
+
labelWidth: 80,
|
|
660
|
+
column: []
|
|
661
|
+
}
|
|
662
|
+
//快捷设计表格
|
|
663
|
+
const tableData = []
|
|
664
|
+
let index = 0
|
|
665
|
+
|
|
666
|
+
//将列配置的新增赋值到表单和表格中
|
|
667
|
+
data.forEach(item => {
|
|
668
|
+
if (item[this.type + 'Display'] == 1) {
|
|
669
|
+
const formObj = {
|
|
670
|
+
label: item.label,
|
|
671
|
+
prop: item.field,
|
|
672
|
+
sort: index,
|
|
673
|
+
type: this.getFormType(item)
|
|
674
|
+
}
|
|
675
|
+
const tableObj = {
|
|
676
|
+
prop: item.field,
|
|
677
|
+
title: item.title,
|
|
678
|
+
sort: index,
|
|
679
|
+
//为空默认文本框
|
|
680
|
+
selectDom: item.selectDom ? item.selectDom : 1,
|
|
681
|
+
required: item.required,
|
|
682
|
+
//有字典值则赋值否则为空对象
|
|
683
|
+
form: {}
|
|
684
|
+
}
|
|
685
|
+
if (item.dictCode != '' || item.dictCode != null) {
|
|
686
|
+
tableObj.form = {dictCode: item.dictCode}
|
|
687
|
+
}
|
|
688
|
+
if (item.dictTable != '' || item.dictTable != null) {
|
|
689
|
+
tableObj.form = {dictTable: item.dictTable}
|
|
690
|
+
}
|
|
691
|
+
for (let key of Object.keys(item)) {
|
|
692
|
+
if (!tableObj[key]) {
|
|
693
|
+
tableObj.form[key] = item[key]
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
for (let event of this.events) {
|
|
697
|
+
if (item[event] != undefined && !(item[event] instanceof Function)) {
|
|
698
|
+
formObj[event] = eval("(params)=>{" + item[event] + "}")
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
index++;
|
|
702
|
+
option.column.push(formObj)
|
|
703
|
+
tableData.push(tableObj)
|
|
704
|
+
}
|
|
705
|
+
})
|
|
706
|
+
this.baseOption = option
|
|
707
|
+
this.gridOptions.data = tableData
|
|
708
|
+
//计算每行列数
|
|
709
|
+
this.designForm.span = 24 / this.baseOption.span
|
|
710
|
+
this.codeForm = this.jsonFormat(this.baseOption)
|
|
711
|
+
this.updateSort();
|
|
712
|
+
},
|
|
713
|
+
getColumn(item) {
|
|
714
|
+
let obj = {
|
|
715
|
+
prop: item.field,
|
|
716
|
+
title: item.title || item.label,
|
|
717
|
+
sort: this.gridOptions.data ? this.gridOptions.data.length : 0,
|
|
718
|
+
//为空默认文本框
|
|
719
|
+
selectDom: item.selectDom ? item.selectDom : 1,
|
|
720
|
+
//有字典值则赋值否则为空对象
|
|
721
|
+
form: item.dictCode != '' || item.dictCode ? {
|
|
722
|
+
dictCode: item.dictCode
|
|
723
|
+
} : {}
|
|
724
|
+
}
|
|
725
|
+
return obj;
|
|
726
|
+
},
|
|
727
|
+
//列配置新增多选更新
|
|
728
|
+
updateData(row, column) {
|
|
729
|
+
if (row[column.field] == '1') {
|
|
730
|
+
for (const item of this.gridOptions.data) {
|
|
731
|
+
if (item.prop == row.field) return
|
|
732
|
+
}
|
|
733
|
+
let tableObj = this.getColumn(row);
|
|
734
|
+
this.gridOptions.data.push(tableObj)
|
|
735
|
+
} else {
|
|
736
|
+
this.gridOptions.data = this.gridOptions.data.filter(item => item.prop != row.field)
|
|
737
|
+
}
|
|
738
|
+
this.reloadData();
|
|
739
|
+
this.refreshForm()
|
|
740
|
+
},
|
|
741
|
+
reloadData(data) {
|
|
742
|
+
if (data) {
|
|
743
|
+
this.gridOptions.data = data;
|
|
744
|
+
}
|
|
745
|
+
this.$ref.vexGridRef.reloadData(this.gridOptions.data)
|
|
746
|
+
},
|
|
747
|
+
//列配置新增全选与全不选
|
|
748
|
+
setAll({list, isAll}) {
|
|
749
|
+
let data = []
|
|
750
|
+
if (isAll) {
|
|
751
|
+
for (let item of list) {
|
|
752
|
+
data.push(this.getColumn(item));
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
this.reloadData(data);
|
|
756
|
+
this.refreshForm()
|
|
757
|
+
},
|
|
758
|
+
//基础表单 > 快捷设计表单更新
|
|
759
|
+
designFormChange() {
|
|
760
|
+
//行数转换为尺寸
|
|
761
|
+
this.baseOption.span = this.parseInt(24 / this.designForm.span)
|
|
762
|
+
//JSON格式化
|
|
763
|
+
this.codeForm = this.jsonFormat(this.baseOption)
|
|
764
|
+
},
|
|
765
|
+
codeMirrorChange(row) {
|
|
766
|
+
for (const row of this.gridOptions.data) {
|
|
767
|
+
this.setChange(row)
|
|
768
|
+
}
|
|
769
|
+
},
|
|
770
|
+
setChange(row) {
|
|
771
|
+
this.$nextTick(() => {
|
|
772
|
+
if (row.prop && row.change) {
|
|
773
|
+
for (let item of this.baseOption.column) {
|
|
774
|
+
if (item.prop == row.prop) {
|
|
775
|
+
item.change = row.change
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
this.codeForm = this.jsonFormat(this.baseOption)
|
|
780
|
+
})
|
|
781
|
+
},
|
|
782
|
+
//基础表单 > 快捷设计表格输入框更新
|
|
783
|
+
inputChange(row) {
|
|
784
|
+
this.$nextTick(() => {
|
|
785
|
+
if (row.prop != "") {
|
|
786
|
+
for (let item of this.baseOption.column) {
|
|
787
|
+
if (item.prop == row.prop) {
|
|
788
|
+
//将表格的label变成显示名或标题
|
|
789
|
+
if (row.showName != "") {
|
|
790
|
+
item.label = row.showName
|
|
791
|
+
item.title = row.title
|
|
792
|
+
} else {
|
|
793
|
+
item.label = row.title
|
|
794
|
+
delete item.title
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
break
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
this.codeForm = this.jsonFormat(this.baseOption)
|
|
801
|
+
})
|
|
802
|
+
},
|
|
803
|
+
//控件类型更新
|
|
804
|
+
dictChange(row) {
|
|
805
|
+
this.$nextTick(() => {
|
|
806
|
+
this.baseOption.column.forEach(item => {
|
|
807
|
+
if (item.prop == row.prop) {
|
|
808
|
+
item.type = this.getFormType(row)
|
|
809
|
+
this.codeForm = this.jsonFormat(this.baseOption)
|
|
810
|
+
return
|
|
811
|
+
}
|
|
812
|
+
})
|
|
813
|
+
})
|
|
814
|
+
},
|
|
815
|
+
refreshForm() {
|
|
816
|
+
if (this.update != true) {
|
|
817
|
+
setTimeout(() => {
|
|
818
|
+
this.refreshForm()
|
|
819
|
+
}, 200)
|
|
820
|
+
}
|
|
821
|
+
this.update = false;
|
|
822
|
+
let data = JSON.parse(JSON.stringify(this.gridOptions.data));
|
|
823
|
+
let columns = []
|
|
824
|
+
let index = 1;
|
|
825
|
+
for (let d of data) {
|
|
826
|
+
d.sort = index;
|
|
827
|
+
d.change = ''
|
|
828
|
+
columns.push(this.dataToCode(d));
|
|
829
|
+
index++;
|
|
830
|
+
}
|
|
831
|
+
columns.sort((a, b) => {
|
|
832
|
+
return a.sort - b.sort
|
|
833
|
+
})
|
|
834
|
+
|
|
835
|
+
this.setCodeForm(columns)
|
|
836
|
+
this.setBaseOption(columns);
|
|
837
|
+
this.update = true;
|
|
838
|
+
},
|
|
839
|
+
setCodeForm(columns) {
|
|
840
|
+
let option = JSON.parse(JSON.stringify(this.baseOption));
|
|
841
|
+
option.column = JSON.parse(JSON.stringify(columns));
|
|
842
|
+
this.codeForm = this.jsonFormat(option)
|
|
843
|
+
},
|
|
844
|
+
dataToCode({form, prop, selectDom, title}) {
|
|
845
|
+
let item = {prop: prop, selectDom: selectDom, label: form.showName ? form.showName : title};
|
|
846
|
+
if (selectDom != 1) {
|
|
847
|
+
item.type = this.getFormType({selectDom: selectDom})
|
|
848
|
+
}
|
|
849
|
+
for (let key of Object.keys(form)) {
|
|
850
|
+
if (form[key] != undefined && form[key] != '' && key.indexOf('$') == -1) {
|
|
851
|
+
item[key] = form[key];
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
return item;
|
|
855
|
+
},
|
|
856
|
+
//表格拖动更新
|
|
857
|
+
updateSort() {
|
|
858
|
+
this.$nextTick(() => {
|
|
859
|
+
//el绑定元素需要找到vxe的DOM下的tbody元素
|
|
860
|
+
let $vxeGrid = this.$refs.vexGridRef
|
|
861
|
+
let that = this
|
|
862
|
+
Sortable.create($vxeGrid.$el.querySelector('.body--wrapper>.vxe-table--body tbody'), {
|
|
863
|
+
animation: 150,//拖拽动画过渡时间
|
|
864
|
+
sort: true,
|
|
865
|
+
handle: '.move', //必须设置该属性,属性值为你要拖动的该单元格的样式名
|
|
866
|
+
// 元素被选中
|
|
867
|
+
onStart: function (/**Event*/evt) {
|
|
868
|
+
//关闭所有展开行
|
|
869
|
+
$vxeGrid?.clearRowExpand()
|
|
870
|
+
evt.oldIndex; // element index within parent
|
|
871
|
+
},
|
|
872
|
+
// 结束拖拽
|
|
873
|
+
onEnd: function (/**Event*/{oldIndex, newIndex}) {
|
|
874
|
+
const list = JSON.parse(JSON.stringify(that.gridOptions.data)) //保存旧数据
|
|
875
|
+
const targetRow = list.splice(oldIndex, 1)[0] //保存移动的元素并删除原列表中移动的元素
|
|
876
|
+
list.splice(newIndex, 0, targetRow) //插入到目标新索引中
|
|
877
|
+
const newsArr = JSON.parse(JSON.stringify(list)) //重新赋值数组
|
|
878
|
+
//将新表格数据重新排序
|
|
879
|
+
for (let i = 0; i < newsArr.length; i++) {
|
|
880
|
+
newsArr[i].sort = i
|
|
881
|
+
}
|
|
882
|
+
that.gridOptions.data = newsArr;
|
|
883
|
+
//把表单的排序号和表格的排序号保持一致
|
|
884
|
+
newsArr.forEach(tableItem => {
|
|
885
|
+
that.baseOption.column.forEach(formItem => {
|
|
886
|
+
if (tableItem.prop == formItem.prop) {
|
|
887
|
+
formItem.sort = tableItem.sort
|
|
888
|
+
}
|
|
889
|
+
})
|
|
890
|
+
})
|
|
891
|
+
//将表单重新排序
|
|
892
|
+
that.baseOption.column.sort((a, b) => {
|
|
893
|
+
return a.sort - b.sort
|
|
894
|
+
})
|
|
895
|
+
that.codeForm = that.jsonFormat(that.baseOption)
|
|
896
|
+
},
|
|
897
|
+
});
|
|
898
|
+
});
|
|
899
|
+
},
|
|
900
|
+
// 更换表单
|
|
901
|
+
onChangeForm(value) {
|
|
902
|
+
if (value) {
|
|
903
|
+
get(this.http, "/online/formDesigner/queryById", {
|
|
904
|
+
id: value
|
|
905
|
+
}).then((data) => {
|
|
906
|
+
this.formJson = JSON.parse(data.formJson)
|
|
907
|
+
this.formKey++
|
|
908
|
+
})
|
|
909
|
+
}
|
|
910
|
+
},
|
|
911
|
+
// 获取新增表单配置数据
|
|
912
|
+
getData() {
|
|
913
|
+
if (this.formType == 0 && this.gridOptions.data.length == 0) {
|
|
914
|
+
return undefined;
|
|
915
|
+
}
|
|
916
|
+
let obj = {
|
|
917
|
+
vexTable: this.gridOptions,
|
|
918
|
+
baseForm: this.baseOption,
|
|
919
|
+
codeForm: this.codeForm,
|
|
920
|
+
designer: this.formType,
|
|
921
|
+
updateKey: this.form.updateKey,
|
|
922
|
+
saveUrl: this.form.saveUrl,
|
|
923
|
+
customJson: this.formJson,
|
|
924
|
+
customForm: this.customForm
|
|
925
|
+
}
|
|
926
|
+
return obj
|
|
927
|
+
},
|
|
928
|
+
/**
|
|
929
|
+
* 右边字段配置删除行数据
|
|
930
|
+
* @param row
|
|
931
|
+
* @returns {Promise<void>}
|
|
932
|
+
*/
|
|
933
|
+
async removeRowEvent(row) {
|
|
934
|
+
const type = await VXETable.modal.confirm('您确定要删除该数据?')
|
|
935
|
+
const $grid = this.$ref.vexGridRef
|
|
936
|
+
if ($grid && type === 'confirm') {
|
|
937
|
+
await $grid.remove(row)
|
|
938
|
+
this.gridOptions.data = this.gridOptions.data.filter(item => item._X_ROW_KEY != row._X_ROW_KEY)
|
|
939
|
+
this.removeColumnEvent(row)
|
|
940
|
+
}
|
|
941
|
+
},
|
|
942
|
+
/**
|
|
943
|
+
* 删除表单属性(快捷设计属性)
|
|
944
|
+
* @param row
|
|
945
|
+
*/
|
|
946
|
+
removeColumnEvent(row) {
|
|
947
|
+
this.baseOption.column = this.baseOption.column.filter(item => item.prop != row.prop)
|
|
948
|
+
this.codeForm = this.jsonFormat(this.baseOption)
|
|
949
|
+
}
|
|
950
|
+
},
|
|
951
|
+
mounted() {
|
|
952
|
+
this.updateSort()
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
</script>
|
|
957
|
+
|
|
958
|
+
<style lang="scss" scoped>
|
|
959
|
+
.cm-editor {
|
|
960
|
+
height: 100%;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
.box-card {
|
|
964
|
+
width: calc(100% - 24px);
|
|
965
|
+
height: calc(100% - 24px);
|
|
966
|
+
}
|
|
967
|
+
</style>
|