1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
import { Vue, Component, Prop } from 'vue-property-decorator';
import './app-form-group.less';
@Component({})
export default class AppFormGroup extends Vue {
/**
* 标题
*
* @type {string}
* @memberof AppFormGroup
*/
@Prop() public caption?: string;
/**
* 内置界面样式
*
* @type {string}
* @memberof AppFormGroup
*/
@Prop() public uiStyle?: string;
/**
* 布局模式
*
* @type {string}
* @memberof AppFormGroup
*/
@Prop() public layoutType?: string;
/**
* 是否显示标题
*
* @type {boolean}
* @memberof AppFormGroup
*/
@Prop({ default: true }) public isShowCaption!: boolean;
/**
* 信息面板模式
*
* @type {boolean}
* @memberof AppFormGroup
*/
@Prop({ default: false }) public isInfoGroupMode!: boolean;
/**
* 界面行为组
*
* @type {*}
* @memberof AppFormGroup
*/
@Prop() public uiActionGroup?: any;
/**
* 标题栏关闭模式
* 0: 不支持关闭
* 1: 默认打开
* 2: 默认关闭
*
* @type {(number | 0 | 1 | 2)}
* @memberof AppFormGroup
*/
@Prop({ default: 0 }) public titleBarCloseMode!: number | 0 | 1 | 2;
/**
* 收缩内容
*
* @type {boolean}
* @memberof AppFormGroup
*/
public collapseContant: boolean = false;
/**
* 计算样式
*
* @readonly
* @type {string[]}
* @memberof AppFormGroup
*/
get classes(): string[] {
return [
'app-form-group',
this.isShowCaption && this.collapseContant ? 'app-group-collapse-contant' : '',
this.isInfoGroupMode ? 'app-info-group-mode' : '',
Object.is(this.layoutType, 'FLEX') ? 'app-group-flex' : '',
this.isShowCaption ? '' : 'app-group-hiddden-caption',
];
}
/**
* vue 生命周期
*
* @memberof AppFormGroup
*/
public created() {
this.collapseContant = this.titleBarCloseMode === 2 ? true : false;
}
/**
* 触发收缩
*
* @memberof AppFormGroup
*/
public clickCollapse(): void {
this.collapseContant = !this.collapseContant;
}
/**
* 执行界面行
*
* @param {*} $event
* @memberof AppFormGroup
*/
public doUIAction($event: any, item: any): void {
this.$emit('groupuiactionclick', { event: $event, item: item });
}
/**
* 绘制界面行为项
*
* @param {*} item
* @returns
* @memberof AppFormGroup
*/
public renderActionItem(item: any) {
return (
<span class='item' on-click={($event: any) => this.doUIAction($event, item)}>
{
item.icon && !Object.is(item.icon, '') ?
<i class={item.icon} ></i> :
item.img && !Object.is(item.img, '') ?
<img src={item.img} /> :
''
}
<span>
{
this.uiActionGroup.langbase && !Object.is(this.uiActionGroup.langbase, '')
&& item.uiactiontag && !Object.is(item.uiactiontag, '') ?
this.$t(`${this.uiActionGroup.langbase}.uiactions.${item.uiactiontag}`)
: item.caption
}
</span>
</span>
);
}
/**
* 绘制逐项展开
*
* @returns
* @memberof AppFormGroup
*/
public renderItemExtractMode() {
return (
<span class='item-extract-mode'>
{
this.uiActionGroup.details && Array.isArray(this.uiActionGroup.details) ?
this.uiActionGroup.details.map((detail: any) => {
return this.renderActionItem(detail);
})
:
''
}
</span>
);
}
/**
* 绘制分组展开项
*
* @returns
* @memberof AppFormGroup
*/
public renderItemsExtractMode() {
return (
<dropdown transfer={true} trigger='click'>
<a href='javascript:void(0)'>
{this.uiActionGroup.caption}
</a>
{
this.uiActionGroup.details && Array.isArray(this.uiActionGroup.details) ?
<dropdown-menu slot='list'>
{
this.uiActionGroup.details.map((detail: any) => {
return (
<dropdown-item name={detail.name}>{this.renderActionItem(detail)}</dropdown-item>
);
})
}
</dropdown-menu>
: ''
}
</dropdown>
);
}
/**
* 绘制界面行为组
*
* @returns
* @memberof AppFormGroup
*/
public renderUIActionGroup() {
return (
<a slot='extra'>
{
this.uiActionGroup.extractMode && Object.is(this.uiActionGroup.extractMode, 'ITEMS') ?
this.renderItemsExtractMode() :
this.renderItemExtractMode()
}
</a >
);
}
/**
* 绘制标题收缩模式
*
* @returns
* @memberof AppFormGroup
*/
public renderTitleBarCloseMode() {
return (
this.titleBarCloseMode !== 0 ?
<icon
type={this.collapseContant ? 'ios-arrow-dropright-circle' : 'ios-arrow-dropdown-circle'}
on-click={() => this.clickCollapse()}>
</icon>
: ''
);
}
/**
* 内容绘制
*
* @memberof AppFormGroup
*/
public render() {
if (Object.is(this.uiStyle, 'STYLE2')) {
return (
<app-form-group2
caption={this.caption}
uiStyle={this.uiStyle}
layoutType={this.layoutType}
isShowCaption={this.isShowCaption}
uiActionGroup={this.uiActionGroup}
titleBarCloseMode={this.titleBarCloseMode}>
{this.$slots.default}
</app-form-group2>
);
} else {
return (
this.isShowCaption ?
<card bordered={false} dis-hover={true} class={this.classes}>
<p class='' slot='title'>
{this.renderTitleBarCloseMode()}
{this.caption}
</p>
{this.uiActionGroup ? this.renderUIActionGroup() : ''}
{Object.is(this.layoutType, 'FLEX') ? this.$slots.default : <row gutter={10}> {this.$slots.default} </row>}
</card> :
<row class={this.classes}>
{this.$slots.default}
</row>
);
}
}
}