af-mobile-client-vue3 1.4.13 → 1.4.15

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.
@@ -1,211 +1,211 @@
1
- <script setup lang="ts">
2
- import {
3
- Field as VanField,
4
- Picker as VanPicker,
5
- Popup as VanPopup,
6
- Search as VanSearch,
7
- } from 'vant'
8
- import { computed, defineEmits, defineModel, defineProps, onBeforeMount, ref, watch } from 'vue'
9
-
10
- const props = defineProps({
11
- columns: {
12
- type: Array,
13
- default() {
14
- return []
15
- },
16
- },
17
- option: {
18
- type: Object,
19
- default() {
20
- return { text: 'label', value: 'value', children: 'children' }
21
- },
22
- },
23
- offOption: { // 关闭option配置key-value;当数据是非集合的数组的时候,开启
24
- type: Boolean,
25
- default: false,
26
- },
27
- border: { // 是否展示边框
28
- type: Boolean,
29
- default: false,
30
- },
31
- lazyLoad: { // 是否启用懒加载
32
- type: String,
33
- default: 'false',
34
- },
35
- onSearch: { // 懒加载时的搜索函数
36
- type: Function,
37
- default: null,
38
- },
39
- })
40
- const emits = defineEmits(['confirm', 'change', 'cancel', 'input'])
41
- const show = ref(false)
42
- const resultValue = defineModel()
43
- const columnsData = ref([])
44
- const selectedOption = ref([])
45
- const searchValue = ref('')
46
- const isLoading = ref(false)
47
-
48
- // 转换空children为空字符串
49
- function transformColumns(data) {
50
- return data.map((item) => {
51
- if (item.children && item.children.length === 0) {
52
- return {
53
- ...item,
54
- children: '',
55
- }
56
- }
57
- else if (item.children && item.children.length !== 0) {
58
- return { ...item, children: transformColumns(item.children) }
59
- }
60
- else {
61
- return { ...item }
62
- }
63
- })
64
- }
65
- const filteredColumns = ref([])
66
-
67
- watch(
68
- () => searchValue.value,
69
- async (newValue) => {
70
- if (props.lazyLoad && props.lazyLoad === 'true' && props.onSearch) {
71
- if (!newValue) {
72
- filteredColumns.value = []
73
- return
74
- }
75
-
76
- isLoading.value = true
77
- try {
78
- const results = await props.onSearch(newValue)
79
- filteredColumns.value = transformColumns(results || [])
80
- }
81
- catch (error) {
82
- console.error('懒加载搜索失败:', error)
83
- filteredColumns.value = []
84
- }
85
- finally {
86
- isLoading.value = false
87
- }
88
- }
89
- else {
90
- // 普通搜索模式
91
- if (!newValue) {
92
- filteredColumns.value = columnsData.value
93
- return
94
- }
95
-
96
- const searchTextLower = newValue.toLowerCase()
97
- filteredColumns.value = columnsData.value.filter((item) => {
98
- const text = props.offOption ? item : item[props.option.text]
99
- return text?.toString().toLowerCase().includes(searchTextLower)
100
- })
101
- }
102
- },
103
- { immediate: true },
104
- )
105
-
106
- onBeforeMount(() => {
107
- columnsData.value = transformColumns(props.columns)
108
- filteredColumns.value = columnsData.value
109
- })
110
-
111
- const resultLabel = computed({
112
- get() {
113
- if (!resultValue.value)
114
- return ''
115
- const res = props.columns.filter((item) => {
116
- const data = props.offOption ? item : item[props.option.value]
117
- return data === resultValue.value
118
- })
119
- return res.length ? (props.offOption ? res[0] : res[0][props.option.text]) : ''
120
- },
121
- set() {
122
-
123
- },
124
- })
125
-
126
- function onConfirm(value, _index) {
127
- resultValue.value = props.offOption ? value.selectedValues : value.selectedValues[0]
128
- // resultValue.value = value.selectedValues
129
- selectedOption.value = value.selectedOptions
130
- show.value = !show.value
131
- emits('confirm', value.selectedValues[0], value.selectedOptions)
132
- }
133
-
134
- function change(val, index) {
135
- emits('change', val, index, resultValue.value)
136
- }
137
-
138
- function cancel(val, index) {
139
- show.value = !show.value
140
- emits('cancel', val, index, resultValue.value)
141
- }
142
-
143
- function showPopu(disabled) {
144
- if (disabled !== undefined && disabled !== false)
145
- return false
146
- columnsData.value = transformColumns(props.columns)
147
- filteredColumns.value = columnsData.value
148
- searchValue.value = '' // 重置搜索
149
- show.value = !show.value
150
- }
151
-
152
- watch(() => resultValue, (newVal, _oldVal) => {
153
- columnsData.value = transformColumns(props.columns)
154
- filteredColumns.value = columnsData.value
155
- emits('input', newVal)
156
- })
157
-
158
- // 监听 columns 变化
159
- watch(() => props.columns, () => {
160
- columnsData.value = transformColumns(props.columns)
161
- filteredColumns.value = columnsData.value
162
- searchValue.value = ''
163
- }, { deep: true })
164
- </script>
165
-
166
- <template>
167
- <VanField
168
- v-model="resultLabel"
169
- v-bind="$attrs"
170
- readonly
171
- :is-link="true"
172
- :border="props.border"
173
- @click="showPopu($attrs.readonly)"
174
- />
175
- <VanPopup v-model:show="show" position="bottom">
176
- <div class="x-select-popup">
177
- <!-- 搜索框 -->
178
- <VanSearch
179
- v-model="searchValue"
180
- placeholder="搜索"
181
- />
182
-
183
- <!-- 选择器 -->
184
- <VanPicker
185
- :loading="isLoading"
186
- v-bind="$attrs"
187
- :columns="filteredColumns"
188
- :columns-field-names="props.option"
189
- show-toolbar
190
- :value-key="props.option.text"
191
- @cancel="cancel"
192
- @confirm="onConfirm"
193
- @change="change"
194
- />
195
- </div>
196
- </VanPopup>
197
- </template>
198
-
199
- <style scoped>
200
- .loading-container {
201
- display: flex;
202
- justify-content: center;
203
- align-items: center;
204
- height: 200px;
205
- }
206
-
207
- .loading-text {
208
- color: #969799;
209
- font-size: 14px;
210
- }
211
- </style>
1
+ <script setup lang="ts">
2
+ import {
3
+ Field as VanField,
4
+ Picker as VanPicker,
5
+ Popup as VanPopup,
6
+ Search as VanSearch,
7
+ } from 'vant'
8
+ import { computed, defineEmits, defineModel, defineProps, onBeforeMount, ref, watch } from 'vue'
9
+
10
+ const props = defineProps({
11
+ columns: {
12
+ type: Array,
13
+ default() {
14
+ return []
15
+ },
16
+ },
17
+ option: {
18
+ type: Object,
19
+ default() {
20
+ return { text: 'label', value: 'value', children: 'children' }
21
+ },
22
+ },
23
+ offOption: { // 关闭option配置key-value;当数据是非集合的数组的时候,开启
24
+ type: Boolean,
25
+ default: false,
26
+ },
27
+ border: { // 是否展示边框
28
+ type: Boolean,
29
+ default: false,
30
+ },
31
+ lazyLoad: { // 是否启用懒加载
32
+ type: String,
33
+ default: 'false',
34
+ },
35
+ onSearch: { // 懒加载时的搜索函数
36
+ type: Function,
37
+ default: null,
38
+ },
39
+ })
40
+ const emits = defineEmits(['confirm', 'change', 'cancel', 'input'])
41
+ const show = ref(false)
42
+ const resultValue = defineModel()
43
+ const columnsData = ref([])
44
+ const selectedOption = ref([])
45
+ const searchValue = ref('')
46
+ const isLoading = ref(false)
47
+
48
+ // 转换空children为空字符串
49
+ function transformColumns(data) {
50
+ return data.map((item) => {
51
+ if (item.children && item.children.length === 0) {
52
+ return {
53
+ ...item,
54
+ children: '',
55
+ }
56
+ }
57
+ else if (item.children && item.children.length !== 0) {
58
+ return { ...item, children: transformColumns(item.children) }
59
+ }
60
+ else {
61
+ return { ...item }
62
+ }
63
+ })
64
+ }
65
+ const filteredColumns = ref([])
66
+
67
+ watch(
68
+ () => searchValue.value,
69
+ async (newValue) => {
70
+ if (props.lazyLoad && props.lazyLoad === 'true' && props.onSearch) {
71
+ if (!newValue) {
72
+ filteredColumns.value = []
73
+ return
74
+ }
75
+
76
+ isLoading.value = true
77
+ try {
78
+ const results = await props.onSearch(newValue)
79
+ filteredColumns.value = transformColumns(results || [])
80
+ }
81
+ catch (error) {
82
+ console.error('懒加载搜索失败:', error)
83
+ filteredColumns.value = []
84
+ }
85
+ finally {
86
+ isLoading.value = false
87
+ }
88
+ }
89
+ else {
90
+ // 普通搜索模式
91
+ if (!newValue) {
92
+ filteredColumns.value = columnsData.value
93
+ return
94
+ }
95
+
96
+ const searchTextLower = newValue.toLowerCase()
97
+ filteredColumns.value = columnsData.value.filter((item) => {
98
+ const text = props.offOption ? item : item[props.option.text]
99
+ return text?.toString().toLowerCase().includes(searchTextLower)
100
+ })
101
+ }
102
+ },
103
+ { immediate: true },
104
+ )
105
+
106
+ onBeforeMount(() => {
107
+ columnsData.value = transformColumns(props.columns)
108
+ filteredColumns.value = columnsData.value
109
+ })
110
+
111
+ const resultLabel = computed({
112
+ get() {
113
+ if (!resultValue.value)
114
+ return ''
115
+ const res = props.columns.filter((item) => {
116
+ const data = props.offOption ? item : item[props.option.value]
117
+ return data === resultValue.value
118
+ })
119
+ return res.length ? (props.offOption ? res[0] : res[0][props.option.text]) : ''
120
+ },
121
+ set() {
122
+
123
+ },
124
+ })
125
+
126
+ function onConfirm(value, _index) {
127
+ resultValue.value = props.offOption ? value.selectedValues : value.selectedValues[0]
128
+ // resultValue.value = value.selectedValues
129
+ selectedOption.value = value.selectedOptions
130
+ show.value = !show.value
131
+ emits('confirm', value.selectedValues[0], value.selectedOptions)
132
+ }
133
+
134
+ function change(val, index) {
135
+ emits('change', val, index, resultValue.value)
136
+ }
137
+
138
+ function cancel(val, index) {
139
+ show.value = !show.value
140
+ emits('cancel', val, index, resultValue.value)
141
+ }
142
+
143
+ function showPopu(disabled) {
144
+ if (disabled !== undefined && disabled !== false)
145
+ return false
146
+ columnsData.value = transformColumns(props.columns)
147
+ filteredColumns.value = columnsData.value
148
+ searchValue.value = '' // 重置搜索
149
+ show.value = !show.value
150
+ }
151
+
152
+ watch(() => resultValue, (newVal, _oldVal) => {
153
+ columnsData.value = transformColumns(props.columns)
154
+ filteredColumns.value = columnsData.value
155
+ emits('input', newVal)
156
+ })
157
+
158
+ // 监听 columns 变化
159
+ watch(() => props.columns, () => {
160
+ columnsData.value = transformColumns(props.columns)
161
+ filteredColumns.value = columnsData.value
162
+ searchValue.value = ''
163
+ }, { deep: true })
164
+ </script>
165
+
166
+ <template>
167
+ <VanField
168
+ v-model="resultLabel"
169
+ v-bind="$attrs"
170
+ readonly
171
+ :is-link="true"
172
+ :border="props.border"
173
+ @click="showPopu($attrs.readonly)"
174
+ />
175
+ <VanPopup v-model:show="show" position="bottom">
176
+ <div class="x-select-popup">
177
+ <!-- 搜索框 -->
178
+ <VanSearch
179
+ v-model="searchValue"
180
+ placeholder="搜索"
181
+ />
182
+
183
+ <!-- 选择器 -->
184
+ <VanPicker
185
+ :loading="isLoading"
186
+ v-bind="$attrs"
187
+ :columns="filteredColumns"
188
+ :columns-field-names="props.option"
189
+ show-toolbar
190
+ :value-key="props.option.text"
191
+ @cancel="cancel"
192
+ @confirm="onConfirm"
193
+ @change="change"
194
+ />
195
+ </div>
196
+ </VanPopup>
197
+ </template>
198
+
199
+ <style scoped>
200
+ .loading-container {
201
+ display: flex;
202
+ justify-content: center;
203
+ align-items: center;
204
+ height: 200px;
205
+ }
206
+
207
+ .loading-text {
208
+ color: #969799;
209
+ font-size: 14px;
210
+ }
211
+ </style>
@@ -4,7 +4,7 @@ import dayjs from 'dayjs/esm/index'
4
4
  import { ref } from 'vue'
5
5
 
6
6
  const { serviceName, dictName, dictValue, dictType } = defineProps<{
7
- serviceName: string
7
+ serviceName?: string
8
8
  dictName: string | null | undefined
9
9
  dictValue: string | number | null | undefined
10
10
  // 用于非字典型的格式化展示:如日期/小数/整数等
@@ -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>
@@ -225,8 +225,6 @@ function checkModel(val = props.modelValue) {
225
225
  */
226
226
  function getDefaultValue() {
227
227
  const val = props.modelValue
228
- console.warn('>>>>>props', props)
229
- console.warn('>>>> attr', attr)
230
228
  // 如果有有效值,直接返回(datePicker 初始值需按 formValueFormat 归一)
231
229
  // 目的:外部通过 formData 传入的初始值在组件挂载即与配置格式一致
232
230
  if (checkModel(val)) {
@@ -620,7 +618,7 @@ function onCalendarConfirm(values) {
620
618
  // js 函数作为数据源
621
619
  async function updateOptions() {
622
620
  if (attr.keyName && (attr.keyName.toString().includes('async ') || attr.keyName.toString().includes('function '))) {
623
- option.value = await executeStrFunctionByContext(currInst, attr.keyName, [props.form, runLogic, props.mode, getConfigByNameAsync, post])
621
+ option.value = await executeStrFunctionByContext(currInst, attr.keyName, [props.form, runLogic, props.mode, getConfigByNameAsync, post, userState.f.resources])
624
622
  }
625
623
  }
626
624
 
@@ -188,4 +188,4 @@ export interface PolygonLayerConfig {
188
188
  onClick?: (polygon: PolygonData, event: any) => void
189
189
  /** 多边形数据提供者 */
190
190
  dataProvider?: () => PolygonData[] | Promise<PolygonData[]>
191
- }
191
+ }
@@ -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>