|
@@ -8,12 +8,19 @@ import { CommonModule } from '@angular/common';
|
|
|
|
|
|
import { NzPaginationModule } from 'ng-zorro-antd/pagination';
|
|
|
import { NzEmptyModule } from 'ng-zorro-antd/empty';
|
|
|
+import { NzResultModule } from 'ng-zorro-antd/result';
|
|
|
|
|
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
|
import { MatButtonModule } from '@angular/material/button';
|
|
|
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
|
import { UtilnowPipe } from '../../../pipes/utilnow.pipe';
|
|
|
import { NzTableModule } from 'ng-zorro-antd/table';
|
|
|
+import { confirmDialog, openObjectEditDialog } from '../../../schemas/func-parse';
|
|
|
+import { MatIconModule } from '@angular/material/icon';
|
|
|
+import { NzIconModule } from 'ng-zorro-antd/icon';
|
|
|
+import { NzPageHeaderModule } from 'ng-zorro-antd/page-header';
|
|
|
+import { NzBreadCrumbModule } from 'ng-zorro-antd/breadcrumb';
|
|
|
+import { NzTagModule } from 'ng-zorro-antd/tag';
|
|
|
|
|
|
interface SchemaFiled{
|
|
|
key:string,
|
|
@@ -30,8 +37,8 @@ interface SchemaFiled{
|
|
|
imports:[CommonModule,
|
|
|
UtilnowPipe,
|
|
|
// TranslateModule,
|
|
|
- NzPaginationModule,NzEmptyModule,NzTableModule,
|
|
|
- MatButtonModule,MatCheckboxModule,MatSlideToggleModule,
|
|
|
+ NzPaginationModule,NzEmptyModule,NzTableModule,NzResultModule,NzIconModule,
|
|
|
+ MatButtonModule,MatCheckboxModule,MatSlideToggleModule,MatIconModule,
|
|
|
],
|
|
|
providers:[]
|
|
|
})
|
|
@@ -69,6 +76,12 @@ export class CompTableListComponent {
|
|
|
this.refresh();
|
|
|
}
|
|
|
|
|
|
+ createObject(){
|
|
|
+ openObjectEditDialog(this.dialog,this.schema,undefined,()=>{
|
|
|
+ this.refresh();
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
batchHandle(button:any){
|
|
|
// console.log(this.currentLang,'888888888888888888')
|
|
|
button?.handle({
|
|
@@ -83,7 +96,9 @@ export class CompTableListComponent {
|
|
|
onButtonHandleCallBack:Function|undefined
|
|
|
buttonHandle(button:any,object:any){
|
|
|
let that = this
|
|
|
- button?.handle({object:object,dialog:this.dialog,callback:this.onButtonHandleCallBack},that.currentLang)
|
|
|
+ if(button?.handle){
|
|
|
+ button?.handle({object:object,dialog:this.dialog,callback:this.onButtonHandleCallBack},that.currentLang)
|
|
|
+ }
|
|
|
}
|
|
|
refresh(page?:number){
|
|
|
if(page){this.pageIndex=page}
|
|
@@ -152,4 +167,66 @@ export class CompTableListComponent {
|
|
|
object.set(key,!object.get(key))
|
|
|
object.save();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 行选择处理逻辑
|
|
|
+ */
|
|
|
+ checked = false;
|
|
|
+ indeterminate = false;
|
|
|
+ setOfCheckedId = new Set<string>();
|
|
|
+
|
|
|
+ updateCheckedSet(id: string, checked: boolean): void {
|
|
|
+ if (checked) {
|
|
|
+ this.setOfCheckedId.add(id);
|
|
|
+ } else {
|
|
|
+ this.setOfCheckedId.delete(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ onCurrentPageDataChange(event:any): void {
|
|
|
+ this.refreshCheckedStatus();
|
|
|
+ }
|
|
|
+
|
|
|
+ refreshCheckedStatus(): void {
|
|
|
+ const listOfEnabledData = this.list // .filter(({ disabled }) => !disabled);
|
|
|
+ this.checked = listOfEnabledData.every(({ id }) => this.setOfCheckedId.has(id));
|
|
|
+ this.indeterminate = listOfEnabledData.some(({ id }) => this.setOfCheckedId.has(id)) && !this.checked;
|
|
|
+ }
|
|
|
+
|
|
|
+ onItemChecked(id: string, checked: boolean): void {
|
|
|
+ this.updateCheckedSet(id, checked);
|
|
|
+ this.refreshCheckedStatus();
|
|
|
+ }
|
|
|
+
|
|
|
+ onAllChecked(checked: boolean): void {
|
|
|
+ this.list
|
|
|
+ // .filter(({ disabled }) => !disabled)
|
|
|
+ .forEach(({ id }) => this.updateCheckedSet(id, checked));
|
|
|
+ this.refreshCheckedStatus();
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 选择快捷功能:批量处理
|
|
|
+ */
|
|
|
+ // 批量删除
|
|
|
+ deleteSelected(){
|
|
|
+ confirmDialog(this.dialog,{
|
|
|
+ title:"批量删除",
|
|
|
+ message:"删除后数据不可恢复,请谨慎操作",
|
|
|
+ danger:true,
|
|
|
+ handleOK:async ()=>{
|
|
|
+ let selectedList = this.list.filter(item=>this.setOfCheckedId.has(item?.id))
|
|
|
+ let deletePromiseList = selectedList.map(item=>{
|
|
|
+ return new Promise((resolve=>{
|
|
|
+ item.set("isDeleted",true);
|
|
|
+ item.save();
|
|
|
+ }))
|
|
|
+ })
|
|
|
+ try{
|
|
|
+ await Promise.all(deletePromiseList)
|
|
|
+ }catch(err){}
|
|
|
+ this.refresh();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|