af-mobile-client-vue3 1.0.70 → 1.0.72

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,230 +1,241 @@
1
- <script setup lang="ts">
2
- import {defineEmits, defineModel, defineProps, onMounted, ref, watch} from 'vue'
3
- import {
4
- Button as VanButton,
5
- Col as VanCol,
6
- DropdownItem as VanDropdownItem,
7
- DropdownMenu as VanDropdownMenu,
8
- Icon as VanIcon,
9
- Row as VanRow,
10
- showFailToast,
11
- } from 'vant'
12
- import XGridDropOption from '@af-mobile-client-vue3/components/core/XGridDropOption/index.vue'
13
- import XFormItem from '@af-mobile-client-vue3/components/data/XFormItem/index.vue'
14
- const props = defineProps<{
15
- orderVal?: string
16
- sortordVal?: string
17
- orderList?: any[]
18
- formQuery?: any[]
19
- }>()
20
-
21
- const emit = defineEmits([
22
- 'update:orderVal',
23
- 'update:sortordVal',
24
- 'update:conditionParams',
25
- 'onRefresh',
26
- ])
27
- // 排序字段
28
- const currentOrderVal = defineModel('orderVal')
29
- // 排序规则
30
- const currentSortordVal = defineModel('sortordVal')
31
- // 下拉菜单元素
32
- const listFilterMenu = ref(null)
33
- // 排序规则列表
34
- const sortordList = ref([
35
- { title: '正序', value: 'ascend' },
36
- { title: '倒序', value: 'descend' },
37
- ])
38
- const colFieldNames = {
39
- text: 'title',
40
- value: 'value'
41
- }
42
- // 查询条件参数 !!!!!建议最后点击确认的时候完成这个的整理
43
- const conditionParams = ref({})
44
-
45
- // 重置某个选项
46
- function resetOptionItem(type) {
47
- if(conditionParams.value[type] != undefined){
48
- conditionParams.value[type] = undefined
49
- }
50
- }
51
- // 重置所有选项
52
- function resetOption() {
53
- currentOrderVal.value = undefined
54
- currentSortordVal.value = undefined
55
- // 条件参数
56
- conditionParams.value = {}
57
- }
58
- function checkOrderOption() {
59
- let isCheck = true
60
- if (currentOrderVal.value) {
61
- if (!currentSortordVal.value) {
62
- showFailToast('排序规则不能为空')
63
- isCheck = false
64
- }
65
- }
66
- else if (currentSortordVal.value) {
67
- if (!currentOrderVal.value) {
68
- showFailToast('排序字段不能为空')
69
- isCheck = false
70
- }
71
- }
72
- return isCheck
73
- }
74
- // 确认筛选条件
75
- function confirmOption() {
76
- const isCheck = checkOrderOption()
77
- if (isCheck) {
78
- const isEmptyObject = Object.keys(conditionParams.value).length === 0
79
- emit('update:conditionParams', isEmptyObject ? undefined : conditionParams.value)
80
- emit('onRefresh', {})
81
- listFilterMenu.value.toggle(false)
82
- }
83
- }
84
-
85
- onMounted(() => {
86
- // currentOrderVal.value = props.orderVal
87
- // currentSortordVal.value = props.sortordVal
88
- // disposalData()
89
- })
90
-
91
- </script>
92
-
93
- <template>
94
- <div id="XCellListFilter">
95
- <VanDropdownMenu :close-on-click-outside="false">
96
- <VanDropdownItem ref="listFilterMenu">
97
- <template #title>
98
- <VanIcon name="filter-o" size="20" />
99
- </template>
100
- <div class="order-condition">
101
- <template v-if="props.orderList.length>0">
102
- <VanRow justify="space-between" class="filter-title">
103
- <VanCol span="10">
104
- 排序字段
105
- </VanCol>
106
- <VanCol span="2">
107
- <div class="reset-item" @click.stop="currentOrderVal = undefined">
108
- 重置
109
- </div>
110
- </VanCol>
111
- </VanRow>
112
- <XGridDropOption :columns="props.orderList" :columns-field-names="colFieldNames" v-model="currentOrderVal"/>
113
- <VanRow justify="space-between" class="filter-title">
114
- <VanCol span="10">
115
- 排序规则
116
- </VanCol>
117
- <VanCol span="2">
118
- <div class="reset-item" @click.stop="currentSortordVal = undefined">
119
- 重置
120
- </div>
121
- </VanCol>
122
- </VanRow>
123
- <XGridDropOption :columns="sortordList" :columns-field-names="colFieldNames" v-model="currentSortordVal"/>
124
- </template>
125
- <template v-for="(item, index) in props.formQuery" :key="item.model">
126
- <VanRow justify="space-between" class="filter-title">
127
- <VanCol span="10">
128
- {{ item.name }}
129
- </VanCol>
130
- <VanCol span="2">
131
- <div class="reset-item" @click.stop="resetOptionItem(item.model)">
132
- 重置
133
- </div>
134
- </VanCol>
135
- </VanRow>
136
- <XFormItem :attr="item" v-model="conditionParams[item.model]" :show-label="false"/>
137
- </template>
138
- </div>
139
- <div class="operations-panel">
140
- <VanButton type="default" @click="resetOption">
141
- 重置
142
- </VanButton>
143
- <VanButton type="primary" @click="confirmOption">
144
- 查询
145
- </VanButton>
146
- </div>
147
- </VanDropdownItem>
148
- </VanDropdownMenu>
149
- </div>
150
- </template>
151
-
152
- <style scoped lang="less">
153
- #XCellListFilter {
154
- .order-condition {
155
- // padding-bottom: 10px;
156
- max-height: calc(var(--van-picker-toolbar-height) + var(--van-padding-base) + var(--van-tabs-line-height) + 35vh);
157
- overflow-y: auto;
158
- width: 100%;
159
- background-color: white;
160
- .filter-title {
161
- height: 2rem;
162
- font-size: 13px;
163
- font-weight: 600;
164
- line-height: 2rem;
165
- margin: 5px 1rem 1px 1rem;
166
- color: black;
167
- }
168
- .range-picker-list {
169
- .range-picker-title {
170
- height: 2rem;
171
- font-size: 13px;
172
- font-weight: 600;
173
- line-height: 2rem;
174
- margin: 5px 1rem 1px 1rem;
175
- color: black;
176
- }
177
- .range-picker-time {
178
- display: inline-block;
179
- background: #f8f8f8;
180
- border-radius: 8px;
181
- font-size: 13px;
182
- margin: 0 1rem;
183
- height: 2rem;
184
- line-height: 2rem;
185
- width: 40vw;
186
- text-align: center;
187
- }
188
- /* 已完成选择的时间 */
189
- .active-picker-time {
190
- color: blue;
191
- }
192
- }
193
- /* 重置元素按钮 */
194
- .reset-item {
195
- font-weight: 500;
196
- color: blue;
197
- }
198
- }
199
- /* 下拉菜单的操作面板 */
200
- .operations-panel {
201
- display: flex;
202
- overflow: hidden;
203
- user-select: none;
204
- padding: 10px;
205
-
206
- & > .van-button {
207
- flex: 1;
208
- margin: 0;
209
-
210
- &:first-child {
211
- margin-right: 12px;
212
- }
213
- }
214
- }
215
- /* 时间范围组件 */
216
- .rangePicker-comp-box {
217
- :deep(.van-calendar) {
218
- height: 58vh;
219
- }
220
- :deep(.van-calendar__header-title) {
221
- background-color: rgba(25, 137, 250, 0.1);
222
- height: 8vh;
223
- line-height: 8vh;
224
- }
225
- :deep(.van-calendar__month-mark) {
226
- color: rgba(25, 137, 250, 0.1);
227
- }
228
- }
229
- }
230
- </style>
1
+ <script setup lang="ts">
2
+ import { defineEmits, defineModel, defineProps, onMounted, ref } from 'vue'
3
+ import {
4
+ Button as VanButton,
5
+ Col as VanCol,
6
+ DropdownItem as VanDropdownItem,
7
+ DropdownMenu as VanDropdownMenu,
8
+ Icon as VanIcon,
9
+ Row as VanRow,
10
+ showFailToast,
11
+ } from 'vant'
12
+ import XGridDropOption from '@af-mobile-client-vue3/components/core/XGridDropOption/index.vue'
13
+ import XFormItem from '@af-mobile-client-vue3/components/data/XFormItem/index.vue'
14
+
15
+ const props = defineProps<{
16
+ orderVal?: string
17
+ sortordVal?: string
18
+ orderList?: any[]
19
+ formQuery?: any[]
20
+ buttonState?: any
21
+ }>()
22
+
23
+ const emit = defineEmits([
24
+ 'update:orderVal',
25
+ 'update:sortordVal',
26
+ 'update:conditionParams',
27
+ 'onRefresh',
28
+ 'addOption',
29
+ ])
30
+ // 排序字段
31
+ const currentOrderVal = defineModel('orderVal')
32
+ // 排序规则
33
+ const currentSortordVal = defineModel('sortordVal')
34
+ // 下拉菜单元素
35
+ const listFilterMenu = ref(null)
36
+ // 排序规则列表
37
+ const sortordList = ref([
38
+ { title: '正序', value: 'ascend' },
39
+ { title: '倒序', value: 'descend' },
40
+ ])
41
+ const colFieldNames = {
42
+ text: 'title',
43
+ value: 'value',
44
+ }
45
+
46
+ // 查询条件参数 !!!!!建议最后点击确认的时候完成这个的整理
47
+ const conditionParams = ref({})
48
+
49
+ // 重置某个选项
50
+ function resetOptionItem(type) {
51
+ if (conditionParams.value[type] !== undefined)
52
+ conditionParams.value[type] = undefined
53
+ }
54
+ // 重置所有选项
55
+ function resetOption() {
56
+ currentOrderVal.value = undefined
57
+ currentSortordVal.value = undefined
58
+ // 条件参数
59
+ conditionParams.value = {}
60
+ }
61
+ function checkOrderOption() {
62
+ let isCheck = true
63
+ if (currentOrderVal.value) {
64
+ if (!currentSortordVal.value) {
65
+ showFailToast('排序规则不能为空')
66
+ isCheck = false
67
+ }
68
+ }
69
+ else if (currentSortordVal.value) {
70
+ if (!currentOrderVal.value) {
71
+ showFailToast('排序字段不能为空')
72
+ isCheck = false
73
+ }
74
+ }
75
+ return isCheck
76
+ }
77
+ // 确认筛选条件
78
+ function confirmOption() {
79
+ const isCheck = checkOrderOption()
80
+ if (isCheck) {
81
+ const isEmptyObject = Object.keys(conditionParams.value).length === 0
82
+ emit('update:conditionParams', isEmptyObject ? undefined : conditionParams.value)
83
+ emit('onRefresh', {})
84
+ listFilterMenu.value.toggle(false)
85
+ }
86
+ }
87
+
88
+ // 新增按钮
89
+ function addOption() {
90
+ emit('addOption')
91
+ }
92
+
93
+ onMounted(() => {
94
+ // currentOrderVal.value = props.orderVal
95
+ // currentSortordVal.value = props.sortordVal
96
+ // disposalData()
97
+ })
98
+ </script>
99
+
100
+ <template>
101
+ <div id="XCellListFilter">
102
+ <VanDropdownMenu :close-on-click-outside="false">
103
+ <VanDropdownItem ref="listFilterMenu">
104
+ <template #title>
105
+ <VanIcon name="filter-o" size="20" />
106
+ </template>
107
+ <div class="order-condition">
108
+ <template v-if="props.orderList.length > 0">
109
+ <VanRow justify="space-between" class="filter-title">
110
+ <VanCol span="10">
111
+ 排序字段
112
+ </VanCol>
113
+ <VanCol span="2">
114
+ <div class="reset-item" @click.stop="currentOrderVal = undefined">
115
+ 重置
116
+ </div>
117
+ </VanCol>
118
+ </VanRow>
119
+ <XGridDropOption :columns="props.orderList" :columns-field-names="colFieldNames" />
120
+ <VanRow justify="space-between" class="filter-title">
121
+ <VanCol span="10">
122
+ 排序规则
123
+ </VanCol>
124
+ <VanCol span="2">
125
+ <div class="reset-item" @click.stop="currentSortordVal = undefined">
126
+ 重置
127
+ </div>
128
+ </VanCol>
129
+ </VanRow>
130
+ <XGridDropOption :columns="sortordList" :columns-field-names="colFieldNames" />
131
+ </template>
132
+ <template v-for="(item, index) in props.formQuery" :key="`${item.model}${index}`">
133
+ <VanRow justify="space-between" class="filter-title">
134
+ <VanCol span="10">
135
+ {{ item.name }}
136
+ </VanCol>
137
+ <VanCol span="2">
138
+ <div class="reset-item" @click.stop="resetOptionItem(item.model)">
139
+ 重置
140
+ </div>
141
+ </VanCol>
142
+ </VanRow>
143
+ <XFormItem v-model="conditionParams[item.model]" :form='conditionParams' :attr="item" :show-label="false" />
144
+ </template>
145
+ </div>
146
+ <div class="operations-panel">
147
+ <VanButton type="default" @click="resetOption">
148
+ 重置
149
+ </VanButton>
150
+ <VanButton v-if="props.buttonState.add && props.buttonState.add === true" type="primary" @click="addOption">
151
+ 新增
152
+ </VanButton>
153
+ <VanButton type="primary" @click="confirmOption">
154
+ 查询
155
+ </VanButton>
156
+ </div>
157
+ </VanDropdownItem>
158
+ </VanDropdownMenu>
159
+ </div>
160
+ </template>
161
+
162
+ <style scoped lang="less">
163
+ #XCellListFilter {
164
+ .order-condition {
165
+ // padding-bottom: 10px;
166
+ max-height: calc(var(--van-picker-toolbar-height) + var(--van-padding-base) + var(--van-tabs-line-height) + 35vh);
167
+ overflow-y: auto;
168
+ width: 100%;
169
+ background-color: white;
170
+ .filter-title {
171
+ height: 2rem;
172
+ font-size: 13px;
173
+ font-weight: 600;
174
+ line-height: 2rem;
175
+ margin: 5px 1rem 1px 1rem;
176
+ color: black;
177
+ }
178
+ .range-picker-list {
179
+ .range-picker-title {
180
+ height: 2rem;
181
+ font-size: 13px;
182
+ font-weight: 600;
183
+ line-height: 2rem;
184
+ margin: 5px 1rem 1px 1rem;
185
+ color: black;
186
+ }
187
+ .range-picker-time {
188
+ display: inline-block;
189
+ background: #f8f8f8;
190
+ border-radius: 8px;
191
+ font-size: 13px;
192
+ margin: 0 1rem;
193
+ height: 2rem;
194
+ line-height: 2rem;
195
+ width: 40vw;
196
+ text-align: center;
197
+ }
198
+ /* 已完成选择的时间 */
199
+ .active-picker-time {
200
+ color: blue;
201
+ }
202
+ }
203
+ /* 重置元素按钮 */
204
+ .reset-item {
205
+ font-weight: 500;
206
+ color: blue;
207
+ }
208
+ }
209
+ /* 下拉菜单的操作面板 */
210
+ .operations-panel {
211
+ display: flex;
212
+ overflow: hidden;
213
+ user-select: none;
214
+ padding: 10px;
215
+ gap: 12px;
216
+
217
+ & > .van-button {
218
+ flex: 1;
219
+ margin: 0;
220
+
221
+ //&:first-child {
222
+ // margin-right: 12px;
223
+ //}
224
+ }
225
+ }
226
+ /* 时间范围组件 */
227
+ .rangePicker-comp-box {
228
+ :deep(.van-calendar) {
229
+ height: 58vh;
230
+ }
231
+ :deep(.van-calendar__header-title) {
232
+ background-color: rgba(25, 137, 250, 0.1);
233
+ height: 8vh;
234
+ line-height: 8vh;
235
+ }
236
+ :deep(.van-calendar__month-mark) {
237
+ color: rgba(25, 137, 250, 0.1);
238
+ }
239
+ }
240
+ }
241
+ </style>
@@ -4,10 +4,11 @@ import {
4
4
  CellGroup as VanCellGroup,
5
5
  Form as VanForm,
6
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
7
  import { useRoute } from 'vue-router'
8
+ import type { FormInstance } from 'vant'
9
+ import { computed, defineEmits, defineProps, onBeforeMount, reactive, ref, watch } from 'vue'
10
+ import XFormItem from '@af-mobile-client-vue3/components/data/XFormItem/index.vue'
11
+ import NormalDataLayout from "@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue";
11
12
 
12
13
  interface FormItem {
13
14
  addOrEdit: string
@@ -15,16 +16,25 @@ interface FormItem {
15
16
  type?: string
16
17
  model?: string
17
18
  }
19
+
20
+ interface GroupFormItems {
21
+ btnName?: string
22
+ formJson: any[] // 根据实际类型调整
23
+ }
18
24
  const props = withDefaults(defineProps<{
19
- groupFormItems?: object,
20
- serviceName?: string,
21
- formData?: object,
25
+ groupFormItems?: GroupFormItems
26
+ serviceName?: string
27
+ formData?: object
22
28
  formName?: string
29
+ mode?: string
30
+ submitButton?: boolean
23
31
  }>(), {
24
32
  groupFormItems: null,
25
33
  serviceName: undefined,
26
34
  formData: null,
27
- formName: 'default'
35
+ formName: 'default',
36
+ mode: '查询',
37
+ submitButton: true,
28
38
  })
29
39
  const route = useRoute()
30
40
  const emits = defineEmits(['onSubmit'])
@@ -36,15 +46,13 @@ const formGroupName = ref(null)
36
46
  const myServiceName = ref('')
37
47
  const loaded = ref(false)
38
48
  let myGetDataParams = reactive({})
39
- const mode = route.query.mode as string
40
49
  const realJsonData = computed(() => {
41
- let list = myFormItems.value.filter(item => {
50
+ return myFormItems.value.filter((item) => {
42
51
  return item.addOrEdit !== 'no'
43
52
  })
44
- return list
45
53
  })
46
- onBeforeMount( () => {
47
- init({ formItems: props.groupFormItems, serviceName:props.serviceName, formData: props.formData, formName:props.formName })
54
+ onBeforeMount(() => {
55
+ init({ formItems: props.groupFormItems, serviceName: props.serviceName, formData: props.formData, formName: props.formName })
48
56
  })
49
57
  function init(params) {
50
58
  const {
@@ -52,7 +60,7 @@ function init(params) {
52
60
  serviceName,
53
61
  getDataParams = {},
54
62
  formData = null,
55
- formName = 'default'
63
+ formName = 'default',
56
64
  } = params
57
65
  loaded.value = false
58
66
  myFormItems.value = JSON.parse(JSON.stringify(formItems.formJson)) as FormItem[]
@@ -62,9 +70,9 @@ function init(params) {
62
70
  const item = realJsonData.value[i]
63
71
  setFormProps(form, item)
64
72
  }
65
- if(formData){
73
+ if (formData)
66
74
  form.value = formData
67
- }
75
+
68
76
  myGetDataParams = getDataParams
69
77
  loaded.value = true
70
78
  }
@@ -113,33 +121,35 @@ function onSubmit() {
113
121
  async function validate() {
114
122
  await formRef.value?.validate()
115
123
  }
116
- watch(()=>props.formData, (val)=>{
124
+ watch(() => props.formData, (_val) => {
117
125
  form.value = props.formData
118
126
  })
119
127
  defineExpose({ init, form, formGroupName, validate })
120
128
  </script>
121
129
 
122
130
  <template>
123
- <VanForm @submit="onSubmit" ref="formRef">
131
+ <VanForm ref="formRef" @submit="onSubmit">
124
132
  <VanCellGroup inset>
125
133
  <XFormItem
126
- :mode="mode"
127
134
  v-for="(item, index) in realJsonData"
128
135
  :key="index"
129
136
  v-model="form[item.model]"
137
+ :mode="props.mode"
138
+ :form="form"
130
139
  :attr="item"
131
140
  :rules="rules"
132
141
  :service-name="myServiceName"
133
142
  :get-data-params="myGetDataParams"
134
143
  />
135
144
  </VanCellGroup>
136
- <div style="margin: 16px;" v-if="!groupFormItems.showSubmitBtn || groupFormItems.showSubmitBtn===undefined ? true : false">
145
+ <div v-if="props.submitButton" style="margin: 16px;">
137
146
  <VanButton round block type="primary" native-type="submit">
138
- 提交
147
+ {{ props.groupFormItems?.btnName ? props.groupFormItems.btnName : '提交' }}
139
148
  </VanButton>
140
149
  <slot />
141
150
  </div>
142
151
  </VanForm>
152
+
143
153
  </template>
144
154
 
145
155
  <style scoped>