af-mobile-client-vue3 1.0.69 → 1.0.70

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "af-mobile-client-vue3",
3
3
  "type": "module",
4
- "version": "1.0.69",
4
+ "version": "1.0.70",
5
5
  "description": "Vue + Vite component lib",
6
6
  "license": "MIT",
7
7
  "engines": {
@@ -120,7 +120,7 @@ const resultLabel = computed(()=>{
120
120
  :border="false"
121
121
  :is-link="$attrs.disabled === undefined"
122
122
  error-message-align="right"
123
- @click="showPopu($attrs.disabled)"
123
+ @click="showPopu($attrs.readonly)"
124
124
  />
125
125
  <VanPopup v-model:show="show" position="bottom">
126
126
  <div class="van-picker__toolbar">
@@ -75,12 +75,11 @@ function cancel(val, index) {
75
75
  emits('cancel', val, index, resultValue.value)
76
76
  }
77
77
  function showPopu(disabled) {
78
- columnsData.value = JSON.parse(JSON.stringify(props.columns))
79
78
  // resultValue.value = `${selectValue}`
80
79
  if (disabled !== undefined && disabled !== false)
81
80
  return false
82
- else
83
- show.value = !show.value
81
+ columnsData.value = JSON.parse(JSON.stringify(props.columns))
82
+ show.value = !show.value
84
83
  }
85
84
 
86
85
  // watch(() => selectValue, (newVal, _oldVal) => {
@@ -101,7 +100,7 @@ watch(() => resultValue, (newVal, _oldVal) => {
101
100
  :is-link="true"
102
101
  :border="props.border"
103
102
  error-message-align="right"
104
- @click="showPopu($attrs.disabled)"
103
+ @click="showPopu($attrs.readonly)"
105
104
  />
106
105
  <VanPopup v-model:show="show" position="bottom">
107
106
  <VanField v-if="props.isSearch" v-model="searchVal" input-align="left" placeholder="搜索" @input="search" />
@@ -1,147 +1,147 @@
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, reactive, ref, defineEmits, defineProps, onBeforeMount, watch} from 'vue'
9
- import XFormItem from '@af-mobile-client-vue3/components/data/XFormItem/index.vue'
10
- import { useRoute } from 'vue-router'
11
-
12
- interface FormItem {
13
- addOrEdit: string
14
- isOnlyAddOrEdit?: boolean
15
- type?: string
16
- model?: string
17
- }
18
- const props = withDefaults(defineProps<{
19
- groupFormItems?: object,
20
- serviceName?: string,
21
- formData?: object,
22
- formName?: string
23
- }>(), {
24
- groupFormItems: null,
25
- serviceName: undefined,
26
- formData: null,
27
- formName: 'default'
28
- })
29
- const route = useRoute()
30
- const emits = defineEmits(['onSubmit'])
31
- const formRef = ref<FormInstance>()
32
- const myFormItems = ref<FormItem[]>([])
33
- const rules = reactive({})
34
- const form = ref({})
35
- const formGroupName = ref(null)
36
- const myServiceName = ref('')
37
- const loaded = ref(false)
38
- let myGetDataParams = reactive({})
39
- const mode = route.query.mode as string
40
- const realJsonData = computed(() => {
41
- let list = myFormItems.value.filter(item => {
42
- return item.addOrEdit !== 'no'
43
- })
44
- return list
45
- })
46
- onBeforeMount( () => {
47
- init({ formItems: props.groupFormItems, serviceName:props.serviceName, formData: props.formData, formName:props.formName })
48
- })
49
- function init(params) {
50
- const {
51
- formItems,
52
- serviceName,
53
- getDataParams = {},
54
- formData = null,
55
- formName = 'default'
56
- } = params
57
- loaded.value = false
58
- myFormItems.value = JSON.parse(JSON.stringify(formItems.formJson)) as FormItem[]
59
- myServiceName.value = serviceName
60
- formGroupName.value = formName
61
- for (let i = 0; i < realJsonData.value.length; i++) {
62
- const item = realJsonData.value[i]
63
- setFormProps(form, item)
64
- }
65
- if(formData){
66
- form.value = formData
67
- }
68
- myGetDataParams = getDataParams
69
- loaded.value = true
70
- }
71
-
72
- function setFormProps(form, item) {
73
- form.value[item.model] = undefined
74
- if (item.rule) {
75
- rules[item.model] = []
76
- let defaultValue
77
- let message
78
- switch (item.rule.type) {
79
- case 'number':
80
- message = '数字'
81
- defaultValue = 0
82
- break
83
- case 'integer':
84
- message = '整数'
85
- defaultValue = 0
86
- break
87
- case 'float':
88
- message = '小数'
89
- defaultValue = 0.0
90
- break
91
- case 'string':
92
- message = '字符串'
93
- defaultValue = ''
94
- break
95
- }
96
- rules[item.model].push({
97
- type: item.rule.type,
98
- message: `${item.name}必须为${message}`,
99
- transform: (value) => {
100
- if (value && value.length !== 0)
101
- return Number(value)
102
- else
103
- return defaultValue
104
- },
105
- trigger: 'blur',
106
- })
107
- }
108
- }
109
-
110
- function onSubmit() {
111
- emits('onSubmit', form.value)
112
- }
113
- async function validate() {
114
- await formRef.value?.validate()
115
- }
116
- watch(()=>props.formData, (val)=>{
117
- form.value = props.formData
118
- })
119
- defineExpose({ init, form, formGroupName, validate })
120
- </script>
121
-
122
- <template>
123
- <VanForm @submit="onSubmit" ref="formRef">
124
- <VanCellGroup inset>
125
- <XFormItem
126
- :mode="mode"
127
- v-for="(item, index) in realJsonData"
128
- :key="index"
129
- v-model="form[item.model]"
130
- :attr="item"
131
- :rules="rules"
132
- :service-name="myServiceName"
133
- :get-data-params="myGetDataParams"
134
- />
135
- </VanCellGroup>
136
- <div style="margin: 16px;" v-if="myFormItems.showSubmitBtn">
137
- <VanButton round block type="primary" native-type="submit">
138
- 提交 {{myFormItems.showSubmitBtn}}
139
- </VanButton>
140
- <slot />
141
- </div>
142
- </VanForm>
143
- </template>
144
-
145
- <style scoped>
146
-
147
- </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, reactive, ref, defineEmits, defineProps, onBeforeMount, watch} from 'vue'
9
+ import XFormItem from '@af-mobile-client-vue3/components/data/XFormItem/index.vue'
10
+ import { useRoute } from 'vue-router'
11
+
12
+ interface FormItem {
13
+ addOrEdit: string
14
+ isOnlyAddOrEdit?: boolean
15
+ type?: string
16
+ model?: string
17
+ }
18
+ const props = withDefaults(defineProps<{
19
+ groupFormItems?: object,
20
+ serviceName?: string,
21
+ formData?: object,
22
+ formName?: string
23
+ }>(), {
24
+ groupFormItems: null,
25
+ serviceName: undefined,
26
+ formData: null,
27
+ formName: 'default'
28
+ })
29
+ const route = useRoute()
30
+ const emits = defineEmits(['onSubmit'])
31
+ const formRef = ref<FormInstance>()
32
+ const myFormItems = ref<FormItem[]>([])
33
+ const rules = reactive({})
34
+ const form = ref({})
35
+ const formGroupName = ref(null)
36
+ const myServiceName = ref('')
37
+ const loaded = ref(false)
38
+ let myGetDataParams = reactive({})
39
+ const mode = route.query.mode as string
40
+ const realJsonData = computed(() => {
41
+ let list = myFormItems.value.filter(item => {
42
+ return item.addOrEdit !== 'no'
43
+ })
44
+ return list
45
+ })
46
+ onBeforeMount( () => {
47
+ init({ formItems: props.groupFormItems, serviceName:props.serviceName, formData: props.formData, formName:props.formName })
48
+ })
49
+ function init(params) {
50
+ const {
51
+ formItems,
52
+ serviceName,
53
+ getDataParams = {},
54
+ formData = null,
55
+ formName = 'default'
56
+ } = params
57
+ loaded.value = false
58
+ myFormItems.value = JSON.parse(JSON.stringify(formItems.formJson)) as FormItem[]
59
+ myServiceName.value = serviceName
60
+ formGroupName.value = formName
61
+ for (let i = 0; i < realJsonData.value.length; i++) {
62
+ const item = realJsonData.value[i]
63
+ setFormProps(form, item)
64
+ }
65
+ if(formData){
66
+ form.value = formData
67
+ }
68
+ myGetDataParams = getDataParams
69
+ loaded.value = true
70
+ }
71
+
72
+ function setFormProps(form, item) {
73
+ form.value[item.model] = undefined
74
+ if (item.rule) {
75
+ rules[item.model] = []
76
+ let defaultValue
77
+ let message
78
+ switch (item.rule.type) {
79
+ case 'number':
80
+ message = '数字'
81
+ defaultValue = 0
82
+ break
83
+ case 'integer':
84
+ message = '整数'
85
+ defaultValue = 0
86
+ break
87
+ case 'float':
88
+ message = '小数'
89
+ defaultValue = 0.0
90
+ break
91
+ case 'string':
92
+ message = '字符串'
93
+ defaultValue = ''
94
+ break
95
+ }
96
+ rules[item.model].push({
97
+ type: item.rule.type,
98
+ message: `${item.name}必须为${message}`,
99
+ transform: (value) => {
100
+ if (value && value.length !== 0)
101
+ return Number(value)
102
+ else
103
+ return defaultValue
104
+ },
105
+ trigger: 'blur',
106
+ })
107
+ }
108
+ }
109
+
110
+ function onSubmit() {
111
+ emits('onSubmit', form.value)
112
+ }
113
+ async function validate() {
114
+ await formRef.value?.validate()
115
+ }
116
+ watch(()=>props.formData, (val)=>{
117
+ form.value = props.formData
118
+ })
119
+ defineExpose({ init, form, formGroupName, validate })
120
+ </script>
121
+
122
+ <template>
123
+ <VanForm @submit="onSubmit" ref="formRef">
124
+ <VanCellGroup inset>
125
+ <XFormItem
126
+ :mode="mode"
127
+ v-for="(item, index) in realJsonData"
128
+ :key="index"
129
+ v-model="form[item.model]"
130
+ :attr="item"
131
+ :rules="rules"
132
+ :service-name="myServiceName"
133
+ :get-data-params="myGetDataParams"
134
+ />
135
+ </VanCellGroup>
136
+ <div style="margin: 16px;" v-if="!groupFormItems.showSubmitBtn || groupFormItems.showSubmitBtn===undefined ? true : false">
137
+ <VanButton round block type="primary" native-type="submit">
138
+ 提交
139
+ </VanButton>
140
+ <slot />
141
+ </div>
142
+ </VanForm>
143
+ </template>
144
+
145
+ <style scoped>
146
+
147
+ </style>
@@ -14,11 +14,13 @@ import {getConfigByName, query} from '@af-mobile-client-vue3/services/api/common
14
14
  const props = withDefaults(defineProps<{
15
15
  configName?: string
16
16
  serviceName?: string,
17
- groupFormData?: object
17
+ groupFormData?: object,
18
+ showSubmit: boolean
18
19
  }>(), {
19
20
  configName: '',
20
21
  serviceName: undefined,
21
- groupFormData: {}
22
+ groupFormData: {},
23
+ showSubmit: true
22
24
  })
23
25
  const emit = defineEmits(['submit'])
24
26
  const router = useRouter()
@@ -60,7 +62,7 @@ const submit = async () => {
60
62
  </div>
61
63
  </VanTab>
62
64
  </VanTabs>
63
- <VanButton round block type="primary" @click="submit">
65
+ <VanButton round block type="primary" @click="submit" v-if="showSubmit">
64
66
  提交
65
67
  </VanButton>
66
68
  </div>
@@ -68,6 +70,7 @@ const submit = async () => {
68
70
  <style scoped lang="less">
69
71
  #x-form-group{
70
72
  background-color: rgb(247,248,250);
73
+ padding-bottom: 10px;
71
74
  .x-form-group-item{
72
75
  margin:20px 0;
73
76
  }
@@ -140,6 +140,16 @@ onBeforeMount(() => {
140
140
  const labelData = computed(()=>{
141
141
  return props.showLabel?attr.name:null
142
142
  })
143
+ const readonly = computed(()=>{
144
+ return attr.addOrEdit === 'readonly'
145
+ })
146
+ const placeholder = computed(()=>{
147
+ if (attr.addOrEdit === 'readonly') {
148
+ return ' 暂无内容 ~ '
149
+ }else{
150
+ return attr.placeholder ? attr.placeholder : `请选择${attr.name}`
151
+ }
152
+ })
143
153
  const formatDate = date => `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`
144
154
 
145
155
  function onCalendarConfirm(values) {
@@ -168,7 +178,7 @@ function init() {
168
178
  }
169
179
 
170
180
  function initRadioValue() {
171
- if (mode === '新增/修改' && attr.type === 'radio' && !localValue.value) {
181
+ if ((mode === '新增' || mode === '修改') && attr.type === 'radio' && !localValue.value) {
172
182
  if (attr.keys && attr.keys.length > 0)
173
183
  localValue.value = attr.keys[0].value
174
184
  else if (option && option.value.length > 0)
@@ -266,7 +276,7 @@ function updateFile(files, _index) {
266
276
  :rules="[{ required: attr.rule.required === 'true', message: '至少选择一项' }]"
267
277
  >
268
278
  <template #input>
269
- <van-checkbox-group v-model="localValue as any[]" direction="horizontal" shape="square">
279
+ <van-checkbox-group v-model="localValue as any[]" direction="horizontal" shape="square" :disabled="readonly">
270
280
  <VanCheckbox v-for="(item, index) in option" :key="index" style="padding: 2px" :name="item[columnsField.value]" :shape="rules?.[attr.model].shape" :value="item[columnsField.value]">
271
281
  {{ item[columnsField.text] }}
272
282
  </VanCheckbox>
@@ -292,7 +302,8 @@ function updateFile(files, _index) {
292
302
  v-else
293
303
  :label="labelData"
294
304
  v-model="localValue"
295
- :placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
305
+ :readonly="readonly"
306
+ :placeholder="placeholder"
296
307
  :columns="option"
297
308
  :option="attr.option ? attr.option : columnsField"
298
309
  :rules="[{ required: attr.rule.required === 'true', message: '至少选择一项' }]"
@@ -308,7 +319,7 @@ function updateFile(files, _index) {
308
319
  :rules="[{ required: attr.rule.required === 'true', message: '必须选择一项' }]"
309
320
  >
310
321
  <template #input>
311
- <VanRadioGroup v-model="localValue" direction="horizontal">
322
+ <VanRadioGroup v-model="localValue" direction="horizontal" :disabled="readonly">
312
323
  <VanRadio v-for="(item, index) in option" :key="index" style="padding: 2px" :name="item[columnsField.value]" :value="item[columnsField.value]">
313
324
  {{ item[columnsField.text] }}
314
325
  </VanRadio>
@@ -337,6 +348,7 @@ function updateFile(files, _index) {
337
348
  v-if="attr.type === 'stepper'"
338
349
  name="stepper"
339
350
  :label="labelData"
351
+ :readonly="readonly"
340
352
  :rules="[{ required: attr.rule.required === 'true', message: `未调整${attr.name}` }]"
341
353
  >
342
354
  <template #input>
@@ -349,6 +361,7 @@ function updateFile(files, _index) {
349
361
  v-if="attr.type === 'rate'"
350
362
  name="rate"
351
363
  :label="labelData"
364
+ :readonly="readonly"
352
365
  :rules="[{ required: attr.rule.required === 'true', message: `未进行${attr.name}评分` }]"
353
366
  >
354
367
  <template #input>
@@ -361,6 +374,7 @@ function updateFile(files, _index) {
361
374
  v-if="attr.type === 'slider'"
362
375
  name="slider"
363
376
  :label="labelData"
377
+ :readonly="readonly"
364
378
  :rules="[{ required: attr.rule.required === 'true', message: `未移动${attr.name}滑块` }]"
365
379
  >
366
380
  <template #input>
@@ -393,6 +407,7 @@ function updateFile(files, _index) {
393
407
  name="picker"
394
408
  :placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
395
409
  :label="labelData" readonly
410
+ :readonly="readonly"
396
411
  is-link
397
412
  @click="showPicker = true"
398
413
  :rules="[{ required: attr.rule.required === 'true', message: `未选择${attr.name}` }]"
@@ -402,7 +417,7 @@ function updateFile(files, _index) {
402
417
  v-model="localValue as Numeric[]"
403
418
  :title="attr.name"
404
419
  :columns="attr.selectKey"
405
- :readonly="attr.readonly"
420
+ :readonly="readonly"
406
421
  :columns-field-names="attr.customFieldName ? attr.customFieldName : { text: 'text', value: 'value', children: 'children' }"
407
422
  :confirm-button-text="attr.confirmButtonText || attr.confirmButtonText === '' ? attr.confirmButtonText : '确认'"
408
423
  :cancel-button-text="attr.cancelButtonText || attr.cancelButtonText === '' ? attr.cancelButtonText : '取消'"
@@ -440,8 +455,8 @@ function updateFile(files, _index) {
440
455
  :label="labelData"
441
456
  readonly
442
457
  :is-link="true"
443
- :placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
444
- @click="showDatePicker = true"
458
+ :placeholder="placeholder"
459
+ @click="readonly ? null: showDatePicker = true"
445
460
  :rules="[{ required: attr.rule.required === 'true', message: '未选择日期' }]"
446
461
  />
447
462
  <VanPopup v-model:show="showDatePicker" position="bottom" teleport="body">
@@ -452,7 +467,6 @@ function updateFile(files, _index) {
452
467
  :confirm-button-text="attr.confirmButtonText ? attr.confirmButtonText : '确认'"
453
468
  :cancel-button-text="attr.cancelButtonText ? attr.cancelButtonText : '取消'"
454
469
  :columns-type="attr.columnsType ? attr.columnsType : ['year', 'month', 'day']"
455
- :readonly="attr.readonly ? attr.readonly : false"
456
470
  @cancel="showDatePicker = false"
457
471
  @confirm="onDatePickerConfirm"
458
472
  />
@@ -518,7 +532,7 @@ function updateFile(files, _index) {
518
532
  is-link
519
533
  readonly
520
534
  :label="labelData"
521
- @click="showArea = true"
535
+ @click="readonly ? null : showArea = true"
522
536
  :rules="[{ required: attr.rule.required === 'true', message: '未选择地区' }]"
523
537
  />
524
538
  <VanPopup v-model:show="showArea" position="bottom" teleport="body">
@@ -532,10 +546,11 @@ function updateFile(files, _index) {
532
546
  <!-- 单选下拉列表 -->
533
547
  <XSelect
534
548
  v-if="attr.type === 'select'"
535
- v-model="localValue"
536
549
  :label="labelData"
550
+ v-model="localValue"
551
+ :readonly="readonly"
537
552
  clearable
538
- :placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
553
+ :placeholder="placeholder"
539
554
  :columns="option"
540
555
  :option="attr.option ? attr.option : columnsField"
541
556
  :rules="[{ required: attr.rule.required === 'true', message: '必须选择一项' }]"
@@ -550,6 +565,7 @@ function updateFile(files, _index) {
550
565
  autosize
551
566
  :label="labelData"
552
567
  type="textarea"
568
+ :readonly="readonly"
553
569
  :maxlength="attr.maxlength"
554
570
  :placeholder="attr.placeholder ? attr.placeholder : `请输入${attr.name}`"
555
571
  show-word-limit
@@ -564,9 +580,9 @@ function updateFile(files, _index) {
564
580
  :label="labelData"
565
581
  :required="attr.required"
566
582
  :type="attr.type"
567
- :readonly="attr.readonly"
583
+ :readonly="readonly"
568
584
  :disabled="attr.disabled"
569
- :placeholder="attr.placeholder ? attr.placeholder : `请输入${attr.name}`"
585
+ :placeholder="placeholder"
570
586
  :error-message="attr.errorMessage"
571
587
  :clearable="attr.clearable"
572
588
  :rules="[{ required: attr.rule.required === 'true', message: `必须填写${attr.name}` }]"
@@ -30,7 +30,7 @@ function toDetail(item) {
30
30
  console.log('item=====',item)
31
31
  router.push({
32
32
  name:'XFormView',
33
- params:{id: item.ao_id,openid: 1},
33
+ params:{id: item.od_id,openid: 1},
34
34
  query:{formConfigName: configName, formServiceName: serviceName ,mode:'新增'},
35
35
  })
36
36
  }
@@ -1,24 +1,19 @@
1
1
  <script setup lang="ts">
2
- import {
3
- Tabs as VanTabs,
4
- Tab as VanTab,
5
- Row as VanRow,
6
- Button as VanButton
7
- } from 'vant'
8
- import { defineProps, watchEffect, onBeforeMount, ref, onMounted, watch, defineEmits } from 'vue'
2
+ import { onBeforeMount, ref } from 'vue'
9
3
  import { useUserStore } from '@af-mobile-client-vue3/stores/modules/user'
10
4
  import XFormGroup from '@af-mobile-client-vue3/components/data/XFormGroup/index.vue'
11
5
  import NormalDataLayout from '@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue'
12
6
  import { runLogic } from '@af-mobile-client-vue3/services/api/common'
13
- import { useRoute } from 'vue-router'
7
+ import {useRoute, useRouter} from 'vue-router'
14
8
  import { formatDate } from '@af-mobile-client-vue3/hooks/useCommon'
15
- import {getConfigByName, query} from '@af-mobile-client-vue3/services/api/common'
9
+ import {showSuccessToast} from "vant";
16
10
 
17
- const router = useRoute()
11
+ const route = useRoute()
12
+ const router = useRouter()
18
13
  const formData = ref({})
19
14
  function initComponents () {
20
- console.log('router.params=', router.params)
21
- runLogic('getLngPurchaseOrderAuditGroupData', {id: router.params?.id}, 'af-gaslink').then((res) => {
15
+ console.log('router.params=', route.params)
16
+ runLogic('getLngPurchaseOrderAuditGroupData', {id: route.params?.id}, 'af-gaslink').then((res) => {
22
17
  console.log('调用logic完成==',res)
23
18
  formData.value = {...res}
24
19
  console.log('赋值完成===', formData.value)
@@ -42,6 +37,8 @@ const submit = (formData) => {
42
37
  console.log('param===', param)
43
38
  runLogic('lngPurchaseOrderAuditSubmit', param, 'af-gaslink').then((res) => {
44
39
  console.log('res===', res)
40
+ showSuccessToast('审核成功!')
41
+ router.go(-1)
45
42
  })
46
43
  }
47
44
  </script>