提交 1c5dbba0 编写于 作者: W wq1234wq

业务代码

上级 100fb7ae
<p align="center">
<a href="https://ng-alain.com">
<img width="100" src="https://ng-alain.com/assets/img/logo-color.svg">
</a>
</p>
<h1 align="center">NG-ALAIN</h1>
<div align="center">
一个基于 Antd 中后台前端解决方案,提供更多通用性业务模块,让开发者更加专注于业务。
[![Build Status](https://dev.azure.com/ng-alain/ng-alain/_apis/build/status/ng-alain-CI?branchName=master)](https://dev.azure.com/ng-alain/ng-alain/_build/latest?definitionId=2&branchName=master)
[![GitHub Release Date](https://img.shields.io/github/release-date/ng-alain/ng-alain.svg?style=flat-square)](https://github.com/ng-alain/ng-alain/releases)
[![NPM version](https://img.shields.io/npm/v/ng-alain.svg?style=flat-square)](https://www.npmjs.com/package/ng-alain)
[![prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://prettier.io/)
[![GitHub license](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](https://github.com/ng-alain/ng-alain/blob/master/LICENSE)
[![Gitter](https://img.shields.io/gitter/room/ng-alain/ng-alain.svg?style=flat-square)](https://gitter.im/ng-alain/ng-alain)
[![ng-zorro-vscode](https://img.shields.io/badge/ng--zorro-VSCODE-brightgreen.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=cipchk.ng-zorro-vscode)
[![ng-alain-vscode](https://img.shields.io/badge/ng--alain-VSCODE-brightgreen.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=cipchk.ng-alain-vscode)
</div>
[English](README.md) | 简体中文
## 快速入门
- [如何开始使用?](https://ng-alain.com/docs/getting-started)
## 链接
+ [Document](https://ng-alain.com) ([Surge Mirror](https://ng-alain-doc.surge.sh))
+ [@delon Source](https://github.com/ng-alain/delon)
+ [DEMO](https://ng-alain.surge.sh) ([国内镜像](https://ng-alain.gitee.io/))
## 特性
+ 基于 `ng-zorro-antd`
+ 响应式
+ 国际化
+ 基建类库 [@delon](https://github.com/ng-alain/delon)(包括:业务组件、ACL访问控制、缓存、授权、动态表单等)
+ 延迟加载及良好的启用画面
+ 良好的UI路由设计
+ 定制主题
+ Less预编译
+ RTL
+ 良好的目录组织结构
+ 简单升级
+ 支持Docker部署
## Architecture
![Architecture](https://raw.githubusercontent.com/ng-alain/delon/master/_screenshot/architecture.png)
> [delon](https://github.com/ng-alain/delon) 是基于 Ant Design 设计理念的企业级中后台前端业务型组件库。
## 应用截图
![desktop](https://raw.githubusercontent.com/ng-alain/delon/master/_screenshot/desktop.png)
![ipad](https://raw.githubusercontent.com/ng-alain/delon/master/_screenshot/ipad.png)
![iphone](https://raw.githubusercontent.com/ng-alain/delon/master/_screenshot/iphone.png)
## 如何贡献
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/ng-alain/ng-alain/pulls)
在任何形式的参与前,请先阅读 [贡献者文档](https://github.com/ng-alain/ng-alain/blob/master/CONTRIBUTING.md)。如果你希望参与贡献,欢迎 [Pull Request](https://github.com/ng-alain/ng-alain/pulls),或给我们 [报告 Bug](https://ng-alain.com/issue-helper/index.html#zh)
> 强烈推荐阅读 [《提问的智慧》](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way)(**本指南不提供此项目的实际支持服务!**)、[《如何向开源社区提问题》](https://github.com/seajs/seajs/issues/545) 和 [《如何有效地报告 Bug》](http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html)、[《如何向开源项目提交无法解答的问题》](https://zhuanlan.zhihu.com/p/25795393),更好的问题更容易获得帮助。
## 赞助
ng-alain是MIT协议的开源项目。为了项目能够更好的持续的发展,我们期望获得更多的支持者,你可以通过如下任何一种方式支持我们:
- [patreon](https://www.patreon.com/cipchk)
- [opencollective](https://opencollective.com/ng-alain)
- [paypal](https://www.paypal.me/cipchk)
- [支付宝或微信](https://ng-alain.com/assets/donate.png)
或购买我们 [商品主题](https://e.ng-alain.com/)
## Backers
Thank you to all our backers! 🙏
<a href="https://opencollective.com/ng-alain#backers" target="_blank"><img src="https://opencollective.com/ng-alain/backers.svg?width=890"></a>
### License
The MIT License (see the [LICENSE](https://github.com/ng-alain/ng-alain/blob/master/LICENSE) file for the full text)
<p align="center">
<a href="https://ng-alain.com">
<img width="100" src="https://ng-alain.com/assets/img/logo-color.svg">
</a>
</p>
<h1 align="center">NG-ALAIN</h1>
<div align="center">
Out-of-box UI solution for enterprise applications, Let developers focus on business.
[![Build Status](https://dev.azure.com/ng-alain/ng-alain/_apis/build/status/ng-alain-CI?branchName=master)](https://dev.azure.com/ng-alain/ng-alain/_build/latest?definitionId=2&branchName=master)
[![Dependency Status](https://david-dm.org/ng-alain/ng-alain/status.svg?style=flat-square)](https://david-dm.org/ng-alain/ng-alain)
[![GitHub Release Date](https://img.shields.io/github/release-date/ng-alain/ng-alain.svg?style=flat-square)](https://github.com/ng-alain/ng-alain/releases)
[![NPM version](https://img.shields.io/npm/v/ng-alain.svg?style=flat-square)](https://www.npmjs.com/package/ng-alain)
[![prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://prettier.io/)
[![GitHub license](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](https://github.com/ng-alain/ng-alain/blob/master/LICENSE)
[![Gitter](https://img.shields.io/gitter/room/ng-alain/ng-alain.svg?style=flat-square)](https://gitter.im/ng-alain/ng-alain)
[![ng-zorro-vscode](https://img.shields.io/badge/ng--zorro-VSCODE-brightgreen.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=cipchk.ng-zorro-vscode)
[![ng-alain-vscode](https://img.shields.io/badge/ng--alain-VSCODE-brightgreen.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=cipchk.ng-alain-vscode)
</div>
English | [简体中文](README-zh_CN.md)
## Quickstart
- [Getting Started](https://ng-alain.com/docs/getting-started)
## Links
+ [Document](https://ng-alain.com) ([Surge Mirror](https://ng-alain-doc.surge.sh))
+ [@delon Source](https://github.com/ng-alain/delon)
+ [DEMO](https://ng-alain.surge.sh) ([国内镜像](https://ng-alain.gitee.io/))
## Features
+ `ng-zorro-antd` based
+ Responsive Layout
+ I18n
+ [@delon](https://github.com/ng-alain/delon)
+ Lazy load Assets
+ UI Router States
+ Customize Theme
+ Less preprocessor
+ RTL
+ Well organized & commented code
+ Simple upgrade
+ Support Docker deploy
## Architecture
![Architecture](https://raw.githubusercontent.com/ng-alain/delon/master/_screenshot/architecture.png)
> [delon](https://github.com/ng-alain/delon) is a production-ready solution for admin business components packages, Built on the design principles developed by Ant Design.
## App Shots
![desktop](https://raw.githubusercontent.com/ng-alain/delon/master/_screenshot/desktop.png)
![ipad](https://raw.githubusercontent.com/ng-alain/delon/master/_screenshot/ipad.png)
![iphone](https://raw.githubusercontent.com/ng-alain/delon/master/_screenshot/iphone.png)
## Contributing
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/ng-alain/ng-alain/pulls)
We welcome all contributions. Please read our [CONTRIBUTING.md](https://github.com/ng-alain/ng-alain/blob/master/CONTRIBUTING.md) first. You can submit any ideas as [pull requests](https://github.com/ng-alain/ng-alain/pulls) or as [GitHub issues](https://github.com/ng-alain/ng-alain/issues).
> If you're new to posting issues, we ask that you read [*How To Ask Questions The Smart Way*](http://www.catb.org/~esr/faqs/smart-questions.html) (**This guide does not provide actual support services for this project!**), [How to Ask a Question in Open Source Community](https://github.com/seajs/seajs/issues/545) and [How to Report Bugs Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html) prior to posting. Well written bug reports help us help you!
## Donation
ng-alain is an MIT-licensed open source project. In order to achieve better and sustainable development of the project, we expect to gain more backers. You can support us in any of the following ways:
- [patreon](https://www.patreon.com/cipchk)
- [opencollective](https://opencollective.com/ng-alain)
- [paypal](https://www.paypal.me/cipchk)
- [支付宝或微信](https://ng-alain.com/assets/donate.png)
Or purchasing our [business theme](https://e.ng-alain.com/).
## Backers
Thank you to all our backers! 🙏
<a href="https://opencollective.com/ng-alain#backers" target="_blank"><img src="https://opencollective.com/ng-alain/backers.svg?width=890"></a>
### License
The MIT License (see the [LICENSE](https://github.com/ng-alain/ng-alain/blob/master/LICENSE) file for the full text)
import { Injectable } from '@angular/core';
import { CacheService } from '@delon/cache';
@Injectable()
export class Globals {
drawerwidth: number = 720;
nzMaskClosable: boolean = true;
UserWigets: string[] = [];
constructor(public srv: CacheService) {
this.srv.get<UserProfile>('userProfile').subscribe((x) => {
this.drawerwidth = x.drawerwidth;
this.nzMaskClosable = x.nzMaskClosable;
this.UserWigets = x.UserWigets;
});
}
public load() { }
}
export interface UserProfile {
drawerwidth: number;
nzMaskClosable: boolean;
UserWigets: string[];
}
\ No newline at end of file
......@@ -5,8 +5,8 @@ import { ALAIN_I18N_TOKEN, MenuService, SettingsService, TitleService } from '@d
import { TranslateService } from '@ngx-translate/core';
import { NzSafeAny } from 'ng-zorro-antd/core/types';
import { NzIconService } from 'ng-zorro-antd/icon';
import { zip } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { concat, zip } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { ICONS } from '../../../style-icons';
import { ICONS_AUTO } from '../../../style-icons-auto';
import { I18NService } from '../i18n/i18n.service';
......@@ -33,41 +33,67 @@ export class StartupService {
load(): Promise<void> {
// only works with promises
// https://github.com/angular/angular/issues/15088
return new Promise((resolve) => {
zip(this.httpClient.get(`assets/tmp/i18n/${this.i18n.defaultLang}.json`), this.httpClient.get('assets/tmp/app-data.json'))
.pipe(
// 接收其他拦截器后产生的异常消息
catchError((res) => {
console.warn(`StartupService.load: Network request failed`, res);
resolve();
return [];
}),
)
.subscribe(
([langData, appData]) => {
// setting language data
this.translate.setTranslation(this.i18n.defaultLang, langData);
this.translate.setDefaultLang(this.i18n.defaultLang);
// application data
const res = appData as NzSafeAny;
// 应用信息:包括站点名、描述、年份
this.settingService.setApp(res.app);
// 用户信息:包括姓名、头像、邮箱地址
this.settingService.setUser(res.user);
// ACL:设置权限为全量
this.aclService.setFull(true);
// 初始化菜单
this.menuService.add(res.menu);
// 设置页面标题的后缀
this.titleService.default = '';
this.titleService.suffix = res.app.name;
},
() => {},
() => {
resolve();
},
);
});
return concat(this.httpClient.get(`assets/tmp/i18n/${this.i18n.defaultLang}.json`).pipe(map(langData => {
this.translate.setTranslation(this.i18n.defaultLang, langData);
this.translate.setDefaultLang(this.i18n.defaultLang);
})), this.httpClient.get('/api/Account/MyInfo').pipe(map(appData => {
const res = appData as NzSafeAny;
this.settingService.setApp(res.app);
this.settingService.setUser(res.user);
this.aclService.setFull(true);
this.menuService.add(res.menu);
this.titleService.default = '';
this.titleService.suffix = res.app.name;
}))).toPromise()
// return new Promise((resolve) => {
// zip(this.httpClient.get(`assets/tmp/i18n/${this.i18n.defaultLang}.json`), this.httpClient.get('assets/tmp/app-data.json'))
// .pipe(
// // 接收其他拦截器后产生的异常消息
// catchError((res) => {
// console.warn(`StartupService.load: Network request failed`, res);
// resolve();
// return [];
// }),
// )
// .subscribe(
// ([langData, appData]) => {
// // setting language data
// this.translate.setTranslation(this.i18n.defaultLang, langData);
// this.translate.setDefaultLang(this.i18n.defaultLang);
// // application data
// const res = appData as NzSafeAny;
// // 应用信息:包括站点名、描述、年份
// this.settingService.setApp(res.app);
// // 用户信息:包括姓名、头像、邮箱地址
// this.settingService.setUser(res.user);
// // ACL:设置权限为全量
// this.aclService.setFull(true);
// // 初始化菜单
// this.menuService.add(res.menu);
// // 设置页面标题的后缀
// this.titleService.default = '';
// this.titleService.suffix = res.app.name;
// },
// () => { },
// () => {
// resolve();
// },
// );
// });
}
}
export class AppMessage {
ErrType?: number;
ErrMessage?: string;
Result?: any;
ErrLevel?: string;
IsVisble?: boolean;
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AreacascaderComponent } from './areacascader.component';
describe('AreacascaderComponent', () => {
let component: AreacascaderComponent;
let fixture: ComponentFixture<AreacascaderComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AreacascaderComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(AreacascaderComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-areacascader',
templateUrl: './areacascader.component.html',
styleUrls: ['./areacascader.component.less']
})
export class AreacascaderComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
import { AbstractControl, ValidatorFn, Validators } from "@angular/forms";
import { NzSafeAny } from "ng-zorro-antd/core/types";
export type MyErrorsOptions = { 'zh-cn': string; en: string } & Record<string, NzSafeAny>;
export type MyValidationErrors = Record<string, MyErrorsOptions>;
export class MyValidators extends Validators {
static minLength(minLength: number): ValidatorFn {
return (control: AbstractControl): MyValidationErrors | null => {
if (Validators.minLength(minLength)(control) === null) {
return null;
}
return { minlength: { 'zh-cn': `最小长度为 ${minLength}`, en: `MinLength is ${minLength}` } };
};
}
static maxLength(maxLength: number): ValidatorFn {
return (control: AbstractControl): MyValidationErrors | null => {
if (Validators.maxLength(maxLength)(control) === null) {
return null;
}
return { maxlength: { 'zh-cn': `最大长度为 ${maxLength}`, en: `MaxLength is ${maxLength}` } };
};
}
static mobile(control: AbstractControl): MyValidationErrors | null {
const value = control.value;
if (isEmptyInputValue(value)) {
return null;
}
return isMobile(value) ? null : { mobile: { 'zh-cn': `手机号码格式不正确`, en: `Mobile phone number is not valid` } };
}
static nullbigintid(control: AbstractControl): MyValidationErrors | null {
const value = control.value;
if (value !== 0) {
return null;
}
return { messsage: { 'zh-cn': `值不能为空`, en: `this value is not empty` } };
}
}
function isEmptyInputValue(value: NzSafeAny): boolean {
return value == null || value.length === 0;
}
function isMobile(value: string): boolean {
return typeof value === 'string' && /(^1\d{10}$)/.test(value);
}
<p>customerform works!</p>
<page-header [breadcrumb]="phNgContent" [title]="title">
<ng-template #phNgContent class> </ng-template>
<nz-card [nzBordered]="false">
<form nz-form [formGroup]="form" (ngSubmit)="submit()" se-container="1" labelWidth="200">
<se label="客户名称" error="客户名称" required>
<input nz-input formControlName="name" placeholder="客户名称" />
</se>
<se label="客户邮箱地址" error="客户邮箱地址">
<input nz-input formControlName="email" placeholder="客户邮箱地址" />
</se>
<se label="联系电话" error="联系电话">
<input nz-input formControlName="phone" placeholder="联系电话" />
</se>
<se label="国家" error="国家">
<input nz-input formControlName="country" placeholder="国家" />
</se>
<se label="省" error="省">
<input nz-input formControlName="province" placeholder="省" />
</se>
<se label="城市" error="城市">
<input nz-input formControlName="city" placeholder="城市" />
</se>
<se label="街道" error="街道">
<input nz-input formControlName="street" placeholder="街道" />
</se>
<se label="地址" error="地址">
<input nz-input formControlName="address" placeholder="地址" />
</se>
<se label="邮编" error="邮编">
<input nz-input formControlName="zipCode" placeholder="邮编" />
</se>
<se>
<input nz-input formControlName="DeviceId" placeholder="Action" type="hidden" />
<button nz-button type="reset" (click)="close()">取消</button>
<button nz-button nzType="primary" [disabled]="form.invalid" type="submit"
[nzLoading]="submitting">保存</button>
</se>
</form>
</nz-card>
</page-header>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { ModalHelper, _HttpClient } from '@delon/theme';
import { Component, OnInit, Input } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { NzMessageService } from 'ng-zorro-antd/message';
import { NzDrawerRef } from 'ng-zorro-antd/drawer';
import { NzUploadFile } from 'ng-zorro-antd/upload';
import { Observable, Observer, of } from 'rxjs';
import { catchError, map, mergeMap } from 'rxjs/operators';
;
import { MyValidators } from '../../common/validators/MyValidators';
import { AppMessage } from '../../common/AppMessage';
@Component({
selector: 'app-customerform',
templateUrl: './customerform.component.html',
......@@ -7,9 +18,74 @@ import { Component, OnInit } from '@angular/core';
})
export class CustomerformComponent implements OnInit {
constructor() { }
isManufactorLoading: Boolean = false;
ngOnInit(): void {
optionList: any;
@Input() id: string = '-1';
RoleLogo: NzUploadFile[] = [];
nodes = [];
title: string = '';
loading = false;
avatarUrl?: string;
constructor(
private _router: ActivatedRoute,
private router: Router,
private _formBuilder: FormBuilder,
private _httpClient: _HttpClient,
private fb: FormBuilder,
private msg: NzMessageService,
private drawerRef: NzDrawerRef<string>,
) { }
form!: FormGroup;
submitting = false;
ngOnInit() {
const { nullbigintid } = MyValidators;
this.form = this.fb.group({
name: [null, [Validators.required]],
id: [0, []],
email: [0, [nullbigintid]],
phone: [null, []],
country: [null, []],
province: [0, []],
city: [null, []],
street: [null, []],
address: [null, []],
zipCode: [null, []],
});
if (this.id !== '-1') {
this._httpClient.get<AppMessage>('/api/Customers/' + this.id).subscribe(
(x) => {
this.form.patchValue(x.Result);
},
(y) => { },
() => { },
);
}
}
submit() {
this.submitting = true;
if (this.id !== "-1") {
this._httpClient.put<AppMessage>("/api/Customers", this.form.value).subscribe();
} else {
this._httpClient.post<AppMessage>("/api/Customers", this.form.value).subscribe();
}
}
close(): void {
this.drawerRef.close(this.id);
}
}
<p>customerlist works!</p>
<page-header [title]="'设备列表'">
<nz-card [nzBordered]="false" class>
<form nz-form class="search__form" action="search">
<div nz-row [nzGutter]="{ xs: 8, sm: 8, md: 8, lg: 24, xl: 48, xxl: 48 }">
<div nz-col nzMd="8" nzSm="24">
<nz-form-item>
<nz-form-label nzFor="DeviceName">设备名称</nz-form-label>
<nz-form-control>
<input nz-input [(ngModel)]="q.DeviceName" placeholder="请输入设备名称"
[ngModelOptions]="{ standalone: true }" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="24" [class.text-right]="expandForm" style="text-align: right">
<button nz-button type="submit" [nzType]="'primary'" (click)="getData()">搜索</button>
<!--<button nz-button type="submit" (click)="getData()" [nzType]="'primary'" [nzLoading]="loading">查询</button>-->
<button nz-button type="reset" (click)="reset()" class="mx-sm">重置</button>
</div>
</div>
<button nz-button [nzType]="'primary'" (click)="edit('-1')" acl [acl-ability]="37">
<i nz-icon nzType="plus"></i>
<span>{{ 'button.new' | translate }}</span>
</button>
<!--<button nz-button [nzType]="'primary'" [routerLink]="['/manage/authority/roleform']" [queryParams]="{Id:-1}">
<i nz-icon nzType="plus"></i>
<span>{{ 'button.new' | translate }}</span>
</button>-->
<st #st [columns]="columns" [data]="url" ps="20" [page]="page" [req]="req" [res]="res">
<ng-template st-row="UserStatus" let-i>
<nz-badge [nzStatus]="i.statusType" [nzText]="i.statusText"></nz-badge>
</ng-template>
<ng-template st-row="UserLogo" let-i>
<nz-avatar [nzSrc]="i" nzSize="large" [nzShape]="'square'"></nz-avatar>
</ng-template>
</st>
</form>
</nz-card>
<ng-template #modalContent>
<nz-form-item>
<nz-form-label nzFor="no">描述</nz-form-label>
<nz-form-control>
<input nz-input [(ngModel)]="description" name="description" placeholder="请输入" id="no" />
</nz-form-control>
</nz-form-item>
</ng-template>
</page-header-wrapper>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import { ChangeDetectorRef, Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { STChange, STColumn, STComponent, STData, STPage, STReq, STRes } from '@delon/abc/st';
import { ModalHelper, _HttpClient } from '@delon/theme';
import { NzMessageService } from 'ng-zorro-antd/message';
import { map, tap } from 'rxjs/operators';
import { Validators, FormBuilder, FormGroup } from '@angular/forms/forms';
import { NzDrawerRef, NzDrawerService } from 'ng-zorro-antd/drawer';
import { ACLService } from '@delon/acl';
import { Globals } from 'src/app/core/Globals';
import { CustomerformComponent } from '../customerform/customerform.component';
@Component({
selector: 'app-customerlist',
templateUrl: './customerlist.component.html',
......@@ -7,9 +17,120 @@ import { Component, OnInit } from '@angular/core';
})
export class CustomerlistComponent implements OnInit {
constructor() { }
constructor(
private http: _HttpClient,
public msg: NzMessageService,
private modal: ModalHelper,
private cdr: ChangeDetectorRef,
private _router: Router,
private drawerService: NzDrawerService,
private globals: Globals,
aclSrv: ACLService,
) { }
page: STPage = {
front: false,
total: true,
zeroIndexed: true,
};
q: {
pi: number;
ps: number;
sorter: string;
status: number | null;
} = {
pi: 0,
ps: 10,
sorter: '',
status: null,
};
total = 0;
data: any[] = [];
loading = false;
url = 'api/Customers/Tenant';
req: STReq = { method: 'POST', allInBody: true, reName: { pi: 'offset', ps: 'limit' }, params: this.q };
// 定义返回的参数
res: STRes = {
reName: {
total: 'total',
list: 'rows',
},
};
@ViewChild('st', { static: true })
st!: STComponent;
columns: STColumn[] = [
{ title: '', index: 'id', type: 'checkbox' },
{ title: 'id', index: 'id' },
{ title: '客户名称', index: 'name', render: 'name' },
{ title: '联系电话', index: 'email' },
{ title: '客户邮箱地址', index: 'phone' },
{ title: '国家', index: 'country' },
{ title: '', index: 'province' },
{ title: '城市', index: 'city' },
{ title: '街道', index: 'street' },
{ title: '联系电话', index: 'address' },
{ title: '地址', index: 'zipCode' },
{ title: '最后登录时间', type: 'date', index: 'UserLastLogin' },
{
title: '操作',
buttons: [
{
acl: 9,
text: '修改',
click: (item: any) => {
this.edit(item.UserId);
},
},
{
acl: 10,
text: '删除',
click: (item: any) => { },
},
],
},
];
selectedRows: STData[] = [];
description = '';
totalCallNo = 0;
expandForm = false;
ngOnInit(): void {
}
edit(id: string): void {
let title = id == '-1' ? '新建客户' : '修改客户'
const drawerRef = this.drawerService.create<CustomerformComponent, { id: string }, string>({
nzTitle: title,
nzContent: CustomerformComponent,
nzWidth: this.globals.drawerwidth,
nzMaskClosable: this.globals.nzMaskClosable,
nzContentParams: {
id: id,
},
});
drawerRef.afterOpen.subscribe(() => { });
drawerRef.afterClose.subscribe((data) => {
console.log(data);
if (typeof data === 'string') {
}
});
}
reset() {
}
delete(id: string) {
this.http.delete('/api/Customers/' + id, {}).subscribe(x => { }, y => { }, () => { })
}
}
<p>deviceform works!</p>
<page-header [breadcrumb]="phNgContent" [title]="title">
<ng-template #phNgContent class> </ng-template>
<nz-card [nzBordered]="false">
<form nz-form [formGroup]="form" (ngSubmit)="submit()" se-container="1" labelWidth="200">
<se label="客户名称" error="客户名称" required>
<input nz-input formControlName="name" placeholder="客户名称" />
</se>
<se label="客户邮箱地址" error="客户邮箱地址">
<input nz-input formControlName="email" placeholder="客户邮箱地址" />
</se>
<se label="联系电话" error="联系电话">
<input nz-input formControlName="phone" placeholder="联系电话" />
</se>
<se label="国家" error="国家">
<input nz-input formControlName="country" placeholder="国家" />
</se>
<se label="省" error="省">
<input nz-input formControlName="province" placeholder="省" />
</se>
<se label="城市" error="城市">
<input nz-input formControlName="city" placeholder="城市" />
</se>
<se label="街道" error="街道">
<input nz-input formControlName="street" placeholder="街道" />
</se>
<se label="地址" error="地址">
<input nz-input formControlName="address" placeholder="地址" />
</se>
<se label="邮编" error="邮编">
<input nz-input formControlName="zipCode" placeholder="邮编" />
</se>
<se>
<input nz-input formControlName="DeviceId" placeholder="Action" type="hidden" />
<button nz-button type="reset" (click)="close()">取消</button>
<button nz-button nzType="primary" [disabled]="form.invalid" type="submit"
[nzLoading]="submitting">保存</button>
</se>
</form>
</nz-card>
</page-header>
\ No newline at end of file
......@@ -7,9 +7,74 @@ import { Component, OnInit } from '@angular/core';
})
export class DeviceformComponent implements OnInit {
constructor() { }
isManufactorLoading: Boolean = false;
ngOnInit(): void {
optionList: any;
@Input() id: string = '-1';
RoleLogo: NzUploadFile[] = [];
nodes = [];
title: string = '';
loading = false;
avatarUrl?: string;
constructor(
private _router: ActivatedRoute,
private router: Router,
private _formBuilder: FormBuilder,
private _httpClient: _HttpClient,
private fb: FormBuilder,
private msg: NzMessageService,
private drawerRef: NzDrawerRef<string>,
) { }
form!: FormGroup;
submitting = false;
ngOnInit() {
const { nullbigintid } = MyValidators;
this.form = this.fb.group({
name: [null, [Validators.required]],
id: [0, []],
email: [0, [nullbigintid]],
phone: [null, []],
country: [null, []],
province: [0, []],
city: [null, []],
street: [null, []],
address: [null, []],
zipCode: [null, []],
});
if (this.id !== '-1') {
this._httpClient.get<AppMessage>('/api/Customers/' + this.id).subscribe(
(x) => {
this.form.patchValue(x.Result);
},
(y) => { },
() => { },
);
}
}
submit() {
this.submitting = true;
if (this.id !== "-1") {
this._httpClient.put<AppMessage>("/api/Customers", this.form.value).subscribe();
} else {
this._httpClient.post<AppMessage>("/api/Customers", this.form.value).subscribe();
}
}
close(): void {
this.drawerRef.close(this.id);
}
}
......@@ -15,4 +15,4 @@ const COMPONENTS: Type<null>[] = [];
imports: [SharedModule, RouteRoutingModule],
declarations: [...COMPONENTS, TenantlistComponent, TenantformComponent, CustomerlistComponent, CustomerformComponent, DeviceformComponent, DevicelistComponent],
})
export class RoutesModule {}
export class RoutesModule { }
<p>tenantform works!</p>
<page-header [breadcrumb]="phNgContent" [title]="title">
<ng-template #phNgContent class> </ng-template>
<nz-card [nzBordered]="false">
<form nz-form [formGroup]="form" (ngSubmit)="submit()" se-container="1" labelWidth="200">
<se label="客户名称" error="客户名称" required>
<input nz-input formControlName="name" placeholder="客户名称" />
</se>
<se label="客户邮箱地址" error="客户邮箱地址">
<input nz-input formControlName="email" placeholder="客户邮箱地址" />
</se>
<se label="联系电话" error="联系电话">
<input nz-input formControlName="phone" placeholder="联系电话" />
</se>
<se label="国家" error="国家">
<input nz-input formControlName="country" placeholder="国家" />
</se>
<se label="省" error="省">
<input nz-input formControlName="province" placeholder="省" />
</se>
<se label="城市" error="城市">
<input nz-input formControlName="city" placeholder="城市" />
</se>
<se label="街道" error="街道">
<input nz-input formControlName="street" placeholder="街道" />
</se>
<se label="地址" error="地址">
<input nz-input formControlName="address" placeholder="地址" />
</se>
<se label="邮编" error="邮编">
<input nz-input formControlName="zipCode" placeholder="邮编" />
</se>
<se>
<input nz-input formControlName="DeviceId" placeholder="Action" type="hidden" />
<button nz-button type="reset" (click)="close()">取消</button>
<button nz-button nzType="primary" [disabled]="form.invalid" type="submit"
[nzLoading]="submitting">保存</button>
</se>
</form>
</nz-card>
</page-header>
\ No newline at end of file
......@@ -7,9 +7,73 @@ import { Component, OnInit } from '@angular/core';
})
export class TenantformComponent implements OnInit {
constructor() { }
isManufactorLoading: Boolean = false;
ngOnInit(): void {
optionList: any;
@Input() id: string = '-1';
nodes = [];
title: string = '';
loading = false;
avatarUrl?: string;
constructor(
private _router: ActivatedRoute,
private router: Router,
private _formBuilder: FormBuilder,
private _httpClient: _HttpClient,
private fb: FormBuilder,
private msg: NzMessageService,
private drawerRef: NzDrawerRef<string>,
) { }
form!: FormGroup;
submitting = false;
ngOnInit() {
const { nullbigintid } = MyValidators;
this.form = this.fb.group({
name: [null, [Validators.required]],
id: [0, []],
email: [0, [nullbigintid]],
phone: [null, []],
country: [null, []],
province: [0, []],
city: [null, []],
street: [null, []],
address: [null, []],
zipCode: [null, []],
});
if (this.id !== '-1') {
this._httpClient.get<AppMessage>('/api/Customers/' + this.id).subscribe(
(x) => {
this.form.patchValue(x.Result);
},
(y) => { },
() => { },
);
}
}
submit() {
this.submitting = true;
if (this.id !== "-1") {
this._httpClient.put<AppMessage>("/api/Customers", this.form.value).subscribe();
} else {
this._httpClient.post<AppMessage>("/api/Customers", this.form.value).subscribe();
}
}
close(): void {
this.drawerRef.close(this.id);
}
}
......@@ -30,7 +30,7 @@ import { NzTagModule } from 'ng-zorro-antd/tag';
import { NzTimePickerModule } from 'ng-zorro-antd/time-picker';
import { NzToolTipModule } from 'ng-zorro-antd/tooltip';
import { NzUploadModule } from 'ng-zorro-antd/upload';
import { NzPageHeaderModule } from 'ng-zorro-antd/page-header';
export const SHARED_ZORRO_MODULES = [
NzButtonModule,
NzMessageModule,
......@@ -63,5 +63,5 @@ export const SHARED_ZORRO_MODULES = [
NzDividerModule,
NzProgressModule,
NzPopconfirmModule,
NzUploadModule,
NzUploadModule, NzPageHeaderModule
];
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册