easybill-ui 1.2.16 → 1.2.18
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 +5 -1
- package/components/CurdForm/src/components/index.ts +2 -0
- package/components/CurdForm/src/components/schema-form-checkbox.vue +2 -2
- package/components/CurdForm/src/components/schema-form-radio.vue +40 -39
- package/components/CurdForm/src/components/schema-form-select-v2.vue +60 -0
- package/components/CurdForm/src/components/schema-form-select.vue +5 -5
- package/components/CurdForm/src/types.ts +12 -5
- package/components/CurdTable/src/CurdTable.vue +2 -2
- package/components/CurdTable/src/STableItem.vue +7 -6
- package/components/CurdTable/src/types.ts +1 -0
- package/components/FormDialog/src/types.ts +1 -1
- package/package.json +2 -2
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
:class="getFormItemStyle(formItem)"
|
|
11
11
|
v-bind="getFormItemProps(formItem)"
|
|
12
12
|
>
|
|
13
|
+
<template v-for="(item, key) in formItem.formItemProps?.slots" :key="key" #[key]="row">
|
|
14
|
+
<component :is="item" v-bind="row" />
|
|
15
|
+
</template>
|
|
16
|
+
|
|
13
17
|
<slot :name="formItem.prop" :form-item="formItem" :form-model="formModel"></slot>
|
|
14
18
|
<FormItem v-if="!(formItem.prop && $slots[formItem.prop])" :form-item="formItem" :form-model="formModel" @change="onChange">
|
|
15
19
|
<template #prefix>
|
|
@@ -175,7 +179,7 @@ const getFormItemProps = (formItem: FormItemType) => {
|
|
|
175
179
|
if (formItem.formItemProps instanceof Function) {
|
|
176
180
|
return formItem.formItemProps(formModel, formItem)
|
|
177
181
|
}
|
|
178
|
-
const { ...attrs } = formItem.formItemProps
|
|
182
|
+
const { slots, ...attrs } = formItem.formItemProps
|
|
179
183
|
return { ...attrs }
|
|
180
184
|
}
|
|
181
185
|
return {}
|
|
@@ -7,6 +7,7 @@ import SchemaFormDatePicker from "./schema-form-date-picker.vue"
|
|
|
7
7
|
import SchemaFormInputNumber from "./schema-form-input-number.vue"
|
|
8
8
|
import SchemaFormInput from "./schema-form-input.vue"
|
|
9
9
|
import SchemaFormRadio from "./schema-form-radio.vue"
|
|
10
|
+
import SchemaFormSelectV2 from "./schema-form-select-v2.vue"
|
|
10
11
|
import SchemaFormSelect from "./schema-form-select.vue"
|
|
11
12
|
import SchemaFormSwitch from "./schema-form-switch.vue"
|
|
12
13
|
import SchemaFormTimePicker from "./schema-form-time-picker.vue"
|
|
@@ -18,6 +19,7 @@ interface PresetMap {
|
|
|
18
19
|
const presetMap: PresetMap = {
|
|
19
20
|
"schema-input": SchemaFormInput,
|
|
20
21
|
"schema-select": SchemaFormSelect,
|
|
22
|
+
"schema-select-v2": SchemaFormSelectV2,
|
|
21
23
|
"schema-radio": SchemaFormRadio,
|
|
22
24
|
"schema-checkbox": SchemaFormCheckbox,
|
|
23
25
|
"schema-input-number": SchemaFormInputNumber,
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
</div>
|
|
6
6
|
<el-checkbox-group v-if="!formItem.loading && formItem.options && formItem.options.length" v-model="model" :class="[props?.showType]" style="width: 100%" v-bind="props" v-on="eventObject">
|
|
7
7
|
<template v-for="option in formItem.options" :key="option.value">
|
|
8
|
-
<el-checkbox-button v-if="props?.componentName == 'button'" :
|
|
9
|
-
<el-checkbox v-else :
|
|
8
|
+
<el-checkbox-button v-if="props?.componentName == 'button'" :disabled="option.disabled" :style="option.style" v-bind="option"> {{ option.label }} </el-checkbox-button>
|
|
9
|
+
<el-checkbox v-else :disabled="option.disabled" :style="option.style" v-bind="option"> {{ option.label }} </el-checkbox>
|
|
10
10
|
</template>
|
|
11
11
|
</el-checkbox-group>
|
|
12
12
|
<div v-if="!formItem.loading && !formItem.options?.length" class="empty">
|
|
@@ -1,58 +1,59 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="schema-form-radio">
|
|
3
|
-
<div v-if="formItem.loading" class="loading" style="color: #999; font-size: 12px">
|
|
3
|
+
<div v-if="props.formItem.loading" class="loading" style="color: #999; font-size: 12px">
|
|
4
4
|
<el-icon class="is-loading"><Loading /></el-icon> {{ t("el.form.loading") }}
|
|
5
5
|
</div>
|
|
6
|
-
<el-radio-group v-if="!formItem.loading &&
|
|
7
|
-
<template v-for="option in
|
|
8
|
-
<
|
|
9
|
-
<
|
|
6
|
+
<el-radio-group v-if="!props.formItem.loading && options?.length" v-model="model" :class="[props?.props?.showType]" v-bind="props.props" v-on="props.eventObject">
|
|
7
|
+
<template v-for="(option, index) in options" :key="option.value">
|
|
8
|
+
<component :is="props?.props?.type == 'button' || props?.props?.componentName == 'button' ? 'el-radio-button' : 'el-radio'" :value="option.value" :disabled="option.disabled" :border="option.border" :size="option.size" :style="option.style">
|
|
9
|
+
<component v-if="option.component" :is="option.component" :row="option" :$index="index" :form-model="props.formModel" :form-item="props.formItem" :props="props.props" />
|
|
10
|
+
<span v-else-if="option.html" v-html="option.html"></span>
|
|
10
11
|
<span v-else>{{ option.label }}</span>
|
|
11
|
-
<FormTooltip v-if="option.tooltip" :tooltip="option.tooltip" :form-item="formItem" :form-model="formModel" />
|
|
12
|
-
</
|
|
13
|
-
<el-radio v-else :value="option.value" :disabled="option.disabled">
|
|
14
|
-
<span v-if="option.html" v-html="option.html"></span>
|
|
15
|
-
<span v-else>{{ option.label }}</span>
|
|
16
|
-
<FormTooltip v-if="option.tooltip" :tooltip="option.tooltip" :form-item="formItem" :form-model="formModel" />
|
|
17
|
-
</el-radio>
|
|
12
|
+
<FormTooltip v-if="option.tooltip" :tooltip="option.tooltip" :form-item="props.formItem" :form-model="props.formModel" />
|
|
13
|
+
</component>
|
|
18
14
|
</template>
|
|
19
15
|
</el-radio-group>
|
|
20
|
-
<div v-if="!formItem.loading && !
|
|
21
|
-
<component :is="empty" v-if="empty" :form-model="formModel" :form-item="formItem" :props="props" />
|
|
16
|
+
<div v-if="!props.formItem.loading && !options?.length" class="empty">
|
|
17
|
+
<component :is="empty" v-if="empty" :form-model="props.formModel" :form-item="props.formItem" :props="props.props" />
|
|
22
18
|
<template v-else>
|
|
23
|
-
<el-icon><Warning /></el-icon> <span>{{ props.noDataText || t("el.form.nodata") }}</span>
|
|
19
|
+
<el-icon><Warning /></el-icon> <span>{{ props.props?.noDataText || t("el.form.nodata") }}</span>
|
|
24
20
|
</template>
|
|
25
21
|
</div>
|
|
26
22
|
</div>
|
|
27
23
|
</template>
|
|
28
|
-
<script lang="ts">
|
|
24
|
+
<script lang="ts" setup>
|
|
29
25
|
import { Loading, Warning } from "@element-plus/icons-vue"
|
|
30
26
|
import { useLocale } from "easybill-ui"
|
|
31
|
-
import { computed,
|
|
27
|
+
import { computed, toRaw } from "vue"
|
|
32
28
|
import FormTooltip from "../FormTooltip.vue"
|
|
33
|
-
import { FormItemProps } from "../types"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
type: [String, Number, Boolean],
|
|
41
|
-
default: null,
|
|
42
|
-
},
|
|
29
|
+
import { FormItemProps, type CurdFormOptionItem } from "../types"
|
|
30
|
+
|
|
31
|
+
const props = defineProps({
|
|
32
|
+
...FormItemProps,
|
|
33
|
+
modelValue: {
|
|
34
|
+
type: [String, Number, Boolean],
|
|
35
|
+
default: null,
|
|
43
36
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
37
|
+
})
|
|
38
|
+
const emits = defineEmits(["update:modelValue"])
|
|
39
|
+
const model = computed({
|
|
40
|
+
get: () => props.modelValue,
|
|
41
|
+
set: (val) => emits("update:modelValue", val),
|
|
42
|
+
})
|
|
43
|
+
const { t } = useLocale()
|
|
44
|
+
const empty = computed(() => toRaw(props.props.empty) || "")
|
|
45
|
+
const options = computed(() => {
|
|
46
|
+
const alloptions: CurdFormOptionItem[] = []
|
|
47
|
+
if (props.props.all) {
|
|
48
|
+
const optionItem: CurdFormOptionItem = { value: "", label: t("el.form.all") }
|
|
49
|
+
if (typeof props.props.all == "boolean") {
|
|
50
|
+
alloptions.push(optionItem)
|
|
51
|
+
} else if (typeof props.props.all == "object") {
|
|
52
|
+
Object.assign(optionItem, props.props.all)
|
|
53
|
+
alloptions.push(optionItem)
|
|
55
54
|
}
|
|
56
|
-
}
|
|
55
|
+
}
|
|
56
|
+
const opts = props.formItem.options || []
|
|
57
|
+
return [...alloptions, ...opts]
|
|
57
58
|
})
|
|
58
59
|
</script>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-select-v2 v-model="model" style="width: 100%" :options="list" :loading="props.formItem.loading || loading" v-bind="selectProps" v-on="props.eventObject">
|
|
3
|
+
<template v-for="(item, key) in props.props?.slots" :key="key" #[key]>
|
|
4
|
+
<component :is="item" v-model="model" :form-item="props.formItem" :form-model="props.formModel" :props="props.props" :event-object="props.eventObject" />
|
|
5
|
+
</template>
|
|
6
|
+
</el-select-v2>
|
|
7
|
+
</template>
|
|
8
|
+
<script lang="ts" setup>
|
|
9
|
+
import { computed, onMounted, ref, watch } from "vue"
|
|
10
|
+
import type { CurdFormOptionItem } from "../types"
|
|
11
|
+
import { FormItemProps } from "../types"
|
|
12
|
+
|
|
13
|
+
const props = defineProps({
|
|
14
|
+
...FormItemProps,
|
|
15
|
+
modelValue: {
|
|
16
|
+
type: [String, Number, Boolean, Array],
|
|
17
|
+
default: null,
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
const emits = defineEmits(["update:modelValue"])
|
|
21
|
+
const model = computed({
|
|
22
|
+
get: () => props.modelValue,
|
|
23
|
+
set: (val) => emits("update:modelValue", val),
|
|
24
|
+
})
|
|
25
|
+
const loading = ref(false)
|
|
26
|
+
// 有的options是从接口里拿的,掉接口需要时间,初始全选的时候全选的按钮没有勾选上,所以监听options
|
|
27
|
+
const list = ref(props.formItem.options || [])
|
|
28
|
+
watch(
|
|
29
|
+
() => props.formItem.options,
|
|
30
|
+
(val) => {
|
|
31
|
+
list.value = val || []
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
deep: true,
|
|
35
|
+
},
|
|
36
|
+
)
|
|
37
|
+
onMounted(() => {})
|
|
38
|
+
const { filterMethod, remoteMethod, ...selectProps } = props.props
|
|
39
|
+
// 前端筛选
|
|
40
|
+
if (filterMethod) {
|
|
41
|
+
selectProps.filterMethod = function (val: string) {
|
|
42
|
+
const remoteMehotd1 = filterMethod as (val: string, optionItem?: CurdFormOptionItem) => Promise<CurdFormOptionItem[]>
|
|
43
|
+
list.value = props.formItem?.options?.filter((a) => remoteMehotd1(val, a)) || []
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// 远程筛选
|
|
47
|
+
if (selectProps.remote && remoteMethod) {
|
|
48
|
+
selectProps.remoteMethod = function (val: string) {
|
|
49
|
+
loading.value = true
|
|
50
|
+
const remoteMehotd1 = remoteMethod as (val: string, optionItem?: CurdFormOptionItem) => Promise<CurdFormOptionItem[]>
|
|
51
|
+
remoteMehotd1(val)
|
|
52
|
+
.then((res) => {
|
|
53
|
+
list.value = res
|
|
54
|
+
})
|
|
55
|
+
.finally(() => {
|
|
56
|
+
loading.value = false
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<el-select v-model="model" style="width: 100%" :loading="formItem.loading || loading" v-bind="
|
|
2
|
+
<el-select v-model="model" style="width: 100%" :loading="formItem.loading || loading" v-bind="selectProps" v-on="eventObject">
|
|
3
3
|
<el-option v-if="props.all && !props.multiple" value="" :label="t('el.form.all')"></el-option>
|
|
4
4
|
<el-checkbox v-if="props.all && props.multiple" v-model="checked" :label="t('el.form.allSelect')" class="schema-form-select-check" />
|
|
5
5
|
<template v-for="option in list" :key="option.value">
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
<template v-else>{{ option.label }}</template>
|
|
9
9
|
</el-option>
|
|
10
10
|
</template>
|
|
11
|
-
<template v-for="(item, key) in props
|
|
12
|
-
<component :is="item" v-model="model" :form-item="props.formItem" :form-model="props.formModel" :props="
|
|
11
|
+
<template v-for="(item, key) in props?.slots" :key="key" #[key]>
|
|
12
|
+
<component :is="item" v-model="model" :form-item="props.formItem" :form-model="props.formModel" :props="props" :event-object="eventObject" />
|
|
13
13
|
</template>
|
|
14
14
|
</el-select>
|
|
15
15
|
</template>
|
|
@@ -42,7 +42,7 @@ export default defineComponent({
|
|
|
42
42
|
set(val) {
|
|
43
43
|
const options = props.formItem.options || []
|
|
44
44
|
model.value = val ? options.map((a) => a.value) : []
|
|
45
|
-
if (props?.eventObject?.change) props.eventObject.change()
|
|
45
|
+
if (props?.eventObject?.change) props.eventObject.change(props.formModel, props.formItem)
|
|
46
46
|
},
|
|
47
47
|
})
|
|
48
48
|
const loading = ref(false)
|
|
@@ -62,7 +62,7 @@ export default defineComponent({
|
|
|
62
62
|
// 前端筛选
|
|
63
63
|
if (filterMethod) {
|
|
64
64
|
selectProps.filterMethod = function (val: string) {
|
|
65
|
-
const remoteMehotd1 =
|
|
65
|
+
const remoteMehotd1 = filterMethod as (val: string, optionItem?: CurdFormOptionItem) => Promise<CurdFormOptionItem[]>
|
|
66
66
|
list.value = props.formItem?.options?.filter((a) => remoteMehotd1(val, a))
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -44,8 +44,12 @@ export interface FormItem {
|
|
|
44
44
|
sortIndex?: number
|
|
45
45
|
}
|
|
46
46
|
export type FormItemTypeEmun = "input" | "select" | "radio" | "checkbox" | "input-number" | "switch" | "file" | "date-picker" | "time-picker" | "color-picker" | "value" | "tree-select" | "autocomplete"
|
|
47
|
-
export interface FormItemPropObject {
|
|
48
|
-
|
|
47
|
+
export interface FormItemPropObject extends Fields {
|
|
48
|
+
slots?: Record<string, (props?: FormItemPropObject) => VNode | VNode[] | string | null>
|
|
49
|
+
all?: boolean | CurdFormOptionItem
|
|
50
|
+
empty?: string | VNode
|
|
51
|
+
noDataText?: string
|
|
52
|
+
style?: Record<string, string> | string
|
|
49
53
|
}
|
|
50
54
|
export interface TooltipProps {
|
|
51
55
|
effect: "dark" | "light"
|
|
@@ -77,7 +81,10 @@ export interface Fields {
|
|
|
77
81
|
[key: string]: unknown
|
|
78
82
|
}
|
|
79
83
|
export interface CurdFormOptionItem extends OptionItem {
|
|
80
|
-
|
|
84
|
+
component?: string | ReturnType<typeof defineComponent>
|
|
85
|
+
disabled?: boolean
|
|
86
|
+
type?: string | "radio" | "button"
|
|
87
|
+
rawContent?: boolean
|
|
81
88
|
}
|
|
82
89
|
// interface EventObjectDefault {
|
|
83
90
|
// change?: (formModel: Fields, formItem: FormItem, proxy: any) => void
|
|
@@ -104,11 +111,11 @@ export const FormItemProps = {
|
|
|
104
111
|
default: () => ({}),
|
|
105
112
|
},
|
|
106
113
|
props: {
|
|
107
|
-
type: Object as PropType<
|
|
114
|
+
type: Object as PropType<FormItemPropObject>,
|
|
108
115
|
default: () => ({}),
|
|
109
116
|
},
|
|
110
117
|
eventObject: {
|
|
111
|
-
type: Object as PropType<Fields & { change:
|
|
118
|
+
type: Object as PropType<Fields & { change: (formModel: Fields, formItem: FormItem) => void | boolean }>,
|
|
112
119
|
default: () => ({}),
|
|
113
120
|
},
|
|
114
121
|
modelValue: {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
</template>
|
|
29
29
|
</STableItem>
|
|
30
30
|
</template>
|
|
31
|
-
<el-table-column v-if="!option.hideOperation" :label="t('el.table.operation')" fixed="right" :width="option.operationWidth || '200'" align="left">
|
|
31
|
+
<!-- <el-table-column v-if="!option.hideOperation" :label="t('el.table.operation')" fixed="right" :width="option.operationWidth || '200'" align="left">
|
|
32
32
|
<template #default="scope">
|
|
33
33
|
<slot name="operation" v-bind="scope"></slot>
|
|
34
34
|
<template v-if="!$slots.operationBtn">
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
</el-dropdown>
|
|
62
62
|
</template>
|
|
63
63
|
</template>
|
|
64
|
-
</el-table-column>
|
|
64
|
+
</el-table-column> -->
|
|
65
65
|
<template #empty>
|
|
66
66
|
<slot name="empty"></slot>
|
|
67
67
|
<el-empty v-if="!$slots.empty" :image-size="30" />
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<el-table-column v-if="!props.schema.hidden" :fixed="props.schema.fixed" v-bind="getColumnAttrs">
|
|
3
|
-
<template #header>
|
|
3
|
+
<template #header="scope">
|
|
4
4
|
<div class="header-td" :class="[props.schema.align]">
|
|
5
|
-
<slot name="header"></slot>
|
|
6
|
-
<
|
|
5
|
+
<slot name="header" v-bind="scope"></slot>
|
|
6
|
+
<component v-if="props.schema.headerComponent" :is="props.schema.headerComponent" v-bind="scope" />
|
|
7
|
+
<STableItemHeader v-else-if="!props.isSlotHeader" :schema-item="props.schema" />
|
|
7
8
|
<STableItemFilter v-if="props.schema.filter && props.schema.filter.inner" ref="tableItemFilterRef" :filter="filterSchema" @change="onChange" />
|
|
8
9
|
</div>
|
|
9
10
|
</template>
|
|
10
11
|
<template #default="scope">
|
|
11
|
-
<slot v-bind="scope"></slot>
|
|
12
|
-
<template v-if="props.schema.children?.length">
|
|
12
|
+
<slot name="default" v-bind="scope"></slot>
|
|
13
|
+
<!-- <template v-if="props.schema.children?.length">
|
|
13
14
|
<template v-for="item in props.schema.children" :key="item.label">
|
|
14
15
|
<STableItem :ref="(el) => (tableItemRefs[item.prop] = el)" :schema="item" :is-slot="props.isSlot" :is-slot-header="props.isSlotHeader" :option="option" @search="onItemChange">
|
|
15
16
|
<template #default>
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
</template>
|
|
37
38
|
<template v-else>{{ getValue(scope.row) }}</template>
|
|
38
39
|
</span>
|
|
39
|
-
</template>
|
|
40
|
+
</template> -->
|
|
40
41
|
</template>
|
|
41
42
|
</el-table-column>
|
|
42
43
|
</template>
|
|
@@ -38,6 +38,7 @@ export interface ColumnItemCtx<T> extends Partial<TableColumnCtx<T>> {
|
|
|
38
38
|
copy?: boolean // 对某一列的单元格的值进行复制
|
|
39
39
|
vHtml?: boolean //当前列是否v-html渲染
|
|
40
40
|
header?: string | TableColumnHeader
|
|
41
|
+
headerComponent?: string | VNode
|
|
41
42
|
}
|
|
42
43
|
interface TableColumnCtx<T> {
|
|
43
44
|
className: string
|
|
@@ -11,7 +11,7 @@ export interface FormDialogOptions extends Partial<DialogProps> {
|
|
|
11
11
|
handleClose?: (e: "close" | "cancel") => void
|
|
12
12
|
setForm?: (form: Fields) => void
|
|
13
13
|
stepProps?: Partial<StepProps & Fields>
|
|
14
|
-
extendContext?: FormContext
|
|
14
|
+
extendContext?: Partial<FormContext>
|
|
15
15
|
confirmBtnText?: string
|
|
16
16
|
cancelBtnText?: string
|
|
17
17
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easybill-ui",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.18",
|
|
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": "2b0e1faf36c35ade4d94791bda35a78ff5050239"
|
|
18
18
|
}
|