easybill-ui 0.1.11 → 0.1.12
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.
|
@@ -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
|
return sFormSchema.value.rules
|
|
125
128
|
})
|
|
126
129
|
|
|
@@ -129,16 +132,16 @@ export default defineComponent({
|
|
|
129
132
|
return schemaFormRef.value?.validate(callback)
|
|
130
133
|
}
|
|
131
134
|
// 调用某个表单项的异步数据接口
|
|
132
|
-
const loadOptions = async (prop: string) => {
|
|
135
|
+
const loadOptions = async (prop: string, option?: any) => {
|
|
133
136
|
const cur = sFormSchema.value.formItem.find((a) => a.prop == prop)
|
|
134
137
|
if (cur && cur.asyncOptions) {
|
|
135
138
|
cur.loading = true
|
|
136
139
|
cur.options =
|
|
137
140
|
(await cur
|
|
138
|
-
.asyncOptions(formModel, cur, curdFormContext)
|
|
141
|
+
.asyncOptions(formModel, cur, curdFormContext, option)
|
|
139
142
|
.catch((err) => console.error("loadOptionError", err))
|
|
140
143
|
.finally(() => (cur.loading = false))) || []
|
|
141
|
-
cur.eventObject?.optionLoaded && cur.eventObject?.optionLoaded(formModel, cur, curdFormContext)
|
|
144
|
+
cur.eventObject?.optionLoaded && cur.eventObject?.optionLoaded(formModel, cur, curdFormContext, option)
|
|
142
145
|
}
|
|
143
146
|
return cur
|
|
144
147
|
}
|
|
@@ -4,7 +4,7 @@ import { OptionItem } from "../../ConstantStatus"
|
|
|
4
4
|
import { defineComponent } from "vue"
|
|
5
5
|
export interface FormSchema extends Partial<FormProps> {
|
|
6
6
|
formItem: Array<FormItem>
|
|
7
|
-
rules?: FormRules
|
|
7
|
+
rules?: FormRules | ((formModel: Fields, context: FormContext) => FormRules)
|
|
8
8
|
labelPosition?: "left" | "right" | "top"
|
|
9
9
|
gutter?: number
|
|
10
10
|
}
|
|
@@ -19,7 +19,7 @@ export interface FormItem {
|
|
|
19
19
|
asyncValue?: (modelRef: Fields, formItem: FormItem) => Promise<string | number | boolean>
|
|
20
20
|
loading?: boolean
|
|
21
21
|
hidden?: boolean | ((model: Fields) => boolean)
|
|
22
|
-
rules?: FormItemRule[]
|
|
22
|
+
rules?: FormItemRule[] | ((formModel: Fields, formItem: FormItem, context: FormContext) => FormItemRule[])
|
|
23
23
|
props?: FormItemPropObject | ((formModel: Fields, formItem: FormItem) => void)
|
|
24
24
|
formItemProps?: FormItemPropObject | ((formModel: Fields, formItem: FormItem) => void)
|
|
25
25
|
labelWidth?: string
|
|
@@ -27,8 +27,8 @@ export interface FormItem {
|
|
|
27
27
|
disabled?: boolean
|
|
28
28
|
tooltip?: string | ((formModel: Fields, formItem: FormItem) => Partial<ElTooltipProps>) | Partial<ElTooltipProps>
|
|
29
29
|
autoload?: boolean
|
|
30
|
-
prefix?: string | any
|
|
31
|
-
suffix?: string | any
|
|
30
|
+
prefix?: string | any
|
|
31
|
+
suffix?: string | any
|
|
32
32
|
}
|
|
33
33
|
export type FormItemTypeEmun = "input" | "select" | "radio" | "checkbox" | "input-number" | "switch" | "file" | "date-picker" | "time-picker" | "color-picker" | "value"
|
|
34
34
|
// type FormItemProps = FormItemPropObject | ((formModel: Fields, formItem: FormItem) => void)
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<slot></slot>
|
|
16
16
|
</div>
|
|
17
17
|
<div v-if="!$slots.default" class="detail-info-body" :class="[props.showType]">
|
|
18
|
-
<div class="table-detail-col" v-for="(item, i) in
|
|
18
|
+
<div class="table-detail-col" v-for="(item, i) in list" :key="i" :span="item.span" :style="getItemStyle(item)">
|
|
19
19
|
<div class="item-col">
|
|
20
20
|
<div v-if="item.label" class="label" :style="{ width: getLabelWidth(item), justifyContent: props.labelPosition || item.labelPosition }">
|
|
21
21
|
<span>{{ item.label }}</span>
|
|
@@ -44,7 +44,7 @@ export default {
|
|
|
44
44
|
}
|
|
45
45
|
</script>
|
|
46
46
|
<script lang="ts" setup>
|
|
47
|
-
import { PropType } from "vue"
|
|
47
|
+
import { PropType, computed } from "vue"
|
|
48
48
|
import { ConstantStatus } from "../../ConstantStatus/src"
|
|
49
49
|
import { DetailDataItem } from "./types"
|
|
50
50
|
import DetailInfoTooltip from "./DetailInfoTooltip.vue"
|
|
@@ -73,6 +73,13 @@ const props = defineProps({
|
|
|
73
73
|
default: "left",
|
|
74
74
|
},
|
|
75
75
|
})
|
|
76
|
+
const list = computed(() => {
|
|
77
|
+
return props.data.filter((item) => {
|
|
78
|
+
if (typeof item.hidden == "function") return item.hidden(props.data)
|
|
79
|
+
if (typeof item.hidden != "undefined") return item.hidden
|
|
80
|
+
return true
|
|
81
|
+
})
|
|
82
|
+
})
|
|
76
83
|
const getLabelWidth = (dataItem: DetailDataItem): string => {
|
|
77
84
|
const labelWidth = typeof dataItem.labelWidth !== "undefined" ? dataItem.labelWidth : props.labelWidth
|
|
78
85
|
const isNum = typeof labelWidth == "number" || (typeof labelWidth == "string" && /^\d+$/.test(labelWidth))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easybill-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
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": "f7e0bce894e43c52b951fb1cdc7a240b81bca37a"
|
|
18
18
|
}
|