From d288924fa69398e40d408864b185071266f14bf8 Mon Sep 17 00:00:00 2001 From: forecho Date: Wed, 21 Oct 2020 17:42:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B4=A6=E6=88=B7=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=86=BB=E7=BB=93&&=E5=86=BB=E7=BB=93=E8=B4=A6=E6=88=B7?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E5=87=BA=E7=8E=B0=E5=86=8D=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86=E9=80=89=E9=A1=B9=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../routes/account/form/form.component.html | 45 +++++++++++-- src/app/routes/account/form/form.component.ts | 65 +++++-------------- .../routes/account/index/index.component.html | 1 + .../routes/account/index/index.component.ts | 4 +- src/app/shared/search/search.component.ts | 2 +- 5 files changed, 61 insertions(+), 56 deletions(-) diff --git a/src/app/routes/account/form/form.component.html b/src/app/routes/account/form/form.component.html index 310163b..1ea5827 100644 --- a/src/app/routes/account/form/form.component.html +++ b/src/app/routes/account/form/form.component.html @@ -1,9 +1,42 @@ - - - + + + diff --git a/src/app/routes/account/form/form.component.ts b/src/app/routes/account/form/form.component.ts index 5d6886a..7a0c039 100644 --- a/src/app/routes/account/form/form.component.ts +++ b/src/app/routes/account/form/form.component.ts @@ -1,61 +1,30 @@ -import { Component } from '@angular/core'; -import { SFSchema, SFSelectWidgetSchema } from '@delon/form'; +import { Component, OnInit } from '@angular/core'; import { _HttpClient } from '@delon/theme'; import { NzMessageService } from 'ng-zorro-antd/message'; import { NzModalRef } from 'ng-zorro-antd/modal'; -import { map } from 'rxjs/operators'; @Component({ selector: 'app-account-form', templateUrl: './form.component.html', }) -export class AccountFormComponent { +export class AccountFormComponent implements OnInit { record: any = {}; - schema: SFSchema = { - properties: { - name: { type: 'string', title: '名称', maxLength: 50 }, - type: { - type: 'string', - title: '帐户类别', - default: 'general_account', - ui: { - widget: 'select', - asyncData: () => { - return this.http.get('/api/accounts/types').pipe( - map((res) => { - return res.data.map((item: any) => { - return { value: item.type, label: item.name }; - }); - }), - ); - }, - } as SFSelectWidgetSchema, - }, - currency_balance: { type: 'number', title: '起始金额', default: 0, ui: { widgetWidth: 200 } }, - currency_code: { - type: 'string', - title: '货币', - default: 'CNY', - enum: [ - { value: 'CNY', label: 'CNY' }, - // { value: 'USD', label: 'USD' }, - ], - }, - // exclude_from_stats: { - // type: 'boolean', - // title: '从统计中排除', - // }, - default: { - type: 'boolean', - title: '默认账户', - }, - }, - required: ['name', 'type', 'balance', 'currency_code'], - ui: { - spanLabelFixed: 150, - grid: { span: 24 }, - }, + accountTypes: []; + + form = { + name: '', + type: 'general_account', + currency_balance: '', + currency_code: 'CNY', + status: 'active', + default: false, + exclude_from_stats: false, }; + ngOnInit(): void { + if (this.record) { + this.form = this.record; + } + } constructor(private http: _HttpClient, private modal: NzModalRef, private msgSrv: NzMessageService) {} diff --git a/src/app/routes/account/index/index.component.html b/src/app/routes/account/index/index.component.html index 8f79875..e816f91 100644 --- a/src/app/routes/account/index/index.component.html +++ b/src/app/routes/account/index/index.component.html @@ -77,6 +77,7 @@ {{ item.type_name }} 默认账户 + 冻结 diff --git a/src/app/routes/account/index/index.component.ts b/src/app/routes/account/index/index.component.ts index 3748492..7d5e3ee 100644 --- a/src/app/routes/account/index/index.component.ts +++ b/src/app/routes/account/index/index.component.ts @@ -90,7 +90,9 @@ export class AccountIndexComponent implements OnInit { } form(record: { id?: number } = {}): void { - this.modal.create(AccountFormComponent, { record }, { size: 'md' }).subscribe((res) => { + console.log(this.accountTypes); + + this.modal.create(AccountFormComponent, { record, accountTypes: this.accountTypes }, { size: 'md' }).subscribe((res) => { this.getData(); this.getOverview(); this.cdr.detectChanges(); diff --git a/src/app/shared/search/search.component.ts b/src/app/shared/search/search.component.ts index ef9f6cc..f5fd48d 100644 --- a/src/app/shared/search/search.component.ts +++ b/src/app/shared/search/search.component.ts @@ -31,7 +31,7 @@ export class RecordSearchComponent implements OnInit { ngOnInit() { this.initQ = deepCopy(this.q); - this.loadSelect('/api/accounts', 'account_id'); + this.loadSelect('/api/accounts?status=active', 'account_id'); this.loadSelect('/api/categories', 'category_id'); this.loadSelect('/api/tags', 'tags'); this.loadSelect('/api/transactions/types', 'transaction_type');