easybill-ui 1.0.0 → 1.0.2
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/components/CurdForm/src/CurdForm.vue +3 -0
- package/components/CurdForm/src/components/schema-form-input.vue +1 -1
- package/components/CurdForm/src/types.ts +16 -10
- package/components/CurdTable/src/CurdTable.vue +3 -1
- package/components/CurdTable/src/types.ts +1 -1
- package/components/DetailInfo/src/types.ts +1 -1
- package/components/TableFilter/src/FilterExternal/FilterExternal.vue +4 -3
- package/components/TableFilter/src/TableFilter.vue +8 -1
- package/components/TableFilter/types.ts +6 -0
- package/package.json +2 -2
|
@@ -121,6 +121,9 @@ export default defineComponent({
|
|
|
121
121
|
|
|
122
122
|
// 生成表单验证规则
|
|
123
123
|
const rules = computed(() => {
|
|
124
|
+
if (typeof sFormSchema.value.rules == "function") {
|
|
125
|
+
return sFormSchema.value.rules(formModel, curdFormContext)
|
|
126
|
+
}
|
|
124
127
|
if (typeof sFormSchema.value.getRules == "function") {
|
|
125
128
|
return sFormSchema.value.getRules(formModel, curdFormContext)
|
|
126
129
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<el-input v-model="model" v-trim :disabled="formItem.disabled || false" v-bind="props" :placeholder="(props.placeholder && String(props.placeholder)) || '请输入' + formItem.label" autocomplete="new-password" v-on="eventObject" />
|
|
2
|
+
<el-input v-model="model" v-trim :disabled="formItem.disabled || false" v-bind="props" :placeholder="(props.placeholder && String(props.placeholder)) || '请输入' + (props.label || formItem.label)" autocomplete="new-password" v-on="eventObject" />
|
|
3
3
|
</template>
|
|
4
4
|
<script lang="ts">
|
|
5
5
|
import { defineComponent, computed } from "vue"
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import { FormRules, FormItemRule,
|
|
1
|
+
import { FormRules, FormItemRule, ElForm, TooltipTriggerType } from "element-plus"
|
|
2
|
+
import type { Arrayable } from "element-plus/es/utils"
|
|
2
3
|
import { PropType } from "vue"
|
|
3
4
|
import { OptionItem } from "../../ConstantStatus"
|
|
4
5
|
import { defineComponent } from "vue"
|
|
5
|
-
export interface FormSchema
|
|
6
|
+
export interface FormSchema {
|
|
6
7
|
formItem: FormItem[]
|
|
7
|
-
rules?: FormRules
|
|
8
|
+
rules?: FormRules | ((formModel: Fields, context: FormContext) => FormRules)
|
|
8
9
|
getRules?: (formModel: Fields, context: FormContext) => FormRules
|
|
9
|
-
labelPosition?:
|
|
10
|
+
labelPosition?: "left" | "right" | "top" | string
|
|
10
11
|
gutter?: number
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
labelWidth?: number | string
|
|
13
|
+
inline?: boolean
|
|
14
|
+
inlineMessage?: boolean
|
|
15
|
+
statusIcon?: boolean
|
|
16
|
+
showMessage?: boolean
|
|
17
|
+
size?: "default" | "small" | "large" | string
|
|
18
|
+
disabled?: boolean
|
|
19
|
+
validateOnRuleChange?: boolean
|
|
20
|
+
hideRequiredAsterisk?: boolean
|
|
21
|
+
scrollToError?: boolean
|
|
16
22
|
}
|
|
17
23
|
export interface FormItem {
|
|
18
24
|
prop: string
|
|
@@ -24,7 +30,7 @@ export interface FormItem {
|
|
|
24
30
|
asyncOptions?: (modelRef: Fields, formItem: any, context: FormContext, config?: any) => Promise<Array<CurdFormOptionItem>>
|
|
25
31
|
loading?: boolean
|
|
26
32
|
hidden?: boolean | ((model: Fields) => boolean)
|
|
27
|
-
rules?: FormItemRule
|
|
33
|
+
rules?: Arrayable<FormItemRule>
|
|
28
34
|
props?: FormItemPropObject | ((formModel: Fields, formItem: any) => FormItemPropObject)
|
|
29
35
|
formItemProps?: FormItemPropObject | ((formModel: Fields, formItem: any) => void)
|
|
30
36
|
labelWidth?: string | number
|
|
@@ -366,7 +366,9 @@ const create = (row?: any) => {
|
|
|
366
366
|
if (rules) {
|
|
367
367
|
let rulesItem: FormItemRule[] = []
|
|
368
368
|
if (!formSchema.rules) formSchema.rules = {}
|
|
369
|
-
formSchema.rules
|
|
369
|
+
if (typeof formSchema.rules !== "function") {
|
|
370
|
+
formSchema.rules[item.prop] = rules
|
|
371
|
+
}
|
|
370
372
|
}
|
|
371
373
|
}
|
|
372
374
|
columns.value.map((a) => {
|
|
@@ -112,7 +112,7 @@ export interface PropOption {
|
|
|
112
112
|
customActivatedFetch: boolean // 自定义执行onActivated内部的fetch执行,完全交由父组件控制
|
|
113
113
|
autoload: boolean
|
|
114
114
|
menuEvent: Partial<Record<MenuEventKey, () => void>>
|
|
115
|
-
filterAttrs: Partial<
|
|
115
|
+
filterAttrs: Partial<FormSchema>
|
|
116
116
|
formAttrs: FormAttrs
|
|
117
117
|
editOptions: FormDialogOptions
|
|
118
118
|
createOptions: FormDialogOptions
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<CurdForm ref="formRef" v-model="query" inline class="filter-external" :form-schema="formSchema" @change="onChange">
|
|
2
|
+
<CurdForm ref="formRef" v-model="query" inline class="filter-external" :form-schema="formSchema" v-bind="option?.formProps" @change="onChange">
|
|
3
3
|
<template #defaultFilter>
|
|
4
4
|
<slot></slot>
|
|
5
5
|
</template>
|
|
6
6
|
</CurdForm>
|
|
7
7
|
</template>
|
|
8
8
|
<script lang="ts" setup>
|
|
9
|
-
import { ref, watch, PropType } from "vue"
|
|
9
|
+
import { ref, watch, PropType, inject } from "vue"
|
|
10
10
|
import CurdForm from "../../../CurdForm"
|
|
11
|
-
import { ParamsItem, ListQuery } from "../../types"
|
|
11
|
+
import { ParamsItem, ListQuery, FilterOption } from "../../types"
|
|
12
12
|
import { Fields, FormSchema, FormItem } from "../../../CurdForm"
|
|
13
13
|
const props = defineProps({
|
|
14
14
|
selectParams: {
|
|
@@ -28,6 +28,7 @@ const props = defineProps({
|
|
|
28
28
|
default: false,
|
|
29
29
|
},
|
|
30
30
|
})
|
|
31
|
+
const option = inject<FilterOption>("option")
|
|
31
32
|
const query = ref<any>({})
|
|
32
33
|
// 特殊处理数组
|
|
33
34
|
const formItemLeft = props.selectParams.filter((a) => a.external === true || a.external === "left").sort((a, b) => parseInt(String(b.sortIndex || 0)) - parseInt(String(a.sortIndex || 0))) as FormItem[]
|
|
@@ -51,6 +51,10 @@ const props = defineProps({
|
|
|
51
51
|
type: Object as PropType<I.ListQuery>,
|
|
52
52
|
default: undefined,
|
|
53
53
|
},
|
|
54
|
+
option: {
|
|
55
|
+
type: Object as PropType<Partial<I.FilterOption>>,
|
|
56
|
+
default: undefined,
|
|
57
|
+
},
|
|
54
58
|
})
|
|
55
59
|
const emit = defineEmits(["search"])
|
|
56
60
|
const searchRef = ref()
|
|
@@ -174,7 +178,9 @@ const clear = () => {
|
|
|
174
178
|
}
|
|
175
179
|
// 重新调用selectParams
|
|
176
180
|
const refreshSelectParams = () => {
|
|
177
|
-
|
|
181
|
+
if (props.schema) {
|
|
182
|
+
selectParams.value = deepClone(props.schema)
|
|
183
|
+
}
|
|
178
184
|
}
|
|
179
185
|
const getCurrentIndex = () => {
|
|
180
186
|
return searchRef.value && searchRef.value.currentIndex
|
|
@@ -195,6 +201,7 @@ provide("tableFilter", tableFilterContext)
|
|
|
195
201
|
provide("state", state)
|
|
196
202
|
provide("selectList", selectList)
|
|
197
203
|
provide("selectParams", selectParams)
|
|
204
|
+
provide("option", props.option)
|
|
198
205
|
defineExpose({ setItem, selectList, loadOptions, clear, refreshSelectParams, getCurrentIndex, listQuery, selectParams })
|
|
199
206
|
onMounted(() => {
|
|
200
207
|
getTags()
|
|
@@ -17,3 +17,9 @@ export interface TableFilterContext {
|
|
|
17
17
|
export interface ListQuery {
|
|
18
18
|
[key: string]: any //string | boolean | number | Array<string> | Array<number>
|
|
19
19
|
}
|
|
20
|
+
export interface FilterOption {
|
|
21
|
+
formProps: {
|
|
22
|
+
labelWidth?: string | number
|
|
23
|
+
labelPosition?: "left" | "right" | "center" | string
|
|
24
|
+
}
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easybill-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A component library for easybill",
|
|
5
5
|
"author": "tuchongyang <779311998@qq.com>",
|
|
6
6
|
"private": false,
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
"publishConfig": {
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "6dc20c198be9f3d1c7fde6c788e141eca4146c17"
|
|
18
18
|
}
|