af-mobile-client-vue3 1.4.64 → 1.4.65

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.
@@ -23,6 +23,7 @@ interface FormItem {
23
23
  name?: string
24
24
  rule?: {
25
25
  type: string
26
+ required: string
26
27
  }
27
28
  }
28
29
 
@@ -254,6 +255,11 @@ function setupValidationRules() {
254
255
  if (item.rule) {
255
256
  setFormRule(item)
256
257
  }
258
+
259
+ // 统一处理 image 和 file 类型的 minAcceptCount 验证(无论是否有 rule)
260
+ if ((item.type === 'image' || item.type === 'file') && (item as any).minAcceptCount !== undefined && (item as any).minAcceptCount !== null) {
261
+ setMinAcceptCountRule(item)
262
+ }
257
263
  }
258
264
  }
259
265
 
@@ -300,6 +306,45 @@ function setFormRule(item: FormItem) {
300
306
  },
301
307
  trigger: 'blur',
302
308
  })
309
+
310
+ // 为 image 和 file 类型添加 minAcceptCount 验证
311
+ if ((item.type === 'image' || item.type === 'file') && (item as any).minAcceptCount !== undefined && (item as any).minAcceptCount !== null) {
312
+ setMinAcceptCountRule(item)
313
+ }
314
+ }
315
+
316
+ // 设置 minAcceptCount 验证规则
317
+ function setMinAcceptCountRule(item: FormItem) {
318
+ if (!item.model)
319
+ return
320
+
321
+ const minCount = (item as any).minAcceptCount
322
+ if (minCount === undefined || minCount === null || minCount <= 0)
323
+ return
324
+
325
+ const isRequired = item.rule?.required === 'true'
326
+
327
+ // 如果 rules[item.model] 不存在,先创建
328
+ if (!rules[item.model]) {
329
+ rules[item.model] = []
330
+ }
331
+
332
+ rules[item.model].push({
333
+ validator: (value: any) => {
334
+ const fileList = value
335
+ const fileCount = Array.isArray(fileList) ? fileList.length : 0
336
+
337
+ // 如果非必填且没有文件,不验证数量(允许为空)
338
+ if (fileCount === 0 && !isRequired) {
339
+ return true
340
+ }
341
+
342
+ // 如果有文件或者是必填的,验证数量
343
+ return fileCount >= minCount
344
+ },
345
+ message: `至少需要上传${minCount}张图片`,
346
+ trigger: 'change',
347
+ })
303
348
  }
304
349
 
305
350
  // 重置表单状态
@@ -119,4 +119,4 @@ onUnmounted(() => {
119
119
  color: #ff976a;
120
120
  }
121
121
  }
122
- </style>
122
+ </style>
@@ -99,4 +99,4 @@ onUnmounted(() => {
99
99
  .user-form {
100
100
  padding: 16px;
101
101
  }
102
- </style>
102
+ </style>
@@ -434,6 +434,35 @@ function updateFile(files, _index) {
434
434
  modelData.value = files
435
435
  }
436
436
 
437
+ // 获取文件上传的验证规则(合并 XForm 传递的 rules 和本地必填验证)
438
+ function getFileUploadRules() {
439
+ const rules: any[] = []
440
+
441
+ // 从 XForm 传递的 rules 中获取该字段的验证规则
442
+ if (props.rules && props.rules[attr.model]) {
443
+ rules.push(...props.rules[attr.model])
444
+ }
445
+
446
+ // 如果 XForm 中没有必填规则,则添加本地必填验证
447
+ const isRequired = attr.rule?.required === 'true'
448
+ const hasRequiredRule = rules.some(rule => rule.required === true)
449
+
450
+ if (isRequired && !hasRequiredRule) {
451
+ rules.push({
452
+ required: true,
453
+ message: `请上传${attr.name}`,
454
+ validator: (value: any) => {
455
+ if (!value || (Array.isArray(value) && value.length === 0)) {
456
+ return false
457
+ }
458
+ return true
459
+ },
460
+ })
461
+ }
462
+
463
+ return rules
464
+ }
465
+
437
466
  // 是否只读
438
467
  const readonly = computed(() => {
439
468
  return props.formReadonly || attr.addOrEdit === 'readonly' || mode === '预览' || customizeReadOnly.value
@@ -1264,13 +1293,13 @@ function scanCodeOrNfc(attr) {
1264
1293
  <!-- 图片上传, 手机端拍照 -->
1265
1294
  <VanField
1266
1295
  v-if="(attr.type === 'image' || attr.type === 'file') && showItem"
1267
- name="image"
1296
+ :name="attr.model"
1268
1297
  :label="labelData"
1269
1298
  center
1270
1299
  :label-align="labelAlign"
1271
1300
  :input-align="attr.inputAlign ? attr.inputAlign : 'left'"
1272
- :rules="[{ required: attr.rule.required === 'true', message: `请选择${attr.name}` }]"
1273
- :required="attr.rule.required === 'true'"
1301
+ :rules="getFileUploadRules()"
1302
+ :required="attr.rule?.required === 'true'"
1274
1303
  >
1275
1304
  <template #input>
1276
1305
  <!-- 只读且为空时显示空提示 -->
@@ -1,33 +1,33 @@
1
- <script setup lang="ts">
2
- import { onMounted, ref } from 'vue'
3
- import XReport from './XReport.vue'
4
-
5
- const mainRef = ref()
6
-
7
- onMounted(() => {
8
- // 初始化逻辑
9
- })
10
- </script>
11
-
12
- <template>
13
- <div id="test">
14
- <van-card :bordered="false">
15
- <XReport
16
- ref="mainRef"
17
- :use-oss-for-img="false"
18
- config-name="nurseWorkstationCover"
19
- server-name="af-his"
20
- :show-img-in-cell="true"
21
- :display-only="true"
22
- :edit-mode="false"
23
- :show-save-button="false"
24
- :no-padding="true"
25
- :dont-format="true"
26
- />
27
- </van-card>
28
- </div>
29
- </template>
30
-
31
- <style scoped>
32
-
33
- </style>
1
+ <script setup lang="ts">
2
+ import { onMounted, ref } from 'vue'
3
+ import XReport from './XReport.vue'
4
+
5
+ const mainRef = ref()
6
+
7
+ onMounted(() => {
8
+ // 初始化逻辑
9
+ })
10
+ </script>
11
+
12
+ <template>
13
+ <div id="test">
14
+ <van-card :bordered="false">
15
+ <XReport
16
+ ref="mainRef"
17
+ :use-oss-for-img="false"
18
+ config-name="nurseWorkstationCover"
19
+ server-name="af-his"
20
+ :show-img-in-cell="true"
21
+ :display-only="true"
22
+ :edit-mode="false"
23
+ :show-save-button="false"
24
+ :no-padding="true"
25
+ :dont-format="true"
26
+ />
27
+ </van-card>
28
+ </div>
29
+ </template>
30
+
31
+ <style scoped>
32
+
33
+ </style>
@@ -1,184 +1,184 @@
1
- // print.js
2
-
3
- export function printElement(elementToPrint) {
4
- // 创建一个新的浏览器窗口
5
- const printWindow = window.open('', '_blank', 'height=1024,width=768')
6
- // 设置新窗口的文档内容
7
- printWindow.document.write(`
8
- <html>
9
- <head>
10
- <title>Print</title>
11
- <style>
12
- @page {
13
- size: auto;
14
- margin: 0mm;
15
- }
16
- html, body {
17
- margin: 0;
18
- padding: 0;
19
- width: 100%;
20
- height: 100%;
21
- }
22
- #print-container {
23
- display: none
24
- }
25
- .img{
26
- width: 95%;
27
- height: 180px;
28
- object-fit: cover;
29
- }
30
- .reportMain {
31
- text-align: center;
32
- margin: 0 auto;
33
- font-size: 16px;
34
- color: #000;
35
- background-color: #fff;
36
- border-radius: 8px;
37
-
38
- .reportTitle {
39
- font-weight: bold;
40
- }
41
-
42
- .subTitle {
43
- display: flex;
44
- justify-content: space-between;
45
- margin-bottom: 1%;
46
-
47
- .subTitleItems {
48
- max-width: 30%;
49
- }
50
- }
51
-
52
- .inputsDiv {
53
- display: flex;
54
- justify-content: space-between;
55
- .inputsDivItem {
56
- display: flex;
57
- align-items: center;
58
- padding: 0 4px;
59
- white-space: nowrap;
60
- .inputsDivItemLabel {
61
- padding: 0 4px;
62
- }
63
- }
64
- }
65
-
66
- .reportTable {
67
- width: 100%;
68
- border-collapse: collapse;
69
- table-layout:fixed;
70
- word-break:break-all;
71
- text-align: center;
72
- }
73
- }
74
- .reportMainForDisplay {
75
- text-align: center;
76
- margin: 10% auto;
77
- font-size: 16px;
78
- color: #000;
79
- background-color: #fff;
80
- border-radius: 8px;
81
-
82
- .reportTitle {
83
- font-weight: bold;
84
- }
85
-
86
- .subTitle {
87
- display: flex;
88
- justify-content: space-between;
89
-
90
- .subTitleItems {
91
- max-width: 30%;
92
- }
93
- }
94
-
95
- .inputsDiv {
96
- display: flex;
97
- justify-content: space-around;
98
- .inputsDivItem {
99
- display: flex;
100
- align-items: center;
101
- padding: 0 4px;
102
- white-space: nowrap;
103
- .inputsDivItemLabel {
104
- padding: 0 4px;
105
- }
106
- }
107
- }
108
-
109
- .reportTable {
110
- width: 100%;
111
- border-collapse: collapse;
112
- table-layout:fixed;
113
- word-break:break-all;
114
- }
115
- }
116
- .reportMainNoPadding {
117
- text-align: center;
118
- margin: 0 auto;
119
- font-size: 16px;
120
- color: #000;
121
- background-color: #fff;
122
- border-radius: 8px;
123
-
124
- .reportTitle {
125
- font-weight: bold;
126
- }
127
-
128
- .subTitle {
129
- display: flex;
130
- justify-content: space-between;
131
-
132
- .subTitleItems {
133
- max-width: 30%;
134
- }
135
- }
136
-
137
- .inputsDiv {
138
- display: flex;
139
- justify-content: space-between;
140
- .inputsDivItem {
141
- display: flex;
142
- align-items: center;
143
- padding: 0 4px;
144
- white-space: nowrap;
145
- .inputsDivItemLabel {
146
- padding: 0 4px;
147
- }
148
- }
149
- }
150
-
151
- .reportTable {
152
- width: 100%;
153
- border-collapse: collapse;
154
- table-layout:fixed;
155
- word-break:break-all;
156
- }
157
- }
158
- .tools{
159
- position: fixed;
160
- right: 2%;
161
- text-align: right;
162
- width: 60%;
163
- cursor: pointer;
164
- .toolsItem{
165
- width: 15%;
166
- margin-right: 3%;
167
- display: inline-block;
168
- }
169
- }
170
- </style>
171
- </head>
172
- <body>
173
- <!-- 将需要打印的元素内容复制到新窗口中 -->
174
- ${elementToPrint.innerHTML}
175
- </body>
176
- </html>
177
- `)
178
- // 延迟执行打印,以确保新窗口的内容已加载完成
179
- printWindow.document.close() // 关闭文档流,确保内容完全加载
180
- setTimeout(() => {
181
- printWindow.print() // 调用打印方法
182
- printWindow.close()
183
- }, 500) // 延迟500毫秒后执行打印
184
- }
1
+ // print.js
2
+
3
+ export function printElement(elementToPrint) {
4
+ // 创建一个新的浏览器窗口
5
+ const printWindow = window.open('', '_blank', 'height=1024,width=768')
6
+ // 设置新窗口的文档内容
7
+ printWindow.document.write(`
8
+ <html>
9
+ <head>
10
+ <title>Print</title>
11
+ <style>
12
+ @page {
13
+ size: auto;
14
+ margin: 0mm;
15
+ }
16
+ html, body {
17
+ margin: 0;
18
+ padding: 0;
19
+ width: 100%;
20
+ height: 100%;
21
+ }
22
+ #print-container {
23
+ display: none
24
+ }
25
+ .img{
26
+ width: 95%;
27
+ height: 180px;
28
+ object-fit: cover;
29
+ }
30
+ .reportMain {
31
+ text-align: center;
32
+ margin: 0 auto;
33
+ font-size: 16px;
34
+ color: #000;
35
+ background-color: #fff;
36
+ border-radius: 8px;
37
+
38
+ .reportTitle {
39
+ font-weight: bold;
40
+ }
41
+
42
+ .subTitle {
43
+ display: flex;
44
+ justify-content: space-between;
45
+ margin-bottom: 1%;
46
+
47
+ .subTitleItems {
48
+ max-width: 30%;
49
+ }
50
+ }
51
+
52
+ .inputsDiv {
53
+ display: flex;
54
+ justify-content: space-between;
55
+ .inputsDivItem {
56
+ display: flex;
57
+ align-items: center;
58
+ padding: 0 4px;
59
+ white-space: nowrap;
60
+ .inputsDivItemLabel {
61
+ padding: 0 4px;
62
+ }
63
+ }
64
+ }
65
+
66
+ .reportTable {
67
+ width: 100%;
68
+ border-collapse: collapse;
69
+ table-layout:fixed;
70
+ word-break:break-all;
71
+ text-align: center;
72
+ }
73
+ }
74
+ .reportMainForDisplay {
75
+ text-align: center;
76
+ margin: 10% auto;
77
+ font-size: 16px;
78
+ color: #000;
79
+ background-color: #fff;
80
+ border-radius: 8px;
81
+
82
+ .reportTitle {
83
+ font-weight: bold;
84
+ }
85
+
86
+ .subTitle {
87
+ display: flex;
88
+ justify-content: space-between;
89
+
90
+ .subTitleItems {
91
+ max-width: 30%;
92
+ }
93
+ }
94
+
95
+ .inputsDiv {
96
+ display: flex;
97
+ justify-content: space-around;
98
+ .inputsDivItem {
99
+ display: flex;
100
+ align-items: center;
101
+ padding: 0 4px;
102
+ white-space: nowrap;
103
+ .inputsDivItemLabel {
104
+ padding: 0 4px;
105
+ }
106
+ }
107
+ }
108
+
109
+ .reportTable {
110
+ width: 100%;
111
+ border-collapse: collapse;
112
+ table-layout:fixed;
113
+ word-break:break-all;
114
+ }
115
+ }
116
+ .reportMainNoPadding {
117
+ text-align: center;
118
+ margin: 0 auto;
119
+ font-size: 16px;
120
+ color: #000;
121
+ background-color: #fff;
122
+ border-radius: 8px;
123
+
124
+ .reportTitle {
125
+ font-weight: bold;
126
+ }
127
+
128
+ .subTitle {
129
+ display: flex;
130
+ justify-content: space-between;
131
+
132
+ .subTitleItems {
133
+ max-width: 30%;
134
+ }
135
+ }
136
+
137
+ .inputsDiv {
138
+ display: flex;
139
+ justify-content: space-between;
140
+ .inputsDivItem {
141
+ display: flex;
142
+ align-items: center;
143
+ padding: 0 4px;
144
+ white-space: nowrap;
145
+ .inputsDivItemLabel {
146
+ padding: 0 4px;
147
+ }
148
+ }
149
+ }
150
+
151
+ .reportTable {
152
+ width: 100%;
153
+ border-collapse: collapse;
154
+ table-layout:fixed;
155
+ word-break:break-all;
156
+ }
157
+ }
158
+ .tools{
159
+ position: fixed;
160
+ right: 2%;
161
+ text-align: right;
162
+ width: 60%;
163
+ cursor: pointer;
164
+ .toolsItem{
165
+ width: 15%;
166
+ margin-right: 3%;
167
+ display: inline-block;
168
+ }
169
+ }
170
+ </style>
171
+ </head>
172
+ <body>
173
+ <!-- 将需要打印的元素内容复制到新窗口中 -->
174
+ ${elementToPrint.innerHTML}
175
+ </body>
176
+ </html>
177
+ `)
178
+ // 延迟执行打印,以确保新窗口的内容已加载完成
179
+ printWindow.document.close() // 关闭文档流,确保内容完全加载
180
+ setTimeout(() => {
181
+ printWindow.print() // 调用打印方法
182
+ printWindow.close()
183
+ }, 500) // 延迟500毫秒后执行打印
184
+ }