af-mobile-client-vue3 1.0.89 → 1.0.91

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.
@@ -4,6 +4,7 @@ import {
4
4
  BackTop as VanBackTop,
5
5
  Button as VanButton,
6
6
  Col as VanCol,
7
+ Icon as VanIcon,
7
8
  List as VanList,
8
9
  Popover as VanPopover,
9
10
  PullRefresh as VanPullRefresh,
@@ -54,6 +55,9 @@ const detailColumns = ref([])
54
55
  // 标签列
55
56
  const tagList = ref([])
56
57
 
58
+ // 标题按钮列
59
+ const btnList = ref([])
60
+
57
61
  // 底部列
58
62
  const footColumns = ref([])
59
63
 
@@ -144,6 +148,9 @@ function initComponent() {
144
148
  allActions.value.push({ text: item.actionArr[j].text, func: item.actionArr[j].func })
145
149
  }
146
150
 
151
+ if (item.showTitleBtn)
152
+ btnList.value.push(item)
153
+
147
154
  if (result.showSortIcon && item.sortable) {
148
155
  orderList.value.push({
149
156
  title: item.title,
@@ -307,14 +314,9 @@ function addOption() {
307
314
  }
308
315
 
309
316
  // 处理拨打电话
310
- // function handleCall(item: any) {
311
- // emit('handleCall', item)
312
- // }
313
-
314
- // 处理查看位置
315
- // function handleLocation(item: any) {
316
- // emit('handleLocation', item)
317
- // }
317
+ function handleCall(item: any) {
318
+ emit('handleCall', item)
319
+ }
318
320
  </script>
319
321
 
320
322
  <template>
@@ -380,20 +382,14 @@ function addOption() {
380
382
  />
381
383
  </p>
382
384
  </div>
383
- <!-- <div class="action-buttons">
385
+ <div class="action-buttons">
384
386
  <VanButton
385
387
  class="action-button"
386
388
  icon="phone"
387
389
  size="small"
388
390
  @click.stop="handleCall(item)"
389
391
  />
390
- <VanButton
391
- class="action-button"
392
- icon="location"
393
- size="small"
394
- @click.stop="handleLocation(item)"
395
- />
396
- </div> -->
392
+ </div>
397
393
  </div>
398
394
  </VanCol>
399
395
  </VanRow>
@@ -425,11 +421,15 @@ function addOption() {
425
421
  size="medium"
426
422
  class="tag-item"
427
423
  >
428
- {{ column.title }}:<XBadge
429
- :dict-name="column.dictName"
430
- :dict-value="item[column.dataIndex]"
431
- :service-name="serviceName"
432
- />
424
+ <div class="tag-content">
425
+ <VanIcon v-if="column.tagIcon" :name="column.tagIcon" class="tag-icon" />
426
+ <span class="tag-title">{{ column.title }}:</span>
427
+ <XBadge
428
+ :dict-name="column.dictName"
429
+ :dict-value="item[column.dataIndex]"
430
+ :service-name="serviceName"
431
+ />
432
+ </div>
433
433
  </VanTag>
434
434
  </VanCol>
435
435
  </div>
@@ -609,6 +609,20 @@ function addOption() {
609
609
  display: inline-flex;
610
610
  align-items: center;
611
611
  }
612
+ .tag-content {
613
+ display: flex;
614
+ align-items: center;
615
+ white-space: nowrap;
616
+ }
617
+ .tag-icon {
618
+ margin-right: 4px;
619
+ font-size: 14px;
620
+ display: inline-flex;
621
+ align-items: center;
622
+ }
623
+ .tag-title {
624
+ font-weight: normal;
625
+ }
612
626
  }
613
627
  }
614
628
  }
@@ -1,153 +1,153 @@
1
- <script setup lang="ts">
2
- import {
3
- Button as VanButton,
4
- CellGroup as VanCellGroup,
5
- Form as VanForm,
6
- } from 'vant'
7
- import type { FormInstance } from 'vant'
8
- import { computed, defineEmits, defineProps, onBeforeMount, reactive, ref, watch } from 'vue'
9
- import XFormItem from '@af-mobile-client-vue3/components/data/XFormItem/index.vue'
10
-
11
- interface FormItem {
12
- addOrEdit: string
13
- isOnlyAddOrEdit?: boolean
14
- type?: string
15
- model?: string
16
- }
17
-
18
- interface GroupFormItems {
19
- btnName?: string
20
- formJson: any[] // 根据实际类型调整
21
- }
22
- const props = withDefaults(defineProps<{
23
- groupFormItems?: GroupFormItems
24
- serviceName?: string
25
- formData?: object
26
- formName?: string
27
- mode?: string
28
- submitButton?: boolean
29
- }>(), {
30
- groupFormItems: null,
31
- serviceName: undefined,
32
- formData: null,
33
- formName: 'default',
34
- mode: '查询',
35
- submitButton: true,
36
- })
37
- const emits = defineEmits(['onSubmit'])
38
- const formRef = ref<FormInstance>()
39
- const myFormItems = ref<FormItem[]>([])
40
- const rules = reactive({})
41
- const form = ref({})
42
- const formGroupName = ref(null)
43
- const myServiceName = ref('')
44
- const loaded = ref(false)
45
- let myGetDataParams = reactive({})
46
- const realJsonData = computed(() => {
47
- return myFormItems.value.filter((item) => {
48
- return item.addOrEdit !== 'no'
49
- })
50
- })
51
- onBeforeMount(() => {
52
- init({ formItems: props.groupFormItems, serviceName: props.serviceName, formData: props.formData, formName: props.formName })
53
- })
54
- function init(params) {
55
- const {
56
- formItems,
57
- serviceName,
58
- getDataParams = {},
59
- formData = null,
60
- formName = 'default',
61
- } = params
62
- loaded.value = false
63
- myFormItems.value = JSON.parse(JSON.stringify(formItems.formJson)) as FormItem[]
64
- myServiceName.value = serviceName
65
- formGroupName.value = formName
66
- for (let i = 0; i < realJsonData.value.length; i++) {
67
- const item = realJsonData.value[i]
68
- setFormProps(form, item)
69
- }
70
- if (formData)
71
- form.value = formData
72
-
73
- myGetDataParams = getDataParams
74
- loaded.value = true
75
- }
76
-
77
- function setFormProps(form, item) {
78
- form.value[item.model] = undefined
79
- if (item.rule) {
80
- rules[item.model] = []
81
- let defaultValue
82
- let message
83
- switch (item.rule.type) {
84
- case 'number':
85
- message = '数字'
86
- defaultValue = 0
87
- break
88
- case 'integer':
89
- message = '整数'
90
- defaultValue = 0
91
- break
92
- case 'float':
93
- message = '小数'
94
- defaultValue = 0.0
95
- break
96
- case 'string':
97
- message = '字符串'
98
- defaultValue = ''
99
- break
100
- }
101
- rules[item.model].push({
102
- type: item.rule.type,
103
- message: `${item.name}必须为${message}`,
104
- transform: (value) => {
105
- if (value && value.length !== 0)
106
- return Number(value)
107
- else
108
- return defaultValue
109
- },
110
- trigger: 'blur',
111
- })
112
- }
113
- }
114
-
115
- function onSubmit() {
116
- emits('onSubmit', form.value)
117
- }
118
- async function validate() {
119
- await formRef.value?.validate()
120
- }
121
- watch(() => props.formData, (_val) => {
122
- form.value = props.formData
123
- })
124
- defineExpose({ init, form, formGroupName, validate })
125
- </script>
126
-
127
- <template>
128
- <VanForm ref="formRef" @submit="onSubmit">
129
- <VanCellGroup inset>
130
- <XFormItem
131
- v-for="(item, index) in realJsonData"
132
- :key="index"
133
- v-model="form[item.model]"
134
- :mode="props.mode"
135
- :form="form"
136
- :attr="item"
137
- :rules="rules"
138
- :service-name="myServiceName"
139
- :get-data-params="myGetDataParams"
140
- />
141
- </VanCellGroup>
142
- <div v-if="props.submitButton" style="margin: 16px;">
143
- <VanButton round block type="primary" native-type="submit">
144
- {{ props.groupFormItems?.btnName ? props.groupFormItems.btnName : '提交' }}
145
- </VanButton>
146
- <slot />
147
- </div>
148
- </VanForm>
149
- </template>
150
-
151
- <style scoped>
152
-
153
- </style>
1
+ <script setup lang="ts">
2
+ import {
3
+ Button as VanButton,
4
+ CellGroup as VanCellGroup,
5
+ Form as VanForm,
6
+ } from 'vant'
7
+ import type { FormInstance } from 'vant'
8
+ import { computed, defineEmits, defineProps, onBeforeMount, reactive, ref, watch } from 'vue'
9
+ import XFormItem from '@af-mobile-client-vue3/components/data/XFormItem/index.vue'
10
+
11
+ interface FormItem {
12
+ addOrEdit: string
13
+ isOnlyAddOrEdit?: boolean
14
+ type?: string
15
+ model?: string
16
+ }
17
+
18
+ interface GroupFormItems {
19
+ btnName?: string
20
+ formJson: any[] // 根据实际类型调整
21
+ }
22
+ const props = withDefaults(defineProps<{
23
+ groupFormItems?: GroupFormItems
24
+ serviceName?: string
25
+ formData?: object
26
+ formName?: string
27
+ mode?: string
28
+ submitButton?: boolean
29
+ }>(), {
30
+ groupFormItems: null,
31
+ serviceName: undefined,
32
+ formData: null,
33
+ formName: 'default',
34
+ mode: '查询',
35
+ submitButton: true,
36
+ })
37
+ const emits = defineEmits(['onSubmit'])
38
+ const formRef = ref<FormInstance>()
39
+ const myFormItems = ref<FormItem[]>([])
40
+ const rules = reactive({})
41
+ const form = ref({})
42
+ const formGroupName = ref(null)
43
+ const myServiceName = ref('')
44
+ const loaded = ref(false)
45
+ let myGetDataParams = reactive({})
46
+ const realJsonData = computed(() => {
47
+ return myFormItems.value.filter((item) => {
48
+ return item.addOrEdit !== 'no'
49
+ })
50
+ })
51
+ onBeforeMount(() => {
52
+ init({ formItems: props.groupFormItems, serviceName: props.serviceName, formData: props.formData, formName: props.formName })
53
+ })
54
+ function init(params) {
55
+ const {
56
+ formItems,
57
+ serviceName,
58
+ getDataParams = {},
59
+ formData = null,
60
+ formName = 'default',
61
+ } = params
62
+ loaded.value = false
63
+ myFormItems.value = JSON.parse(JSON.stringify(formItems.formJson)) as FormItem[]
64
+ myServiceName.value = serviceName
65
+ formGroupName.value = formName
66
+ for (let i = 0; i < realJsonData.value.length; i++) {
67
+ const item = realJsonData.value[i]
68
+ setFormProps(form, item)
69
+ }
70
+ if (formData)
71
+ form.value = formData
72
+
73
+ myGetDataParams = getDataParams
74
+ loaded.value = true
75
+ }
76
+
77
+ function setFormProps(form, item) {
78
+ form.value[item.model] = undefined
79
+ if (item.rule) {
80
+ rules[item.model] = []
81
+ let defaultValue
82
+ let message
83
+ switch (item.rule.type) {
84
+ case 'number':
85
+ message = '数字'
86
+ defaultValue = 0
87
+ break
88
+ case 'integer':
89
+ message = '整数'
90
+ defaultValue = 0
91
+ break
92
+ case 'float':
93
+ message = '小数'
94
+ defaultValue = 0.0
95
+ break
96
+ case 'string':
97
+ message = '字符串'
98
+ defaultValue = ''
99
+ break
100
+ }
101
+ rules[item.model].push({
102
+ type: item.rule.type,
103
+ message: `${item.name}必须为${message}`,
104
+ transform: (value) => {
105
+ if (value && value.length !== 0)
106
+ return Number(value)
107
+ else
108
+ return defaultValue
109
+ },
110
+ trigger: 'blur',
111
+ })
112
+ }
113
+ }
114
+
115
+ function onSubmit() {
116
+ emits('onSubmit', form.value)
117
+ }
118
+ async function validate() {
119
+ await formRef.value?.validate()
120
+ }
121
+ watch(() => props.formData, (_val) => {
122
+ form.value = props.formData
123
+ })
124
+ defineExpose({ init, form, formGroupName, validate })
125
+ </script>
126
+
127
+ <template>
128
+ <VanForm ref="formRef" @submit="onSubmit">
129
+ <VanCellGroup inset>
130
+ <XFormItem
131
+ v-for="(item, index) in realJsonData"
132
+ :key="index"
133
+ v-model="form[item.model]"
134
+ :mode="props.mode"
135
+ :form="form"
136
+ :attr="item"
137
+ :rules="rules"
138
+ :service-name="myServiceName"
139
+ :get-data-params="myGetDataParams"
140
+ />
141
+ </VanCellGroup>
142
+ <div v-if="props.submitButton && props.mode !== '预览'" style="margin: 16px;">
143
+ <VanButton round block type="primary" native-type="submit">
144
+ {{ props.groupFormItems?.btnName ? props.groupFormItems.btnName : '提交' }}
145
+ </VanButton>
146
+ <slot />
147
+ </div>
148
+ </VanForm>
149
+ </template>
150
+
151
+ <style scoped>
152
+
153
+ </style>
@@ -361,9 +361,13 @@ onBeforeMount(() => {
361
361
  const labelData = computed(() => {
362
362
  return props.showLabel ? attr.name : null
363
363
  })
364
+ // 是否展示表单左侧label文字
365
+ const labelAlign = computed(() => {
366
+ return attr.labelAlign ? attr.labelAlign : 'top'
367
+ })
364
368
  // 是否只读
365
369
  const readonly = computed(() => {
366
- return attr.addOrEdit === 'readonly'
370
+ return attr.addOrEdit === 'readonly' || mode === '预览'
367
371
  })
368
372
  // 提示内容
369
373
  const placeholder = computed(() => {
@@ -592,6 +596,8 @@ function onPickerCancel() {
592
596
  v-if="attr.type === 'switch' && showItem"
593
597
  name="switch"
594
598
  :label="labelData"
599
+ :label-align="labelAlign"
600
+ :input-align="attr.inputAlign ? attr.inputAlign : 'right'"
595
601
  :rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
596
602
  >
597
603
  <template #input>
@@ -617,6 +623,8 @@ function onPickerCancel() {
617
623
  v-if="attr.showMode === 'checkbox' && mode !== '查询'"
618
624
  name="checkboxGroup"
619
625
  :label="labelData"
626
+ :label-align="labelAlign"
627
+ :input-align="attr.inputAlign ? attr.inputAlign : 'left'"
620
628
  :rules="[{ required: attr.rule.required === 'true', message: `请选择${attr.name}` }]"
621
629
  >
622
630
  <template #input>
@@ -631,6 +639,8 @@ function onPickerCancel() {
631
639
  v-if="attr.showMode === 'checkbox' && mode === '查询'"
632
640
  name="checkboxGroup"
633
641
  :label="labelData"
642
+ :label-align="labelAlign"
643
+ :input-align="attr.inputAlign ? attr.inputAlign : 'left'"
634
644
  :rules="[{ required: attr.rule.required === 'true', message: `请选择${attr.name}` }]"
635
645
  >
636
646
  <template #input>
@@ -661,6 +671,8 @@ function onPickerCancel() {
661
671
  name="radio"
662
672
  :placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
663
673
  :label="labelData"
674
+ :label-align="labelAlign"
675
+ :input-align="attr.inputAlign ? attr.inputAlign : 'left'"
664
676
  :rules="[{ required: attr.rule.required === 'true', message: `请选择${attr.name}` }]"
665
677
  >
666
678
  <template #input>
@@ -678,6 +690,8 @@ function onPickerCancel() {
678
690
  name="radio"
679
691
  :placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
680
692
  :label="labelData"
693
+ :label-align="labelAlign"
694
+ :input-align="attr.inputAlign ? attr.inputAlign : 'left'"
681
695
  :rules="[{ required: attr.rule.required === 'true', message: `请选择${attr.name}` }]"
682
696
  >
683
697
  <template #input>
@@ -694,11 +708,12 @@ function onPickerCancel() {
694
708
  v-if="attr.type === 'stepper' && showItem"
695
709
  name="stepper"
696
710
  :label="labelData"
697
- :readonly="readonly"
711
+ :label-align="labelAlign"
712
+ :input-align="attr.inputAlign ? attr.inputAlign : 'center'"
698
713
  :rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
699
714
  >
700
715
  <template #input>
701
- <VanStepper v-model="(localValue as string)" />
716
+ <VanStepper :disabled="readonly" v-model="(localValue as string)" />
702
717
  </template>
703
718
  </VanField>
704
719
 
@@ -707,11 +722,12 @@ function onPickerCancel() {
707
722
  v-if="attr.type === 'rate' && showItem"
708
723
  name="rate"
709
724
  :label="labelData"
710
- :readonly="readonly"
725
+ :label-align="labelAlign"
726
+ :input-align="attr.inputAlign ? attr.inputAlign : 'center'"
711
727
  :rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
712
728
  >
713
729
  <template #input>
714
- <VanRate v-model="(localValue as number)" />
730
+ <VanRate :size="25" :readonly="readonly" void-color="#eee" void-icon="star" color="#ffd21e" v-model="(localValue as number)" />
715
731
  </template>
716
732
  </VanField>
717
733
 
@@ -720,11 +736,12 @@ function onPickerCancel() {
720
736
  v-if="attr.type === 'slider' && showItem"
721
737
  name="slider"
722
738
  :label="labelData"
723
- :readonly="readonly"
739
+ :label-align="labelAlign"
740
+ :input-align="attr.inputAlign ? attr.inputAlign : 'left'"
724
741
  :rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
725
742
  >
726
743
  <template #input>
727
- <VanSlider v-model="(localValue as number)" />
744
+ <VanSlider :readonly="readonly" v-model="(localValue as number)" />
728
745
  </template>
729
746
  </VanField>
730
747
 
@@ -733,6 +750,8 @@ function onPickerCancel() {
733
750
  v-if="(attr.type === 'image' || attr.type === 'file') && showItem"
734
751
  name="uploader"
735
752
  :label="labelData"
753
+ :label-align="labelAlign"
754
+ :input-align="attr.inputAlign ? attr.inputAlign : 'left'"
736
755
  :rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
737
756
  >
738
757
  <template #input>
@@ -753,10 +772,12 @@ function onPickerCancel() {
753
772
  name="picker"
754
773
  :placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
755
774
  :label="labelData"
756
- :readonly="readonly"
775
+ :label-align="labelAlign"
776
+ :input-align="attr.inputAlign ? attr.inputAlign : 'left'"
777
+ readonly
757
778
  is-link
758
779
  :rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
759
- @click="showPicker = true"
780
+ @click="readonly ? null : showPicker = true"
760
781
  />
761
782
  <VanPopup v-model:show="showPicker" round position="bottom" teleport="body">
762
783
  <VanPicker
@@ -780,6 +801,8 @@ function onPickerCancel() {
780
801
  readonly
781
802
  name="rangePicker"
782
803
  :label="labelData"
804
+ :label-align="labelAlign"
805
+ :input-align="attr.inputAlign ? attr.inputAlign : 'left'"
783
806
  :placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
784
807
  :rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
785
808
  @click="calendarShow = true"
@@ -800,6 +823,8 @@ function onPickerCancel() {
800
823
  v-model="(localValue as string | number)"
801
824
  name="datePicker"
802
825
  :label="labelData"
826
+ :label-align="labelAlign"
827
+ :input-align="attr.inputAlign ? attr.inputAlign : 'left'"
803
828
  readonly
804
829
  :is-link="true"
805
830
  :placeholder="placeholder"
@@ -835,6 +860,8 @@ function onPickerCancel() {
835
860
  v-model="(localValue as string | number)"
836
861
  name="datePicker"
837
862
  :label="labelData"
863
+ :label-align="labelAlign"
864
+ :input-align="attr.inputAlign ? attr.inputAlign : 'left'"
838
865
  readonly
839
866
  :is-link="true"
840
867
  :placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
@@ -875,6 +902,8 @@ function onPickerCancel() {
875
902
  readonly
876
903
  :placeholder="attr.placeholder"
877
904
  :label="labelData"
905
+ :label-align="labelAlign"
906
+ :input-align="attr.inputAlign ? attr.inputAlign : 'left'"
878
907
  :rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
879
908
  @click="showTimePicker = true"
880
909
  />
@@ -885,7 +914,7 @@ function onPickerCancel() {
885
914
  :columns-type="attr.columnsType ? attr.columnsType : ['hour', 'minute', 'second']"
886
915
  :min-time="attr.minTime ? attr.minTime : '00:00:00'"
887
916
  :max-time="attr.maxTime ? attr.maxTime : '23:59:59'"
888
- :readonly="attr.readonly ? attr.readonly : false"
917
+ :readonly="readonly"
889
918
  @cancel="showTimePicker = false"
890
919
  @confirm="onTimePickerConfirm"
891
920
  />
@@ -900,6 +929,8 @@ function onPickerCancel() {
900
929
  is-link
901
930
  readonly
902
931
  :label="labelData"
932
+ :label-align="labelAlign"
933
+ :input-align="attr.inputAlign ? attr.inputAlign : 'left'"
903
934
  :rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
904
935
  @click="readonly ? null : showArea = true"
905
936
  />
@@ -931,9 +962,11 @@ function onPickerCancel() {
931
962
  rows="3"
932
963
  autosize
933
964
  :label="labelData"
965
+ :label-align="labelAlign"
966
+ :input-align="attr.inputAlign ? attr.inputAlign : 'left'"
934
967
  type="textarea"
935
968
  :readonly="readonly"
936
- :maxlength="attr.maxlength"
969
+ :maxlength="attr.maxlength ? attr.maxlength : 200"
937
970
  :placeholder="attr.placeholder ? attr.placeholder : `请输入${attr.name}`"
938
971
  show-word-limit
939
972
  label-align="top"
@@ -945,6 +978,8 @@ function onPickerCancel() {
945
978
  v-if="(attr.type === 'input' || attr.type === 'intervalPicker') && showItem"
946
979
  v-model="(localValue as string)"
947
980
  :label="labelData"
981
+ :label-align="labelAlign"
982
+ :input-align="attr.inputAlign ? attr.inputAlign : 'left'"
948
983
  :type="attr.type"
949
984
  :readonly="readonly"
950
985
  :disabled="attr.disabled"