matrix_components 2.0.316 → 2.0.317
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 +7 -0
- package/dist/matrix_components.css +1 -1
- package/dist/matrix_components.js +43 -22
- package/dist/matrix_components.umd.cjs +1 -1
- package/package.json +1 -1
- package/dist/ComponentDemo/DialogDemo.vue +0 -210
- package/dist/ComponentDemo/ExampleFormConfig.js +0 -270
- package/dist/ComponentDemo/ExcelDemo.vue +0 -263
- package/dist/ComponentDemo/FormDemo.vue +0 -400
- package/dist/ComponentDemo/ImageDemo.vue +0 -143
- package/dist/ComponentDemo/MDDemo.vue +0 -20
- package/dist/ComponentDemo/OfficeDemo.vue +0 -189
- package/dist/ComponentDemo/PdfDemo.vue +0 -207
- package/dist/ComponentDemo/SaturationLineDemo.vue +0 -158
- package/dist/ComponentDemo/SimpleFormConfig.json +0 -97
- package/dist/ComponentDemo/Test.vue +0 -347
- package/dist/ComponentDemo/TestFormConfig.js +0 -129
- package/dist/ComponentDemo/VideoDemo.vue +0 -297
- package/dist/ComponentDemo/WordDemo.vue +0 -191
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="demo-container">
|
|
3
|
-
<div class="control-panel">
|
|
4
|
-
<h3>Excel 预览演示</h3>
|
|
5
|
-
|
|
6
|
-
<!-- 文件上传方式 -->
|
|
7
|
-
<div class="upload-section">
|
|
8
|
-
<h4>方式一:文件上传</h4>
|
|
9
|
-
<el-form-item label="弹框模式:">
|
|
10
|
-
<el-switch v-model="isShowDialog" @change="hideExcelHandler" />
|
|
11
|
-
</el-form-item>
|
|
12
|
-
<input
|
|
13
|
-
type="file"
|
|
14
|
-
@change="importExcel(($event.target as any)?.files?.[0])"
|
|
15
|
-
accept=".xls,.xlsx"
|
|
16
|
-
/>
|
|
17
|
-
<button @click="clearFile" :disabled="!file">清除文件</button>
|
|
18
|
-
</div>
|
|
19
|
-
|
|
20
|
-
<!-- URL方式 -->
|
|
21
|
-
<div class="url-section">
|
|
22
|
-
<h4>方式二:URL地址</h4>
|
|
23
|
-
<input
|
|
24
|
-
v-model="excelUrl"
|
|
25
|
-
type="text"
|
|
26
|
-
placeholder="请输入Excel文件的URL地址"
|
|
27
|
-
class="url-input"
|
|
28
|
-
/>
|
|
29
|
-
<button @click="loadFromUrl" :disabled="!excelUrl.trim()">加载URL</button>
|
|
30
|
-
<button @click="clearUrl" :disabled="!excelUrl">清除URL</button>
|
|
31
|
-
</div>
|
|
32
|
-
<button @click="exportExcel" class="export-btn">导出数据</button>
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
<!-- Excel组件 -->
|
|
36
|
-
<div class="excel-container">
|
|
37
|
-
<NsExcel
|
|
38
|
-
v-if="counts"
|
|
39
|
-
class="excel"
|
|
40
|
-
:file="file"
|
|
41
|
-
:isShowDialog="isShowDialog"
|
|
42
|
-
dialogWidth="1200px"
|
|
43
|
-
dialogHeight="700px"
|
|
44
|
-
ref="excelRef"
|
|
45
|
-
exportType="2"
|
|
46
|
-
@dialogExport="dialogExport"
|
|
47
|
-
></NsExcel>
|
|
48
|
-
</div>
|
|
49
|
-
<!-- 导出数据展示 -->
|
|
50
|
-
<div class="data-display">
|
|
51
|
-
<div class="data-section">
|
|
52
|
-
<h4>导出数据格式1 (原始格式)</h4>
|
|
53
|
-
<pre>{{ data1 }}</pre>
|
|
54
|
-
</div>
|
|
55
|
-
<div class="data-section">
|
|
56
|
-
<h4>导出数据格式2 (Excel格式)</h4>
|
|
57
|
-
<pre>{{ data2 }}</pre>
|
|
58
|
-
</div>
|
|
59
|
-
</div>
|
|
60
|
-
</div>
|
|
61
|
-
</template>
|
|
62
|
-
<script setup lang="ts">
|
|
63
|
-
import { nextTick, ref, watch } from 'vue'
|
|
64
|
-
|
|
65
|
-
const counts = ref(true)
|
|
66
|
-
const isShowDialog = ref(false)
|
|
67
|
-
const file = ref()
|
|
68
|
-
const excelRef = ref()
|
|
69
|
-
const data1 = ref()
|
|
70
|
-
const data2 = ref()
|
|
71
|
-
const excelUrl = ref(
|
|
72
|
-
'https://501351981.github.io/vue-office/examples/dist/static/test-files/test.xlsx',
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
function hideExcelHandler(val: boolean) {
|
|
76
|
-
counts.value = false
|
|
77
|
-
nextTick(() => {
|
|
78
|
-
counts.value = true
|
|
79
|
-
isShowDialog.value = val
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function importExcel(f: any) {
|
|
84
|
-
// 清除URL,使用文件上传
|
|
85
|
-
excelUrl.value = ''
|
|
86
|
-
file.value = f
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function loadFromUrl() {
|
|
90
|
-
if (excelUrl.value.trim()) {
|
|
91
|
-
// 清除文件,使用URL
|
|
92
|
-
file.value = excelUrl.value.trim()
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function clearFile() {
|
|
97
|
-
file.value = null
|
|
98
|
-
data1.value = null
|
|
99
|
-
data2.value = null
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function clearUrl() {
|
|
103
|
-
excelUrl.value = ''
|
|
104
|
-
data1.value = null
|
|
105
|
-
data2.value = null
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function dialogExport(data: any) {
|
|
109
|
-
console.warn(`excel导出数据:${data}`)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function exportExcel() {
|
|
113
|
-
if (excelRef.value) {
|
|
114
|
-
data1.value = excelRef.value.exportExcel(1)
|
|
115
|
-
data2.value = excelRef.value.exportExcel(2)
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
</script>
|
|
119
|
-
<style scoped lang="scss">
|
|
120
|
-
.demo-container {
|
|
121
|
-
padding: 20px;
|
|
122
|
-
max-width: 1400px;
|
|
123
|
-
margin: 0 auto;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.control-panel {
|
|
127
|
-
background: #f5f5f5;
|
|
128
|
-
padding: 20px;
|
|
129
|
-
border-radius: 8px;
|
|
130
|
-
margin-bottom: 20px;
|
|
131
|
-
|
|
132
|
-
h3 {
|
|
133
|
-
margin: 0 0 20px 0;
|
|
134
|
-
color: #333;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
h4 {
|
|
138
|
-
margin: 15px 0 10px 0;
|
|
139
|
-
color: #666;
|
|
140
|
-
font-size: 14px;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.upload-section,
|
|
145
|
-
.url-section,
|
|
146
|
-
.example-section {
|
|
147
|
-
margin-bottom: 20px;
|
|
148
|
-
padding: 15px;
|
|
149
|
-
background: white;
|
|
150
|
-
border-radius: 6px;
|
|
151
|
-
border: 1px solid #e0e0e0;
|
|
152
|
-
|
|
153
|
-
input[type='file'] {
|
|
154
|
-
margin-right: 10px;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.url-input {
|
|
158
|
-
width: 300px;
|
|
159
|
-
padding: 8px 12px;
|
|
160
|
-
border: 1px solid #ddd;
|
|
161
|
-
border-radius: 4px;
|
|
162
|
-
margin-right: 10px;
|
|
163
|
-
font-size: 14px;
|
|
164
|
-
|
|
165
|
-
&:focus {
|
|
166
|
-
outline: none;
|
|
167
|
-
border-color: #409eff;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
button {
|
|
172
|
-
padding: 8px 16px;
|
|
173
|
-
background: #409eff;
|
|
174
|
-
color: white;
|
|
175
|
-
border: none;
|
|
176
|
-
border-radius: 4px;
|
|
177
|
-
cursor: pointer;
|
|
178
|
-
margin-right: 10px;
|
|
179
|
-
font-size: 14px;
|
|
180
|
-
|
|
181
|
-
&:hover:not(:disabled) {
|
|
182
|
-
background: #337ecc;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
&:disabled {
|
|
186
|
-
background: #c0c4cc;
|
|
187
|
-
cursor: not-allowed;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.export-btn {
|
|
193
|
-
padding: 10px 20px;
|
|
194
|
-
background: #67c23a;
|
|
195
|
-
color: white;
|
|
196
|
-
border: none;
|
|
197
|
-
border-radius: 4px;
|
|
198
|
-
cursor: pointer;
|
|
199
|
-
font-size: 16px;
|
|
200
|
-
font-weight: bold;
|
|
201
|
-
|
|
202
|
-
&:hover {
|
|
203
|
-
background: #5daf34;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
.excel {
|
|
208
|
-
width: 100%;
|
|
209
|
-
height: 500px;
|
|
210
|
-
border: 1px solid #e0e0e0;
|
|
211
|
-
border-radius: 8px;
|
|
212
|
-
overflow: hidden;
|
|
213
|
-
margin-bottom: 20px;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.data-display {
|
|
217
|
-
display: flex;
|
|
218
|
-
gap: 20px;
|
|
219
|
-
margin-top: 20px;
|
|
220
|
-
|
|
221
|
-
.data-section {
|
|
222
|
-
flex: 1;
|
|
223
|
-
background: #f9f9f9;
|
|
224
|
-
border-radius: 8px;
|
|
225
|
-
padding: 15px;
|
|
226
|
-
|
|
227
|
-
h4 {
|
|
228
|
-
margin: 0 0 10px 0;
|
|
229
|
-
color: #333;
|
|
230
|
-
font-size: 14px;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
pre {
|
|
234
|
-
background: white;
|
|
235
|
-
padding: 15px;
|
|
236
|
-
border-radius: 4px;
|
|
237
|
-
border: 1px solid #e0e0e0;
|
|
238
|
-
max-height: 300px;
|
|
239
|
-
overflow: auto;
|
|
240
|
-
font-size: 12px;
|
|
241
|
-
line-height: 1.4;
|
|
242
|
-
margin: 0;
|
|
243
|
-
white-space: pre-wrap;
|
|
244
|
-
word-wrap: break-word;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
.excel-container {
|
|
250
|
-
height: 300px;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
@media (max-width: 768px) {
|
|
254
|
-
.data-display {
|
|
255
|
-
flex-direction: column;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
.url-input {
|
|
259
|
-
width: 100% !important;
|
|
260
|
-
margin-bottom: 10px;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
</style>
|
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="demo-container">
|
|
3
|
-
<div class="control-panel">
|
|
4
|
-
<h3>动态表单组件演示</h3>
|
|
5
|
-
|
|
6
|
-
<!-- 配置文件选择 -->
|
|
7
|
-
<!-- <div class="config-section">
|
|
8
|
-
<h4>方式一:选择配置文件</h4>
|
|
9
|
-
<el-select
|
|
10
|
-
v-model="selectedConfig"
|
|
11
|
-
placeholder="请选择表单配置"
|
|
12
|
-
@change="loadConfig"
|
|
13
|
-
class="config-select"
|
|
14
|
-
>
|
|
15
|
-
<el-option
|
|
16
|
-
v-for="config in configOptions"
|
|
17
|
-
:key="config.value"
|
|
18
|
-
:label="config.label"
|
|
19
|
-
:value="config.value"
|
|
20
|
-
/>
|
|
21
|
-
</el-select>
|
|
22
|
-
<el-button @click="reloadConfig" :disabled="!selectedConfig">重新加载</el-button>
|
|
23
|
-
</div> -->
|
|
24
|
-
|
|
25
|
-
<!-- 文件上传方式 -->
|
|
26
|
-
<div class="upload-section">
|
|
27
|
-
<h4>上传配置文件</h4>
|
|
28
|
-
<input
|
|
29
|
-
type="file"
|
|
30
|
-
@change="importConfig(($event.target as any)?.files?.[0])"
|
|
31
|
-
accept=".js,.json"
|
|
32
|
-
/>
|
|
33
|
-
<el-button @click="clearFile" :disabled="!uploadedFile">清除文件</el-button>
|
|
34
|
-
</div>
|
|
35
|
-
|
|
36
|
-
<!-- 表单操作 -->
|
|
37
|
-
<div class="action-section">
|
|
38
|
-
<h4>表单操作</h4>
|
|
39
|
-
<el-button type="primary" @click="validateForm" :disabled="!formLoaded">验证表单</el-button>
|
|
40
|
-
<el-button @click="resetForm" :disabled="!formLoaded">重置表单</el-button>
|
|
41
|
-
<el-button type="info" @click="toggleFormData" :disabled="!formLoaded">
|
|
42
|
-
{{ showFormData ? '隐藏' : '显示' }}表单数据
|
|
43
|
-
</el-button>
|
|
44
|
-
<el-button type="success" @click="exportFormData" :disabled="!formLoaded">导出数据</el-button>
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
|
|
48
|
-
<!-- 表单容器 -->
|
|
49
|
-
<div class="form-container" v-if="formLoaded">
|
|
50
|
-
<NsForm
|
|
51
|
-
ref="formRef"
|
|
52
|
-
v-model="formData"
|
|
53
|
-
:form-items="formItems"
|
|
54
|
-
:rules="formRules"
|
|
55
|
-
:options-data="optionsData"
|
|
56
|
-
label-width="120px"
|
|
57
|
-
:gutter="20"
|
|
58
|
-
:clear-validate-on-init="true"
|
|
59
|
-
@validate="handleValidate"
|
|
60
|
-
@submit="handleSubmit"
|
|
61
|
-
@reset="handleReset"
|
|
62
|
-
>
|
|
63
|
-
<!-- 自定义插槽示例 -->
|
|
64
|
-
<template #customSlot="{ item, formData }">
|
|
65
|
-
<el-input
|
|
66
|
-
v-model="formData[item.prop]"
|
|
67
|
-
placeholder="这是自定义插槽内容"
|
|
68
|
-
prefix-icon="User"
|
|
69
|
-
/>
|
|
70
|
-
</template>
|
|
71
|
-
|
|
72
|
-
<!-- 表单操作按钮 -->
|
|
73
|
-
<template #footer="{ validate, resetFields }">
|
|
74
|
-
<el-form-item>
|
|
75
|
-
<el-button type="primary" @click="validate">提交表单</el-button>
|
|
76
|
-
<el-button @click="resetFields">重置表单</el-button>
|
|
77
|
-
</el-form-item>
|
|
78
|
-
</template>
|
|
79
|
-
</NsForm>
|
|
80
|
-
</div>
|
|
81
|
-
|
|
82
|
-
<!-- 空状态 -->
|
|
83
|
-
<div class="empty-state" v-else>
|
|
84
|
-
<el-empty description="请选择或上传表单配置文件" />
|
|
85
|
-
</div>
|
|
86
|
-
|
|
87
|
-
<!-- 表单数据显示 -->
|
|
88
|
-
<el-card v-if="showFormData && formLoaded" class="data-card">
|
|
89
|
-
<template #header>
|
|
90
|
-
<div class="card-header">
|
|
91
|
-
<span>表单数据</span>
|
|
92
|
-
<el-button type="text" @click="copyFormData">复制数据</el-button>
|
|
93
|
-
</div>
|
|
94
|
-
</template>
|
|
95
|
-
<pre class="form-data-display">{{ JSON.stringify(formData, null, 2) }}</pre>
|
|
96
|
-
</el-card>
|
|
97
|
-
</div>
|
|
98
|
-
</template>
|
|
99
|
-
|
|
100
|
-
<script setup lang="ts">
|
|
101
|
-
import { ElMessage } from 'element-plus'
|
|
102
|
-
import { nextTick, reactive, ref } from 'vue'
|
|
103
|
-
|
|
104
|
-
// 表单引用
|
|
105
|
-
const formRef = ref()
|
|
106
|
-
|
|
107
|
-
// 状态管理
|
|
108
|
-
const formLoaded = ref(false)
|
|
109
|
-
const showFormData = ref(false)
|
|
110
|
-
const selectedConfig = ref('')
|
|
111
|
-
const uploadedFile = ref()
|
|
112
|
-
|
|
113
|
-
// 表单数据
|
|
114
|
-
const formData: any = reactive({})
|
|
115
|
-
const formItems: any = ref([])
|
|
116
|
-
const formRules: any = ref({})
|
|
117
|
-
const optionsData: any = reactive({})
|
|
118
|
-
|
|
119
|
-
// 加载配置文件
|
|
120
|
-
async function loadConfig() {
|
|
121
|
-
if (!selectedConfig.value) return
|
|
122
|
-
|
|
123
|
-
try {
|
|
124
|
-
// 动态导入配置文件
|
|
125
|
-
const configModule = (await import(`@/views/ExampleFormConfig.js`)) as { formConfig: any; default: any }
|
|
126
|
-
const config = configModule.formConfig || configModule.default
|
|
127
|
-
|
|
128
|
-
if (config) {
|
|
129
|
-
initializeForm(config)
|
|
130
|
-
ElMessage.success('配置加载成功')
|
|
131
|
-
} else {
|
|
132
|
-
ElMessage.error('配置文件格式错误')
|
|
133
|
-
}
|
|
134
|
-
} catch (error) {
|
|
135
|
-
console.error('加载配置失败:', error)
|
|
136
|
-
ElMessage.error('配置文件加载失败')
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// 导入配置文件
|
|
141
|
-
function importConfig(file: File) {
|
|
142
|
-
if (!file) return
|
|
143
|
-
|
|
144
|
-
uploadedFile.value = file
|
|
145
|
-
const reader = new FileReader()
|
|
146
|
-
|
|
147
|
-
reader.onload = (e) => {
|
|
148
|
-
try {
|
|
149
|
-
const content = e.target?.result as string
|
|
150
|
-
let config
|
|
151
|
-
|
|
152
|
-
if (file.name.endsWith('.json')) {
|
|
153
|
-
config = JSON.parse(content)
|
|
154
|
-
} else if (file.name.endsWith('.js')) {
|
|
155
|
-
// 简单的JS文件解析(实际项目中可能需要更复杂的处理)
|
|
156
|
-
const configMatch = content.match(/export\s+(?:const|default)\s+\w*\s*=\s*({[\s\S]*});?/)
|
|
157
|
-
if (configMatch) {
|
|
158
|
-
config = eval(`(${configMatch[1]})`)
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (config) {
|
|
163
|
-
initializeForm(config)
|
|
164
|
-
selectedConfig.value = '' // 清除下拉选择
|
|
165
|
-
ElMessage.success('配置文件导入成功')
|
|
166
|
-
} else {
|
|
167
|
-
ElMessage.error('配置文件格式错误')
|
|
168
|
-
}
|
|
169
|
-
} catch (error) {
|
|
170
|
-
console.error('解析配置文件失败:', error)
|
|
171
|
-
ElMessage.error('配置文件解析失败')
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
reader.readAsText(file)
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// 清除上传的文件
|
|
179
|
-
function clearFile() {
|
|
180
|
-
uploadedFile.value = null
|
|
181
|
-
formLoaded.value = false
|
|
182
|
-
showFormData.value = false
|
|
183
|
-
|
|
184
|
-
// 清空表单数据
|
|
185
|
-
Object.keys(formData).forEach(key => {
|
|
186
|
-
delete formData[key]
|
|
187
|
-
})
|
|
188
|
-
formItems.value = []
|
|
189
|
-
formRules.value = {}
|
|
190
|
-
Object.keys(optionsData).forEach(key => {
|
|
191
|
-
delete optionsData[key]
|
|
192
|
-
})
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// 初始化表单
|
|
196
|
-
function initializeForm(config: any) {
|
|
197
|
-
// 清空现有数据
|
|
198
|
-
Object.keys(formData).forEach(key => {
|
|
199
|
-
delete formData[key]
|
|
200
|
-
})
|
|
201
|
-
Object.keys(optionsData).forEach(key => {
|
|
202
|
-
delete optionsData[key]
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
// 设置新数据
|
|
206
|
-
if (config.formData) {
|
|
207
|
-
Object.assign(formData, config.formData)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (config.formItems) {
|
|
211
|
-
formItems.value = config.formItems
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if (config.formRules) {
|
|
215
|
-
formRules.value = config.formRules
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (config.optionsData) {
|
|
219
|
-
Object.assign(optionsData, config.optionsData)
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
formLoaded.value = true
|
|
223
|
-
|
|
224
|
-
// 在下一帧清除表单验证状态
|
|
225
|
-
nextTick(() => {
|
|
226
|
-
if (formRef.value) {
|
|
227
|
-
formRef.value.clearValidate()
|
|
228
|
-
}
|
|
229
|
-
})
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// 验证表单
|
|
233
|
-
async function validateForm() {
|
|
234
|
-
if (!formRef.value) return
|
|
235
|
-
|
|
236
|
-
try {
|
|
237
|
-
const valid = await formRef.value.validate()
|
|
238
|
-
if (valid) {
|
|
239
|
-
ElMessage.success('表单验证通过')
|
|
240
|
-
}
|
|
241
|
-
} catch (error) {
|
|
242
|
-
ElMessage.error('表单验证失败')
|
|
243
|
-
console.error('表单验证失败:', error)
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// 重置表单
|
|
248
|
-
function resetForm() {
|
|
249
|
-
if (!formRef.value) return
|
|
250
|
-
formRef.value.resetFields()
|
|
251
|
-
ElMessage.info('表单已重置')
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// 切换表单数据显示
|
|
255
|
-
function toggleFormData() {
|
|
256
|
-
showFormData.value = !showFormData.value
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// 导出表单数据
|
|
260
|
-
function exportFormData() {
|
|
261
|
-
const dataStr = JSON.stringify(formData, null, 2)
|
|
262
|
-
const blob = new Blob([dataStr], { type: 'application/json' })
|
|
263
|
-
const url = URL.createObjectURL(blob)
|
|
264
|
-
const a = document.createElement('a')
|
|
265
|
-
a.href = url
|
|
266
|
-
a.download = 'form-data.json'
|
|
267
|
-
a.click()
|
|
268
|
-
URL.revokeObjectURL(url)
|
|
269
|
-
ElMessage.success('数据导出成功')
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// 复制表单数据
|
|
273
|
-
async function copyFormData() {
|
|
274
|
-
try {
|
|
275
|
-
await navigator.clipboard.writeText(JSON.stringify(formData, null, 2))
|
|
276
|
-
ElMessage.success('数据已复制到剪贴板')
|
|
277
|
-
} catch (error) {
|
|
278
|
-
ElMessage.error('复制失败')
|
|
279
|
-
console.error('复制失败:', error)
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// 表单事件处理
|
|
284
|
-
function handleValidate(valid: boolean, data: any) {
|
|
285
|
-
console.log('表单验证结果:', valid, data)
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
function handleSubmit(data: any) {
|
|
289
|
-
console.log('表单提交:', data)
|
|
290
|
-
ElMessage.success('表单提交成功')
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function handleReset(data: any) {
|
|
294
|
-
console.log('表单重置:', data)
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// 初始化时加载默认配置
|
|
298
|
-
nextTick(() => {
|
|
299
|
-
selectedConfig.value = 'ExampleFormConfig'
|
|
300
|
-
loadConfig()
|
|
301
|
-
})
|
|
302
|
-
</script>
|
|
303
|
-
|
|
304
|
-
<style scoped lang="scss">
|
|
305
|
-
.demo-container {
|
|
306
|
-
padding: 20px;
|
|
307
|
-
max-width: 1400px;
|
|
308
|
-
margin: 0 auto;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
.control-panel {
|
|
312
|
-
background: #f5f5f5;
|
|
313
|
-
padding: 20px;
|
|
314
|
-
border-radius: 8px;
|
|
315
|
-
margin-bottom: 20px;
|
|
316
|
-
|
|
317
|
-
h3 {
|
|
318
|
-
margin: 0 0 20px 0;
|
|
319
|
-
color: #333;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
h4 {
|
|
323
|
-
margin: 15px 0 10px 0;
|
|
324
|
-
color: #666;
|
|
325
|
-
font-size: 14px;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
.config-section,
|
|
330
|
-
.upload-section,
|
|
331
|
-
.action-section {
|
|
332
|
-
margin-bottom: 20px;
|
|
333
|
-
padding: 15px;
|
|
334
|
-
background: white;
|
|
335
|
-
border-radius: 6px;
|
|
336
|
-
border: 1px solid #e0e0e0;
|
|
337
|
-
|
|
338
|
-
.config-select {
|
|
339
|
-
width: 300px;
|
|
340
|
-
margin-right: 10px;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
input[type='file'] {
|
|
344
|
-
margin-right: 10px;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
.el-button {
|
|
348
|
-
margin-right: 10px;
|
|
349
|
-
margin-bottom: 5px;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
.form-container {
|
|
354
|
-
background: white;
|
|
355
|
-
padding: 20px;
|
|
356
|
-
border-radius: 8px;
|
|
357
|
-
border: 1px solid #e0e0e0;
|
|
358
|
-
margin-bottom: 20px;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
.empty-state {
|
|
362
|
-
text-align: center;
|
|
363
|
-
padding: 60px 20px;
|
|
364
|
-
background: white;
|
|
365
|
-
border-radius: 8px;
|
|
366
|
-
border: 1px solid #e0e0e0;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
.data-card {
|
|
370
|
-
margin-top: 20px;
|
|
371
|
-
|
|
372
|
-
.card-header {
|
|
373
|
-
display: flex;
|
|
374
|
-
justify-content: space-between;
|
|
375
|
-
align-items: center;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
.form-data-display {
|
|
379
|
-
background-color: #f5f7fa;
|
|
380
|
-
padding: 15px;
|
|
381
|
-
border-radius: 4px;
|
|
382
|
-
font-size: 12px;
|
|
383
|
-
line-height: 1.5;
|
|
384
|
-
max-height: 400px;
|
|
385
|
-
overflow-y: auto;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
@media (max-width: 768px) {
|
|
390
|
-
.config-select {
|
|
391
|
-
width: 100% !important;
|
|
392
|
-
margin-bottom: 10px;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
.el-button {
|
|
396
|
-
width: 100%;
|
|
397
|
-
margin-bottom: 10px;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
</style>
|