edit
This commit is contained in:
		@ -2,7 +2,10 @@ import { Component, OnInit, ViewChild } from '@angular/core';
 | 
			
		||||
import { Router } from '@angular/router';
 | 
			
		||||
import { STComponent, STColumn, STChange } from '@delon/abc/st';
 | 
			
		||||
import { SFComponent, SFSchema, SFDateWidgetSchema } from '@delon/form';
 | 
			
		||||
import { NzModalService } from 'ng-zorro-antd/modal';
 | 
			
		||||
import { SystemStaffStaffModalComponent } from 'src/app/routes/sys-setting/components/staff-management/staff-modal/staff-modal.component';
 | 
			
		||||
import { SystemService } from 'src/app/routes/sys-setting/services/system.service';
 | 
			
		||||
import { SettingFinancialComponent } from './setting-financial/setting-financial.component';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-main-account',
 | 
			
		||||
@ -53,7 +56,7 @@ export class MainAccountComponent implements OnInit {
 | 
			
		||||
      buttons: [
 | 
			
		||||
        {
 | 
			
		||||
          text: '财务设置',
 | 
			
		||||
          click: item => this.routeTo(item)
 | 
			
		||||
          click: item => this.settingFinanical(item)
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          text: '合同设置',
 | 
			
		||||
@ -64,7 +67,7 @@ export class MainAccountComponent implements OnInit {
 | 
			
		||||
  ];
 | 
			
		||||
  reqParams = { pageIndex: 1, pageSize: 10 };
 | 
			
		||||
 | 
			
		||||
  constructor(public service: SystemService, private router: Router) {}
 | 
			
		||||
  constructor(public service: SystemService, private router: Router, private nzModalService: NzModalService) {}
 | 
			
		||||
 | 
			
		||||
  ngOnInit(): void {}
 | 
			
		||||
 | 
			
		||||
@ -76,6 +79,17 @@ export class MainAccountComponent implements OnInit {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  settingFinanical(item: any) {
 | 
			
		||||
    const modal = this.nzModalService.create({
 | 
			
		||||
      nzContent: SettingFinancialComponent,
 | 
			
		||||
      nzComponentParams: item ? { i: { ...item, roleId: '1,2,3', name: '用户名', phone: 18555555555 } } : { i: { id: 0 } },
 | 
			
		||||
      nzFooter: null
 | 
			
		||||
    });
 | 
			
		||||
    modal.afterClose.subscribe(res => {
 | 
			
		||||
      this.st.load();
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  routeTo(item?: any) {
 | 
			
		||||
    this.router.navigate(['/financial-management/driver-account-detail/1']);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,11 @@
 | 
			
		||||
<div class="modal-header">
 | 
			
		||||
    <div class="modal-title">财务设置</div>
 | 
			
		||||
</div>
 | 
			
		||||
<div>
 | 
			
		||||
    <sf #sf [compact]="true" [ui]="{'*': { spanLabelFixed: 120, grid: { span: 24 }}}" [schema]="schema" [button]="'none'">
 | 
			
		||||
    </sf>
 | 
			
		||||
</div>
 | 
			
		||||
<div class="modal-footer">
 | 
			
		||||
    <button nz-button type="button" (click)="close()">取消</button>
 | 
			
		||||
    <button nz-button type="button" nzType="primary" (click)="sure()" [disabled]="!sf.valid">确 定</button>
 | 
			
		||||
</div>
 | 
			
		||||
@ -0,0 +1,130 @@
 | 
			
		||||
import { Component, OnInit, ViewChild } from '@angular/core';
 | 
			
		||||
import { SFComponent, SFSchema, SFUISchema } from '@delon/form';
 | 
			
		||||
import { EAEnterpriseService } from '@shared';
 | 
			
		||||
import { NzMessageService } from 'ng-zorro-antd/message';
 | 
			
		||||
import { NzModalRef } from 'ng-zorro-antd/modal';
 | 
			
		||||
import { SystemService } from 'src/app/routes/sys-setting/services/system.service';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-setting-financial',
 | 
			
		||||
  templateUrl: './setting-financial.component.html',
 | 
			
		||||
  styleUrls: ['./setting-financial.component.less']
 | 
			
		||||
})
 | 
			
		||||
export class SettingFinancialComponent implements OnInit {
 | 
			
		||||
  @ViewChild('sf', { static: false })
 | 
			
		||||
  sf!: SFComponent;
 | 
			
		||||
  i: any;
 | 
			
		||||
  schema!: SFSchema;
 | 
			
		||||
  roleList = [];
 | 
			
		||||
  roleNames: any = [];
 | 
			
		||||
  constructor(
 | 
			
		||||
    private modal: NzModalRef,
 | 
			
		||||
    public msgSrv: NzMessageService,
 | 
			
		||||
    public service: SystemService,
 | 
			
		||||
    private enterpriseSrv: EAEnterpriseService
 | 
			
		||||
  ) {}
 | 
			
		||||
 | 
			
		||||
  ngOnInit(): void {
 | 
			
		||||
    if (this.i?.id !== 0) {
 | 
			
		||||
      this.i.roleIds = this.i.roleId !== '' ? this.i.roleId.split(',') : [];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this.initSF(this.i);
 | 
			
		||||
  }
 | 
			
		||||
  initSF(staff: any) {
 | 
			
		||||
    console.log(staff);
 | 
			
		||||
    this.schema = {
 | 
			
		||||
      properties: {
 | 
			
		||||
        name: {
 | 
			
		||||
          title: '公司名称',
 | 
			
		||||
          type: 'string',
 | 
			
		||||
          ui: { widget: 'string', placeholder: '请输入公司名称' },
 | 
			
		||||
          default: staff.name
 | 
			
		||||
        },
 | 
			
		||||
        phone: {
 | 
			
		||||
          title: '纳税人识别号',
 | 
			
		||||
          type: 'string',
 | 
			
		||||
          format: 'mobile',
 | 
			
		||||
          ui: { widget: 'string', placeholder: '请输入纳税人识别号' },
 | 
			
		||||
          default: staff.phone
 | 
			
		||||
        },
 | 
			
		||||
        phone2: {
 | 
			
		||||
          title: '税收分类编码',
 | 
			
		||||
          type: 'string',
 | 
			
		||||
          format: 'mobile',
 | 
			
		||||
          ui: { widget: 'string', placeholder: '请输入税收分类编码' },
 | 
			
		||||
          default: staff.phone
 | 
			
		||||
        },
 | 
			
		||||
        phone3: {
 | 
			
		||||
          title: '发票税率',
 | 
			
		||||
          type: 'string',
 | 
			
		||||
          format: 'mobile',
 | 
			
		||||
          ui: { widget: 'string', placeholder: '请输入发票税率' },
 | 
			
		||||
          default: staff.phone
 | 
			
		||||
        },
 | 
			
		||||
        phone4: {
 | 
			
		||||
          title: '附加费比例',
 | 
			
		||||
          type: 'string',
 | 
			
		||||
          format: 'mobile',
 | 
			
		||||
          ui: { widget: 'string', placeholder: '请输入附加费比例' },
 | 
			
		||||
          default: staff.phone
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      required: ['name', 'phone', 'phone2', 'phone3', 'phone4']
 | 
			
		||||
    };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  sure() {
 | 
			
		||||
    if (!this.sf.value.roleIds || this.sf.value.roleIds.length === 0) {
 | 
			
		||||
      this.service.msgSrv.error('员工角色不能为空!');
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    this.roleNames = [];
 | 
			
		||||
    this.roleList.forEach((item: { id: any; roleName: string }) => {
 | 
			
		||||
      this.sf.value.roleIds.forEach((ele: any) => {
 | 
			
		||||
        if (ele === item.id) {
 | 
			
		||||
          this.roleNames.push(item.roleName);
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
    });
 | 
			
		||||
    if (this.i.id === 0) {
 | 
			
		||||
      const params: any = {
 | 
			
		||||
        ...this.sf.value,
 | 
			
		||||
        roleId: this.sf.value.roleIds,
 | 
			
		||||
        roleNames: this.roleNames.join(','),
 | 
			
		||||
        telephone: this.sf.value.phone,
 | 
			
		||||
        staffName: this.sf.value.name
 | 
			
		||||
      };
 | 
			
		||||
      // this.service.request(this.service.$api_addStaff, params).subscribe((res) => {
 | 
			
		||||
      //   console.log(res);
 | 
			
		||||
      //   if (res) {
 | 
			
		||||
      //     this.service.msgSrv.success('保存成功!');
 | 
			
		||||
      //     this.modal.close(true);
 | 
			
		||||
      //   }
 | 
			
		||||
      //   // this.showInviteFlag = true;
 | 
			
		||||
      //   // this.inviteCode = res.inviteCode;
 | 
			
		||||
      // });
 | 
			
		||||
    } else {
 | 
			
		||||
      const params: any = {
 | 
			
		||||
        appUserId: this.i.appUserId,
 | 
			
		||||
        staffName: this.sf.value.name,
 | 
			
		||||
        roleId: this.sf.value.roleIds,
 | 
			
		||||
        telephone: this.i.telephone
 | 
			
		||||
      };
 | 
			
		||||
      // this.service.request(this.service.$api_editorStaff, params).subscribe((res) => {
 | 
			
		||||
      //   this.service.msgSrv.success('编辑成功!');
 | 
			
		||||
      //   // this.loadMyIdentity();
 | 
			
		||||
      //   this.modal.close(true);
 | 
			
		||||
      // });
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  loadMyIdentity() {
 | 
			
		||||
    this.enterpriseSrv.loadEnterpises().subscribe((data: any[]) => {
 | 
			
		||||
      this.enterpriseSrv.setCache(data);
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  close() {
 | 
			
		||||
    this.modal.destroy();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user