@complex-suite/component-antd 4.10.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.
- package/LayoutResizeObserver.ts +104 -0
- package/LocalResizeObserver.ts +46 -0
- package/README.md +67 -0
- package/antdConfig.ts +361 -0
- package/format.ts +458 -0
- package/history.md +325 -0
- package/icon.ts +65 -0
- package/index.test.ts +5 -0
- package/index.ts +55 -0
- package/package.json +39 -0
- package/plugin.ts +95 -0
- package/quick/QuickCascade.tsx +107 -0
- package/quick/QuickEdit.tsx +117 -0
- package/quick/QuickFloat.tsx +32 -0
- package/quick/QuickFloatModal.tsx +95 -0
- package/quick/QuickFloatValue.tsx +103 -0
- package/quick/QuickList.tsx +433 -0
- package/quick/data/FloatData.ts +77 -0
- package/src/AutoSpin.vue +39 -0
- package/src/AutoText.vue +101 -0
- package/src/ButtonView.tsx +62 -0
- package/src/CollapseArea.tsx +88 -0
- package/src/EditArea.tsx +205 -0
- package/src/EditView.tsx +179 -0
- package/src/FlexBox.tsx +74 -0
- package/src/FormList.tsx +226 -0
- package/src/ImageViewer.tsx +122 -0
- package/src/InfoArea.tsx +182 -0
- package/src/InfoView.tsx +150 -0
- package/src/MenuView.tsx +91 -0
- package/src/ModalView.tsx +274 -0
- package/src/MultipleImport.tsx +231 -0
- package/src/SearchArea.tsx +170 -0
- package/src/SelectText.vue +59 -0
- package/src/SimpleTable.tsx +256 -0
- package/src/SingleImport.tsx +189 -0
- package/src/TableView.tsx +415 -0
- package/src/components/AutoRender.tsx +19 -0
- package/src/components/ChoiceInfo.vue +73 -0
- package/src/components/PaginationView.tsx +103 -0
- package/src/components/TableMenu.tsx +93 -0
- package/src/dictionary/AutoEditItem.tsx +164 -0
- package/src/dictionary/AutoInfoItem.tsx +126 -0
- package/src/dictionary/AutoItem.tsx +219 -0
- package/src/icons/EmptyImage.vue +30 -0
- package/src/icons/ErrorImage.vue +30 -0
- package/src/style/index.css +304 -0
- package/tsconfig.json +8 -0
- package/type.ts +4 -0
- package/vitest.config.ts +11 -0
- package/widthCalculator.ts +20 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { defineComponent, h, PropType, VNode } from "vue"
|
|
2
|
+
import { Input, InputNumber, Textarea, Switch, Select, Divider, Cascader, DatePicker, RangePicker } from "ant-design-vue"
|
|
3
|
+
import { camelToLine } from "@complex-suite/utils"
|
|
4
|
+
import { dataConfig } from "@complex-suite/data"
|
|
5
|
+
import type { DictionaryEditMod } from "@complex-suite/data"
|
|
6
|
+
import PaginationView from "./../components/PaginationView"
|
|
7
|
+
import type { AutoItemPayloadType } from "./AutoItem"
|
|
8
|
+
import EditView from "../EditView"
|
|
9
|
+
import SingleImport from "../SingleImport"
|
|
10
|
+
import MultipleImport from "../MultipleImport"
|
|
11
|
+
import { parseEditAttrs } from "../../format"
|
|
12
|
+
import antdConfig from "../../antdConfig"
|
|
13
|
+
|
|
14
|
+
export default defineComponent({
|
|
15
|
+
name: 'AutoEditItem',
|
|
16
|
+
props: {
|
|
17
|
+
payload: {
|
|
18
|
+
type: Object as PropType<AutoItemPayloadType<'edit'>>,
|
|
19
|
+
required: true
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* 主要模板
|
|
24
|
+
* @returns {VNode}
|
|
25
|
+
*/
|
|
26
|
+
render() {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
let tag: any
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
let children: any = undefined
|
|
31
|
+
const target = this.payload.target as DictionaryEditMod
|
|
32
|
+
const targetAttrs = parseEditAttrs(target, this.payload)!
|
|
33
|
+
targetAttrs.pushClass('complex-edit-item')
|
|
34
|
+
targetAttrs.pushClass('complex-edit-item-' + camelToLine(target.type, '-'))
|
|
35
|
+
targetAttrs.merge(antdConfig.componentConfig.parseData(target.$local, 'target'))
|
|
36
|
+
let item = null
|
|
37
|
+
if (!(this.payload.parent as InstanceType<typeof EditView>).gridParse && target.$width) {
|
|
38
|
+
targetAttrs.style.width = typeof target.$width === 'number' ? dataConfig.formatPixel(target.$width) : target.$width
|
|
39
|
+
}
|
|
40
|
+
const targetRender = antdConfig.componentConfig.parseData(target.$renders, 'target')
|
|
41
|
+
const option = antdConfig.componentConfig.parseAttrs(targetAttrs)
|
|
42
|
+
// 考虑一个默认的值,inline模式下和其他模式下的默认值,避免出现问题
|
|
43
|
+
if (targetRender) {
|
|
44
|
+
item = targetRender({
|
|
45
|
+
...this.payload,
|
|
46
|
+
option: option
|
|
47
|
+
})
|
|
48
|
+
} else if (target.type === 'input') {
|
|
49
|
+
tag = Input
|
|
50
|
+
} else if (target.type === 'inputNumber') {
|
|
51
|
+
tag = InputNumber
|
|
52
|
+
} else if (target.type === 'textArea') {
|
|
53
|
+
tag = Textarea
|
|
54
|
+
} else if (target.type === 'switch') {
|
|
55
|
+
tag = Switch
|
|
56
|
+
} else if (target.type === 'select') {
|
|
57
|
+
tag = Select
|
|
58
|
+
const $data = target
|
|
59
|
+
children = {}
|
|
60
|
+
const dropdownRender = antdConfig.componentConfig.parseData(target.$renders, 'dropdown')
|
|
61
|
+
const optionRender = antdConfig.componentConfig.parseData(target.$renders, 'option')
|
|
62
|
+
const tagRender = antdConfig.componentConfig.parseData(target.$renders, 'tag')
|
|
63
|
+
if (dropdownRender) {
|
|
64
|
+
children.dropdownRender = dropdownRender
|
|
65
|
+
} else {
|
|
66
|
+
const dropdownTopRender = antdConfig.componentConfig.parseData(target.$renders, 'dropdownTop')
|
|
67
|
+
const dropdownBottomRender = antdConfig.componentConfig.parseData(target.$renders, 'dropdownBottom')
|
|
68
|
+
if (dropdownTopRender || $data.$pagination || dropdownBottomRender) {
|
|
69
|
+
children.dropdownRender = (payload: { menuNode: VNode }) => {
|
|
70
|
+
const vNodes = [payload.menuNode]
|
|
71
|
+
if (dropdownTopRender) {
|
|
72
|
+
vNodes.unshift(dropdownTopRender({
|
|
73
|
+
payload: this.payload
|
|
74
|
+
}) as VNode)
|
|
75
|
+
vNodes.unshift(h(Divider, {
|
|
76
|
+
style: {
|
|
77
|
+
margin: '4px 0'
|
|
78
|
+
}
|
|
79
|
+
}))
|
|
80
|
+
}
|
|
81
|
+
if (dropdownBottomRender) {
|
|
82
|
+
vNodes.push(h(Divider, {
|
|
83
|
+
style: {
|
|
84
|
+
margin: '4px 0'
|
|
85
|
+
}
|
|
86
|
+
}))
|
|
87
|
+
vNodes.push(dropdownBottomRender({
|
|
88
|
+
payload: this.payload
|
|
89
|
+
}) as VNode)
|
|
90
|
+
}
|
|
91
|
+
if ($data.$pagination) {
|
|
92
|
+
vNodes.push(h(Divider, {
|
|
93
|
+
style: {
|
|
94
|
+
margin: '4px 0'
|
|
95
|
+
}
|
|
96
|
+
}))
|
|
97
|
+
vNodes.push(h(PaginationView, {
|
|
98
|
+
pagination: $data.$pagination,
|
|
99
|
+
simple: true,
|
|
100
|
+
onPage() {
|
|
101
|
+
($data.$option as any).open = true
|
|
102
|
+
$data.loadData(true).then(() => {
|
|
103
|
+
($data.$option as any).open = undefined
|
|
104
|
+
}, () => {
|
|
105
|
+
($data.$option as any).open = undefined
|
|
106
|
+
})
|
|
107
|
+
},
|
|
108
|
+
onSize() {
|
|
109
|
+
($data.$option as any).open = true
|
|
110
|
+
$data.loadData(true).then(() => {
|
|
111
|
+
($data.$option as any).open = undefined
|
|
112
|
+
}, () => {
|
|
113
|
+
($data.$option as any).open = undefined
|
|
114
|
+
})
|
|
115
|
+
},
|
|
116
|
+
onClick(e: Event) {
|
|
117
|
+
e.preventDefault()
|
|
118
|
+
}
|
|
119
|
+
}))
|
|
120
|
+
const dropdownPaginationBottomRender = antdConfig.componentConfig.parseData(target.$renders, 'dropdownPaginationBottom')
|
|
121
|
+
if (dropdownPaginationBottomRender) {
|
|
122
|
+
vNodes.push(h(Divider, {
|
|
123
|
+
style: {
|
|
124
|
+
margin: '4px 0'
|
|
125
|
+
}
|
|
126
|
+
}))
|
|
127
|
+
vNodes.push(dropdownPaginationBottomRender({
|
|
128
|
+
payload: this.payload
|
|
129
|
+
}) as VNode)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return vNodes
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (optionRender) {
|
|
137
|
+
children.option = optionRender
|
|
138
|
+
}
|
|
139
|
+
if (tagRender) {
|
|
140
|
+
children.tagRender = tagRender
|
|
141
|
+
}
|
|
142
|
+
} else if (target.type === 'cascader') {
|
|
143
|
+
tag = Cascader
|
|
144
|
+
} else if (target.type === 'date') {
|
|
145
|
+
tag = DatePicker
|
|
146
|
+
} else if (target.type === 'dateRange') {
|
|
147
|
+
tag = RangePicker
|
|
148
|
+
} else if (target.type === 'file') {
|
|
149
|
+
if (!target.multiple) {
|
|
150
|
+
tag = SingleImport
|
|
151
|
+
} else {
|
|
152
|
+
tag = MultipleImport
|
|
153
|
+
}
|
|
154
|
+
} else if (target.type === 'custom') {
|
|
155
|
+
tag = target.$custom
|
|
156
|
+
} else if (target.type === 'form') {
|
|
157
|
+
tag = EditView
|
|
158
|
+
}
|
|
159
|
+
if (tag) {
|
|
160
|
+
item = h(tag, option, children)
|
|
161
|
+
}
|
|
162
|
+
return item
|
|
163
|
+
}
|
|
164
|
+
})
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { defineComponent, h, PropType } from "vue"
|
|
2
|
+
import { AttrsValue, ButtonEdit, ButtonGroupEdit, ContentEdit, dataConfig, DictionaryValue, ObserveList, FormEdit } from "@complex-suite/data"
|
|
3
|
+
import type { ButtonEditOption } from "@complex-suite/data"
|
|
4
|
+
import ButtonView from "../ButtonView"
|
|
5
|
+
import type { AutoItemPayloadType, AutoItemParser } from "./AutoItem"
|
|
6
|
+
import InfoView from "../InfoView"
|
|
7
|
+
import type { InfoViewProps } from "../InfoView"
|
|
8
|
+
import antdConfig from "../../antdConfig"
|
|
9
|
+
|
|
10
|
+
export const bindButtonClick = function(prop: string, option: ButtonEdit['$option'], payload: AutoItemPayloadType<AutoItemParser>) {
|
|
11
|
+
if (!option.upload) {
|
|
12
|
+
return function() {
|
|
13
|
+
(payload as AutoItemPayloadType<'edit'>).parent.$emit('menu', prop, payload)
|
|
14
|
+
if (option.click) {
|
|
15
|
+
return option.click(payload)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
return option.click
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default defineComponent({
|
|
24
|
+
name: 'AutoInfoItem',
|
|
25
|
+
props: {
|
|
26
|
+
payload: {
|
|
27
|
+
type: Object as PropType<AutoItemPayloadType<AutoItemParser>>,
|
|
28
|
+
required: true
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* 主要模板
|
|
33
|
+
* @returns {VNode}
|
|
34
|
+
*/
|
|
35
|
+
render() {
|
|
36
|
+
const targetRender = antdConfig.componentConfig.parseData(this.payload.target.$renders, 'target')
|
|
37
|
+
if (targetRender) {
|
|
38
|
+
return targetRender({
|
|
39
|
+
...this.payload
|
|
40
|
+
})
|
|
41
|
+
} else {
|
|
42
|
+
const targetAttrs = antdConfig.componentConfig.parseData(this.payload.target.$local, 'target') || new AttrsValue()
|
|
43
|
+
if (!(this.payload.parent as InstanceType<typeof InfoView>).gridParse && this.payload.target.$width) {
|
|
44
|
+
targetAttrs.style.width = typeof this.payload.target.$width === 'number' ? dataConfig.formatPixel(this.payload.target.$width) : this.payload.target.$width
|
|
45
|
+
}
|
|
46
|
+
if (this.payload.target instanceof ButtonEdit) {
|
|
47
|
+
const option = {
|
|
48
|
+
...this.payload.target.$option
|
|
49
|
+
}
|
|
50
|
+
if (!option.name) {
|
|
51
|
+
option.name = this.payload.target.$name
|
|
52
|
+
}
|
|
53
|
+
if (!option.prop) {
|
|
54
|
+
option.prop = this.payload.prop
|
|
55
|
+
}
|
|
56
|
+
if (this.payload.loading) {
|
|
57
|
+
option.loading = true
|
|
58
|
+
} else if (this.payload.target.$option.loading && typeof this.payload.target.$option.loading === 'function') {
|
|
59
|
+
option.loading = this.payload.target.$option.loading(this.payload)
|
|
60
|
+
}
|
|
61
|
+
if (this.payload.disabled) {
|
|
62
|
+
option.disabled = true
|
|
63
|
+
} else if (this.payload.target.$option.disabled && typeof this.payload.target.$option.disabled === 'function') {
|
|
64
|
+
option.disabled = this.payload.target.$option.disabled(this.payload)
|
|
65
|
+
}
|
|
66
|
+
option.click = bindButtonClick(this.payload.target.$prop, this.payload.target.$option, this.payload)
|
|
67
|
+
targetAttrs.props.data = option
|
|
68
|
+
return h(ButtonView, antdConfig.componentConfig.parseAttrs(targetAttrs) as { data: ButtonEditOption })
|
|
69
|
+
} else if (this.payload.target instanceof ButtonGroupEdit) {
|
|
70
|
+
const { target } = this.payload
|
|
71
|
+
return h('div', antdConfig.componentConfig.parseAttrs(targetAttrs), [
|
|
72
|
+
target.$list.map((buttonOption, index) => {
|
|
73
|
+
const interval = (index !== target.$list.length - 1) ? target.interval : undefined
|
|
74
|
+
const option = {
|
|
75
|
+
...buttonOption
|
|
76
|
+
}
|
|
77
|
+
if (this.payload.loading) {
|
|
78
|
+
option.loading = true
|
|
79
|
+
} else if (buttonOption.loading && typeof buttonOption.loading === 'function') {
|
|
80
|
+
option.loading = buttonOption.loading(this.payload)
|
|
81
|
+
}
|
|
82
|
+
if (this.payload.disabled) {
|
|
83
|
+
option.disabled = true
|
|
84
|
+
} else if (buttonOption.disabled && typeof buttonOption.disabled === 'function') {
|
|
85
|
+
option.disabled = buttonOption.disabled(this.payload)
|
|
86
|
+
}
|
|
87
|
+
option.click = bindButtonClick(buttonOption.prop!, buttonOption, this.payload)
|
|
88
|
+
return h(ButtonView, {
|
|
89
|
+
style: {
|
|
90
|
+
marginRight: interval
|
|
91
|
+
},
|
|
92
|
+
data: option
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
])
|
|
96
|
+
} else if (this.payload.target instanceof ContentEdit) {
|
|
97
|
+
const { target } = this.payload
|
|
98
|
+
targetAttrs.pushStyle(target.$option.style)
|
|
99
|
+
return h('div', antdConfig.componentConfig.parseAttrs(targetAttrs), [target.$option.data])
|
|
100
|
+
} else if (this.payload.target instanceof FormEdit) {
|
|
101
|
+
const { target } = this.payload
|
|
102
|
+
// 额外则直接解析数据
|
|
103
|
+
targetAttrs.merge(new AttrsValue({
|
|
104
|
+
props: {
|
|
105
|
+
list: target.$runtime.observeList as ObserveList,
|
|
106
|
+
data: target.$runtime.form!.getData(),
|
|
107
|
+
type: target.$runtime.type!,
|
|
108
|
+
gridParse: target.$option.gridParse === false ? undefined : (target.$option.gridParse || target.$runtime.dictionary!.$layout.grid.getValue(this.payload.type)),
|
|
109
|
+
menu: target.$option.menu,
|
|
110
|
+
disabled: this.payload.disabled
|
|
111
|
+
} as InfoViewProps
|
|
112
|
+
}))
|
|
113
|
+
return h(InfoView, antdConfig.componentConfig.parseAttrs(targetAttrs) as unknown as InfoViewProps)
|
|
114
|
+
} else {
|
|
115
|
+
// 额外则直接解析数据
|
|
116
|
+
const { target, targetData, prop } = this.payload
|
|
117
|
+
let text = targetData[prop]
|
|
118
|
+
const parent = target.$getParent() as DictionaryValue
|
|
119
|
+
if (parent && parent.parse) {
|
|
120
|
+
text = parent.parse(text, this.payload)
|
|
121
|
+
}
|
|
122
|
+
return h('div', antdConfig.componentConfig.parseAttrs(targetAttrs), antdConfig.showValue(text))
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
})
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { defineComponent, h, PropType } from "vue"
|
|
2
|
+
import { Col, FormItem, Row, Tooltip } from "ant-design-vue"
|
|
3
|
+
import { AttrsValue, FormValue, DefaultInfo, ObserveList, DefaultEdit, GridParse, DefaultSimpleEdit } from "@complex-suite/data"
|
|
4
|
+
import type { DictionaryEditMod } from "@complex-suite/data"
|
|
5
|
+
import EditView from "../EditView"
|
|
6
|
+
import InfoView from "../InfoView"
|
|
7
|
+
import AutoEditItem from "./AutoEditItem"
|
|
8
|
+
import AutoInfoItem from "./AutoInfoItem"
|
|
9
|
+
import antdConfig from "../../antdConfig"
|
|
10
|
+
|
|
11
|
+
export type AutoItemParser = 'info' | 'edit'
|
|
12
|
+
|
|
13
|
+
export interface AutoItemPayloadType<P extends AutoItemParser = 'edit'> {
|
|
14
|
+
prop: string
|
|
15
|
+
type: string
|
|
16
|
+
target: DefaultInfo
|
|
17
|
+
index: number
|
|
18
|
+
list: ObserveList
|
|
19
|
+
choice?: number
|
|
20
|
+
disabled?: boolean
|
|
21
|
+
loading?: boolean
|
|
22
|
+
targetData: Record<PropertyKey, any>
|
|
23
|
+
form: P extends 'edit' ? FormValue : undefined
|
|
24
|
+
data: P extends 'info' ? Record<PropertyKey, any> : undefined
|
|
25
|
+
parent: P extends 'edit' ? InstanceType<typeof EditView> : InstanceType<typeof InfoView>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface AutoItemProps<P extends AutoItemParser = 'edit'> {
|
|
29
|
+
parser: P
|
|
30
|
+
target: DefaultInfo
|
|
31
|
+
index: number
|
|
32
|
+
list: ObserveList
|
|
33
|
+
type: string
|
|
34
|
+
gridParse?: GridParse
|
|
35
|
+
choice?: number
|
|
36
|
+
collapse?: boolean
|
|
37
|
+
disabled?: boolean
|
|
38
|
+
loading?: boolean
|
|
39
|
+
form: P extends 'edit' ? FormValue : undefined
|
|
40
|
+
data: P extends 'info' ? Record<PropertyKey, any> : undefined
|
|
41
|
+
parent: P extends 'edit' ? InstanceType<typeof EditView> : InstanceType<typeof InfoView>
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default defineComponent({
|
|
45
|
+
name: 'AutoItem',
|
|
46
|
+
props: {
|
|
47
|
+
parser: {
|
|
48
|
+
type: String as PropType<AutoItemProps<AutoItemParser>['parser']>,
|
|
49
|
+
required: true
|
|
50
|
+
},
|
|
51
|
+
target: {
|
|
52
|
+
type: Object as PropType<AutoItemProps<AutoItemParser>['target']>,
|
|
53
|
+
required: true
|
|
54
|
+
},
|
|
55
|
+
index: {
|
|
56
|
+
type: Number,
|
|
57
|
+
required: true
|
|
58
|
+
},
|
|
59
|
+
list: {
|
|
60
|
+
type: Object as PropType<AutoItemProps<AutoItemParser>['list']>,
|
|
61
|
+
required: true
|
|
62
|
+
},
|
|
63
|
+
type: { // formType
|
|
64
|
+
type: String,
|
|
65
|
+
required: true
|
|
66
|
+
},
|
|
67
|
+
gridParse: {
|
|
68
|
+
type: Object as PropType<AutoItemProps<AutoItemParser>['gridParse']>,
|
|
69
|
+
required: false
|
|
70
|
+
},
|
|
71
|
+
choice: {
|
|
72
|
+
type: Number,
|
|
73
|
+
required: false
|
|
74
|
+
},
|
|
75
|
+
collapse: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
required: false
|
|
78
|
+
},
|
|
79
|
+
disabled: {
|
|
80
|
+
type: Boolean,
|
|
81
|
+
required: false
|
|
82
|
+
},
|
|
83
|
+
loading: {
|
|
84
|
+
type: Boolean,
|
|
85
|
+
required: false
|
|
86
|
+
},
|
|
87
|
+
form: {
|
|
88
|
+
type: Object as PropType<AutoItemProps<AutoItemParser>['form']>,
|
|
89
|
+
required: false
|
|
90
|
+
},
|
|
91
|
+
data: {
|
|
92
|
+
type: Object as PropType<AutoItemProps<AutoItemParser>['data']>,
|
|
93
|
+
required: false
|
|
94
|
+
},
|
|
95
|
+
parent: { // EditView实例
|
|
96
|
+
type: Object as PropType<AutoItemProps<AutoItemParser>['parent']>,
|
|
97
|
+
required: true
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
computed: {
|
|
101
|
+
payload() {
|
|
102
|
+
let disabled = this.disabled
|
|
103
|
+
if (!disabled && this.target instanceof DefaultSimpleEdit) {
|
|
104
|
+
disabled = this.target.disabled.getValue(this.type)
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
prop: this.target.$prop,
|
|
108
|
+
type: this.type,
|
|
109
|
+
target: this.target,
|
|
110
|
+
index: this.index,
|
|
111
|
+
list: this.list,
|
|
112
|
+
choice: this.choice,
|
|
113
|
+
disabled: disabled,
|
|
114
|
+
loading: this.loading,
|
|
115
|
+
targetData: this.form ? this.form.data : this.data!,
|
|
116
|
+
form: this.form,
|
|
117
|
+
data: this.data,
|
|
118
|
+
parent: this.parent,
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
isEdit() {
|
|
122
|
+
return this.parser === 'edit' && antdConfig.isEdit(this.target)
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
methods: {
|
|
126
|
+
renderTip() {
|
|
127
|
+
const mainRender = antdConfig.componentConfig.parseData(this.target.$renders, 'main')
|
|
128
|
+
const item = !mainRender ? this.renderContent() : mainRender(this.payload)
|
|
129
|
+
if (this.target.$tip) {
|
|
130
|
+
return h(Tooltip, {
|
|
131
|
+
title: this.target.$tip.getData ? this.target.$tip.getData(this.payload) : this.target.$tip.data,
|
|
132
|
+
placement: this.target.$tip.location,
|
|
133
|
+
...antdConfig.componentConfig.parseAttrs(this.target.$tip.$attrs)
|
|
134
|
+
}, {
|
|
135
|
+
default: () => item
|
|
136
|
+
})
|
|
137
|
+
} else {
|
|
138
|
+
return item
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
renderLabel() {
|
|
142
|
+
const labelAttrs = antdConfig.componentConfig.parseData(this.target.$local, 'label') || new AttrsValue()
|
|
143
|
+
labelAttrs.pushClass('complex-auto-item-label')
|
|
144
|
+
labelAttrs.pushClass(`complex-auto-item-${(this.parent as InstanceType<typeof EditView> | InstanceType<typeof InfoView>).labelAlign}-label`)
|
|
145
|
+
if (this.target.colon && this.target.$name) {
|
|
146
|
+
labelAttrs.pushClass('complex-auto-item-colon-label')
|
|
147
|
+
}
|
|
148
|
+
return h('div', antdConfig.componentConfig.parseAttrs(labelAttrs), {
|
|
149
|
+
default: () => this.target.$name
|
|
150
|
+
})
|
|
151
|
+
},
|
|
152
|
+
renderContent() {
|
|
153
|
+
if (this.isEdit) {
|
|
154
|
+
return h(AutoEditItem, {
|
|
155
|
+
payload: this.payload as AutoItemPayloadType<'edit'>
|
|
156
|
+
})
|
|
157
|
+
} else {
|
|
158
|
+
return h(AutoInfoItem, {
|
|
159
|
+
payload: this.payload as AutoItemPayloadType<'info'>
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
render() {
|
|
165
|
+
if (antdConfig.parseCollapse(this.collapse, this.target.$collapse)) {
|
|
166
|
+
const mainRender = antdConfig.componentConfig.parseData(this.target.$renders, 'main')
|
|
167
|
+
if (!mainRender) {
|
|
168
|
+
if (this.isEdit) {
|
|
169
|
+
// edit
|
|
170
|
+
const mainAttributes = new AttrsValue({
|
|
171
|
+
class: ['complex-auto-item'],
|
|
172
|
+
props: {
|
|
173
|
+
name: this.target.$prop,
|
|
174
|
+
label: this.target.$name,
|
|
175
|
+
colon: this.target.colon,
|
|
176
|
+
required: (this.target as DictionaryEditMod).required,
|
|
177
|
+
rules: this.target instanceof DefaultEdit ? this.target.parseRuleList(this.payload.targetData, this.payload.type) : undefined
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
if (this.gridParse) {
|
|
181
|
+
mainAttributes.props.labelCol = this.gridParse!.parseData(this.target.$grid, 'label', this.type)
|
|
182
|
+
mainAttributes.props.wrapperCol = this.gridParse!.parseData(this.target.$grid, 'content', this.type)
|
|
183
|
+
}
|
|
184
|
+
mainAttributes.merge(antdConfig.componentConfig.parseData(this.target.$local, 'main'))
|
|
185
|
+
return h(FormItem, antdConfig.componentConfig.parseAttrs(mainAttributes), { default: () => this.renderTip() })
|
|
186
|
+
} else {
|
|
187
|
+
// info
|
|
188
|
+
const mainAttributes = new AttrsValue({
|
|
189
|
+
class: ['complex-auto-item', 'complex-auto-item-info']
|
|
190
|
+
})
|
|
191
|
+
mainAttributes.merge(antdConfig.componentConfig.parseData(this.target.$local, 'main'))
|
|
192
|
+
if (this.gridParse) {
|
|
193
|
+
return h(Row, antdConfig.componentConfig.parseAttrs(mainAttributes), {
|
|
194
|
+
default: () => [
|
|
195
|
+
h(Col, antdConfig.parseGrid((this.payload.parent as InstanceType<typeof EditView> | InstanceType<typeof InfoView>).gridParse!.parseData(this.payload.target.$grid, 'label', this.payload.type)), {
|
|
196
|
+
default: () => this.renderLabel()
|
|
197
|
+
}),
|
|
198
|
+
h(Col, antdConfig.parseGrid((this.payload.parent as InstanceType<typeof EditView> | InstanceType<typeof InfoView>).gridParse!.parseData(this.payload.target.$grid, 'content', this.payload.type)), {
|
|
199
|
+
default: () => this.renderTip()
|
|
200
|
+
})
|
|
201
|
+
]
|
|
202
|
+
})
|
|
203
|
+
} else {
|
|
204
|
+
return h('div', antdConfig.componentConfig.parseAttrs(mainAttributes), {
|
|
205
|
+
default: () => [
|
|
206
|
+
this.renderLabel(),
|
|
207
|
+
this.renderTip()
|
|
208
|
+
]
|
|
209
|
+
})
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
return mainRender(this.payload)
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
return null
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg t="1743059212679" class="complex-local-icon complex-local-icon-empty-image" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3040" xmlns:xlink="http://www.w3.org/1999/xlink" :width="size" :height="size">
|
|
3
|
+
<path :fill="color" d="M128 832V512h64v146.752l192-192L749.248 832H832V192H512V128h320a64 64 0 0 1 64 64v640a64 64 0 0 1-64 64H192a64 64 0 0 1-64-64z m256-274.752l-192 192V832h466.752L384 557.248z" p-id="3041"></path>
|
|
4
|
+
<path :fill="color" d="M768 384a128 128 0 1 1-256 0 128 128 0 0 1 256 0z m-64 0a64 64 0 1 0-128 0 64 64 0 0 0 128 0zM402.048 355.84l-45.248 45.184-90.496-90.496-90.496 90.496-45.312-45.248 90.56-90.496-90.56-90.496 45.312-45.248L266.24 220.032l90.496-90.496 45.248 45.248-90.496 90.496 90.496 90.496z" p-id="3042"></path>
|
|
5
|
+
</svg>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import { defineComponent, PropType } from "vue"
|
|
10
|
+
import { dataConfig } from "@complex-suite/data"
|
|
11
|
+
import type { localIconProps } from "../../type"
|
|
12
|
+
|
|
13
|
+
export default defineComponent({
|
|
14
|
+
name: 'EmptyImage',
|
|
15
|
+
props: {
|
|
16
|
+
size: {
|
|
17
|
+
type: Number as PropType<localIconProps['size']>,
|
|
18
|
+
required: false,
|
|
19
|
+
default: 128
|
|
20
|
+
},
|
|
21
|
+
color: {
|
|
22
|
+
type: String as PropType<localIconProps['color']>,
|
|
23
|
+
required: false,
|
|
24
|
+
default: () => {
|
|
25
|
+
return dataConfig.style.color.disabled
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
</script>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg t="1743059212679" class="complex-local-icon complex-local-icon-error-image" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3040" xmlns:xlink="http://www.w3.org/1999/xlink" :width="size" :height="size">
|
|
3
|
+
<path :fill="color" d="M128 832V512h64v146.752l192-192L749.248 832H832V192H512V128h320a64 64 0 0 1 64 64v640a64 64 0 0 1-64 64H192a64 64 0 0 1-64-64z m256-274.752l-192 192V832h466.752L384 557.248z" p-id="3041"></path>
|
|
4
|
+
<path :fill="color" d="M768 384a128 128 0 1 1-256 0 128 128 0 0 1 256 0z m-64 0a64 64 0 1 0-128 0 64 64 0 0 0 128 0zM402.048 355.84l-45.248 45.184-90.496-90.496-90.496 90.496-45.312-45.248 90.56-90.496-90.56-90.496 45.312-45.248L266.24 220.032l90.496-90.496 45.248 45.248-90.496 90.496 90.496 90.496z" p-id="3042"></path>
|
|
5
|
+
</svg>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import { defineComponent, PropType } from "vue"
|
|
10
|
+
import { dataConfig } from "@complex-suite/data"
|
|
11
|
+
import type { localIconProps } from "../../type"
|
|
12
|
+
|
|
13
|
+
export default defineComponent({
|
|
14
|
+
name: 'ErrorImage',
|
|
15
|
+
props: {
|
|
16
|
+
size: {
|
|
17
|
+
type: Number as PropType<localIconProps['size']>,
|
|
18
|
+
required: false,
|
|
19
|
+
default: 128
|
|
20
|
+
},
|
|
21
|
+
color: {
|
|
22
|
+
type: String as PropType<localIconProps['color']>,
|
|
23
|
+
required: false,
|
|
24
|
+
default: () => {
|
|
25
|
+
return dataConfig.style.color.danger
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
</script>
|