@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
package/src/FormList.tsx
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { defineComponent, h, PropType } from "vue"
|
|
2
|
+
import { Form, FormItemRest, Table } from "ant-design-vue"
|
|
3
|
+
import type { TableColumnType, TableProps } from "ant-design-vue"
|
|
4
|
+
import { FormValue, ListEdit } from "@complex-suite/data"
|
|
5
|
+
import MenuView from "./MenuView"
|
|
6
|
+
import type { customRenderPayload, tablePayload } from "./TableView"
|
|
7
|
+
import antdConfig from "../antdConfig"
|
|
8
|
+
import AutoEditItem from "./dictionary/AutoEditItem"
|
|
9
|
+
import type { AutoItemPayloadType } from "./dictionary/AutoItem"
|
|
10
|
+
import AutoInfoItem from "./dictionary/AutoInfoItem"
|
|
11
|
+
|
|
12
|
+
export default defineComponent({
|
|
13
|
+
name: 'FormList',
|
|
14
|
+
props: {
|
|
15
|
+
runtime: {
|
|
16
|
+
type: Object as PropType<ListEdit['$runtime']>,
|
|
17
|
+
required: true
|
|
18
|
+
},
|
|
19
|
+
value: {
|
|
20
|
+
type: Object as PropType<Record<PropertyKey, any>[]>,
|
|
21
|
+
required: false
|
|
22
|
+
},
|
|
23
|
+
type: {
|
|
24
|
+
type: String,
|
|
25
|
+
required: true
|
|
26
|
+
},
|
|
27
|
+
header: {
|
|
28
|
+
type: Object as PropType<ListEdit['$option']['header']>,
|
|
29
|
+
required: false
|
|
30
|
+
},
|
|
31
|
+
menu: {
|
|
32
|
+
type: Object as PropType<ListEdit['$option']['menu']>,
|
|
33
|
+
required: false
|
|
34
|
+
},
|
|
35
|
+
tableProps: {
|
|
36
|
+
type: Object as PropType<TableProps>,
|
|
37
|
+
required: false
|
|
38
|
+
},
|
|
39
|
+
disabled: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
required: false
|
|
42
|
+
},
|
|
43
|
+
loading: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
required: false
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
emits: ['update:value', 'header'],
|
|
49
|
+
setup() {
|
|
50
|
+
const formItemContext = Form.useInjectFormItemContext()
|
|
51
|
+
console.log(formItemContext)
|
|
52
|
+
},
|
|
53
|
+
data () {
|
|
54
|
+
return {
|
|
55
|
+
currentValue: this.value || []
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
computed: {
|
|
59
|
+
currentColumnList() {
|
|
60
|
+
const list = []
|
|
61
|
+
const columnList = this.runtime.observeList?.data
|
|
62
|
+
if (columnList) {
|
|
63
|
+
for (let i = 0; i < columnList.length; i++) {
|
|
64
|
+
const column = columnList[i]
|
|
65
|
+
const currentProp = column.$prop
|
|
66
|
+
const targetRender = this.$slots[currentProp] || antdConfig.componentConfig.parseData(column.$renders, 'target')
|
|
67
|
+
const pureRender = antdConfig.componentConfig.parseData(column.$renders, 'pure')
|
|
68
|
+
const attrs = antdConfig.componentConfig.parseData(column.$local, 'target')
|
|
69
|
+
const columnItem: TableColumnType = {
|
|
70
|
+
dataIndex: currentProp,
|
|
71
|
+
title: column.$name,
|
|
72
|
+
width: column.$width,
|
|
73
|
+
ellipsis: false,
|
|
74
|
+
...antdConfig.componentConfig.parseAttrs(attrs)
|
|
75
|
+
}
|
|
76
|
+
if (!pureRender) {
|
|
77
|
+
if (!targetRender) {
|
|
78
|
+
columnItem.customRender = ({ record, index }: customRenderPayload) => {
|
|
79
|
+
if (currentProp === antdConfig.table.auto.index.prop) {
|
|
80
|
+
// 自动index
|
|
81
|
+
return antdConfig.table.renderIndex(record, index, undefined)
|
|
82
|
+
}
|
|
83
|
+
const form = this.runtime.formList![index]
|
|
84
|
+
if (antdConfig.isEdit(column)) {
|
|
85
|
+
return h(FormItemRest, {}, {
|
|
86
|
+
default: () => [
|
|
87
|
+
h(AutoEditItem, {
|
|
88
|
+
payload: {
|
|
89
|
+
prop: currentProp,
|
|
90
|
+
type: this.type,
|
|
91
|
+
target: column,
|
|
92
|
+
index: index,
|
|
93
|
+
list: this.runtime.observeList!,
|
|
94
|
+
disabled: this.disabled,
|
|
95
|
+
loading: this.loading,
|
|
96
|
+
targetData: form.data,
|
|
97
|
+
form: form,
|
|
98
|
+
data: undefined,
|
|
99
|
+
parent: this as any,
|
|
100
|
+
} as AutoItemPayloadType<'edit'>
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
})
|
|
104
|
+
} else {
|
|
105
|
+
return h(AutoInfoItem, {
|
|
106
|
+
payload: {
|
|
107
|
+
prop: currentProp,
|
|
108
|
+
type: this.type,
|
|
109
|
+
target: column,
|
|
110
|
+
index: index,
|
|
111
|
+
list: this.runtime.observeList!,
|
|
112
|
+
disabled: this.disabled,
|
|
113
|
+
loading: this.loading,
|
|
114
|
+
targetData: form.data,
|
|
115
|
+
form: undefined,
|
|
116
|
+
data: form.data,
|
|
117
|
+
parent: this as any,
|
|
118
|
+
} as AutoItemPayloadType<'info'>
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
columnItem.customRender = ({ text, record, index }: customRenderPayload) => {
|
|
124
|
+
const payload: tablePayload = {
|
|
125
|
+
targetData: record,
|
|
126
|
+
type: this.type,
|
|
127
|
+
index: index,
|
|
128
|
+
payload: { column: column }
|
|
129
|
+
}
|
|
130
|
+
text = antdConfig.table.renderTableValue(text, payload)
|
|
131
|
+
if (targetRender) {
|
|
132
|
+
// 插槽
|
|
133
|
+
return targetRender({
|
|
134
|
+
text: text,
|
|
135
|
+
payload
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
if (columnItem.ellipsis) {
|
|
139
|
+
// 自动省略切自动换行
|
|
140
|
+
return antdConfig.table.renderAutoText(text as string, column, payload, antdConfig.componentConfig.parseData(column.$local, 'autoText'))
|
|
141
|
+
}
|
|
142
|
+
return text
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
} else {
|
|
146
|
+
columnItem.customRender = ({ text, record, index }: customRenderPayload) => {
|
|
147
|
+
const payload: tablePayload = {
|
|
148
|
+
targetData: record,
|
|
149
|
+
type: this.type,
|
|
150
|
+
index: index,
|
|
151
|
+
payload: { column: column }
|
|
152
|
+
}
|
|
153
|
+
return pureRender({
|
|
154
|
+
text: text,
|
|
155
|
+
payload
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
list.push(columnItem)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return list
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
watch: {
|
|
166
|
+
value(val?: Record<PropertyKey, any>[]) {
|
|
167
|
+
console.log('value change', val)
|
|
168
|
+
if (val) {
|
|
169
|
+
if (val !== this.currentValue) {
|
|
170
|
+
this.currentValue = val
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
this.currentValue = []
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
currentValue(val: Record<PropertyKey, any>[]) {
|
|
177
|
+
console.log('currentValue change', val)
|
|
178
|
+
this.$emit('update:value', val)
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
methods: {
|
|
182
|
+
buildValue() {
|
|
183
|
+
const form = new FormValue()
|
|
184
|
+
this.runtime.dictionary!.parseData(this.runtime.dictionaryList!, form, this.type).then(res => {
|
|
185
|
+
this.currentValue.push(res.data)
|
|
186
|
+
this.runtime.formList!.push(form)
|
|
187
|
+
})
|
|
188
|
+
},
|
|
189
|
+
renderTable() {
|
|
190
|
+
return h(Table, {
|
|
191
|
+
rowKey: this.runtime?.dictionary?.getProp('id') as string,
|
|
192
|
+
pagination: false,
|
|
193
|
+
columns: this.currentColumnList,
|
|
194
|
+
dataSource: this.currentValue
|
|
195
|
+
})
|
|
196
|
+
},
|
|
197
|
+
renderHeader() {
|
|
198
|
+
if (this.header) {
|
|
199
|
+
return this.header.map(headerMenu => {
|
|
200
|
+
return h(MenuView, {
|
|
201
|
+
data: headerMenu,
|
|
202
|
+
disabled: this.disabled,
|
|
203
|
+
loading: this.loading,
|
|
204
|
+
onClick: () => {
|
|
205
|
+
if (headerMenu.prop === '$build') {
|
|
206
|
+
this.buildValue()
|
|
207
|
+
}
|
|
208
|
+
this.$emit('header', headerMenu.prop)
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
})
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
/**
|
|
216
|
+
* 主要模板
|
|
217
|
+
|
|
218
|
+
* @returns {VNode}
|
|
219
|
+
*/
|
|
220
|
+
render() {
|
|
221
|
+
const render = h('div', { class: 'complex-form-list' }, {
|
|
222
|
+
default: () => [this.renderHeader(), this.renderTable()]
|
|
223
|
+
})
|
|
224
|
+
return render
|
|
225
|
+
}
|
|
226
|
+
})
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { defineComponent, h, PropType, VNode } from "vue"
|
|
2
|
+
import { dataConfig } from "@complex-suite/data"
|
|
3
|
+
import ModalView from "./ModalView"
|
|
4
|
+
import type { ModalViewProps } from "./ModalView"
|
|
5
|
+
import icon from "../icon"
|
|
6
|
+
import type { localIconProps } from "../type"
|
|
7
|
+
|
|
8
|
+
type renderType = (payload: localIconProps) => VNode | VNode[]
|
|
9
|
+
|
|
10
|
+
export default defineComponent({
|
|
11
|
+
name: 'ImageViewer',
|
|
12
|
+
props: {
|
|
13
|
+
src: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: false
|
|
16
|
+
},
|
|
17
|
+
width: {
|
|
18
|
+
type: Number,
|
|
19
|
+
required: false,
|
|
20
|
+
default: 100
|
|
21
|
+
},
|
|
22
|
+
height: {
|
|
23
|
+
type: Number,
|
|
24
|
+
required: false
|
|
25
|
+
},
|
|
26
|
+
modal: {
|
|
27
|
+
type: Object as PropType<ModalViewProps>,
|
|
28
|
+
required: false
|
|
29
|
+
},
|
|
30
|
+
emptyRender: {
|
|
31
|
+
type: Function as PropType<renderType>,
|
|
32
|
+
required: false
|
|
33
|
+
},
|
|
34
|
+
errorRender: {
|
|
35
|
+
type: Function as PropType<renderType>,
|
|
36
|
+
required: false
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
data() {
|
|
40
|
+
return {
|
|
41
|
+
isError: false
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
computed: {
|
|
45
|
+
currentHeight() {
|
|
46
|
+
return this.height || this.width
|
|
47
|
+
},
|
|
48
|
+
currentSize() {
|
|
49
|
+
return this.width >= this.currentHeight ? this.width : this.currentHeight
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
watch: {
|
|
53
|
+
// 监听src变化,重置加载状态
|
|
54
|
+
src(val) {
|
|
55
|
+
if (val) {
|
|
56
|
+
this.isError = false
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
methods: {
|
|
61
|
+
renderImage() {
|
|
62
|
+
if (this.src && !this.isError) {
|
|
63
|
+
return h('img', {
|
|
64
|
+
class: this.modal ? 'complex-image-viewer-content complex-image-viewer-content-has-modal' : 'complex-image-viewer-content',
|
|
65
|
+
src: this.src,
|
|
66
|
+
onError: () => {
|
|
67
|
+
this.isError = true
|
|
68
|
+
},
|
|
69
|
+
onClick: this.modal ? () => {
|
|
70
|
+
(this.$refs.modal as InstanceType<typeof ModalView>).show()
|
|
71
|
+
} : undefined
|
|
72
|
+
})
|
|
73
|
+
} else if (this.isError) {
|
|
74
|
+
return h('div', {
|
|
75
|
+
class: 'complex-image-viewer-error'
|
|
76
|
+
}, [
|
|
77
|
+
!this.errorRender ? icon.local('errorImage', { size: this.currentSize }) : this.errorRender({ size: this.currentSize })
|
|
78
|
+
])
|
|
79
|
+
} else {
|
|
80
|
+
return h('div', {
|
|
81
|
+
class: 'complex-image-viewer-empty'
|
|
82
|
+
}, [
|
|
83
|
+
!this.emptyRender ? icon.local('emptyImage', { size: this.currentSize }) : this.emptyRender({ size: this.currentSize })
|
|
84
|
+
])
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
renderModal() {
|
|
88
|
+
if (this.modal) {
|
|
89
|
+
return h(ModalView, {
|
|
90
|
+
ref: 'modal',
|
|
91
|
+
title: '图片查看',
|
|
92
|
+
...this.modal
|
|
93
|
+
}, {
|
|
94
|
+
default: ({ width }: { width: number }) => {
|
|
95
|
+
const currentWidth = dataConfig.formatPixel(width)
|
|
96
|
+
return h('img', {
|
|
97
|
+
src: this.src,
|
|
98
|
+
style: {
|
|
99
|
+
width: currentWidth,
|
|
100
|
+
height: 'auto'
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
render() {
|
|
109
|
+
const width = dataConfig.formatPixel(this.width)
|
|
110
|
+
const height = dataConfig.formatPixel(this.currentHeight)
|
|
111
|
+
return h('div', {
|
|
112
|
+
class: 'complex-image-viewer',
|
|
113
|
+
style: {
|
|
114
|
+
width: width,
|
|
115
|
+
height: height
|
|
116
|
+
}
|
|
117
|
+
}, [
|
|
118
|
+
this.renderImage(),
|
|
119
|
+
this.renderModal()
|
|
120
|
+
])
|
|
121
|
+
}
|
|
122
|
+
})
|
package/src/InfoArea.tsx
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { defineComponent, h, PropType } from "vue"
|
|
2
|
+
import { getEnv } from "@complex-suite/utils"
|
|
3
|
+
import { DictionaryData, DictionaryValue, FormValue, ObserveList } from "@complex-suite/data"
|
|
4
|
+
import type { AttrsValueInitOption } from "@complex-suite/data"
|
|
5
|
+
import InfoView from "./InfoView"
|
|
6
|
+
import type { InfoViewDefaultProps } from "./InfoView"
|
|
7
|
+
import type { AutoItemPayloadType } from "./dictionary/AutoItem"
|
|
8
|
+
import antdConfig from "../antdConfig"
|
|
9
|
+
|
|
10
|
+
export interface InfoAreaDefaultProps extends InfoViewDefaultProps {
|
|
11
|
+
dictionary: DictionaryData
|
|
12
|
+
type?: string
|
|
13
|
+
observe?: boolean
|
|
14
|
+
inline?: boolean
|
|
15
|
+
onInit?: (observeList: ObserveList, form: FormValue, type: string, editArea: any) => void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface InfoAreaProps extends InfoAreaDefaultProps {
|
|
19
|
+
data?: Record<PropertyKey, any>
|
|
20
|
+
infoAttrs?: AttrsValueInitOption
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface InfoAreaOption extends InfoAreaProps {
|
|
24
|
+
ref?: string
|
|
25
|
+
onMenu?: (prop: string, payload: AutoItemPayloadType<'info'>) => unknown
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default defineComponent({
|
|
29
|
+
name: 'InfoArea',
|
|
30
|
+
emits: {
|
|
31
|
+
menu: (prop: string, _payload: AutoItemPayloadType<'info'>) => {
|
|
32
|
+
return !!typeof prop
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
props: {
|
|
36
|
+
dictionary: {
|
|
37
|
+
type: Object as PropType<InfoAreaProps['dictionary']>,
|
|
38
|
+
required: true
|
|
39
|
+
},
|
|
40
|
+
type: {
|
|
41
|
+
type: String,
|
|
42
|
+
required: false
|
|
43
|
+
},
|
|
44
|
+
observe: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
required: false,
|
|
47
|
+
default: () => {
|
|
48
|
+
return antdConfig.info.observe
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
inline: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
required: false,
|
|
54
|
+
default: () => {
|
|
55
|
+
return antdConfig.info.inline
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
data: {
|
|
59
|
+
type: Object as PropType<InfoAreaProps['data']>,
|
|
60
|
+
required: false
|
|
61
|
+
},
|
|
62
|
+
infoAttrs: {
|
|
63
|
+
type: Object as PropType<InfoAreaProps['infoAttrs']>,
|
|
64
|
+
required: false
|
|
65
|
+
},
|
|
66
|
+
menu: {
|
|
67
|
+
type: Object as PropType<InfoAreaProps['menu']>,
|
|
68
|
+
required: false
|
|
69
|
+
},
|
|
70
|
+
labelAlign: { // label 标签的文本对齐方式
|
|
71
|
+
type: String as PropType<InfoAreaProps['labelAlign']>,
|
|
72
|
+
required: false,
|
|
73
|
+
default: 'right'
|
|
74
|
+
},
|
|
75
|
+
gridParse: {
|
|
76
|
+
type: Object as PropType<InfoAreaProps['gridParse']>,
|
|
77
|
+
required: false
|
|
78
|
+
},
|
|
79
|
+
gridRowProps: { // gridRowProps设置项
|
|
80
|
+
type: Object as PropType<InfoAreaProps['gridRowProps']>,
|
|
81
|
+
required: false
|
|
82
|
+
},
|
|
83
|
+
onInit: {
|
|
84
|
+
type: Function as PropType<InfoAreaProps['onInit']>,
|
|
85
|
+
required: false
|
|
86
|
+
},
|
|
87
|
+
disabled: {
|
|
88
|
+
type: Boolean,
|
|
89
|
+
required: false
|
|
90
|
+
},
|
|
91
|
+
loading: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
required: false
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
data() {
|
|
97
|
+
return {
|
|
98
|
+
localType: undefined as undefined | string,
|
|
99
|
+
localData: undefined as undefined | Record<PropertyKey, any>,
|
|
100
|
+
form: new FormValue(),
|
|
101
|
+
dictionaryList: [] as DictionaryValue[],
|
|
102
|
+
observeList: undefined as undefined | ObserveList,
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
computed: {
|
|
106
|
+
currentType() {
|
|
107
|
+
return this.localType || this.type
|
|
108
|
+
},
|
|
109
|
+
currentData() {
|
|
110
|
+
return this.localData || this.data
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
mounted() {
|
|
114
|
+
if (this.currentType && this.currentData) {
|
|
115
|
+
this.$show()
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
beforeUnmount() {
|
|
119
|
+
if (this.observeList) {
|
|
120
|
+
this.observeList.reset()
|
|
121
|
+
this.observeList = undefined
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
methods: {
|
|
125
|
+
$show(type?: string, data?: Record<PropertyKey, any>) {
|
|
126
|
+
this.localType = type
|
|
127
|
+
this.localData = data || undefined
|
|
128
|
+
this.init()
|
|
129
|
+
},
|
|
130
|
+
init() {
|
|
131
|
+
this.dictionaryList = this.dictionary.getList(this.currentType!)
|
|
132
|
+
const observeList = this.dictionary.getObserveList(this.currentType!, this.dictionaryList as DictionaryValue[], this.observe)
|
|
133
|
+
this.dictionary.parseData(this.dictionaryList as DictionaryValue[], this.form, this.currentType!, this.currentData, '$info').then(() => {
|
|
134
|
+
// data生成完成后再进行list赋值,避免list提前赋值导致的EditView提前加载导致的数据为空的加载
|
|
135
|
+
if (this.onInit) {
|
|
136
|
+
this.onInit(observeList, this.form, this.currentType!, this)
|
|
137
|
+
}
|
|
138
|
+
this.observeList = observeList
|
|
139
|
+
if (this.observe) {
|
|
140
|
+
this.observeList!.startObserve(this.form.getData(), this.currentType)
|
|
141
|
+
} else if (getEnv('real') === 'development') {
|
|
142
|
+
// 开发环境下
|
|
143
|
+
const list: string[] = []
|
|
144
|
+
this.observeList.$map.forEach(item => {
|
|
145
|
+
if (item.$observe) {
|
|
146
|
+
list.push(item.$prop)
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
if (list.length > 0) {
|
|
150
|
+
console.error(`[${list.join('/')}]模块存在observe监控函数,当前observe未开启,请确认!`)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
},
|
|
155
|
+
renderInfo() {
|
|
156
|
+
if (this.observeList) {
|
|
157
|
+
const info = h(InfoView, {
|
|
158
|
+
data: this.form.getData(),
|
|
159
|
+
list: this.observeList as ObserveList,
|
|
160
|
+
menu: this.menu,
|
|
161
|
+
type: this.currentType!,
|
|
162
|
+
labelAlign: this.labelAlign,
|
|
163
|
+
gridParse: this.inline ? undefined : (this.gridParse || this.dictionary.$layout.grid.getValue(this.currentType!)),
|
|
164
|
+
gridRowProps: this.gridRowProps!,
|
|
165
|
+
infoAttrs: this.infoAttrs,
|
|
166
|
+
collapse: this.dictionary.$collapse,
|
|
167
|
+
disabled: this.disabled,
|
|
168
|
+
loading: this.loading,
|
|
169
|
+
onMenu: (prop: string, payload: AutoItemPayloadType<'info'>) => {
|
|
170
|
+
this.$emit('menu', prop, payload)
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
return info
|
|
174
|
+
} else {
|
|
175
|
+
return null
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
render() {
|
|
180
|
+
return h('div', { class: 'complex-info-area' }, [this.renderInfo()])
|
|
181
|
+
}
|
|
182
|
+
})
|
package/src/InfoView.tsx
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { defineComponent, h, PropType, markRaw } from "vue"
|
|
2
|
+
import { Col, Row } from "ant-design-vue"
|
|
3
|
+
import type { RowProps } from "ant-design-vue"
|
|
4
|
+
import { ObserveList, DefaultInfo, AttrsValue, GridParse } from "@complex-suite/data"
|
|
5
|
+
import type { AttrsValueInitOption } from "@complex-suite/data"
|
|
6
|
+
import AutoItem from "./dictionary/AutoItem"
|
|
7
|
+
import type { AutoItemPayloadType, AutoItemProps } from "./dictionary/AutoItem"
|
|
8
|
+
import antdConfig from "../antdConfig"
|
|
9
|
+
|
|
10
|
+
export interface InfoViewDefaultProps {
|
|
11
|
+
menu?: DefaultInfo[]
|
|
12
|
+
labelAlign?: 'center' | 'right' | 'left'
|
|
13
|
+
gridParse?: GridParse
|
|
14
|
+
gridRowProps?: RowProps
|
|
15
|
+
collapse?: boolean
|
|
16
|
+
disabled?: boolean
|
|
17
|
+
loading?: boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface InfoViewProps extends InfoViewDefaultProps {
|
|
21
|
+
data: Record<PropertyKey, any>
|
|
22
|
+
list: ObserveList
|
|
23
|
+
type: string
|
|
24
|
+
infoAttrs?: AttrsValueInitOption
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default defineComponent({
|
|
28
|
+
name: 'InfoView',
|
|
29
|
+
emits: {
|
|
30
|
+
menu: (prop: string, _payload: AutoItemPayloadType<'info'>) => {
|
|
31
|
+
return !!prop
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
props: {
|
|
35
|
+
data: {
|
|
36
|
+
type: Object as PropType<InfoViewProps['data']>,
|
|
37
|
+
required: true
|
|
38
|
+
},
|
|
39
|
+
list: {
|
|
40
|
+
type: Object as PropType<InfoViewProps['list']>,
|
|
41
|
+
required: true
|
|
42
|
+
},
|
|
43
|
+
menu: {
|
|
44
|
+
type: Object as PropType<InfoViewProps['menu']>,
|
|
45
|
+
required: false
|
|
46
|
+
},
|
|
47
|
+
type: {
|
|
48
|
+
type: String,
|
|
49
|
+
required: true
|
|
50
|
+
},
|
|
51
|
+
labelAlign: { // label 标签的文本对齐方式
|
|
52
|
+
type: String as PropType<InfoViewProps['labelAlign']>,
|
|
53
|
+
required: false,
|
|
54
|
+
default: 'right'
|
|
55
|
+
},
|
|
56
|
+
gridParse: {
|
|
57
|
+
type: Object as PropType<InfoViewProps['gridParse']>,
|
|
58
|
+
required: false
|
|
59
|
+
},
|
|
60
|
+
gridRowProps: { // gridRowProps设置项
|
|
61
|
+
type: Object as PropType<InfoViewProps['gridRowProps']>,
|
|
62
|
+
required: false
|
|
63
|
+
},
|
|
64
|
+
infoAttrs: {
|
|
65
|
+
type: Object as PropType<InfoViewProps['infoAttrs']>,
|
|
66
|
+
required: false
|
|
67
|
+
},
|
|
68
|
+
collapse: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
required: false
|
|
71
|
+
},
|
|
72
|
+
disabled: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
required: false
|
|
75
|
+
},
|
|
76
|
+
loading: {
|
|
77
|
+
type: Boolean,
|
|
78
|
+
required: false
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
computed: {
|
|
82
|
+
currentInfoAttrs() {
|
|
83
|
+
const layoutClass = `complex-info-${this.gridParse ? 'grid' : 'inline'}`
|
|
84
|
+
const currentInfoAttrs = new AttrsValue(this.infoAttrs)
|
|
85
|
+
currentInfoAttrs.pushClass('complex-info')
|
|
86
|
+
currentInfoAttrs.pushClass(layoutClass)
|
|
87
|
+
return currentInfoAttrs
|
|
88
|
+
},
|
|
89
|
+
concatList() {
|
|
90
|
+
if (this.menu && this.menu.length > 0) {
|
|
91
|
+
return this.list.data.concat(this.menu)
|
|
92
|
+
} else {
|
|
93
|
+
return this.list.data
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
currentList() {
|
|
97
|
+
return this.concatList.filter(item => (!item.$hidden && !item.$frozen))
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
methods: {
|
|
101
|
+
parseGrid(data: DefaultInfo) {
|
|
102
|
+
return antdConfig.parseGrid(this.gridParse!.parseData(data.$grid, 'main', this.type))
|
|
103
|
+
},
|
|
104
|
+
getItemProps(data: DefaultInfo, index: number) {
|
|
105
|
+
return {
|
|
106
|
+
parser: 'info',
|
|
107
|
+
target: data,
|
|
108
|
+
index: index,
|
|
109
|
+
list: this.list,
|
|
110
|
+
type: this.type,
|
|
111
|
+
gridParse: this.gridParse,
|
|
112
|
+
collapse: this.collapse,
|
|
113
|
+
disabled: this.disabled,
|
|
114
|
+
loading: this.loading,
|
|
115
|
+
data: this.data,
|
|
116
|
+
form: undefined,
|
|
117
|
+
parent: markRaw(this)
|
|
118
|
+
} as AutoItemProps<'info'>
|
|
119
|
+
},
|
|
120
|
+
renderItem(item: DefaultInfo, index: number) {
|
|
121
|
+
return h(AutoItem, this.getItemProps(item, index))
|
|
122
|
+
},
|
|
123
|
+
renderList() {
|
|
124
|
+
if (!this.gridParse) {
|
|
125
|
+
return this.currentList.map((item, index) => {
|
|
126
|
+
return this.renderItem(item, index)
|
|
127
|
+
})
|
|
128
|
+
} else {
|
|
129
|
+
return this.currentList.map((item, index) => {
|
|
130
|
+
return h(Col, this.parseGrid(item), {
|
|
131
|
+
default: () => this.renderItem(item, index)
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
/**
|
|
138
|
+
* 主要模板
|
|
139
|
+
|
|
140
|
+
* @returns {VNode}
|
|
141
|
+
*/
|
|
142
|
+
render() {
|
|
143
|
+
const list = this.renderList()
|
|
144
|
+
return h('div', antdConfig.componentConfig.parseAttrs(this.currentInfoAttrs), this.gridParse ? [
|
|
145
|
+
h(Row, { ...this.gridRowProps }, {
|
|
146
|
+
default: () => list
|
|
147
|
+
})
|
|
148
|
+
] : list)
|
|
149
|
+
}
|
|
150
|
+
})
|