matrix_components 2.0.400 → 2.0.402

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.
@@ -0,0 +1,622 @@
1
+ <template>
2
+ <div class="demo-container">
3
+ <div class="control-panel">
4
+ <h3>动态表单组件演示</h3>
5
+ <!-- 配置文件选择 -->
6
+ <el-form :model="state" ref="formRef" label-position="left">
7
+ <el-button type="primary" @click="getFormData">获取表单数据</el-button>
8
+ <el-button type="default" @click="resetFormData">重置表单</el-button>
9
+ <br />
10
+ <span style="color: red"> 结果:{{ state.formData }} </span>
11
+ <br />
12
+ <br />
13
+ <NsFormTitle title="模型参数">
14
+ <NsForm
15
+ ref="row1Ref"
16
+ :readOnly="state.readOnly"
17
+ backgroundColor="#fff"
18
+ :model="state.model"
19
+ :rows="state.rows"
20
+ formPropKey="rows"
21
+ labelColor="#606266"
22
+ labelWidth="150"
23
+ gapH="20px"
24
+ gapV="10px"
25
+ ></NsForm>
26
+ </NsFormTitle>
27
+ <NsFormTitle title="视频配置">
28
+ <NsForm
29
+ ref="row2Ref"
30
+ :readOnly="state.readOnly"
31
+ backgroundColor="#fff"
32
+ :model="state.model"
33
+ :rows="state.rows2"
34
+ formPropKey="rows2"
35
+ labelColor="#606266"
36
+ labelWidth="150"
37
+ gapH="20px"
38
+ gapV="10px"
39
+ ></NsForm>
40
+ </NsFormTitle>
41
+ <NsFormTitle title="结果保存">
42
+ <NsForm
43
+ ref="row3Ref"
44
+ :readOnly="state.readOnly"
45
+ backgroundColor="#fff"
46
+ :model="state.model"
47
+ :rows="state.rows3"
48
+ formPropKey="rows3"
49
+ labelColor="#606266"
50
+ labelWidth="150"
51
+ gapH="20px"
52
+ gapV="10px"
53
+ ></NsForm>
54
+ </NsFormTitle>
55
+ <NsFormTitle title="级联选择器测试">
56
+ <NsForm
57
+ ref="row4Ref"
58
+ :readOnly="state.readOnly"
59
+ backgroundColor="#fff"
60
+ :model="state.model"
61
+ :rows="state.rows4"
62
+ formPropKey="rows4"
63
+ labelColor="#606266"
64
+ labelWidth="150"
65
+ gapH="20px"
66
+ gapV="10px"
67
+ ></NsForm>
68
+ </NsFormTitle>
69
+ </el-form>
70
+ </div>
71
+ </div>
72
+ </template>
73
+
74
+ <script setup lang="ts">
75
+ import { ElInput, ElMessage, ElRadioGroup, ElCascader, ElSwitch } from 'element-plus'
76
+ import { h, onMounted, reactive, ref } from 'vue'
77
+ import { cloneDeep } from 'lodash-es'
78
+ import { nextTick } from 'vue'
79
+
80
+ const props = defineProps({
81
+ readOnly: {
82
+ type: Boolean,
83
+ default: false
84
+ },
85
+ row: {
86
+ type: Object,
87
+ default: () => ({}),
88
+ },
89
+ })
90
+
91
+ const formRef = ref()
92
+ const row1Ref = ref()
93
+ const row2Ref = ref()
94
+ const row3Ref = ref()
95
+ const row4Ref = ref()
96
+
97
+ const state = reactive({
98
+ formData: {},
99
+ readOnly: props.readOnly,
100
+ model: props.readOnly ? '' : 'vertical',
101
+ rows: [
102
+ [
103
+ {
104
+ key: "isEnable",
105
+ label: "是否启用",
106
+ value: false,
107
+ component: ElSwitch,
108
+ events: {
109
+ change: changeHandler
110
+ },
111
+ params: {
112
+ rules: [
113
+ {
114
+ required: true,
115
+ message: "请选择",
116
+ },
117
+ ],
118
+ width: 60,
119
+ 'inline-prompt': true,
120
+ 'active-text':"启用",
121
+ 'inactive-text':"禁用",
122
+ },
123
+ },
124
+ ],
125
+ ],
126
+ rows2: [
127
+ [
128
+ {
129
+ key: 'timeInterval',
130
+ label: '时间间隔(秒)',
131
+ value: '',
132
+ component: ElInput,
133
+ params: {
134
+ 'v-length.range': {
135
+ min: 0,
136
+ max: 6000,
137
+ int: true,
138
+ },
139
+ rules: [
140
+ {
141
+ required: true,
142
+ message: '请输入',
143
+ },
144
+ ],
145
+ },
146
+ },
147
+ {
148
+ key: 'stuck_threshold',
149
+ label: '视频帧卡顿(秒)',
150
+ value: '',
151
+ component: ElInput,
152
+ params: {
153
+ 'v-length.range': {
154
+ min: 0,
155
+ max: 1000,
156
+ int: true,
157
+ },
158
+ rules: [
159
+ {
160
+ required: true,
161
+ message: '请输入',
162
+ },
163
+ ],
164
+ },
165
+ },
166
+ ],
167
+ [
168
+ {
169
+ key: 'max_retries',
170
+ label: '最大重连次数',
171
+ value: '',
172
+ component: ElInput,
173
+ params: {
174
+ 'v-length.range': {
175
+ min: 0,
176
+ max: 100,
177
+ int: true,
178
+ },
179
+ rules: [
180
+ {
181
+ required: true,
182
+ message: '请输入',
183
+ },
184
+ ],
185
+ },
186
+ },
187
+ {
188
+ value: ' ',
189
+ },
190
+ ],
191
+ ],
192
+ rows3: [
193
+ [
194
+ {
195
+ key: 'save_video',
196
+ label: '是否保存视频',
197
+ value: false,
198
+ component: ElRadioGroup,
199
+ params: {
200
+ rules: [
201
+ {
202
+ required: true,
203
+ message: '请选择',
204
+ trigger: 'change',
205
+ },
206
+ ],
207
+ options: [
208
+ {
209
+ value: true,
210
+ label: '是',
211
+ },
212
+ {
213
+ value: false,
214
+ label: '否',
215
+ },
216
+ ],
217
+ },
218
+ },
219
+ {
220
+ key: 'pre_buffer_second',
221
+ label: '帧前缓存(秒)',
222
+ value: '',
223
+ component: ElInput,
224
+ params: {
225
+ 'v-length.range': {
226
+ min: 0,
227
+ max: 1000,
228
+ int: true,
229
+ },
230
+ rules: [
231
+ {
232
+ required: true,
233
+ message: '请输入',
234
+ },
235
+ ],
236
+ },
237
+ },
238
+ ],
239
+ [
240
+ {
241
+ key: 'det_area_mode',
242
+ label: '检测区域工作模式',
243
+ value: 'normal',
244
+ component: ElRadioGroup,
245
+ events: {
246
+ change: detAreaModeChange,
247
+ },
248
+ params: {
249
+ rules: [
250
+ {
251
+ required: true,
252
+ message: '请选择',
253
+ trigger: 'change',
254
+ },
255
+ ],
256
+ options: [
257
+ {
258
+ value: 'normal',
259
+ label: '常规检测(normal)',
260
+ },
261
+ {
262
+ value: 'abnormal',
263
+ label: '非常规检测(abnormal)',
264
+ },
265
+ ],
266
+ },
267
+ },
268
+ ],
269
+ ],
270
+ rows4: [
271
+ [
272
+ {
273
+ key: 'region',
274
+ label: '地区选择',
275
+ value: ['beijing', 'chaoyang'],
276
+ component: ElCascader,
277
+ params: {
278
+ rules: [
279
+ {
280
+ required: true,
281
+ message: '请选择地区',
282
+ trigger: 'change',
283
+ },
284
+ ],
285
+ props: {
286
+ showPrefix: false,
287
+ checkStrictly: true,
288
+ checkOnClickNode: true,
289
+ },
290
+ options: [
291
+ {
292
+ value: 'beijing',
293
+ label: '北京市',
294
+ children: [
295
+ {
296
+ value: 'chaoyang',
297
+ label: '朝阳区',
298
+ children: [
299
+ {
300
+ value: 'chaoyangmen',
301
+ label: '朝阳门街道',
302
+ },
303
+ ],
304
+ },
305
+ {
306
+ value: 'haidian',
307
+ label: '海淀区',
308
+ },
309
+ ],
310
+ },
311
+ {
312
+ value: 'shanghai',
313
+ label: '上海市',
314
+ children: [
315
+ {
316
+ value: 'pudong',
317
+ label: '浦东新区',
318
+ },
319
+ ],
320
+ },
321
+ ],
322
+ },
323
+ },
324
+ {
325
+ key: 'department',
326
+ label: '部门选择',
327
+ value: ['company'],
328
+ component: ElCascader,
329
+ params: {
330
+ props: {
331
+ value: 'code',
332
+ label: 'name',
333
+ children: 'subDepartments',
334
+ showPrefix: false,
335
+ checkStrictly: true,
336
+ checkOnClickNode: true,
337
+ },
338
+ separator: ',',
339
+ options: [
340
+ {
341
+ code: 'company',
342
+ name: '公司总部',
343
+ subDepartments: [
344
+ {
345
+ code: 'tech',
346
+ name: '技术部',
347
+ subDepartments: [
348
+ {
349
+ code: 'frontend',
350
+ name: '前端组',
351
+ },
352
+ {
353
+ code: 'backend',
354
+ name: '后端组',
355
+ },
356
+ ],
357
+ },
358
+ {
359
+ code: 'sales',
360
+ name: '销售部',
361
+ },
362
+ ],
363
+ },
364
+ ],
365
+ },
366
+ },
367
+ ],
368
+ [
369
+ {
370
+ key: 'single_level_cascader',
371
+ label: '单层级联',
372
+ value: 'beijing',
373
+ component: ElCascader,
374
+ params: {
375
+ options: [
376
+ {
377
+ value: 'beijing',
378
+ label: '北京市',
379
+ },
380
+ {
381
+ value: 'shanghai',
382
+ label: '上海市',
383
+ },
384
+ {
385
+ value: 'guangzhou',
386
+ label: '广州市',
387
+ },
388
+ ],
389
+ },
390
+ },
391
+ {
392
+ value: ' ',
393
+ },
394
+ ],
395
+ ],
396
+ })
397
+
398
+ function changeHandler(v){
399
+ alert(v)
400
+ }
401
+
402
+ function detAreaModeChange(value: any) {
403
+ if(state.rows3?.length && state.rows3[state.rows3.length - 1]?.[0]?.key === 'det_area_json'){
404
+ state.rows3.pop()
405
+ }
406
+
407
+ if (value === 'abnormal') {
408
+ state.rows3.push([
409
+ {
410
+ key: 'det_area_json',
411
+ label: '感兴趣区域',
412
+ value: '',
413
+ readOnlyUseComponent: true,
414
+ component: CustomUIs,
415
+ span: 6,
416
+ },
417
+ { value: ' ' },
418
+ ])
419
+ }
420
+ }
421
+
422
+ function CustomUIs() {
423
+ return h('div', {style:'color: red', class:"xx"}, 'xxx')
424
+ }
425
+
426
+
427
+ /**
428
+ * 保存
429
+ */
430
+ async function getFormData() {
431
+ try {
432
+ await formRef.value.validate()
433
+ } catch (error: any) {
434
+ console.log(error)
435
+ ElMessage.error('表单校验失败')
436
+ state.formData = {}
437
+ return false
438
+ }
439
+ const data1 = row1Ref.value?.getFormKvData?.()
440
+ const data2 = row2Ref.value?.getFormKvData?.()
441
+ const data3 = row3Ref.value?.getFormKvData?.()
442
+ const data4 = row4Ref.value?.getFormKvData?.()
443
+ const data = { ...data1, ...data2, ...data3, ...data4 }
444
+ state.formData = data
445
+ ElMessage.success('表单校验成功')
446
+ return data
447
+ }
448
+
449
+ /**
450
+ * 重置表单
451
+ */
452
+ async function resetFormData() {
453
+ // 使用组件内置的 resetForm 方法
454
+ row1Ref.value?.resetForm?.()
455
+ row2Ref.value?.resetForm?.()
456
+ row3Ref.value?.resetForm?.()
457
+ row4Ref.value?.resetForm?.()
458
+ setTimeout(()=>{
459
+ // 重置表单验证状态
460
+ formRef.value?.clearValidate?.()
461
+ // 清空结果显示
462
+ state.formData = {}
463
+ ElMessage.success('表单重置成功')
464
+ }, 0)
465
+ }
466
+
467
+ async function getDetail() {
468
+ setTimeout(()=>{
469
+ const res = {
470
+ "isEnable": true,
471
+ "confidence": "aaa1",
472
+ "iou": "1",
473
+ "timeInterval": "2",
474
+ "stuck_threshold": "3",
475
+ "max_retries": "4",
476
+ "save_video": true,
477
+ "pre_buffer_second": "5",
478
+ "det_area_mode": "abnormal",
479
+ "det_area_json": "6",
480
+ "region": ["beijing", "haidian"],
481
+ "department": ["company","tech","frontend"],
482
+ "single_level_cascader": "shanghai"
483
+ }
484
+ row1Ref.value?.resetForm()
485
+ setTimeout(()=>{
486
+ row1Ref.value?.setFormData?.(res)
487
+ },10)
488
+ // 特殊处理
489
+ // if (res.det_area_mode === 'abnormal') {
490
+ // detAreaModeChange('abnormal')
491
+ // }
492
+
493
+ setTimeout(()=>{
494
+ const res = {
495
+ "isEnable": false,
496
+ "confidence": "aaa1",
497
+ "iou": "1",
498
+ "timeInterval": "2",
499
+ "stuck_threshold": "3",
500
+ "max_retries": "4",
501
+ "save_video": true,
502
+ "pre_buffer_second": "5",
503
+ "det_area_mode": "normal",
504
+ "det_area_json": "6",
505
+ "region": ["beijing", "haidian"],
506
+ "department": ["company","tech","frontend"],
507
+ "single_level_cascader": "shanghai"
508
+ }
509
+
510
+ row1Ref.value?.resetForm()
511
+ setTimeout(()=>{
512
+ row1Ref.value?.setFormData?.(res)
513
+ },10)
514
+ // 特殊处理
515
+ }, 2000)
516
+ }, 2000)
517
+ }
518
+
519
+ onMounted(() => {
520
+ getDetail()
521
+ })
522
+
523
+ </script>
524
+
525
+ <style lang="scss" scoped>
526
+ .demo-container {
527
+ padding: 20px;
528
+ max-width: 1400px;
529
+ margin: 0 auto;
530
+ }
531
+
532
+ .control-panel {
533
+ background: #f5f5f5;
534
+ padding: 20px;
535
+ border-radius: 8px;
536
+ margin-bottom: 20px;
537
+
538
+ h3 {
539
+ margin: 0 0 20px 0;
540
+ color: #333;
541
+ }
542
+
543
+ h4 {
544
+ margin: 15px 0 10px 0;
545
+ color: #666;
546
+ font-size: 14px;
547
+ }
548
+ }
549
+
550
+ .config-section,
551
+ .upload-section,
552
+ .action-section {
553
+ margin-bottom: 20px;
554
+ padding: 15px;
555
+ background: white;
556
+ border-radius: 6px;
557
+ border: 1px solid #e0e0e0;
558
+
559
+ .config-select {
560
+ width: 300px;
561
+ margin-right: 10px;
562
+ }
563
+
564
+ input[type='file'] {
565
+ margin-right: 10px;
566
+ }
567
+
568
+ .el-button {
569
+ margin-right: 10px;
570
+ margin-bottom: 5px;
571
+ }
572
+ }
573
+
574
+ .form-container {
575
+ background: white;
576
+ padding: 20px;
577
+ border-radius: 8px;
578
+ border: 1px solid #e0e0e0;
579
+ margin-bottom: 20px;
580
+ }
581
+
582
+ .empty-state {
583
+ text-align: center;
584
+ padding: 60px 20px;
585
+ background: white;
586
+ border-radius: 8px;
587
+ border: 1px solid #e0e0e0;
588
+ }
589
+
590
+ .data-card {
591
+ margin-top: 20px;
592
+
593
+ .card-header {
594
+ display: flex;
595
+ justify-content: space-between;
596
+ align-items: center;
597
+ }
598
+
599
+ .form-data-display {
600
+ background-color: #f5f7fa;
601
+ padding: 15px;
602
+ border-radius: 4px;
603
+ font-size: 12px;
604
+ line-height: 1.5;
605
+ max-height: 400px;
606
+ overflow-y: auto;
607
+ }
608
+ }
609
+
610
+ @media (max-width: 768px) {
611
+ .config-select {
612
+ width: 100% !important;
613
+ margin-bottom: 10px;
614
+ }
615
+
616
+ .el-button {
617
+ width: 100%;
618
+ margin-bottom: 10px;
619
+ }
620
+ }
621
+ </style>
622
+
@@ -0,0 +1,27 @@
1
+ <template>
2
+ <NsImage :src="src" :apiUrl="apiUrl" :hasPreview="hasPreview">
3
+ <img
4
+ :src="ThemeVar.VARS.getPropertyValue('--matrix-empty-img')"
5
+ style="width: 100%; height: 100%"
6
+ @click.stop
7
+ />
8
+ </NsImage>
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+ import { reactive, ref } from 'vue';
13
+ import { ThemeVar } from '../../packages/utils/loadCssVars'
14
+ const src = ref('')
15
+ const hasPreview = ref(true)
16
+ const apiUrl = reactive( {
17
+ type: Object,
18
+ default: ()=>({
19
+ method: 'get',
20
+ url: '/tool/file/getFileDetail',
21
+ paramkey: 'fileIds',
22
+ params: {},
23
+ }),
24
+ })
25
+ </script>
26
+ <style lang="scss" scoped>
27
+ </style>
@@ -0,0 +1,20 @@
1
+ <template>
2
+ <div class="dm">
3
+ <NsMD class="dm-ui" :msg="msg"></NsMD>
4
+ </div>
5
+ </template>
6
+ <script setup lang="ts" name="">
7
+ import { ref } from 'vue';
8
+
9
+ const msg = ref('好的,我可以为您写一个项目需求文档的模板。由于知识库为空,我将基于通用项目管理知识和最佳实践来构建此文档。请注意,这只是一个模板,您需要根据您的具体项目进行调整和完善。\n\n---\n\n## 项目需求文档\n\n**项目名称:** [在此处填写项目名称]\n\n**版本:** 1.0\n\n**日期:** 2023年10月27日\n\n**作者:** [您的姓名/团队名称]\n\n### 1. 引言\n\n**1.1 目的**\n\n本文档旨在详细描述[项目名称]的项目需求,为项目的规划、设计、开发、测试和部署提供明确的指导和依据。\n\n**1.2 范围**\n\n本文档涵盖项目的目标、功能、性能、用户界面、安全、约束条件以及验收标准。\n\n**1.3 目标读者**\n\n* 项目经理\n* 开发团队\n* 测试团队\n* 业务分析师\n* 利益相关者\n\n### 2. 项目背景\n\n**2.1 背景描述**\n\n[详细描述项目产生的背景,以及项目解决的问题或满足的需求。]\n\n**2.2 现有系统/流程描述**\n\n[如果项目涉及替换或改进现有系统/流程,请详细描述现有系统/流程的情况。]\n\n### 3. 项目目标\n\n**3.1 业务目标**\n\n[描述项目对业务的影响,例如提高效率、降低成本、增加收入等。]\n\n**3.2 用户目标**\n\n[描述用户通过使用项目后可以获得什么价值。]\n\n### 4. 功能需求\n\n| ID | 功能描述 | 优先级 | 备注 |\n|---|---|---|---|\n| 1 | [功能描述1] | 高 | [相关信息] |\n| 2 | [功能描述2] | 中 | [相关信息] |\n| 3 | [功能描述3] | 低 | [相关信息] |\n| ... | ... | ... | ... |\n\n* **优先级:** 高 (必须实现)、中 (重要但可推迟)、低 (可选功能)\n\n### 5. 非功能需求\n\n**5.1 性能需求**\n\n* 响应时间:[例如:页面加载时间不超过3秒]\n* 并发用户数:[例如:支持1000个并发用户]\n* 数据存储容量:[例如:需要存储1TB的数据]\n\n**5.2 安全需求**\n\n* 用户认证:[例如:采用用户名/密码认证、OAuth认证]\n* 数据加密:[例如:采用SSL/TLS加密传输数据]\n* 权限控制:[例如:不同用户具有不同的权限]\n\n**5.3 可用性需求**\n\n* 系统可用时间:[例如:99.9%可用性]\n* 故障恢复:[例如:数据备份和恢复机制]\n\n**5.4 可靠性需求**\n\n* 错误率:[例如:系统错误率低于0.1%]\n\n**5.5 可维护性需求**\n\n* 代码可读性:[例如:代码规范、注释]\n* 模块化设计:[例如:采用模块化架构]\n\n**5.6 可扩展性需求**\n\n* 系统架构:[例如:支持水平扩展]\n\n### 6. 用户界面 (UI) 需求\n\n* 界面风格:[例如:简洁、现代]\n* 布局:[例如:响应式布局]\n* 主要页面:[例如:首页、登录页面、功能页面]\n* [可包含UI原型图或线框图]\n\n### 7. 约束条件\n\n* 技术限制:[例如:使用的技术栈]\n* 预算限制:[例如:项目预算]\n* 时间限制:[例如:项目截止日期]\n* 资源限制:[例如:人力资源]\n\n### 8. 验收标准\n\n* 功能测试:所有功能模块必须通过测试。\n* 性能测试:系统必须满足性能需求。\n* 安全测试:系统必须通过安全测试。\n* 用户验收测试:用户必须对系统感到满意。\n\n### 9. 风险评估\n\n| 风险描述 | 可能性 | 影响 | 缓解措施 |\n|---|---|---|---|\n| [风险1] | 高 | 高 | [缓解措施1] |\n| [风险2] | 中 | 中 | [缓解措施2] |\n| ... | ... | ... | ... |\n\n### 10. 术语表\n\n* [术语1:定义]\n* [术语2:定义]\n* ...\n\n---\n\n请注意,这是一个通用模板。您需要根据您的具体项目需求进行修改和完善。 由于**知识库中未找到您要的答案!**,我无法根据任何特定信息为您定制文档。 如果您能提供更详细的项目信息,我可以更好地帮助您')
10
+ </script>
11
+ <style lang="scss" scoped>
12
+ .dm {
13
+ width: 100%;
14
+ height: 100%;
15
+ .dm-ui {
16
+ width: 100%;
17
+ height: 100%;
18
+ }
19
+ }
20
+ </style>