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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
import { CreateElement } from 'vue';
import { Emit, Prop, Watch } from 'vue-property-decorator';
import { throttle, Util } from 'ibiz-core';
import { DataViewControlBase } from '../../../widgets';
/**
* 数据视图部件基类
*
* @export
* @class AppDataViewBase
* @extends {DataViewControlBase}
*/
export class AppDataViewBase extends DataViewControlBase {
/**
* 部件动态参数
*
* @memberof AppDataViewBase
*/
@Prop() public declare dynamicProps: any;
/**
* 部件静态参数
*
* @memberof AppDataViewBase
*/
@Prop() public declare staticProps: any;
/**
* 监听动态参数变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof AppDataViewBase
*/
@Watch('dynamicProps', {
immediate: true,
})
public onDynamicPropsChange(newVal: any, oldVal: any) {
if (newVal && !Util.isFieldsSame(newVal, oldVal)) {
super.onDynamicPropsChange(newVal, oldVal);
}
}
/**
* 监听静态参数变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof AppDataViewBase
*/
@Watch('staticProps', {
immediate: true,
})
public onStaticPropsChange(newVal: any, oldVal: any) {
if (newVal && !Util.isFieldsSame(newVal, oldVal)) {
super.onStaticPropsChange(newVal, oldVal);
}
}
/**
* 部件事件
*
* @param 抛出参数
* @memberof AppDataViewBase
*/
@Emit('ctrl-event')
public ctrlEvent({ controlname, action, data }: { controlname: string, action: string, data: any }): void { }
/**
* @description 是否显示回到顶部
* @readonly
* @type {boolean}
* @memberof AppDataViewBase
*/
get backTopVisible(): boolean {
let visible: boolean = false;
const el = document.querySelector(`#${this.controlId}`);
if (el) {
visible = true;
}
return visible;
}
/**
* 绘制分组
*
* @param {*} h
* @return {*}
* @memberof AppDataViewBase
*/
public renderGroup(h: any) {
return this.groupData.map((group: any, index: number) => {
return (
<el-collapse-item class="app-control-dataview__content__group" name={group.group}>
<div slot="title" class="group__title">
<div class="group__caption">{group.label}</div>
<div class="group__action">
{/* TODO 分组界面行为组 */}
{/* {this.renderGroupAction(group)} */}
</div>
</div>
{ this.hasChildrenRender(h, group) }
</el-collapse-item>
);
});
}
/**
* 绘制有子成员项
*
* @param {*} h
* @param {*} group
* @return {*}
* @memberof AppDataViewBase
*/
public hasChildrenRender(h: any, group: any) {
if (group.children.length > 0) {
const { cardColXS, cardColSM, cardColMD, cardColLG } = this.controlInstance;
return group.children.map((groupChild: any, index: number) => {
return (
<a href={groupChild.starturl}>
<i-col xs={cardColXS} sm={cardColSM} md={cardColMD} class="group__content" lg={cardColLG}>
{this.renderCard(groupChild)}
</i-col>
</a>
);
});
} else {
return (
<div class="group__empty">
{this.$t('app.commonwords.nodata')}
</div>
);
}
}
/**
* 渲染数据视图项行为
*
* @param {*} item
* @return {*}
* @memberof AppDataViewBase
*/
public renderDataViewItemAction(item: any) {
return Object.keys(this.actionModel).map((key: string) => {
if (item[key].visabled) {
const action = this.actionModel[key];
return (
<el-button type='text' disabled={item[key].disabled}
class="bottom__action"
on-click={($event: any) => {
this.handleActionClick(item, $event, action, action);
}}>
{action.showIcon && <i class={[action.cssClass, "bottom__action__icon"]}></i>}
<span>
{action.showCaption ? this.$tl(action.lanResTag, action?.caption ? action.caption : '') : ''}
</span>
</el-button>
)
}
});
}
/**
* 渲染数据视图项
*
* @param {*} item
* @return {*}
* @memberof AppDataViewBase
*/
public renderDataViewItem(item: any) {
return (
<div class="item__content">
<div class="item__content__top">
<div class="top__title">
<span>{item.srfmajortext}</span>
</div>
{item.content && <div class="top__description">{item.content}</div>}
</div>
{
this.actionModel && Object.keys(this.actionModel).length > 0 &&
<div class="item__content__bottom">
{this.renderDataViewItemAction(item)}
</div>
}
</div>
)
}
/**
* 渲染卡片
*
* @param {*} item
* @return {*}
* @memberof AppDataViewBase
*/
public renderCard(item: any) {
const style: any = {
width: this.controlInstance.cardWidth > 0 ? `${this.controlInstance.cardWidth}px` : false,
height: this.controlInstance.cardHeight > 0 ? `${this.controlInstance.cardHeight}px` : false
};
const itemCssName = {
"app-control-dataview__content__item": true,
"is-active": item.srfchecked === 1
}
const itemCss = this.controlInstance.getItemPSSysCss();
if (itemCss) {
Object.assign(itemCssName, {
[itemCss.cssName] : true,
})
}
return (
<el-card
shadow="hover"
body-style={style}
class={itemCssName}
nativeOnClick={() => throttle(this.handleClick, [item], this)}
nativeOnDblclick={() => throttle(this.handleDblClick, [item], this)}>
{this.controlInstance.getItemPSLayoutPanel()
? this.renderItemPSLayoutPanel(item)
: this.renderDataViewItem(item)}
</el-card>
);
}
/**
* 绘制数据视图内容
*
* @memberof AppDataViewBase
*/
public renderDataViewContent(h: CreateElement) {
if (!this.isEnableGroup) {
const { cardColXS, cardColSM, cardColMD, cardColLG } = this.controlInstance;
return this.items.map((item: any, index: number) => {
return (
<i-col xs={cardColXS} sm={cardColSM} md={cardColMD} lg={cardColLG}>
{this.renderCard(item)}
</i-col>
);
});
} else {
return <el-collapse v-model={this.activeName}>{this.renderGroup(h)}</el-collapse>;
}
}
/**
* @description 绘制加载更多
* @return {*}
* @memberof AppDataViewBase
*/
renderLoadMore(){
if (this.enablePagingBar || Object.is(this.totalRecord, this.items.length)) {
return null;
}
return (
<div
onclick={(event: MouseEvent) => {
this.loadMore(event);
}}
class='app-control-dataview__load--more'
>
{this.$t('app.dataview.loadmore')}
</div>
);
}
/**
* 绘制排序栏
*
* @memberof AppDataViewBase
*/
public renderSortBar(h: any) {
return (
<app-sort-bar
sortModel={this.sortModel}
sortField={this.sortField}
sortDir={this.sortDir}
entityName={this.appDeCodeName}
on-clickSort={(val: any) => throttle(this.sortClick, [val], this)}
></app-sort-bar>
);
}
/**
* 绘制分页栏
*
* @memberof AppDataViewBase
*/
public renderPaging() {
if (!this.enablePagingBar) {
return null;
}
const pageText = <span>{this.$t('app.dataview.sum')} {this.totalRecord} {this.$t('app.dataview.data')}</span>
return this.items?.length > 0 ? (
<row class='app-control-dataview__pagination control-footer'>
<page
class='pagination--pull-right'
on-on-change={($event: any) => this.pageOnChange($event)}
on-on-page-size-change={($event: any) => this.onPageSizeChange($event)}
transfer={true}
total={this.totalRecord}
show-sizer
current={this.curPage}
page-size={this.limit}
page-size-opts={[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]}
show-elevator
show-total
>
{this.renderBatchToolbar()}
<span>
<i-button icon='md-refresh' class="pagination__refresh" title={this.$t('app.grid.refresh')} on-click={() => throttle(this.pageRefresh, [], this)}></i-button>
</span>
{pageText}
</page>
</row>
) : null;
}
/**
* 绘制
*
* @memberof AppDataViewBase
*/
public render(h: CreateElement) {
if (!this.controlIsLoaded) {
return null;
}
const { controlClassNames } = this.renderOptions;
return (
<div class={controlClassNames}>
{this.hasSortBar && (
<div class='control-header app-control-dataview__header'>{this.renderSortBar(h)}</div>
)}
{this.items.length > 0 && (
<row class='control-content app-control-dataview__content' gutter={24} type='flex' justify='start'>
{this.renderDataViewContent(h)}
{this.renderLoadMore()}
</row>
)}
{this.renderPaging()}
{!this.enablePagingBar ? this.renderBatchToolbar() : null}
{!this.ctrlLoadingService?.isLoading ? this.renderEmptyDataTip() : this.renderLoadDataTip()}
{this.backTopVisible && <el-backtop target={`#${this.controlId}`}></el-backtop>}
</div>
);
}
/**
* 销毁视图回调
*
* @memberof AppDataViewBase
*/
public destroyed() {
this.ctrlDestroyed();
}
}