Files
bbq/src/app/routes/sys-setting/components/cart-config/cart-config-action-modal/cart-config-action-modal.component.ts
Taric Xin df711ddcb8 edit
2021-12-02 10:10:24 +08:00

125 lines
3.2 KiB
TypeScript

import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { SFComponent, SFRadioWidgetSchema, SFSchema, SFStringWidgetSchema, SFUISchema } from '@delon/form';
import { NzMessageService } from 'ng-zorro-antd/message';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { SystemService } from '../../../services/system.service';
@Component({
selector: 'app-cart-config-action-modal',
templateUrl: './cart-config-action-modal.component.html',
styleUrls: ['./cart-config-action-modal.component.less']
})
export class CartConfigActionModalComponent implements OnInit {
@ViewChild('sf', { static: false })
sf!: SFComponent;
i: any;
schema!: SFSchema;
ui: SFUISchema = {
'*': {
spanLabelFixed: 120,
grid: { span: 24 }
}
};
@Input()
configType: number = 1;
constructor(private modal: NzModalRef, public service: SystemService) {}
ngOnInit(): void {
this.initSF(this.i);
console.log(this.configType);
}
initSF(staff: any) {
let required: any = [];
switch (this.configType) {
case 1:
required = ['phone1'];
break;
case 2:
required = ['phone2'];
break;
case 3:
required = ['phone3'];
break;
default:
break;
}
this.schema = {
properties: {
phone1: {
title: '车型',
type: 'string',
ui: {
placeholder: '请输入',
hidden: this.configType === 2 || this.configType === 3
},
default: staff.phone1
},
phone2: {
title: '车长',
type: 'string',
ui: {
placeholder: '请输入',
addOnAfter: '米',
hidden: this.configType === 1 || this.configType === 3
} as SFStringWidgetSchema,
default: staff.phone2
},
phone3: {
title: '物品名称',
type: 'string',
ui: {
placeholder: '请输入',
hidden: this.configType === 1 || this.configType === 2
},
default: staff.phone3
},
roleId: {
type: 'string',
title: '状态',
enum: [
{ label: '启用', value: 1 },
{ label: '停用', value: 0 }
],
ui: {
widget: 'radio'
} as SFRadioWidgetSchema,
default: staff?.roleId || 1
}
},
required: required
};
}
sure() {
if (this.i.id === 0) {
const params: any = {
...this.sf.value,
roleId: this.sf.value.roleId,
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.roleId,
telephone: this.i.telephone
};
}
}
close() {
this.modal.destroy();
}
}