122 changed files with 3132 additions and 589 deletions
@ -0,0 +1,64 @@ |
|||
<div class="w-60 overflow-auto"> |
|||
<div class="flex items-center"> |
|||
<div class="flex-1 pr-2"> |
|||
<nz-input-group [nzSuffix]="suffixIcon"> |
|||
<input type="text" nz-input placeholder="请输入关键字" [(ngModel)]="searchValue" /> |
|||
</nz-input-group> |
|||
<ng-template #suffixIcon> |
|||
<span nz-icon nzType="search"></span> |
|||
</ng-template> |
|||
</div> |
|||
@if (createable) { |
|||
<button nz-button nzType="primary" (click)="onCreate(0)">添加</button> |
|||
} |
|||
</div> |
|||
<div class="py-4"> |
|||
<nz-tree |
|||
class="tree" |
|||
nzBlockNode |
|||
[nzData]="nodes" |
|||
[nzExpandedKeys]="expandedKeys" |
|||
[(nzSelectedKeys)]="selectedKeys" |
|||
[nzSearchValue]="searchValue" |
|||
(nzClick)="nzEvent($event)" |
|||
(nzExpandChange)="onExpandChange($event)" |
|||
[nzTreeTemplate]="nzTreeTemplate" |
|||
> |
|||
<ng-template #nzTreeTemplate let-node let-origin="origin"> |
|||
<div class="custom-node flex items-center overflow-hidden"> |
|||
<div class="flex-1"> |
|||
@switch (origin.organizationType) { |
|||
@case ('0') { |
|||
<span nz-icon nzType="bank" nzTheme="outline"></span> |
|||
} |
|||
@case ('1') { |
|||
<span nz-icon nzType="cluster" nzTheme="outline"></span> |
|||
} |
|||
@case ('2') { |
|||
<span nz-icon nzType="team" nzTheme="outline"></span> |
|||
} |
|||
} |
|||
<span class="ml-2 overflow-hidden text-ellipsis">{{ node.title }}</span> |
|||
</div> |
|||
<button |
|||
nz-button |
|||
nz-dropdown |
|||
[nzDropdownMenu]="menu" |
|||
nzType="text" |
|||
onclick="event.stopPropagation()" |
|||
> |
|||
<span nz-icon nzType="more"></span> |
|||
</button> |
|||
<nz-dropdown-menu #menu="nzDropdownMenu"> |
|||
<ul nz-menu> |
|||
<li nz-menu-item (click)="onCreate(origin.parentId)">添加同级分类</li> |
|||
<li nz-menu-item (click)="onCreate(origin.categoryId)">添加下级分类</li> |
|||
<li nz-menu-divider></li> |
|||
<li nz-menu-item (click)="onDelete(origin.categoryId)">删除</li> |
|||
</ul> |
|||
</nz-dropdown-menu> |
|||
</div> |
|||
</ng-template> |
|||
</nz-tree> |
|||
</div> |
|||
</div> |
|||
@ -0,0 +1,7 @@ |
|||
.tree { |
|||
::ng-deep { |
|||
.ant-tree-switcher { |
|||
align-self: center; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,153 @@ |
|||
import { Component, EventEmitter, Input, OnInit, Output, TemplateRef } from '@angular/core' |
|||
import { FormBuilder, FormGroup } from '@angular/forms' |
|||
import { ApiService } from 'app/services' |
|||
import { SharedModule } from 'app/shared/shared.module' |
|||
import { FormValidators } from 'app/utils' |
|||
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
|||
import { NzDrawerRef, NzDrawerService } from 'ng-zorro-antd/drawer' |
|||
import { NzMessageService } from 'ng-zorro-antd/message' |
|||
import { NzModalService } from 'ng-zorro-antd/modal' |
|||
import { NzFormatEmitEvent, NzTreeNodeOptions } from 'ng-zorro-antd/tree' |
|||
|
|||
interface CateGoryInterface { |
|||
categoryId: number |
|||
categoryName: string |
|||
createTime: string |
|||
depth: string |
|||
lowerLimit: number | null |
|||
parentId: number |
|||
safetyLimit: number | null |
|||
upperLimit: number | null |
|||
} |
|||
function buildTree(organizations: CateGoryInterface[]): NzTreeNodeOptions[] { |
|||
const map: { [parentId: number]: NzTreeNodeOptions[] } = {} |
|||
|
|||
organizations.forEach((org) => { |
|||
if (!map[org.parentId]) { |
|||
map[org.parentId] = [] |
|||
} |
|||
const treeNode: NzTreeNodeOptions = { |
|||
...org, |
|||
title: org.categoryName, |
|||
key: org.categoryId.toString(), |
|||
} |
|||
map[org.parentId].push(treeNode) |
|||
}) |
|||
|
|||
const build = (parentId: number): NzTreeNodeOptions[] => { |
|||
if (!map[parentId]) { |
|||
return [] |
|||
} |
|||
return map[parentId].map((node) => { |
|||
const children = build(parseInt(node.key)) |
|||
return { |
|||
...node, |
|||
isLeaf: children.length === 0, |
|||
children, |
|||
} |
|||
}) |
|||
} |
|||
|
|||
return build(0) |
|||
} |
|||
|
|||
@Component({ |
|||
selector: 'app-component-basic-category-tree', |
|||
standalone: true, |
|||
imports: [SharedModule], |
|||
templateUrl: './component-basic-category-tree.component.html', |
|||
styleUrl: './component-basic-category-tree.component.less', |
|||
}) |
|||
export class ComponentBasicCategoryTreeComponent { |
|||
constructor( |
|||
private api: ApiService, |
|||
private drawer: NzDrawerService, |
|||
private fb: FormBuilder, |
|||
private msg: NzMessageService, |
|||
private modal: NzModalService, |
|||
) {} |
|||
|
|||
@Input() createable = true |
|||
|
|||
@Output() onSelectedChange = new EventEmitter<NzSafeAny>() |
|||
|
|||
drawerRef?: NzDrawerRef |
|||
|
|||
searchValue = '' |
|||
|
|||
parentId?: number |
|||
|
|||
nodes: NzSafeAny[] = [] |
|||
|
|||
expandedKeys: string[] = [] |
|||
|
|||
selectedKeys: string[] = [] |
|||
|
|||
initTree() { |
|||
this.api.getBasicCategoryTree().subscribe((res) => { |
|||
this.nodes = buildTree(res.body) |
|||
this.expandedKeys = [...this.expandedKeys] |
|||
console.log('this.selectedKeys', this.selectedKeys) |
|||
if (this.selectedKeys.length === 0) { |
|||
this.selectedKeys = [this.nodes[0].key] |
|||
} else { |
|||
this.selectedKeys = [...this.selectedKeys] |
|||
} |
|||
|
|||
const node = res.body.find((node: NzSafeAny) => String(node.categoryId) === this.selectedKeys[0]) |
|||
this.onSelectedChange.emit(node) |
|||
}) |
|||
} |
|||
|
|||
ngOnInit(): void { |
|||
this.initTree() |
|||
} |
|||
|
|||
nzEvent(event: NzFormatEmitEvent): void { |
|||
if (event.eventName === 'click') { |
|||
const { node } = event |
|||
this.selectedKeys = event.keys ?? [] |
|||
this.onSelectedChange.emit(node?.origin) |
|||
} |
|||
} |
|||
|
|||
onExpandChange(e: NzFormatEmitEvent) { |
|||
this.expandedKeys = e.keys ?? [] |
|||
} |
|||
|
|||
onSelectedKeysChange(e: string[]) { |
|||
console.log('e', e) |
|||
} |
|||
|
|||
onCreate(parentId: number) { |
|||
this.api |
|||
.addBasicCategoryTree({ |
|||
depth: '', |
|||
lowerLimit: 0, |
|||
safetyLimit: 0, |
|||
upperLimit: 0, |
|||
parentId, |
|||
categoryName: '新分类', |
|||
}) |
|||
.subscribe((res) => { |
|||
this.initTree() |
|||
this.msg.success(res.desc) |
|||
}) |
|||
} |
|||
|
|||
onDelete(id: number) { |
|||
this.modal.confirm({ |
|||
nzTitle: '警告', |
|||
nzContent: '是否要删除该分类?', |
|||
nzOnOk: () => { |
|||
this.api.deleteBasicCategory([id]).subscribe((res) => { |
|||
if (this.selectedKeys.includes(String(id))) { |
|||
this.selectedKeys = [] |
|||
} |
|||
this.msg.success(res.desc) |
|||
this.initTree() |
|||
}) |
|||
}, |
|||
}) |
|||
} |
|||
} |
|||
@ -0,0 +1,113 @@ |
|||
<div class="overflow-auto"> |
|||
<div class="flex items-center"> |
|||
<div class="flex-1"> |
|||
<nz-input-group [nzSuffix]="suffixIcon"> |
|||
<input type="text" nz-input placeholder="请输入关键字" [(ngModel)]="searchValue" /> |
|||
</nz-input-group> |
|||
<ng-template #suffixIcon> |
|||
<span nz-icon nzType="search"></span> |
|||
</ng-template> |
|||
</div> |
|||
@if (createable) { |
|||
<button nz-button class="pl-2" nzType="primary" nz-dropdown [nzDropdownMenu]="createMenu">添加</button> |
|||
<nz-dropdown-menu #createMenu="nzDropdownMenu"> |
|||
<ul nz-menu> |
|||
<li nz-menu-item (click)="onCreate(true, orgFormTpl, confirmTpl)">添加组织</li> |
|||
<li nz-menu-item (click)="onCreate(false, orgFormTpl, confirmTpl)">添加岗位</li> |
|||
</ul> |
|||
</nz-dropdown-menu> |
|||
} |
|||
</div> |
|||
<div class="py-4"> |
|||
<nz-tree |
|||
class="tree" |
|||
nzBlockNode |
|||
[nzData]="nodes" |
|||
[nzExpandedKeys]="expandedKeys" |
|||
[nzSearchValue]="searchValue" |
|||
(nzClick)="nzEvent($event)" |
|||
(nzExpandChange)="onExpandChange($event)" |
|||
[nzTreeTemplate]="nzTreeTemplate" |
|||
> |
|||
<ng-template #nzTreeTemplate let-node let-origin="origin"> |
|||
<div class="custom-node flex items-center overflow-hidden"> |
|||
<div class="flex-1"> |
|||
@switch (origin.organizationType) { |
|||
@case ('0') { |
|||
<span nz-icon nzType="bank" nzTheme="outline"></span> |
|||
} |
|||
@case ('1') { |
|||
<span nz-icon nzType="cluster" nzTheme="outline"></span> |
|||
} |
|||
@case ('2') { |
|||
<span nz-icon nzType="team" nzTheme="outline"></span> |
|||
} |
|||
} |
|||
<span class="ml-2 overflow-hidden text-ellipsis">{{ node.title }}</span> |
|||
</div> |
|||
@if (createable) { |
|||
<button |
|||
nz-button |
|||
nz-dropdown |
|||
[nzDropdownMenu]="menu" |
|||
nzType="text" |
|||
onclick="event.stopPropagation()" |
|||
> |
|||
<span nz-icon nzType="more"></span> |
|||
</button> |
|||
<nz-dropdown-menu #menu="nzDropdownMenu"> |
|||
<ul nz-menu> |
|||
<li nz-menu-item (click)="onCreate(true, orgFormTpl, confirmTpl, origin)">添加组织</li> |
|||
<li nz-menu-item (click)="onCreate(false, orgFormTpl, confirmTpl, origin)">添加岗位</li> |
|||
<li nz-menu-item (click)="onCreate(false, orgFormTpl, confirmTpl, origin, true)"> |
|||
编辑 |
|||
</li> |
|||
<li nz-menu-divider></li> |
|||
<li nz-menu-item (click)="onDelete(origin.organizationId)">删除</li> |
|||
</ul> |
|||
</nz-dropdown-menu> |
|||
} |
|||
</div> |
|||
</ng-template> |
|||
</nz-tree> |
|||
</div> |
|||
|
|||
<ng-template #orgFormTpl> |
|||
<form nz-form nzLayout="vertical" [formGroup]="form"> |
|||
<nz-form-item> |
|||
<nz-form-label> 名称 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="organizationName" placeholder="请输入名称" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
@if (isOrg) { |
|||
<nz-form-item> |
|||
<nz-form-label> 类型 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-radio-group formControlName="organizationType"> |
|||
<label nz-radio nzValue="0"> 公司 </label> |
|||
<label nz-radio nzValue="1"> 部门 </label> |
|||
</nz-radio-group> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
} |
|||
<nz-form-item> |
|||
<nz-form-label> 状态 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-switch formControlName="status"></nz-switch> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</form> |
|||
</ng-template> |
|||
|
|||
<ng-template #errorTpl let-control> |
|||
<form-error-tips [control]="control"></form-error-tips> |
|||
</ng-template> |
|||
|
|||
<ng-template #confirmTpl> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button nzType="primary" (click)="onConfirm()">确定</button> |
|||
<button *nzSpaceItem nz-button nzType="default" (click)="onCancel()">取消</button> |
|||
</nz-space> |
|||
</ng-template> |
|||
</div> |
|||
@ -0,0 +1,7 @@ |
|||
.tree { |
|||
::ng-deep { |
|||
.ant-tree-switcher { |
|||
align-self: center; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,186 @@ |
|||
import { Component, EventEmitter, Input, OnInit, Output, TemplateRef } from '@angular/core' |
|||
import { FormBuilder, FormGroup } from '@angular/forms' |
|||
import { ApiService } from 'app/services' |
|||
import { SharedModule } from 'app/shared/shared.module' |
|||
import { FormValidators } from 'app/utils' |
|||
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
|||
import { NzDrawerRef, NzDrawerService } from 'ng-zorro-antd/drawer' |
|||
import { NzMessageService } from 'ng-zorro-antd/message' |
|||
import { NzModalService } from 'ng-zorro-antd/modal' |
|||
import { NzFormatEmitEvent, NzTreeNodeOptions } from 'ng-zorro-antd/tree' |
|||
|
|||
interface Organization { |
|||
depth: string |
|||
orderNum: number |
|||
organizationId: number |
|||
organizationName: string |
|||
organizationType: string |
|||
parentId: number |
|||
status: string |
|||
} |
|||
function buildTree(organizations: Organization[]): NzTreeNodeOptions[] { |
|||
const map: { [parentId: number]: NzTreeNodeOptions[] } = {} |
|||
|
|||
organizations.forEach((org) => { |
|||
if (!map[org.parentId]) { |
|||
map[org.parentId] = [] |
|||
} |
|||
const treeNode: NzTreeNodeOptions = { |
|||
...org, |
|||
title: org.organizationName, |
|||
key: org.organizationId.toString(), |
|||
} |
|||
map[org.parentId].push(treeNode) |
|||
}) |
|||
|
|||
const build = (parentId: number): NzTreeNodeOptions[] => { |
|||
if (!map[parentId]) { |
|||
return [] |
|||
} |
|||
return map[parentId].map((node) => { |
|||
const children = build(parseInt(node.key)) |
|||
return { |
|||
...node, |
|||
isLeaf: children.length === 0, |
|||
children, |
|||
} |
|||
}) |
|||
} |
|||
|
|||
return build(0) |
|||
} |
|||
|
|||
@Component({ |
|||
selector: 'app-component-org-tree', |
|||
standalone: true, |
|||
imports: [SharedModule], |
|||
templateUrl: './component-org-tree.component.html', |
|||
styleUrl: './component-org-tree.component.less', |
|||
}) |
|||
export class ComponentOrgTreeComponent implements OnInit { |
|||
constructor( |
|||
private api: ApiService, |
|||
private drawer: NzDrawerService, |
|||
private fb: FormBuilder, |
|||
private msg: NzMessageService, |
|||
private modal: NzModalService, |
|||
) {} |
|||
|
|||
@Input() createable = true |
|||
|
|||
@Output() onOrgSelectedChange = new EventEmitter<NzSafeAny>() |
|||
|
|||
drawerRef?: NzDrawerRef |
|||
|
|||
isOrg = false |
|||
|
|||
searchValue = '' |
|||
|
|||
parentId?: number |
|||
|
|||
nodes: NzSafeAny[] = [] |
|||
|
|||
expandedKeys: string[] = [] |
|||
|
|||
form!: FormGroup |
|||
|
|||
initForm() { |
|||
this.form = this.fb.group({ |
|||
organizationId: this.fb.control<number | null>(null, []), |
|||
organizationName: this.fb.control('', [FormValidators.required('请输入组织名称')]), |
|||
organizationType: this.fb.control<string>('1', []), |
|||
status: this.fb.control(true, []), |
|||
}) |
|||
} |
|||
|
|||
initTree() { |
|||
this.api.getOrgTree().subscribe((res) => { |
|||
this.nodes = buildTree(res.body) |
|||
this.expandedKeys = [...this.expandedKeys] |
|||
}) |
|||
} |
|||
|
|||
ngOnInit(): void { |
|||
this.initTree() |
|||
this.initForm() |
|||
} |
|||
|
|||
nzEvent(event: NzFormatEmitEvent): void { |
|||
if (event.eventName === 'click') { |
|||
const { node } = event |
|||
this.onOrgSelectedChange.emit(event.keys?.length === 0 ? null : node?.origin) |
|||
} |
|||
} |
|||
|
|||
onExpandChange(e: NzFormatEmitEvent) { |
|||
this.expandedKeys = e.keys ?? [] |
|||
} |
|||
|
|||
onSelectedKeysChange(e: string[]) { |
|||
console.log('e', e) |
|||
} |
|||
|
|||
onCreate( |
|||
isOrg: boolean, |
|||
nzContent: TemplateRef<NzSafeAny>, |
|||
nzFooter: TemplateRef<NzSafeAny>, |
|||
origin?: NzSafeAny, |
|||
edit?: boolean, |
|||
) { |
|||
this.isOrg = isOrg |
|||
|
|||
this.form.patchValue({ |
|||
organizationType: isOrg ? '1' : '2', |
|||
}) |
|||
if (edit) { |
|||
this.isOrg = origin.organizationType !== '2' |
|||
this.form.patchValue(origin) |
|||
} else { |
|||
this.parentId = origin?.organizationId |
|||
} |
|||
|
|||
this.drawerRef = this.drawer.create({ |
|||
nzTitle: '组织管理', |
|||
nzContent, |
|||
nzWidth: 600, |
|||
nzFooter, |
|||
}) |
|||
} |
|||
|
|||
onDelete(id: number) { |
|||
this.modal.confirm({ |
|||
nzTitle: '警告', |
|||
nzContent: '是否要删除该组织?', |
|||
nzOnOk: () => { |
|||
this.api.deleteOrg(id).subscribe((res) => { |
|||
this.msg.success(res.desc) |
|||
this.initTree() |
|||
}) |
|||
}, |
|||
}) |
|||
} |
|||
|
|||
onConfirm() { |
|||
if (FormValidators.validateFormGroup(this.form)) { |
|||
const { value } = this.form |
|||
this.api |
|||
.saveOrg({ |
|||
...value, |
|||
status: value.status ? 0 : 1, |
|||
parentId: this.parentId, |
|||
}) |
|||
.subscribe((res) => { |
|||
this.initTree() |
|||
this.msg.success(res.desc) |
|||
this.onCancel() |
|||
}) |
|||
} |
|||
} |
|||
|
|||
onCancel() { |
|||
this.drawerRef?.close() |
|||
this.form.reset() |
|||
this.isOrg = false |
|||
this.parentId = void 0 |
|||
} |
|||
} |
|||
@ -1,5 +1,3 @@ |
|||
// export * from "./form-error-tips/form-error-tips.component";
|
|||
// export * from "./server-paginated-table";
|
|||
|
|||
export * from './header/header.component' |
|||
export * from './layout/layout.component' |
|||
export * from './component-org-tree/component-org-tree.component' |
|||
export * from './component-basic-category-tree/component-basic-category-tree.component' |
|||
export * from './select-user-by-org/select-user-by-org.component' |
|||
|
|||
@ -1,15 +0,0 @@ |
|||
:host { |
|||
display: block; |
|||
height: 100%; |
|||
} |
|||
|
|||
.app-width { |
|||
::ng-deep { |
|||
router-outlet+* { |
|||
display: block; |
|||
width: 100%; |
|||
height: 100%; |
|||
// overflow: hidden; |
|||
} |
|||
} |
|||
} |
|||
@ -1,14 +0,0 @@ |
|||
import { Component } from '@angular/core'; |
|||
import { HeaderComponent } from "../header/header.component"; |
|||
import { SharedModule } from "../../shared/shared.module"; |
|||
|
|||
@Component({ |
|||
standalone: true, |
|||
selector: 'app-layout', |
|||
templateUrl: './layout.component.html', |
|||
styleUrls: ['./layout.component.less'], |
|||
imports: [SharedModule, HeaderComponent] |
|||
}) |
|||
export class LayoutComponent { |
|||
|
|||
} |
|||
@ -0,0 +1,74 @@ |
|||
<div |
|||
class="cursor-pointer trigger min-h-[100px] max-h-[200px] overflow-auto p-3" |
|||
(click)="onTriggerClick(selectUserModalTpl)" |
|||
> |
|||
@if (selectedKeys.size > 0) { |
|||
<ng-container [ngTemplateOutlet]="selectedUserTpl"></ng-container> |
|||
} @else { |
|||
<div class="p-3 h-full flex min-h-[100px] items-center justify-center w-full text-black opacity-50"> |
|||
<i nz-icon nzType="plus" class="text-large"></i> |
|||
<span class="ml-2"> |
|||
{{ placeholder }} |
|||
</span> |
|||
</div> |
|||
} |
|||
</div> |
|||
|
|||
<ng-template #selectedUserTpl> |
|||
@for (uid of selectedKeys; track $index) { |
|||
<span class="mr-2 mb-2"> |
|||
<nz-tag>{{ allGetedDataMap.get(uid).userName }}</nz-tag> |
|||
</span> |
|||
} |
|||
</ng-template> |
|||
|
|||
<ng-template #selectUserModalTpl> |
|||
<div class="cursor-pointer trigger min-h-[100px] max-h-[200px] overflow-auto p-3"> |
|||
<ng-container [ngTemplateOutlet]="selectedUserTpl"></ng-container> |
|||
</div> |
|||
|
|||
<div class="mt-3"> |
|||
<nz-card |
|||
nzTitle="员工" |
|||
[nzBordered]="true" |
|||
class="user-select" |
|||
nzSize="small" |
|||
[nzBodyStyle]="{ padding: '0px' }" |
|||
> |
|||
<div class="h-96 flex"> |
|||
<div class="flex-1 org py-3 px-2 overflow-auto"> |
|||
<app-component-org-tree [createable]="false" (onOrgSelectedChange)="onOrgSelectedChange($event)" /> |
|||
</div> |
|||
<div class="flex-1 flex flex-col overflow-hidden relative user-list"> |
|||
<div class="hd flex items-center justify-between py-2 px-3"> |
|||
<!-- <a nz-button nzType="link" class="flex"> 已选 1/{{ currentUsers.length }} </a> --> |
|||
<span class="flex"> 全选 </span> |
|||
<label |
|||
nz-checkbox |
|||
[nzIndeterminate]="indeterminate" |
|||
[nzChecked]="allChecked" |
|||
(nzCheckedChange)="onAllCheckedChange($event)" |
|||
> |
|||
</label> |
|||
</div> |
|||
<div class="bd flex-1 overflow-auto"> |
|||
<ul> |
|||
@for (item of currentUsers; track $index) { |
|||
<li class="item flex items-center justify-between py-2 px-3"> |
|||
<span class="flex-1"> {{ item.userName }} </span> |
|||
<label |
|||
nz-checkbox |
|||
(nzCheckedChange)="onUserCheckedChange($event, item.userId)" |
|||
[nzValue]="item.userId" |
|||
[nzChecked]="selectedKeys.has(item.userId)" |
|||
> |
|||
</label> |
|||
</li> |
|||
} |
|||
</ul> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</nz-card> |
|||
</div> |
|||
</ng-template> |
|||
@ -0,0 +1,21 @@ |
|||
.trigger { |
|||
border: 1px dashed #e0e0e0; |
|||
} |
|||
|
|||
.user-select { |
|||
.org { |
|||
border-right: 1px solid #e0e0e0; |
|||
} |
|||
|
|||
.user-list { |
|||
.hd { |
|||
border-bottom: 1px solid #e0e0e0; |
|||
} |
|||
|
|||
.item { |
|||
&:hover { |
|||
background-color: #f0f1f4; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,128 @@ |
|||
import { CommonModule } from '@angular/common' |
|||
import { Component, Input, OnInit, TemplateRef, forwardRef } from '@angular/core' |
|||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
|||
import { NzCardModule } from 'ng-zorro-antd/card' |
|||
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
|||
import { NzIconModule } from 'ng-zorro-antd/icon' |
|||
import { NzModalModule, NzModalService } from 'ng-zorro-antd/modal' |
|||
import { NzTreeModule } from 'ng-zorro-antd/tree' |
|||
import { ComponentOrgTreeComponent } from '../component-org-tree/component-org-tree.component' |
|||
import { NzButtonModule } from 'ng-zorro-antd/button' |
|||
import { NzCheckboxModule } from 'ng-zorro-antd/checkbox' |
|||
import { ApiService } from 'app/services' |
|||
import { NzMessageModule, NzMessageService } from 'ng-zorro-antd/message' |
|||
import { MaxPageSize } from 'app/app.config' |
|||
import { NzTagModule } from 'ng-zorro-antd/tag' |
|||
|
|||
@Component({ |
|||
selector: 'app-select-user-by-org', |
|||
standalone: true, |
|||
imports: [ |
|||
CommonModule, |
|||
ComponentOrgTreeComponent, |
|||
NzButtonModule, |
|||
NzCheckboxModule, |
|||
NzTreeModule, |
|||
NzModalModule, |
|||
NzIconModule, |
|||
NzCardModule, |
|||
NzMessageModule, |
|||
NzTagModule, |
|||
], |
|||
templateUrl: './select-user-by-org.component.html', |
|||
styleUrl: './select-user-by-org.component.less', |
|||
providers: [ |
|||
{ |
|||
provide: NG_VALUE_ACCESSOR, |
|||
multi: true, |
|||
useExisting: forwardRef(() => SelectUserByOrgComponent), |
|||
}, |
|||
], |
|||
}) |
|||
export class SelectUserByOrgComponent implements ControlValueAccessor, OnInit { |
|||
constructor( |
|||
private modal: NzModalService, |
|||
private api: ApiService, |
|||
private msg: NzMessageService, |
|||
) {} |
|||
|
|||
@Input() placeholder: string = '请选择' |
|||
|
|||
@Input() modalTitle: string = '选择' |
|||
|
|||
allGetedDataMap = new Map<number, NzSafeAny>() |
|||
|
|||
currentUsers: NzSafeAny[] = [] |
|||
|
|||
selectedKeys = new Set<number>() |
|||
|
|||
indeterminate = false |
|||
|
|||
allChecked = false |
|||
|
|||
ngOnInit(): void {} |
|||
|
|||
onTriggerClick(nzContent: TemplateRef<NzSafeAny>) { |
|||
this.modal.create({ |
|||
nzTitle: this.modalTitle, |
|||
nzContent, |
|||
nzWidth: '660px', |
|||
}) |
|||
} |
|||
|
|||
onOrgSelectedChange(v: NzSafeAny) { |
|||
this.api |
|||
.getUserPage({ pageSize: MaxPageSize, pageNum: 1, organizationId: v.organizationId }) |
|||
.subscribe((res) => { |
|||
if (Array.isArray(res.body?.rows) && res.body.rows.length > 0) { |
|||
res.body.rows.forEach((element: NzSafeAny) => { |
|||
this.currentUsers = res.body.rows |
|||
this.allGetedDataMap.set(element.userId, element) |
|||
}) |
|||
} |
|||
}) |
|||
} |
|||
|
|||
onUserCheckedChange(e: boolean, v: number) { |
|||
if (e) { |
|||
this.selectedKeys.add(v) |
|||
} else { |
|||
this.selectedKeys.delete(v) |
|||
} |
|||
this.statusChange() |
|||
} |
|||
|
|||
statusChange() { |
|||
this.allChecked = this.selectedKeys.size === this.currentUsers.length |
|||
this.indeterminate = this.selectedKeys.size > 0 && this.selectedKeys.size < this.currentUsers.length |
|||
} |
|||
|
|||
onAllCheckedChange(e: boolean) { |
|||
if (e) { |
|||
this.currentUsers.forEach((element) => { |
|||
this.selectedKeys.add(element.userId) |
|||
}) |
|||
} else { |
|||
this.selectedKeys.clear() |
|||
} |
|||
this.statusChange() |
|||
} |
|||
|
|||
onTouched = () => {} |
|||
|
|||
onChange(v: string[]) { |
|||
console.log('v', v) |
|||
} |
|||
|
|||
writeValue(v: any): void {} |
|||
|
|||
registerOnChange(fn: any): void { |
|||
this.onChange = fn |
|||
} |
|||
|
|||
registerOnTouched(fn: any): void { |
|||
this.onTouched = fn |
|||
} |
|||
|
|||
setDisabledState?(isDisabled: boolean): void {} |
|||
} |
|||
@ -1,23 +0,0 @@ |
|||
<div class="flex items-center"> |
|||
<div class="flex-1 pr-2"> |
|||
<nz-input-group [nzSuffix]="suffixIcon"> |
|||
<input type="text" nz-input placeholder="请输入关键字" [(ngModel)]="searchValue" /> |
|||
</nz-input-group> |
|||
<ng-template #suffixIcon> |
|||
<span nz-icon nzType="search"></span> |
|||
</ng-template> |
|||
</div> |
|||
@if (createable) { |
|||
<button nz-button nzType="primary">添加</button> |
|||
} |
|||
</div> |
|||
<div class="py-4"> |
|||
<nz-tree |
|||
nzBlockNode |
|||
[nzData]="nodes" |
|||
[nzSearchValue]="searchValue" |
|||
(nzClick)="nzEvent($event)" |
|||
(nzExpandChange)="nzEvent($event)" |
|||
(nzSearchValueChange)="nzEvent($event)" |
|||
></nz-tree> |
|||
</div> |
|||
@ -1,58 +0,0 @@ |
|||
import { Component, Input } from '@angular/core' |
|||
import { SharedModule } from 'app/shared/shared.module' |
|||
import { NzFormatEmitEvent } from 'ng-zorro-antd/tree' |
|||
|
|||
@Component({ |
|||
selector: 'app-component-org-tree', |
|||
standalone: true, |
|||
imports: [SharedModule], |
|||
templateUrl: './component-org-tree.component.html', |
|||
styleUrl: './component-org-tree.component.less', |
|||
}) |
|||
export class ComponentOrgTreeComponent { |
|||
constructor() {} |
|||
|
|||
@Input() createable = true |
|||
|
|||
searchValue = '' |
|||
|
|||
nodes = [ |
|||
{ |
|||
title: '科技部', |
|||
key: '0-0', |
|||
children: [ |
|||
{ |
|||
title: '岗位1', |
|||
key: '0-0-0', |
|||
}, |
|||
{ |
|||
title: '岗位12', |
|||
key: '0-0-1', |
|||
children: [ |
|||
{ title: '0-0-1-0', key: '0-0-1-0', isLeaf: true }, |
|||
{ title: '0-0-1-1', key: '0-0-1-1', isLeaf: true }, |
|||
{ title: '0-0-1-2', key: '0-0-1-2', isLeaf: true }, |
|||
], |
|||
}, |
|||
{ |
|||
title: '岗位14', |
|||
key: '0-0-2', |
|||
isLeaf: true, |
|||
}, |
|||
], |
|||
}, |
|||
{ |
|||
title: '综合办', |
|||
key: '0-1', |
|||
}, |
|||
{ |
|||
title: '办公室', |
|||
key: '0-2', |
|||
isLeaf: true, |
|||
}, |
|||
] |
|||
|
|||
nzEvent(event: NzFormatEmitEvent): void { |
|||
console.log(event) |
|||
} |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
<app-page class="p-3"> |
|||
<div class="flex flex-1"> |
|||
<nz-card [nzBordered]="false" class="org shadow" nzSize="small"> |
|||
<app-component-basic-category-tree #treeEl (onSelectedChange)="onSelectedChange($event)" /> |
|||
</nz-card> |
|||
<div class="flex-1 pl-3"> |
|||
<nz-card [nzBordered]="false" nzTitle="分类信息"> |
|||
<form nz-form nzLayout="vertical" [formGroup]="createForm" class="w-72"> |
|||
<nz-form-item> |
|||
<nz-form-label [nzRequired]="true"> 名称 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="categoryName" placeholder="请输入名称" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 安全库存 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-input-number |
|||
nzPlaceHolder="请输入" |
|||
[nzMin]="0" |
|||
class="!w-full" |
|||
formControlName="safetyLimit" |
|||
/> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 安全库存上限 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-input-number |
|||
nzPlaceHolder="请输入" |
|||
[nzMin]="0" |
|||
class="!w-full" |
|||
formControlName="upperLimit" |
|||
/> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 安全库存下限 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-input-number |
|||
nzPlaceHolder="请输入" |
|||
[nzMin]="0" |
|||
class="!w-full" |
|||
formControlName="lowerLimit" |
|||
/> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-control> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button nzType="primary" (click)="onConfirm()">确定</button> |
|||
</nz-space> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</form> |
|||
</nz-card> |
|||
</div> |
|||
</div> |
|||
</app-page> |
|||
|
|||
<ng-template #errorTpl let-control> |
|||
<form-error-tips [control]="control"></form-error-tips> |
|||
</ng-template> |
|||
@ -0,0 +1,82 @@ |
|||
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core' |
|||
import { SharedModule } from 'app/shared/shared.module' |
|||
|
|||
import { ApiService } from 'app/services' |
|||
import { FormBuilder, FormGroup } from '@angular/forms' |
|||
import { AnyObject, TableOption } from 'app/shared/components/server-paginated-table' |
|||
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
|||
import { NzModalService } from 'ng-zorro-antd/modal' |
|||
import { NzMessageService } from 'ng-zorro-antd/message' |
|||
import { NzDrawerRef, NzDrawerService } from 'ng-zorro-antd/drawer' |
|||
import { lastValueFrom } from 'rxjs' |
|||
import { FormValidators } from 'app/utils' |
|||
import { ComponentBasicCategoryTreeComponent } from 'app/components' |
|||
|
|||
@Component({ |
|||
selector: 'app-basic-category', |
|||
standalone: true, |
|||
imports: [SharedModule, ComponentBasicCategoryTreeComponent], |
|||
templateUrl: './basic-category.component.html', |
|||
styleUrl: './basic-category.component.less', |
|||
}) |
|||
export class BasicCategoryComponent { |
|||
constructor( |
|||
private modal: NzModalService, |
|||
private msg: NzMessageService, |
|||
private drawer: NzDrawerService, |
|||
private api: ApiService, |
|||
private fb: FormBuilder, |
|||
) {} |
|||
|
|||
@ViewChild('treeEl') treeEl!: ComponentBasicCategoryTreeComponent |
|||
|
|||
queryForm!: FormGroup |
|||
|
|||
createForm!: FormGroup |
|||
|
|||
drawerRef?: NzDrawerRef |
|||
|
|||
@ViewChild('drawerFooterTpl') drawerFooterTpl!: TemplateRef<NzSafeAny> |
|||
|
|||
@ViewChild('formContentTpl') formContentTpl!: TemplateRef<NzSafeAny> |
|||
|
|||
initCreateForm() { |
|||
this.createForm = this.fb.group({ |
|||
categoryId: [], |
|||
categoryName: ['', [FormValidators.required('请输入')]], |
|||
safetyLimit: [0, []], |
|||
lowerLimit: [0, []], |
|||
upperLimit: [0, []], |
|||
}) |
|||
} |
|||
initQueryForm() { |
|||
this.queryForm = this.fb.group({ |
|||
name: [''], |
|||
}) |
|||
} |
|||
|
|||
ngOnInit(): void { |
|||
this.initQueryForm() |
|||
this.initCreateForm() |
|||
} |
|||
|
|||
onSelectedChange(v: NzSafeAny) { |
|||
this.createForm.patchValue(v) |
|||
} |
|||
|
|||
onConfirm() { |
|||
if (FormValidators.validateFormGroup(this.createForm)) { |
|||
const { value } = this.createForm |
|||
|
|||
this.api |
|||
.updateBasicCategoryTree({ |
|||
...value, |
|||
}) |
|||
.subscribe((res) => { |
|||
this.msg.success(res.desc) |
|||
console.log('this.treeEl', this.treeEl) |
|||
this.treeEl.initTree() |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
<p>basic-goods-stock works!</p> |
|||
@ -0,0 +1,12 @@ |
|||
import { Component } from '@angular/core'; |
|||
|
|||
@Component({ |
|||
selector: 'app-basic-goods-stock', |
|||
standalone: true, |
|||
imports: [], |
|||
templateUrl: './basic-goods-stock.component.html', |
|||
styleUrl: './basic-goods-stock.component.less' |
|||
}) |
|||
export class BasicGoodsStockComponent { |
|||
|
|||
} |
|||
@ -0,0 +1,108 @@ |
|||
<app-page class="p-3" [actions]="actionsTpl"> |
|||
<ng-template #actionsTpl> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button nzType="primary" (click)="onCreate()">新建</button> |
|||
</nz-space> |
|||
</ng-template> |
|||
<div class="flex-1 overflow-hidden"> |
|||
<app-server-paginated-table [options]="table" [renderColumn]="renderColumnTpl" [formGroup]="queryForm"> |
|||
<ng-template #renderColumnTpl let-data let-key="key" let-row="row"> |
|||
@switch (key) { |
|||
@case ('status') { |
|||
<!-- <nz-badge |
|||
[nzText]="data === 0 ? '在职' : '离职'" |
|||
[nzStatus]="data === 0 ? 'processing' : 'error'" |
|||
/> --> |
|||
} |
|||
|
|||
@default { |
|||
{{ data }} |
|||
} |
|||
} |
|||
</ng-template> |
|||
|
|||
<ng-container *appTableForm> |
|||
<app-query-item label="名称" class="w-60"> |
|||
<input nz-input placeholder="请输入" formControlName="name" /> |
|||
</app-query-item> |
|||
<app-query-item label="编码" class="w-60"> |
|||
<input nz-input placeholder="请输入" formControlName="code" /> |
|||
</app-query-item> |
|||
<app-query-item label="统一社会信用代码"> |
|||
<input nz-input placeholder="请输入" formControlName="uscc" /> |
|||
</app-query-item> |
|||
</ng-container> |
|||
</app-server-paginated-table> |
|||
</div> |
|||
</app-page> |
|||
|
|||
<ng-template #drawerFooterTpl> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button nzType="primary" (click)="onConfirm()">确定</button> |
|||
<button *nzSpaceItem nz-button nzType="default" (click)="onCancel()">取消</button> |
|||
</nz-space> |
|||
</ng-template> |
|||
|
|||
<ng-template #formContentTpl> |
|||
<form nz-form nzLayout="vertical" [formGroup]="createForm"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired> 名称 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="name" placeholder="请输入名称" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 编码 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="code" placeholder="请输入编码" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 统一社会信用代码 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="uscc" placeholder="请输入统一社会信用代码" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 商务联系人 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="businessContactor" placeholder="请输入商务联系人" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 商务联系方式 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="businessContact" placeholder="请输入商务联系方式" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 售后联系人 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="afterSalesContactor" placeholder="请输入售后联系人" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 售后联系方式 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="afterSalesContact" placeholder="请输入售后联系方式" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
|
|||
<nz-form-item> |
|||
<nz-form-label> 地址 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<textarea nz-input formControlName="address" placeholder="请输入地址"></textarea> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 备注 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<textarea nz-input formControlName="notes" placeholder="请输入备注"></textarea> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</form> |
|||
</ng-template> |
|||
|
|||
<ng-template #errorTpl let-control> |
|||
<form-error-tips [control]="control"></form-error-tips> |
|||
</ng-template> |
|||
@ -0,0 +1,136 @@ |
|||
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core' |
|||
import { SharedModule } from 'app/shared/shared.module' |
|||
import { ApiService } from 'app/services' |
|||
import { FormBuilder, FormGroup } from '@angular/forms' |
|||
import { AnyObject, TableOption } from 'app/shared/components/server-paginated-table' |
|||
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
|||
import { NzModalService } from 'ng-zorro-antd/modal' |
|||
import { NzMessageService } from 'ng-zorro-antd/message' |
|||
import { NzDrawerRef, NzDrawerService } from 'ng-zorro-antd/drawer' |
|||
import { lastValueFrom } from 'rxjs' |
|||
import { FormValidators } from 'app/utils' |
|||
|
|||
@Component({ |
|||
selector: 'app-basic-maintainer', |
|||
standalone: true, |
|||
imports: [SharedModule], |
|||
templateUrl: './basic-maintainer.component.html', |
|||
styleUrl: './basic-maintainer.component.less', |
|||
}) |
|||
export class BasicMaintainerComponent { |
|||
constructor( |
|||
private modal: NzModalService, |
|||
private msg: NzMessageService, |
|||
private drawer: NzDrawerService, |
|||
private api: ApiService, |
|||
private fb: FormBuilder, |
|||
) {} |
|||
|
|||
table = new TableOption(this.fetchData.bind(this)) |
|||
|
|||
queryForm!: FormGroup |
|||
|
|||
createForm!: FormGroup |
|||
|
|||
drawerRef?: NzDrawerRef |
|||
|
|||
@ViewChild('drawerFooterTpl') drawerFooterTpl!: TemplateRef<NzSafeAny> |
|||
|
|||
@ViewChild('formContentTpl') formContentTpl!: TemplateRef<NzSafeAny> |
|||
|
|||
initCreateForm() { |
|||
this.createForm = this.fb.group({ |
|||
maintenanceVendorId: [], |
|||
name: ['', [FormValidators.required('请输入')]], |
|||
code: ['', []], |
|||
uscc: ['', []], |
|||
notes: ['', []], |
|||
businessContactor: ['', []], |
|||
businessContact: ['', []], |
|||
afterSalesContactor: ['', []], |
|||
afterSalesContact: ['', []], |
|||
address: ['', []], |
|||
}) |
|||
} |
|||
initQueryForm() { |
|||
this.queryForm = this.fb.group({ |
|||
name: [''], |
|||
uscc: [''], |
|||
code: [''], |
|||
}) |
|||
} |
|||
|
|||
ngOnInit(): void { |
|||
this.table |
|||
|
|||
.setColumn([ |
|||
{ key: 'name', title: '名称' }, |
|||
{ key: 'code', title: '编码' }, |
|||
{ key: 'uscc', title: '统一社会信用代码' }, |
|||
{ key: 'businessContactor', title: '商务联系人' }, |
|||
{ key: 'businessContact', title: '商务联系方式' }, |
|||
{ key: 'afterSalesContactor', title: '售后联系人' }, |
|||
{ key: 'afterSalesContact', title: '售后联系方式' }, |
|||
{ key: 'address', title: '地址' }, |
|||
{ key: 'notes', title: '备注' }, |
|||
]) |
|||
.setRowOperate([ |
|||
{ title: '编辑', onClick: this.onCreate.bind(this) }, |
|||
{ title: '删除', onClick: this.deleteItem.bind(this) }, |
|||
]) |
|||
this.initQueryForm() |
|||
this.initCreateForm() |
|||
} |
|||
|
|||
fetchData(p: {}, q: AnyObject) { |
|||
return this.api.getBasicMaintenanceVendorPage({ ...p, ...q }) |
|||
} |
|||
|
|||
onCreate(data?: NzSafeAny) { |
|||
if (data) { |
|||
this.createForm.patchValue(data) |
|||
} |
|||
this.drawerRef = this.drawer.create({ |
|||
nzTitle: data ? '编辑维保商' : '新增维保商', |
|||
nzContent: this.formContentTpl, |
|||
nzFooter: this.drawerFooterTpl, |
|||
nzWidth: 600, |
|||
nzOnCancel: this.onCancel.bind(this), |
|||
}) |
|||
} |
|||
|
|||
onConfirm() { |
|||
if (FormValidators.validateFormGroup(this.createForm)) { |
|||
const { value } = this.createForm |
|||
|
|||
this.api |
|||
.saveBasicMaintenanceVendor({ |
|||
...value, |
|||
|
|||
// maintenanceVendorId: value.maintenanceVendorId ?? 0,
|
|||
}) |
|||
.subscribe((res) => { |
|||
this.msg.success(res.desc) |
|||
this.onCancel() |
|||
this.table.ref.reload() |
|||
}) |
|||
} |
|||
} |
|||
|
|||
async onCancel() { |
|||
this.drawerRef?.close() |
|||
this.createForm.reset({}) |
|||
} |
|||
|
|||
deleteItem(item: NzSafeAny) { |
|||
this.modal.confirm({ |
|||
nzTitle: '警告', |
|||
nzContent: '是否要删除该维保商?', |
|||
nzOnOk: async () => { |
|||
const res = await lastValueFrom(this.api.deleteBasicMaintenanceVendor([item.maintenanceVendorId])) |
|||
this.msg.success(res.desc) |
|||
this.table.ref.reload() |
|||
}, |
|||
}) |
|||
} |
|||
} |
|||
@ -0,0 +1,75 @@ |
|||
<app-page class="p-3" [actions]="actionsTpl"> |
|||
<ng-template #actionsTpl> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button nzType="primary" (click)="onCreate()">新建</button> |
|||
</nz-space> |
|||
</ng-template> |
|||
<div class="overflow-hidden flex-1"> |
|||
<app-server-paginated-table [options]="table" [renderColumn]="renderColumnTpl" [formGroup]="queryForm"> |
|||
<ng-template #renderColumnTpl let-data let-key="key" let-row="row"> |
|||
@switch (key) { |
|||
@case ('status') { |
|||
<!-- <nz-badge |
|||
[nzText]="data === 0 ? '在职' : '离职'" |
|||
[nzStatus]="data === 0 ? 'processing' : 'error'" |
|||
/> --> |
|||
} |
|||
|
|||
@default { |
|||
{{ data }} |
|||
} |
|||
} |
|||
</ng-template> |
|||
|
|||
<ng-container *appTableForm> |
|||
<app-query-item label="名称" class="w-60"> |
|||
<input nz-input placeholder="请输入" formControlName="name" /> |
|||
</app-query-item> |
|||
<app-query-item label="编码" class="w-60"> |
|||
<input nz-input placeholder="请输入" formControlName="code" /> |
|||
</app-query-item> |
|||
</ng-container> |
|||
</app-server-paginated-table> |
|||
</div> |
|||
</app-page> |
|||
|
|||
<ng-template #drawerFooterTpl> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button nzType="primary" (click)="onConfirm()">确定</button> |
|||
<button *nzSpaceItem nz-button nzType="default" (click)="onCancel()">取消</button> |
|||
</nz-space> |
|||
</ng-template> |
|||
|
|||
<ng-template #formContentTpl> |
|||
<form nz-form nzLayout="vertical" [formGroup]="createForm"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired> 名称 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="name" placeholder="请输入名称" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 编码 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="code" placeholder="请输入编码" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
|
|||
<nz-form-item> |
|||
<nz-form-label> 地址 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<textarea nz-input formControlName="address" placeholder="请输入地址"></textarea> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 备注 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<textarea nz-input formControlName="notes" placeholder="请输入备注"></textarea> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</form> |
|||
</ng-template> |
|||
|
|||
<ng-template #errorTpl let-control> |
|||
<form-error-tips [control]="control"></form-error-tips> |
|||
</ng-template> |
|||
@ -0,0 +1,130 @@ |
|||
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core' |
|||
import { SharedModule } from 'app/shared/shared.module' |
|||
|
|||
import { ApiService } from 'app/services' |
|||
import { FormBuilder, FormGroup } from '@angular/forms' |
|||
import { AnyObject, TableOption } from 'app/shared/components/server-paginated-table' |
|||
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
|||
import { NzModalService } from 'ng-zorro-antd/modal' |
|||
import { NzMessageService } from 'ng-zorro-antd/message' |
|||
import { NzDrawerRef, NzDrawerService } from 'ng-zorro-antd/drawer' |
|||
import { lastValueFrom } from 'rxjs' |
|||
import { FormValidators } from 'app/utils' |
|||
|
|||
@Component({ |
|||
selector: 'app-basic-manufacturer', |
|||
standalone: true, |
|||
imports: [SharedModule], |
|||
templateUrl: './basic-manufacturer.component.html', |
|||
styleUrl: './basic-manufacturer.component.less', |
|||
}) |
|||
export class BasicManufacturerComponent { |
|||
constructor( |
|||
private modal: NzModalService, |
|||
private msg: NzMessageService, |
|||
private drawer: NzDrawerService, |
|||
private api: ApiService, |
|||
private fb: FormBuilder, |
|||
) {} |
|||
|
|||
table = new TableOption(this.fetchData.bind(this)) |
|||
|
|||
queryForm!: FormGroup |
|||
|
|||
createForm!: FormGroup |
|||
|
|||
drawerRef?: NzDrawerRef |
|||
|
|||
@ViewChild('drawerFooterTpl') drawerFooterTpl!: TemplateRef<NzSafeAny> |
|||
|
|||
@ViewChild('formContentTpl') formContentTpl!: TemplateRef<NzSafeAny> |
|||
|
|||
initCreateForm() { |
|||
this.createForm = this.fb.group({ |
|||
manufacturersVendorId: [], |
|||
name: ['', [FormValidators.required('请输入')]], |
|||
code: ['', []], |
|||
notes: ['', []], |
|||
address: ['', []], |
|||
}) |
|||
} |
|||
initQueryForm() { |
|||
this.queryForm = this.fb.group({ |
|||
name: [''], |
|||
|
|||
code: [''], |
|||
}) |
|||
} |
|||
|
|||
ngOnInit(): void { |
|||
this.table |
|||
|
|||
.setColumn([ |
|||
{ key: 'manufacturersVendorId', title: '主键', visible: false }, |
|||
{ key: 'name', title: '名称' }, |
|||
{ key: 'code', title: '编码' }, |
|||
|
|||
{ key: 'address', title: '地址' }, |
|||
{ key: 'notes', title: '备注' }, |
|||
{ key: 'createTime', title: '创建时间' }, |
|||
]) |
|||
.setRowOperate([ |
|||
{ title: '编辑', onClick: this.onCreate.bind(this) }, |
|||
{ title: '删除', onClick: this.deleteItem.bind(this) }, |
|||
]) |
|||
this.initQueryForm() |
|||
this.initCreateForm() |
|||
} |
|||
|
|||
fetchData(p: {}, q: AnyObject) { |
|||
return this.api.getBasicManufacturersVendorPage({ ...p, ...q }) |
|||
} |
|||
|
|||
onCreate(data?: NzSafeAny) { |
|||
if (data) { |
|||
this.createForm.patchValue(data) |
|||
} |
|||
this.drawerRef = this.drawer.create({ |
|||
nzTitle: data ? '编辑生产商' : '新增生产商', |
|||
nzContent: this.formContentTpl, |
|||
nzFooter: this.drawerFooterTpl, |
|||
nzWidth: 600, |
|||
nzOnCancel: this.onCancel.bind(this), |
|||
}) |
|||
} |
|||
|
|||
onConfirm() { |
|||
if (FormValidators.validateFormGroup(this.createForm)) { |
|||
const { value } = this.createForm |
|||
|
|||
this.api |
|||
.saveBasicManufacturersVendor({ |
|||
...value, |
|||
|
|||
// manufacturersVendorId: value.manufacturersVendorId ?? 0,
|
|||
}) |
|||
.subscribe((res) => { |
|||
this.msg.success(res.desc) |
|||
this.onCancel() |
|||
this.table.ref.reload() |
|||
}) |
|||
} |
|||
} |
|||
|
|||
async onCancel() { |
|||
this.drawerRef?.close() |
|||
this.createForm.reset({}) |
|||
} |
|||
|
|||
deleteItem(item: NzSafeAny) { |
|||
this.modal.confirm({ |
|||
nzTitle: '警告', |
|||
nzContent: '是否要删除该生产商?', |
|||
nzOnOk: async () => { |
|||
const res = await lastValueFrom(this.api.deleteBasicManufacturersVendor([item.manufacturersVendorId])) |
|||
this.msg.success(res.desc) |
|||
this.table.ref.reload() |
|||
}, |
|||
}) |
|||
} |
|||
} |
|||
@ -0,0 +1,108 @@ |
|||
<app-page class="p-3" [actions]="actionsTpl"> |
|||
<ng-template #actionsTpl> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button nzType="primary" (click)="onCreate()">新建</button> |
|||
</nz-space> |
|||
</ng-template> |
|||
<div class="flex-1 overflow-hidden"> |
|||
<app-server-paginated-table [options]="table" [renderColumn]="renderColumnTpl" [formGroup]="queryForm"> |
|||
<ng-template #renderColumnTpl let-data let-key="key" let-row="row"> |
|||
@switch (key) { |
|||
@case ('status') { |
|||
<!-- <nz-badge |
|||
[nzText]="data === 0 ? '在职' : '离职'" |
|||
[nzStatus]="data === 0 ? 'processing' : 'error'" |
|||
/> --> |
|||
} |
|||
|
|||
@default { |
|||
{{ data }} |
|||
} |
|||
} |
|||
</ng-template> |
|||
|
|||
<ng-container *appTableForm> |
|||
<app-query-item label="名称" class="w-60"> |
|||
<input nz-input placeholder="请输入" formControlName="name" /> |
|||
</app-query-item> |
|||
<app-query-item label="编码" class="w-60"> |
|||
<input nz-input placeholder="请输入" formControlName="code" /> |
|||
</app-query-item> |
|||
<app-query-item label="统一社会信用代码"> |
|||
<input nz-input placeholder="请输入" formControlName="uscc" /> |
|||
</app-query-item> |
|||
</ng-container> |
|||
</app-server-paginated-table> |
|||
</div> |
|||
</app-page> |
|||
|
|||
<ng-template #drawerFooterTpl> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button nzType="primary" (click)="onConfirm()">确定</button> |
|||
<button *nzSpaceItem nz-button nzType="default" (click)="onCancel()">取消</button> |
|||
</nz-space> |
|||
</ng-template> |
|||
|
|||
<ng-template #formContentTpl> |
|||
<form nz-form nzLayout="vertical" [formGroup]="createForm"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired> 名称 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="name" placeholder="请输入名称" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 编码 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="code" placeholder="请输入编码" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 统一社会信用代码 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="uscc" placeholder="请输入统一社会信用代码" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 商务联系人 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="businessContactor" placeholder="请输入商务联系人" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 商务联系方式 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="businessContact" placeholder="请输入商务联系方式" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 售后联系人 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="afterSalesContactor" placeholder="请输入售后联系人" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 售后联系方式 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="afterSalesContact" placeholder="请输入售后联系方式" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
|
|||
<nz-form-item> |
|||
<nz-form-label> 地址 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<textarea nz-input formControlName="address" placeholder="请输入地址"></textarea> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 备注 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<textarea nz-input formControlName="notes" placeholder="请输入备注"></textarea> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</form> |
|||
</ng-template> |
|||
|
|||
<ng-template #errorTpl let-control> |
|||
<form-error-tips [control]="control"></form-error-tips> |
|||
</ng-template> |
|||
@ -0,0 +1,135 @@ |
|||
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core' |
|||
import { SharedModule } from 'app/shared/shared.module' |
|||
|
|||
import { ApiService } from 'app/services' |
|||
import { FormBuilder, FormGroup } from '@angular/forms' |
|||
import { AnyObject, TableOption } from 'app/shared/components/server-paginated-table' |
|||
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
|||
import { NzModalService } from 'ng-zorro-antd/modal' |
|||
import { NzMessageService } from 'ng-zorro-antd/message' |
|||
import { NzDrawerRef, NzDrawerService } from 'ng-zorro-antd/drawer' |
|||
import { lastValueFrom } from 'rxjs' |
|||
import { FormValidators } from 'app/utils' |
|||
|
|||
@Component({ |
|||
selector: 'app-basic-supplier', |
|||
standalone: true, |
|||
imports: [SharedModule], |
|||
templateUrl: './basic-supplier.component.html', |
|||
styleUrl: './basic-supplier.component.less', |
|||
}) |
|||
export class BasicSupplierComponent { |
|||
constructor( |
|||
private modal: NzModalService, |
|||
private msg: NzMessageService, |
|||
private drawer: NzDrawerService, |
|||
private api: ApiService, |
|||
private fb: FormBuilder, |
|||
) {} |
|||
|
|||
table = new TableOption(this.fetchData.bind(this)) |
|||
|
|||
queryForm!: FormGroup |
|||
|
|||
createForm!: FormGroup |
|||
|
|||
drawerRef?: NzDrawerRef |
|||
|
|||
@ViewChild('drawerFooterTpl') drawerFooterTpl!: TemplateRef<NzSafeAny> |
|||
|
|||
@ViewChild('formContentTpl') formContentTpl!: TemplateRef<NzSafeAny> |
|||
|
|||
initCreateForm() { |
|||
this.createForm = this.fb.group({ |
|||
supplierVendorId: [], |
|||
name: ['', [FormValidators.required('请输入')]], |
|||
code: ['', []], |
|||
uscc: ['', []], |
|||
notes: ['', []], |
|||
businessContactor: ['', []], |
|||
businessContact: ['', []], |
|||
afterSalesContactor: ['', []], |
|||
afterSalesContact: ['', []], |
|||
address: ['', []], |
|||
}) |
|||
} |
|||
initQueryForm() { |
|||
this.queryForm = this.fb.group({ |
|||
name: [''], |
|||
uscc: [''], |
|||
code: [''], |
|||
}) |
|||
} |
|||
|
|||
ngOnInit(): void { |
|||
this.table |
|||
|
|||
.setColumn([ |
|||
{ key: 'name', title: '名称' }, |
|||
{ key: 'code', title: '编码' }, |
|||
{ key: 'uscc', title: '统一社会信用代码' }, |
|||
{ key: 'businessContactor', title: '商务联系人' }, |
|||
{ key: 'businessContact', title: '商务联系方式' }, |
|||
{ key: 'afterSalesContactor', title: '售后联系人' }, |
|||
{ key: 'afterSalesContact', title: '售后联系方式' }, |
|||
{ key: 'address', title: '地址' }, |
|||
{ key: 'notes', title: '备注' }, |
|||
]) |
|||
.setRowOperate([ |
|||
{ title: '编辑', onClick: this.onCreate.bind(this) }, |
|||
{ title: '删除', onClick: this.deleteItem.bind(this) }, |
|||
]) |
|||
this.initQueryForm() |
|||
this.initCreateForm() |
|||
} |
|||
|
|||
fetchData(p: {}, q: AnyObject) { |
|||
return this.api.getBasicSupplierVendorPage({ ...p, ...q }) |
|||
} |
|||
|
|||
onCreate(data?: NzSafeAny) { |
|||
if (data) { |
|||
this.createForm.patchValue(data) |
|||
} |
|||
this.drawerRef = this.drawer.create({ |
|||
nzTitle: data ? '编辑供应商' : '新增供应商', |
|||
nzContent: this.formContentTpl, |
|||
nzFooter: this.drawerFooterTpl, |
|||
nzWidth: 600, |
|||
nzOnCancel: this.onCancel.bind(this), |
|||
}) |
|||
} |
|||
|
|||
onConfirm() { |
|||
if (FormValidators.validateFormGroup(this.createForm)) { |
|||
const { value } = this.createForm |
|||
|
|||
this.api |
|||
.saveBasicSupplierVendor({ |
|||
...value, |
|||
}) |
|||
.subscribe((res) => { |
|||
this.msg.success(res.desc) |
|||
this.onCancel() |
|||
this.table.ref.reload() |
|||
}) |
|||
} |
|||
} |
|||
|
|||
async onCancel() { |
|||
this.drawerRef?.close() |
|||
this.createForm.reset({}) |
|||
} |
|||
|
|||
deleteItem(item: NzSafeAny) { |
|||
this.modal.confirm({ |
|||
nzTitle: '警告', |
|||
nzContent: '是否要删除该供应商?', |
|||
nzOnOk: async () => { |
|||
const res = await lastValueFrom(this.api.deleteBasicSupplierVendor([item.supplierVendorId])) |
|||
this.msg.success(res.desc) |
|||
this.table.ref.reload() |
|||
}, |
|||
}) |
|||
} |
|||
} |
|||
@ -0,0 +1,77 @@ |
|||
<app-page class="p-3" [actions]="actionsTpl"> |
|||
<ng-template #actionsTpl> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button nzType="primary" (click)="onCreate()">新建</button> |
|||
</nz-space> |
|||
</ng-template> |
|||
<div class="flex flex-1"> |
|||
<div class="flex-1"> |
|||
<app-server-paginated-table [options]="table" [renderColumn]="renderColumnTpl" [formGroup]="queryForm"> |
|||
<ng-template #renderColumnTpl let-data let-key="key" let-row="row"> |
|||
@switch (key) { |
|||
@case ('status') { |
|||
<nz-badge |
|||
[nzText]="data === 0 ? '启用' : '禁用'" |
|||
[nzStatus]="data === 0 ? 'processing' : 'error'" |
|||
/> |
|||
} |
|||
|
|||
@default { |
|||
{{ data }} |
|||
} |
|||
} |
|||
</ng-template> |
|||
|
|||
<ng-container *appTableForm> |
|||
<app-query-item label="名称" class="w-60"> |
|||
<input nz-input placeholder="请输入" formControlName="name" /> |
|||
</app-query-item> |
|||
<app-query-item label="状态"> |
|||
<nz-select |
|||
nzPlacement="bottomRight" |
|||
nzBorderless |
|||
class="!w-20" |
|||
[nzDropdownMatchSelectWidth]="false" |
|||
formControlName="status" |
|||
nzAllowClear |
|||
> |
|||
<nz-option [nzValue]="0" nzLabel="启用"></nz-option> |
|||
<nz-option [nzValue]="1" nzLabel="禁用"></nz-option> |
|||
</nz-select> |
|||
</app-query-item> |
|||
</ng-container> |
|||
</app-server-paginated-table> |
|||
</div> |
|||
</div> |
|||
</app-page> |
|||
|
|||
<ng-template #drawerFooterTpl> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button nzType="primary" (click)="onConfirm()">确定</button> |
|||
<button *nzSpaceItem nz-button nzType="default" (click)="onCancel()">取消</button> |
|||
</nz-space> |
|||
</ng-template> |
|||
|
|||
<ng-template #formContentTpl> |
|||
<form nz-form nzLayout="vertical" [formGroup]="createForm"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired> 名称 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="name" placeholder="请输入名称" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired> 状态 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-radio-group formControlName="status"> |
|||
<label nz-radio [nzValue]="0"> 启用 </label> |
|||
<label nz-radio [nzValue]="1"> 禁用 </label> |
|||
</nz-radio-group> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</form> |
|||
</ng-template> |
|||
|
|||
<ng-template #errorTpl let-control> |
|||
<form-error-tips [control]="control"></form-error-tips> |
|||
</ng-template> |
|||
@ -0,0 +1,125 @@ |
|||
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core' |
|||
import { SharedModule } from 'app/shared/shared.module' |
|||
|
|||
import { ApiService } from 'app/services' |
|||
import { FormBuilder, FormGroup } from '@angular/forms' |
|||
import { AnyObject, TableOption } from 'app/shared/components/server-paginated-table' |
|||
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
|||
import { NzModalService } from 'ng-zorro-antd/modal' |
|||
import { NzMessageService } from 'ng-zorro-antd/message' |
|||
import { NzDrawerRef, NzDrawerService } from 'ng-zorro-antd/drawer' |
|||
import { lastValueFrom } from 'rxjs' |
|||
import { FormValidators } from 'app/utils' |
|||
|
|||
@Component({ |
|||
selector: 'app-basic-warehouse', |
|||
standalone: true, |
|||
imports: [SharedModule], |
|||
templateUrl: './basic-warehouse.component.html', |
|||
styleUrl: './basic-warehouse.component.less', |
|||
}) |
|||
export class BasicWarehouseComponent { |
|||
constructor( |
|||
private modal: NzModalService, |
|||
private msg: NzMessageService, |
|||
private drawer: NzDrawerService, |
|||
private api: ApiService, |
|||
private fb: FormBuilder, |
|||
) {} |
|||
|
|||
table = new TableOption(this.fetchData.bind(this)) |
|||
|
|||
queryForm!: FormGroup |
|||
|
|||
createForm!: FormGroup |
|||
|
|||
drawerRef?: NzDrawerRef |
|||
|
|||
@ViewChild('drawerFooterTpl') drawerFooterTpl!: TemplateRef<NzSafeAny> |
|||
|
|||
@ViewChild('formContentTpl') formContentTpl!: TemplateRef<NzSafeAny> |
|||
|
|||
initCreateForm() { |
|||
this.createForm = this.fb.group({ |
|||
warehouseId: [], |
|||
name: ['', [FormValidators.required('请输入')]], |
|||
status: [0, [FormValidators.required('请选择')]], |
|||
notes: ['', []], |
|||
}) |
|||
} |
|||
initQueryForm() { |
|||
this.queryForm = this.fb.group({ |
|||
name: [''], |
|||
status: [], |
|||
}) |
|||
} |
|||
|
|||
ngOnInit(): void { |
|||
this.table |
|||
|
|||
.setColumn([ |
|||
{ key: 'warehouseId', title: '主键', visible: false }, |
|||
{ key: 'name', title: '名称' }, |
|||
{ key: 'status', title: '状态' }, |
|||
{ key: 'createTime', title: '创建时间' }, |
|||
]) |
|||
.setRowOperate([ |
|||
{ title: '编辑', onClick: this.onCreate.bind(this) }, |
|||
{ title: '删除', onClick: this.deleteItem.bind(this) }, |
|||
]) |
|||
this.initQueryForm() |
|||
this.initCreateForm() |
|||
} |
|||
|
|||
fetchData(p: {}, q: AnyObject) { |
|||
return this.api.getBasicWarehousePage({ ...p, ...q }) |
|||
} |
|||
|
|||
onCreate(data?: NzSafeAny) { |
|||
if (data) { |
|||
this.createForm.patchValue(data) |
|||
} |
|||
this.drawerRef = this.drawer.create({ |
|||
nzTitle: data ? '编辑存放仓库' : '新增存放仓库', |
|||
nzContent: this.formContentTpl, |
|||
nzFooter: this.drawerFooterTpl, |
|||
nzWidth: 600, |
|||
nzOnCancel: this.onCancel.bind(this), |
|||
}) |
|||
} |
|||
|
|||
onConfirm() { |
|||
if (FormValidators.validateFormGroup(this.createForm)) { |
|||
const { value } = this.createForm |
|||
|
|||
this.api |
|||
.saveBasicWarehouse({ |
|||
...value, |
|||
|
|||
// warehouseId: value.warehouseId ?? 0,
|
|||
}) |
|||
.subscribe((res) => { |
|||
this.msg.success(res.desc) |
|||
this.onCancel() |
|||
this.table.ref.reload() |
|||
}) |
|||
} |
|||
} |
|||
|
|||
async onCancel() { |
|||
this.drawerRef?.close() |
|||
this.createForm.reset({ status: 0 }) |
|||
} |
|||
|
|||
deleteItem(item: NzSafeAny) { |
|||
this.modal.confirm({ |
|||
nzTitle: '警告', |
|||
nzContent: '是否要删除该存放仓库?', |
|||
nzOnOk: async () => { |
|||
const res = await lastValueFrom(this.api.deleteBasicWarehouse([item.warehouseId])) |
|||
this.msg.success(res.desc) |
|||
this.table.ref.reload() |
|||
}, |
|||
}) |
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
<app-page class="p-3" [actions]="actionsTpl"> |
|||
<ng-template #actionsTpl> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button nzType="primary" (click)="onCreate()">新建</button> |
|||
</nz-space> |
|||
</ng-template> |
|||
<div class="flex flex-1"> |
|||
<div class="flex-1"> |
|||
<app-server-paginated-table [options]="table" [renderColumn]="renderColumnTpl" [formGroup]="queryForm"> |
|||
<ng-template #renderColumnTpl let-data let-key="key" let-row="row"> |
|||
@switch (key) { |
|||
@case ('status') { |
|||
<!-- <nz-badge |
|||
[nzText]="data === 0 ? '在职' : '离职'" |
|||
[nzStatus]="data === 0 ? 'processing' : 'error'" |
|||
/> --> |
|||
} |
|||
|
|||
@default { |
|||
{{ data }} |
|||
} |
|||
} |
|||
</ng-template> |
|||
|
|||
<ng-container *appTableForm> |
|||
<app-query-item label="名称" class="w-60"> |
|||
<input nz-input placeholder="请输入" formControlName="name" /> |
|||
</app-query-item> |
|||
</ng-container> |
|||
</app-server-paginated-table> |
|||
</div> |
|||
</div> |
|||
</app-page> |
|||
|
|||
<ng-template #drawerFooterTpl> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button nzType="primary" (click)="onConfirm()">确定</button> |
|||
<button *nzSpaceItem nz-button nzType="default" (click)="onCancel()">取消</button> |
|||
</nz-space> |
|||
</ng-template> |
|||
|
|||
<ng-template #formContentTpl> |
|||
<form nz-form nzLayout="vertical" [formGroup]="createForm"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired> 名称 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="name" placeholder="请输入名称" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</form> |
|||
</ng-template> |
|||
|
|||
<ng-template #errorTpl let-control> |
|||
<form-error-tips [control]="control"></form-error-tips> |
|||
</ng-template> |
|||
@ -0,0 +1,122 @@ |
|||
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core' |
|||
import { SharedModule } from 'app/shared/shared.module' |
|||
import { ComponentOrgTreeComponent } from 'app/components/component-org-tree/component-org-tree.component' |
|||
|
|||
import { format } from 'date-fns' |
|||
import { ApiService } from 'app/services' |
|||
import { FormBuilder, FormGroup } from '@angular/forms' |
|||
import { AnyObject, TableOption } from 'app/shared/components/server-paginated-table' |
|||
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
|||
import { NzModalService } from 'ng-zorro-antd/modal' |
|||
import { NzMessageService } from 'ng-zorro-antd/message' |
|||
import { NzDrawerRef, NzDrawerService } from 'ng-zorro-antd/drawer' |
|||
import { lastValueFrom } from 'rxjs' |
|||
import { FormValidators } from 'app/utils' |
|||
|
|||
@Component({ |
|||
selector: 'app-save-position', |
|||
standalone: true, |
|||
imports: [SharedModule, ComponentOrgTreeComponent], |
|||
templateUrl: './save-position.component.html', |
|||
styleUrl: './save-position.component.less', |
|||
}) |
|||
export class SavePositionComponent implements OnInit { |
|||
constructor( |
|||
private modal: NzModalService, |
|||
private msg: NzMessageService, |
|||
private drawer: NzDrawerService, |
|||
private api: ApiService, |
|||
private fb: FormBuilder, |
|||
) {} |
|||
|
|||
table = new TableOption(this.fetchData.bind(this)) |
|||
|
|||
queryForm!: FormGroup |
|||
|
|||
createForm!: FormGroup |
|||
|
|||
drawerRef?: NzDrawerRef |
|||
|
|||
@ViewChild('drawerFooterTpl') drawerFooterTpl!: TemplateRef<NzSafeAny> |
|||
|
|||
@ViewChild('formContentTpl') formContentTpl!: TemplateRef<NzSafeAny> |
|||
|
|||
initCreateForm() { |
|||
this.createForm = this.fb.group({ |
|||
positionId: [], |
|||
name: ['', FormValidators.required('请输入')], |
|||
}) |
|||
} |
|||
initQueryForm() { |
|||
this.queryForm = this.fb.group({ |
|||
name: [''], |
|||
}) |
|||
} |
|||
|
|||
ngOnInit(): void { |
|||
this.table |
|||
|
|||
.setColumn([ |
|||
{ key: 'positionId', title: '编号', width: '100px' }, |
|||
{ key: 'name', title: '名称' }, |
|||
]) |
|||
.setRowOperate([ |
|||
{ title: '编辑', onClick: this.onCreate.bind(this) }, |
|||
{ title: '删除', onClick: this.deleteItem.bind(this) }, |
|||
]) |
|||
this.initQueryForm() |
|||
this.initCreateForm() |
|||
} |
|||
|
|||
fetchData(p: {}, q: AnyObject) { |
|||
return this.api.getBasicPositionPage({ ...p, ...q }) |
|||
} |
|||
|
|||
onCreate(data?: NzSafeAny) { |
|||
if (data) { |
|||
this.createForm.patchValue(data) |
|||
} |
|||
this.drawerRef = this.drawer.create({ |
|||
nzTitle: data ? '编辑存放位置' : '新增存放位置', |
|||
nzContent: this.formContentTpl, |
|||
nzFooter: this.drawerFooterTpl, |
|||
nzWidth: 600, |
|||
nzOnCancel: this.onCancel.bind(this), |
|||
}) |
|||
} |
|||
|
|||
onConfirm() { |
|||
if (FormValidators.validateFormGroup(this.createForm)) { |
|||
const { value } = this.createForm |
|||
|
|||
this.api |
|||
.saveBasicPosition({ |
|||
...value, |
|||
parentId: 0, |
|||
positionId: value.positionId ?? 0, |
|||
}) |
|||
.subscribe((res) => { |
|||
this.msg.success(res.desc) |
|||
this.onCancel() |
|||
this.table.ref.reload() |
|||
}) |
|||
} |
|||
} |
|||
|
|||
async onCancel() { |
|||
this.drawerRef?.close() |
|||
this.createForm.reset({}) |
|||
} |
|||
|
|||
deleteItem(item: NzSafeAny) { |
|||
this.modal.confirm({ |
|||
nzTitle: '警告', |
|||
nzContent: '是否要删除该存放位置?', |
|||
nzOnOk: async () => { |
|||
const res = await lastValueFrom(this.api.deleteBasicPosition([item.positionId])) |
|||
this.msg.success(res.desc) |
|||
this.table.ref.reload() |
|||
}, |
|||
}) |
|||
} |
|||
} |
|||
@ -1,4 +1,6 @@ |
|||
:host { |
|||
display: flex !important; |
|||
width: 100%; |
|||
} |
|||
// :host { |
|||
// display: flex !important; |
|||
// width: auto; |
|||
// overflow: hidden; |
|||
|
|||
// } |
|||
@ -0,0 +1,179 @@ |
|||
<app-page class="p-3"> |
|||
<div class="flex-1 overflow-hidden"> |
|||
<app-server-paginated-table |
|||
[options]="table" |
|||
[tableAction]="tableActionTpl" |
|||
[renderColumn]="renderColumnTpl" |
|||
[formGroup]="queryForm" |
|||
> |
|||
<ng-template #renderColumnTpl let-data let-key="key" let-row="row"> |
|||
@switch (key) { |
|||
@case ('fullStocktaking') { |
|||
@switch (data) { |
|||
@case (0) { |
|||
<nz-badge [nzText]="'禁用'" [nzStatus]="'error'" /> |
|||
} |
|||
@case (1) { |
|||
<nz-badge [nzText]="'启用'" [nzStatus]="'processing'" /> |
|||
} |
|||
@default { |
|||
- |
|||
} |
|||
} |
|||
} |
|||
@case ('status') { |
|||
@switch (data) { |
|||
@case (0) { |
|||
<nz-badge [nzText]="'未开始'" [nzStatus]="'default'" /> |
|||
} |
|||
@case (1) { |
|||
<nz-badge [nzText]="'进行中'" [nzStatus]="'processing'" /> |
|||
} |
|||
@case (2) { |
|||
<nz-badge [nzText]="'取消'" [nzStatus]="'error'" /> |
|||
} |
|||
@case (3) { |
|||
<nz-badge [nzText]="'已完成'" [nzStatus]="'success'" /> |
|||
} |
|||
@default { |
|||
- |
|||
} |
|||
} |
|||
} |
|||
|
|||
@default { |
|||
{{ data }} |
|||
} |
|||
} |
|||
</ng-template> |
|||
|
|||
<ng-template #tableActionTpl> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button nzType="primary" (click)="onCreate()">新建</button> |
|||
<button *nzSpaceItem [disabled]="table.ref.selected.size === 0" nz-button (click)="onBegin()"> |
|||
开始盘点 |
|||
</button> |
|||
<button *nzSpaceItem [disabled]="table.ref.selected.size === 0" nz-button (click)="onStop()"> |
|||
结束盘点 |
|||
</button> |
|||
</nz-space> |
|||
</ng-template> |
|||
|
|||
<ng-container *appTableForm> |
|||
<app-query-item label="名称" class="w-60"> |
|||
<input nz-input placeholder="请输入" formControlName="name" /> |
|||
</app-query-item> |
|||
<app-query-item label="编码" class="w-60"> |
|||
<input nz-input placeholder="请输入" formControlName="code" /> |
|||
</app-query-item> |
|||
<app-query-item label="统一社会信用代码"> |
|||
<input nz-input placeholder="请输入" formControlName="uscc" /> |
|||
</app-query-item> |
|||
</ng-container> |
|||
</app-server-paginated-table> |
|||
</div> |
|||
</app-page> |
|||
|
|||
<ng-template #drawerFooterTpl> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button nzType="primary" (click)="onConfirm()">确定</button> |
|||
<button *nzSpaceItem nz-button nzType="default" (click)="onCancel()">取消</button> |
|||
</nz-space> |
|||
</ng-template> |
|||
|
|||
<ng-template #formContentTpl> |
|||
<form nz-form nzLayout="vertical" [formGroup]="createForm"> |
|||
<nz-form-item> |
|||
<nz-form-label nzRequired> 名称 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<input type="text" nz-input formControlName="name" placeholder="请输入名称" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 全员盘点 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<nz-radio-group formControlName="fullStocktaking"> |
|||
<label nz-radio [nzValue]="1">启用</label> |
|||
<label nz-radio [nzValue]="0">禁用</label> |
|||
</nz-radio-group> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 负责人 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<app-select-user-by-org /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 盘点人 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> </nz-form-control> |
|||
</nz-form-item> |
|||
|
|||
<nz-form-item> |
|||
<nz-form-label> 备注 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errorTpl"> |
|||
<textarea nz-input formControlName="notes" placeholder="请输入备注"></textarea> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
|
|||
<h2>盘点范围</h2> |
|||
<nz-form-item> |
|||
<nz-form-label> 购置开始日期 </nz-form-label> |
|||
<nz-form-control> |
|||
<nz-date-picker nzShowTime formControlName="stocktakingStartDate" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 购置结束日期 </nz-form-label> |
|||
<nz-form-control> |
|||
<nz-date-picker nzShowTime formControlName="stocktakingStartDate" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 资产分类 </nz-form-label> |
|||
<nz-form-control> |
|||
<nz-select> </nz-select> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 资产状态 </nz-form-label> |
|||
<nz-form-control> |
|||
<nz-select> </nz-select> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 位置 </nz-form-label> |
|||
<nz-form-control> |
|||
<nz-select> </nz-select> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 仓库 </nz-form-label> |
|||
<nz-form-control> |
|||
<nz-select> </nz-select> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 所属公司 </nz-form-label> |
|||
<nz-form-control> |
|||
<nz-select> </nz-select> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 使用公司/部门 </nz-form-label> |
|||
<nz-form-control> |
|||
<nz-select> </nz-select> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 保管人 </nz-form-label> |
|||
<nz-form-control> |
|||
<nz-select> </nz-select> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</form> |
|||
</ng-template> |
|||
|
|||
<ng-template #errorTpl let-control> |
|||
<form-error-tips [control]="control"></form-error-tips> |
|||
</ng-template> |
|||
@ -0,0 +1,162 @@ |
|||
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core' |
|||
import { SharedModule } from 'app/shared/shared.module' |
|||
import { ApiService } from 'app/services' |
|||
import { FormBuilder, FormGroup } from '@angular/forms' |
|||
import { AnyObject, TableOption } from 'app/shared/components/server-paginated-table' |
|||
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
|||
import { NzModalService } from 'ng-zorro-antd/modal' |
|||
import { NzMessageService } from 'ng-zorro-antd/message' |
|||
import { NzDrawerRef, NzDrawerService } from 'ng-zorro-antd/drawer' |
|||
import { lastValueFrom } from 'rxjs' |
|||
import { FormValidators } from 'app/utils' |
|||
import { SelectUserByOrgComponent } from 'app/components' |
|||
|
|||
@Component({ |
|||
selector: 'app-stockaking-job', |
|||
standalone: true, |
|||
imports: [SharedModule, SelectUserByOrgComponent], |
|||
templateUrl: './stockaking-job.component.html', |
|||
styleUrl: './stockaking-job.component.less', |
|||
}) |
|||
export class StockakingJobComponent { |
|||
constructor( |
|||
private modal: NzModalService, |
|||
private msg: NzMessageService, |
|||
private drawer: NzDrawerService, |
|||
private api: ApiService, |
|||
private fb: FormBuilder, |
|||
) {} |
|||
|
|||
table = new TableOption(this.fetchData.bind(this)) |
|||
|
|||
queryForm!: FormGroup |
|||
|
|||
createForm!: FormGroup |
|||
|
|||
drawerRef?: NzDrawerRef |
|||
|
|||
@ViewChild('drawerFooterTpl') drawerFooterTpl!: TemplateRef<NzSafeAny> |
|||
|
|||
@ViewChild('formContentTpl') formContentTpl!: TemplateRef<NzSafeAny> |
|||
|
|||
initCreateForm() { |
|||
this.createForm = this.fb.group({ |
|||
stocktakingJobId: [], |
|||
name: ['', [FormValidators.required('请输入')]], |
|||
notes: ['', []], |
|||
fullStocktaking: [1, []], |
|||
stocktakingStartDate: [null, []], |
|||
stocktakingEndDate: [null, []], |
|||
}) |
|||
} |
|||
initQueryForm() { |
|||
this.queryForm = this.fb.group({ |
|||
name: [''], |
|||
uscc: [''], |
|||
code: [''], |
|||
}) |
|||
} |
|||
|
|||
ngOnInit(): void { |
|||
this.table |
|||
.setConfig({ |
|||
selectable: true, |
|||
rowKey: 'stocktakingJobId', |
|||
}) |
|||
.setColumn([ |
|||
{ key: 'name', title: '名称' }, |
|||
{ key: 'fullStocktaking', title: '全员盘点' }, |
|||
{ key: 'status', title: '盘点状态' }, |
|||
{ key: 'head', title: '负责人' }, |
|||
{ key: 'stocktakingUserId', title: '盘点人' }, |
|||
{ key: 'stocktakingStartDate', title: '购置开始日期', width: '180px' }, |
|||
{ key: 'stocktakingEndDate', title: '购置结束日期', width: '180px' }, |
|||
{ key: 'createTime', title: '创建时间', width: '180px' }, |
|||
{ key: 'createUser', title: '创建人' }, |
|||
{ key: 'notes', title: '备注' }, |
|||
]) |
|||
.setRowOperate([ |
|||
{ title: '编辑', onClick: this.onCreate.bind(this) }, |
|||
{ title: '编辑', onClick: this.onCreate.bind(this) }, |
|||
{ title: '删除', onClick: this.deleteItem.bind(this) }, |
|||
]) |
|||
this.initQueryForm() |
|||
this.initCreateForm() |
|||
} |
|||
|
|||
fetchData(p: {}, q: AnyObject) { |
|||
return this.api.getStocktakingJobPage({ ...p, ...q }) |
|||
} |
|||
|
|||
onCreate(data?: NzSafeAny) { |
|||
if (data) { |
|||
this.createForm.patchValue(data) |
|||
} |
|||
this.drawerRef = this.drawer.create({ |
|||
nzTitle: data ? '编辑盘点任务' : '新增盘点任务', |
|||
nzContent: this.formContentTpl, |
|||
nzFooter: this.drawerFooterTpl, |
|||
nzWidth: 600, |
|||
nzOnCancel: this.onCancel.bind(this), |
|||
}) |
|||
} |
|||
|
|||
onConfirm() { |
|||
if (FormValidators.validateFormGroup(this.createForm)) { |
|||
const { value } = this.createForm |
|||
|
|||
this.api |
|||
.saveStocktakingJob({ |
|||
...value, |
|||
|
|||
// stocktakingJobId: value.stocktakingJobId ?? 0,
|
|||
}) |
|||
.subscribe((res) => { |
|||
this.msg.success(res.desc) |
|||
this.onCancel() |
|||
this.table.ref.reload() |
|||
}) |
|||
} |
|||
} |
|||
|
|||
async onCancel() { |
|||
this.drawerRef?.close() |
|||
this.createForm.reset({}) |
|||
} |
|||
|
|||
deleteItem(item: NzSafeAny) { |
|||
this.modal.confirm({ |
|||
nzTitle: '警告', |
|||
nzContent: '是否要删除该盘点任务?', |
|||
nzOnOk: async () => { |
|||
const res = await lastValueFrom(this.api.deleteStocktakingJob([item.stocktakingJobId])) |
|||
this.msg.success(res.desc) |
|||
this.table.ref.reload() |
|||
}, |
|||
}) |
|||
} |
|||
onBegin() { |
|||
const ids = Array.from(this.table.ref.selected).map((i) => Number(i)) |
|||
this.modal.confirm({ |
|||
nzTitle: '警告', |
|||
nzContent: '是否要开始该盘点任务?', |
|||
nzOnOk: async () => { |
|||
const res = await lastValueFrom(this.api.beginStocktakingJob(ids)) |
|||
this.msg.success(res.desc) |
|||
this.table.ref.reload() |
|||
}, |
|||
}) |
|||
} |
|||
onStop() { |
|||
const ids = Array.from(this.table.ref.selected).map((i) => Number(i)) |
|||
this.modal.confirm({ |
|||
nzTitle: '警告', |
|||
nzContent: '是否要结束该盘点任务?', |
|||
nzOnOk: async () => { |
|||
const res = await lastValueFrom(this.api.stopStocktakingJob(ids)) |
|||
this.msg.success(res.desc) |
|||
this.table.ref.reload() |
|||
}, |
|||
}) |
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
<p>stockaking-plan works!</p> |
|||
@ -0,0 +1,21 @@ |
|||
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core' |
|||
import { SharedModule } from 'app/shared/shared.module' |
|||
import { ApiService } from 'app/services' |
|||
import { FormBuilder, FormGroup } from '@angular/forms' |
|||
import { AnyObject, TableOption } from 'app/shared/components/server-paginated-table' |
|||
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
|||
import { NzModalService } from 'ng-zorro-antd/modal' |
|||
import { NzMessageService } from 'ng-zorro-antd/message' |
|||
import { NzDrawerRef, NzDrawerService } from 'ng-zorro-antd/drawer' |
|||
import { lastValueFrom } from 'rxjs' |
|||
import { FormValidators } from 'app/utils' |
|||
import { SelectUserByOrgComponent } from 'app/components' |
|||
|
|||
@Component({ |
|||
selector: 'app-stockaking-plan', |
|||
standalone: true, |
|||
imports: [], |
|||
templateUrl: './stockaking-plan.component.html', |
|||
styleUrl: './stockaking-plan.component.less', |
|||
}) |
|||
export class StockakingPlanComponent {} |
|||
@ -1,92 +1,182 @@ |
|||
import { Component, OnInit } from '@angular/core' |
|||
import { AppPageComponent } from 'app/components/app-page/app-page.component' |
|||
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core' |
|||
import { SharedModule } from 'app/shared/shared.module' |
|||
import { ComponentOrgTreeComponent } from '../component-org-tree/component-org-tree.component' |
|||
import { AnyObject, TableOption } from 'app/components/server-paginated-table' |
|||
import { ComponentOrgTreeComponent } from 'app/components/component-org-tree/component-org-tree.component' |
|||
|
|||
import { format } from 'date-fns' |
|||
import { ApiService } from 'app/services' |
|||
import { of } from 'rxjs' |
|||
import { FormBuilder, FormGroup } from '@angular/forms' |
|||
import { AnyObject, TableOption } from 'app/shared/components/server-paginated-table' |
|||
import { NzSafeAny } from 'ng-zorro-antd/core/types' |
|||
import { NzModalService } from 'ng-zorro-antd/modal' |
|||
import { NzMessageService } from 'ng-zorro-antd/message' |
|||
import { NzDrawerRef, NzDrawerService } from 'ng-zorro-antd/drawer' |
|||
import { lastValueFrom } from 'rxjs' |
|||
import { FormValidators } from 'app/utils' |
|||
|
|||
@Component({ |
|||
selector: 'app-org-setting', |
|||
standalone: true, |
|||
imports: [SharedModule, AppPageComponent, ComponentOrgTreeComponent], |
|||
imports: [SharedModule, ComponentOrgTreeComponent], |
|||
templateUrl: './org-setting.component.html', |
|||
styleUrl: './org-setting.component.less', |
|||
}) |
|||
export class OrgSettingComponent implements OnInit { |
|||
constructor(private api: ApiService) {} |
|||
constructor( |
|||
private modal: NzModalService, |
|||
private msg: NzMessageService, |
|||
private drawer: NzDrawerService, |
|||
private api: ApiService, |
|||
private fb: FormBuilder, |
|||
) {} |
|||
|
|||
table = new TableOption(this.fetchData.bind(this)) |
|||
|
|||
queryForm!: FormGroup |
|||
|
|||
createForm!: FormGroup |
|||
|
|||
drawerRef?: NzDrawerRef |
|||
|
|||
organization: null | NzSafeAny = null |
|||
|
|||
iconPreview = '' |
|||
|
|||
uploadLoading = false |
|||
|
|||
@ViewChild('drawerFooterTpl') drawerFooterTpl!: TemplateRef<NzSafeAny> |
|||
|
|||
@ViewChild('formContentTpl') formContentTpl!: TemplateRef<NzSafeAny> |
|||
|
|||
initCreateForm() { |
|||
this.createForm = this.fb.group({ |
|||
userId: [], |
|||
userName: ['', FormValidators.required('请输入')], |
|||
loginName: ['', FormValidators.required('请输入')], |
|||
phone: [ |
|||
'', |
|||
[FormValidators.required('请输入'), FormValidators.pattern(/^1[3-9]\d{9}$/, '请输入正确的手机号')], |
|||
], |
|||
password: [], |
|||
repassword: [], |
|||
email: [], |
|||
status: ['0'], |
|||
sex: ['0'], |
|||
avatar: [], |
|||
roleId: [], |
|||
}) |
|||
} |
|||
initQueryForm() { |
|||
this.queryForm = this.fb.group({ |
|||
userName: [''], |
|||
loginName: [''], |
|||
phone: [''], |
|||
email: [''], |
|||
status: [''], |
|||
sex: [''], |
|||
}) |
|||
} |
|||
|
|||
ngOnInit(): void { |
|||
this.table |
|||
.setConfig({ |
|||
selectable: true, |
|||
}) |
|||
|
|||
.setColumn([ |
|||
{ key: '公司ID', title: '公司ID', visible: true }, |
|||
{ key: '工号', title: '工号' }, |
|||
{ key: '姓名', title: '姓名' }, |
|||
{ key: '性别', title: '性别' }, |
|||
{ key: '手机号', title: '手机号' }, |
|||
{ key: '部门', title: '部门' }, |
|||
{ key: '主岗', title: '主岗' }, |
|||
{ key: 'ID', title: 'ID', visible: false }, |
|||
{ key: '人员ID', title: '人员ID', visible: false }, |
|||
{ key: '状态', title: '状态', visible: false }, |
|||
{ key: '修改人ID', title: '修改人ID', visible: false }, |
|||
{ key: '类型', title: '类型', visible: false }, |
|||
{ key: '直属领导', title: '直属领导', visible: false }, |
|||
{ key: 'extInfo', title: 'extInfo', visible: false }, |
|||
{ key: '身份证', title: '身份证', visible: false }, |
|||
{ key: '兼岗', title: '兼岗', visible: false }, |
|||
{ key: '签约方', title: '签约方', visible: false }, |
|||
{ key: '成本中心', title: '成本中心', visible: false }, |
|||
{ key: '客户信息', title: '客户信息', visible: false }, |
|||
|
|||
{ key: 'createTime', title: '创建时间' }, |
|||
{ key: 'avatar', title: '头像', width: '100px' }, |
|||
{ key: 'userName', title: '姓名' }, |
|||
{ key: 'loginName', title: '账号名' }, |
|||
{ key: 'phone', title: '联系电话' }, |
|||
{ key: 'email', title: '邮箱' }, |
|||
{ key: 'status', title: '状态' }, |
|||
{ key: 'sex', title: '性别' }, |
|||
]) |
|||
.setRowOperate([ |
|||
{ title: '编辑', onClick: this.onCreate.bind(this) }, |
|||
{ title: '删除', onClick: this.deleteItem.bind(this) }, |
|||
]) |
|||
.setRowOperate([{ title: '查看', premissions: [] }, { title: '编辑' }, { title: '删除' }]) |
|||
this.initQueryForm() |
|||
this.initCreateForm() |
|||
} |
|||
|
|||
fetchData(p: {}, q: AnyObject) { |
|||
if (Array.isArray(q['createTime'])) { |
|||
const createTimeStart = q['createTime']?.[0] |
|||
const createTimeEnd = q['createTime']?.[1] |
|||
|
|||
q['createTimeStart'] = createTimeStart ? format(new Date(createTimeStart), 'yyyy-MM-dd HH:mm:ss') : '' |
|||
q['createTimeEnd'] = createTimeEnd ? format(new Date(createTimeEnd), 'yyyy-MM-dd HH:mm:ss') : '' |
|||
} |
|||
return of({ |
|||
data: { |
|||
total: 5, |
|||
records: [ |
|||
{ |
|||
id: 1, |
|||
name: '沙滩', |
|||
price: 590, |
|||
type: 0, |
|||
lifespan: 6, |
|||
number: 20, |
|||
max: 20, |
|||
status: 1, |
|||
createTime: '2024-05-01', |
|||
}, |
|||
return this.api.getUserPage({ ...p, ...q, organizationId: this.organization?.organizationId }) |
|||
} |
|||
|
|||
{ |
|||
id: 2, |
|||
name: '清凉一夏~沙滩排球', |
|||
price: 100000, |
|||
type: 1, |
|||
lifespan: 12, |
|||
max: 20, |
|||
status: 1, |
|||
createTime: '2024-05-01', |
|||
}, |
|||
], |
|||
onOrgSelectedChange(org: NzSafeAny) { |
|||
console.log('org', org) |
|||
this.organization = org |
|||
this.table.ref.search() |
|||
} |
|||
|
|||
onCreate(data?: NzSafeAny) { |
|||
if (data) { |
|||
this.createForm.patchValue(data) |
|||
} |
|||
this.drawerRef = this.drawer.create({ |
|||
nzTitle: data ? '编辑员工' : '新增员工', |
|||
nzContent: this.formContentTpl, |
|||
nzFooter: this.drawerFooterTpl, |
|||
nzWidth: 600, |
|||
nzOnCancel: this.onCancel.bind(this), |
|||
}) |
|||
} |
|||
|
|||
onConfirm() { |
|||
if (FormValidators.validateFormGroup(this.createForm)) { |
|||
const { value } = this.createForm |
|||
if (value.password && value.repassword !== value.password) { |
|||
this.msg.error('两次密码输入不一致') |
|||
return |
|||
} |
|||
this.api |
|||
.saveUser({ |
|||
...value, |
|||
organizationId: this.organization?.organizationId, |
|||
}) |
|||
.subscribe((res) => { |
|||
this.msg.success(res.desc) |
|||
this.onCancel() |
|||
this.table.ref.reload() |
|||
}) |
|||
} |
|||
} |
|||
|
|||
async onCancel() { |
|||
this.drawerRef?.close() |
|||
this.createForm.reset({ |
|||
sex: '0', |
|||
status: '0', |
|||
}) |
|||
} |
|||
|
|||
deleteItem(item: NzSafeAny) { |
|||
this.modal.confirm({ |
|||
nzTitle: '警告', |
|||
nzContent: '是否要删除该员工?', |
|||
nzOnOk: async () => { |
|||
const res = await lastValueFrom(this.api.deleteUser([item.userId])) |
|||
this.msg.success(res.desc) |
|||
this.table.ref.reload() |
|||
}, |
|||
}) |
|||
return this.api.getEntityPage(p, q) |
|||
} |
|||
|
|||
onFileChange(e: Event) { |
|||
const target = e.target as HTMLInputElement |
|||
const file = target.files![0] |
|||
target.value = '' |
|||
if (file.size / 1024 / 1024 >= 2) { |
|||
this.msg.error('图片大小不能超过2M') |
|||
return |
|||
} |
|||
const fileReader = new FileReader() |
|||
fileReader.onload = () => { |
|||
const base64 = fileReader.result as string |
|||
this.iconPreview = base64 |
|||
} |
|||
fileReader.readAsDataURL(file) |
|||
const formdata = new FormData() |
|||
formdata.append('file', file) |
|||
this.api.upload(formdata).subscribe((res) => { |
|||
this.createForm.get('avatar')?.setValue(res.body.fileName) |
|||
}) |
|||
} |
|||
} |
|||
|
|||
@ -1 +1,2 @@ |
|||
<div>ad</div> |
|||
<router-outlet /> |
|||
@ -0,0 +1 @@ |
|||
<p>system-user works!</p> |
|||
@ -0,0 +1,11 @@ |
|||
import { Component } from '@angular/core' |
|||
import { SharedModule } from 'app/shared/shared.module' |
|||
|
|||
@Component({ |
|||
selector: 'app-system-user', |
|||
standalone: true, |
|||
imports: [SharedModule], |
|||
templateUrl: './system-user.component.html', |
|||
styleUrl: './system-user.component.less', |
|||
}) |
|||
export class SystemUserComponent {} |
|||
@ -0,0 +1,6 @@ |
|||
// export * from "./form-error-tips/form-error-tips.component";
|
|||
// export * from "./server-paginated-table";
|
|||
|
|||
export * from './header/header.component' |
|||
export * from './layout/layout.component' |
|||
export * from './user-form/user-form.component' |
|||
@ -0,0 +1,15 @@ |
|||
:host { |
|||
display: block; |
|||
height: 100%; |
|||
} |
|||
|
|||
// .app-width { |
|||
// ::ng-deep { |
|||
// router-outlet+* { |
|||
// display: block; |
|||
// width: 100%; |
|||
// height: 100%; |
|||
// overflow: hidden; |
|||
// } |
|||
// } |
|||
// } |
|||
@ -0,0 +1,8 @@ |
|||
import { Component } from '@angular/core' |
|||
|
|||
@Component({ |
|||
selector: 'app-layout', |
|||
templateUrl: './layout.component.html', |
|||
styleUrls: ['./layout.component.less'], |
|||
}) |
|||
export class LayoutComponent {} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue