|
@@ -1,26 +1,140 @@
|
|
-import { Component, OnInit, ViewChild } from '@angular/core';
|
|
+import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
|
|
import { _HttpClient, ModalHelper } from '@delon/theme';
|
|
import { _HttpClient, ModalHelper } from '@delon/theme';
|
|
import { STColumn, STComponent } from '@delon/abc';
|
|
import { STColumn, STComponent } from '@delon/abc';
|
|
import { SFSchema } from '@delon/form';
|
|
import { SFSchema } from '@delon/form';
|
|
|
|
|
|
import { BasedataMerchantsIndustryAddComponent } from './add/add.component';
|
|
import { BasedataMerchantsIndustryAddComponent } from './add/add.component';
|
|
-import { NzModalService, NzTreeNode,NzDropdownContextComponent } from 'ng-zorro-antd';
|
|
+import {
|
|
|
|
+ NzModalService,
|
|
|
|
+ NzTreeNode,
|
|
|
|
+ NzDropdownContextComponent,
|
|
|
|
+ NzDropdownService,
|
|
|
|
+ NzFormatEmitEvent,
|
|
|
|
+ NzNotificationService,
|
|
|
|
+} from 'ng-zorro-antd';
|
|
|
|
+import { FormBuilder, Validators, FormGroup } from '@angular/forms';
|
|
|
|
+import { BaseCustomerIndustry } from 'app/entity/basedata/base-customer-industry';
|
|
|
|
+import { BaseCustomerIndustryService } from 'app/services/basedata/base-customer-industry.service';
|
|
|
|
+import { I18NService } from '@core';
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-basedata-merchants-industry',
|
|
selector: 'app-basedata-merchants-industry',
|
|
templateUrl: './merchants-industry.component.html',
|
|
templateUrl: './merchants-industry.component.html',
|
|
})
|
|
})
|
|
export class BasedataMerchantsIndustryComponent implements OnInit {
|
|
export class BasedataMerchantsIndustryComponent implements OnInit {
|
|
- constructor(private modalService: NzModalService) {}
|
|
+ constructor(
|
|
|
|
+ private nzDropdownService: NzDropdownService,
|
|
|
|
+ private modalService: NzModalService,
|
|
|
|
+ private fb: FormBuilder,
|
|
|
|
+ private baseCustomerIndustryService: BaseCustomerIndustryService,
|
|
|
|
+ private i18NService: I18NService,
|
|
|
|
+ private nzNotificationService: NzNotificationService,
|
|
|
|
+ ) {}
|
|
|
|
|
|
- ngOnInit() {}
|
|
+ ngOnInit() {
|
|
|
|
+
|
|
|
|
+ this.validateForm = this.fb.group({
|
|
|
|
+ code: [{ value: '', disabled: true }],
|
|
|
|
+ name: [null, [Validators.required]],
|
|
|
|
+ status: [null],
|
|
|
|
+ });
|
|
|
|
+ this.getListIndustryTree();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ validateForm!: FormGroup;
|
|
dropdown: NzDropdownContextComponent;
|
|
dropdown: NzDropdownContextComponent;
|
|
|
|
+ searchValue = '';
|
|
|
|
+ nodes: any = [];
|
|
|
|
+ status = true;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ baseCustomerIndustry: BaseCustomerIndustry = {};
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ getListIndustryTree() {
|
|
|
|
+ let baseCustomerIndustry = new BaseCustomerIndustry();
|
|
|
|
+ baseCustomerIndustry.pkOrg = sessionStorage.getItem('pkOrg');
|
|
|
|
+
|
|
|
|
+ this.baseCustomerIndustryService.getTreeList(baseCustomerIndustry).then(res => {
|
|
|
|
+ this.nodes = res.result;
|
|
|
|
+ console.log('客商树 数据', this.nodes);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ openFolder(data: NzTreeNode | Required<NzFormatEmitEvent>): void {
|
|
|
|
+ if (data instanceof NzTreeNode) {
|
|
|
|
+ data.isExpanded = !data.isExpanded;
|
|
|
|
+ } else {
|
|
|
|
+ const node = data.node;
|
|
|
|
+ if (node) {
|
|
|
|
+ node.isExpanded = !node.isExpanded;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ id = '';
|
|
|
|
+ contextMenu(Fid, $event: MouseEvent, template: TemplateRef<void>): void {
|
|
|
|
+ this.id = Fid;
|
|
|
|
+ this.dropdown = this.nzDropdownService.create($event, template);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ treeClick(event) {
|
|
|
|
+ var getdDepart = event.node.origin;
|
|
|
|
+ if (getdDepart.status == '0') {
|
|
|
|
+
|
|
|
|
+ this.status = false;
|
|
|
|
+ } else {
|
|
|
|
+ this.status = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.baseCustomerIndustry = {
|
|
|
|
+ name: getdDepart.title,
|
|
|
|
+ code: getdDepart.code,
|
|
|
|
+ id: getdDepart.key,
|
|
|
|
+ parentId: getdDepart.parentId,
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ addChild() {
|
|
|
|
+ const modalRef = this.modalService.create({
|
|
|
|
+ nzTitle: '新增',
|
|
|
|
+ nzContent: BasedataMerchantsIndustryAddComponent,
|
|
|
|
+ nzWidth: 600,
|
|
|
|
+ nzComponentParams: {
|
|
|
|
+ parentId: this.id,
|
|
|
|
+ },
|
|
|
|
+ nzFooter: [
|
|
|
|
+ {
|
|
|
|
+ label: '关闭',
|
|
|
|
+ type: 'default',
|
|
|
|
+ onClick: addModel => {
|
|
|
|
+ addModel.close();
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '确定',
|
|
|
|
+ type: 'primary',
|
|
|
|
+
|
|
|
|
+ onClick: addModel => {
|
|
|
|
+ addModel.submitForm().then(() => {
|
|
|
|
+ this.getListIndustryTree();
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
cancel() {
|
|
cancel() {
|
|
this.dropdown.close();
|
|
this.dropdown.close();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
add() {
|
|
add() {
|
|
const modalRef = this.modalService.create({
|
|
const modalRef = this.modalService.create({
|
|
nzTitle: '新增',
|
|
nzTitle: '新增',
|
|
@@ -31,7 +145,7 @@ export class BasedataMerchantsIndustryComponent implements OnInit {
|
|
label: '关闭',
|
|
label: '关闭',
|
|
type: 'default',
|
|
type: 'default',
|
|
onClick: addModel => {
|
|
onClick: addModel => {
|
|
-
|
|
+ addModel.close();
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
{
|
|
@@ -39,12 +153,59 @@ export class BasedataMerchantsIndustryComponent implements OnInit {
|
|
type: 'primary',
|
|
type: 'primary',
|
|
|
|
|
|
onClick: addModel => {
|
|
onClick: addModel => {
|
|
-
|
|
+ addModel.submitForm().then(() => {
|
|
-
|
|
+ this.getListIndustryTree();
|
|
-
|
|
+ });
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
],
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ delete() {
|
|
|
|
+ let baseCustomerIndustry = new BaseCustomerIndustry();
|
|
|
|
+ baseCustomerIndustry.id = this.id;
|
|
|
|
+ this.baseCustomerIndustryService.delete(this.id).then(response => {
|
|
|
|
+ if (response.success) {
|
|
|
|
+
|
|
|
|
+ this.nzNotificationService.success(this.i18NService.fanyi('successful.deletion'), '');
|
|
|
|
+ this.dropdown.close();
|
|
|
|
+ this.getListIndustryTree();
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ this.nzNotificationService.error(this.i18NService.fanyi('delete.failed'), '');
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ reset() {
|
|
|
|
+ this.baseCustomerIndustry = {};
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ submitForm() {
|
|
|
|
+ for (const i in this.validateForm.controls) {
|
|
|
|
+ this.validateForm.controls[i].markAsDirty();
|
|
|
|
+ this.validateForm.controls[i].updateValueAndValidity();
|
|
|
|
+ }
|
|
|
|
+ let valid = this.validateForm.valid;
|
|
|
|
+ if (valid) {
|
|
|
|
+
|
|
|
|
+ if (this.status) {
|
|
|
|
+ this.baseCustomerIndustry.status = '1';
|
|
|
|
+ } else {
|
|
|
|
+ this.baseCustomerIndustry.status = '0';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ this.baseCustomerIndustryService.update(this.baseCustomerIndustry).then(response => {
|
|
|
|
+ if (response.success) {
|
|
|
|
+ this.nzNotificationService.success(this.i18NService.fanyi('save.ok'), '');
|
|
|
|
+ this.getListIndustryTree();
|
|
|
|
+ } else {
|
|
|
|
+ this.nzNotificationService.error(this.i18NService.fanyi('save.not'), '');
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|