소스 검색

【项目立项档案】 完成

liangyan0105 3 년 전
부모
커밋
61c4eaa141

+ 6 - 6
src/app/routes/basedata/merchants-industry/add/add.component.html

@@ -1,19 +1,19 @@
 <form nz-form [formGroup]="validateForm" (ngSubmit)="submitForm()">
   <nz-form-item>
-    <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="code">项目编码</nz-form-label>
+    <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="code">客商编码</nz-form-label>
     <nz-form-control [nzSm]="14" [nzXs]="24" >
-      <input placeholder="自动生成" nz-input formControlName="code" id="code" [(ngModel)]="baseArchivesProjectApproval.code"/>
+      <input placeholder="自动生成" nz-input formControlName="code" id="code" [(ngModel)]="baseCustomerIndustry.code"/>
       <!-- <nz-form-explain *ngIf="validateForm.get('code')?.dirty && validateForm.get('code')?.errors">
-        请输入项目编码
+        请输入项目编码   BaseCustomerIndustry
       </nz-form-explain> -->
     </nz-form-control>
   </nz-form-item>
   <nz-form-item>
-    <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="name">项目名称</nz-form-label>
+    <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="name">客商名称</nz-form-label>
     <nz-form-control [nzSm]="14" [nzXs]="24" >
-      <input nz-input formControlName="name" id="name" [(ngModel)]="baseArchivesProjectApproval.name" maxlength=20/>
+      <input nz-input formControlName="name" id="name" [(ngModel)]="baseCustomerIndustry.name" maxlength=20/>
       <nz-form-explain *ngIf="validateForm.get('name')?.dirty && validateForm.get('name')?.errors">
-        请输入项目名称
+        请输入客商名称
       </nz-form-explain>
     </nz-form-control>
   </nz-form-item>

+ 59 - 15
src/app/routes/basedata/merchants-industry/add/add.component.ts

@@ -1,37 +1,81 @@
-import { Component, OnInit, ViewChild } from '@angular/core';
+import { Component, OnInit } from '@angular/core';
 import { _HttpClient, ModalHelper } from '@delon/theme';
-import { STColumn, STComponent } from '@delon/abc';
-import { SFSchema } from '@delon/form';
-
+// import { STColumn, STComponent } from '@delon/abc';
+// import { SFSchema } from '@delon/form';
+// 以下新增
 import { NzModalRef, NzMessageService, NzNotificationService, NzI18nService } 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({
   selector: 'app-basedata-merchants-industry-add',
   templateUrl: './add.component.html',
 })
 export class BasedataMerchantsIndustryAddComponent implements OnInit {
-  constructor(private modal: NzModalRef) {}
+  constructor(
+    private modal: NzModalRef,
+    private fb: FormBuilder,
+    private baseCustomerIndustryService: BaseCustomerIndustryService,
+    private nzNotificationService: NzNotificationService,
+    private i18NService: I18NService,
+  ) {}
 
-  ngOnInit() {
+  ngOnInit(): void {
     //初始化表单
-    // this.validateForm = this.fb.group({
-    //   code: [{ value: '', disabled: true }, []],
-    //   name: [null, [Validators.required]],
-    //   status: [null],
-    // });
+    this.validateForm = this.fb.group({
+      code: [{ value: '', disabled: true }, []], //客商编码
+      name: [null, [Validators.required]], //客商名称
+      status: [null], //是否启用
+    });
     //新增子集获取父节点id
     // if(this.parentId&&this.parentId!=="0"){
-    // this.baseArchivesProjectApproval.parentId = this.parentId;
+    this.baseCustomerIndustry.parentId = this.parentId;
     // }
   }
+
   validateForm!: FormGroup;
   parentId = '0'; //父级id
-  status = true;
-  //实体
-  // baseArchivesProjectApproval: BaseArchivesProjectApproval = {};
+  status = true; //是否启用
+
+  // 确定 按钮(添加一级)
+  submitForm(): any {
+    console.log('----');
+    return new Promise(resolve => {
+      for (const i in this.validateForm.controls) {
+        this.validateForm.controls[i].markAsDirty();
+        this.validateForm.controls[i].updateValueAndValidity();
+      }
+      let valid = this.validateForm.valid;
+      if (valid) {
+        console.log('valid有效--->', valid);
+        //格式化是否期用
+        if (this.status) {
+          this.baseCustomerIndustry.status = '1';
+        } else {
+          this.baseCustomerIndustry.status = '0';
+        }
+        this.baseCustomerIndustry.pkOrg = sessionStorage.getItem('pkOrg'); //组织
+        this.baseCustomerIndustryService.add(this.baseCustomerIndustry).then(response => {
+          if (response.success) {
+            //保存成功
+            this.nzNotificationService.success(this.i18NService.fanyi('save.ok'), '');
+            this.modal.destroy();
+            resolve();
+          } else {
+            //保存失败
+            this.nzNotificationService.error(this.i18NService.fanyi('save.not'), '');
+          }
+        });
+      }
+    });
+  }
 
   //关闭
   close() {
     this.modal.destroy();
   }
+  //实例化函数
+  baseCustomerIndustry: BaseCustomerIndustry = {};
 }

+ 15 - 13
src/app/routes/basedata/merchants-industry/merchants-industry.component.html

@@ -11,7 +11,7 @@
         <!-- 添加一级 -->
         <div nz-row [nzGutter]="24" style="margin-bottom: 10px;">
           <div nz-col nzMd="24" nzLg="24">
-            <button (click)="add()" nz-button acl [acl-ability]="'base-archives-project-approval:add'" nzType="primary">
+            <button (click)="add()" nz-button nzType="primary">
               添加一级
             </button>
           </div>
@@ -32,7 +32,7 @@
         <!-- tree -->
         <div nz-row [nzGutter]="24">
           <div nz-col nzMd="24" nzLg="24">
-            <!-- <nz-tree
+            <nz-tree
               [nzData]="nodes"
               [nzSearchValue]="searchValue"
               (nzClick)="treeClick($event)"
@@ -40,10 +40,10 @@
             >
               <ng-template #contextTemplate>
                 <ul nz-menu nzInDropDown>
-                  <li nz-menu-item (click)="addChild()" acl [acl-ability]="'base-archives-project-approval:add'">
+                  <li nz-menu-item (click)="addChild()">
                     {{ 'button.add' | translate }}
                   </li>
-                  <li nz-menu-item (click)="delete()" acl [acl-ability]="'base-archives-project-approval:delete'">
+                  <li nz-menu-item (click)="delete()">
                     {{ 'table.delete' | translate }}
                   </li>
                   <li nz-menu-item (click)="cancel()">{{ 'button.cancel' | translate }}</li>
@@ -59,7 +59,7 @@
                   </span>
                 </span>
               </ng-template>
-            </nz-tree> -->
+            </nz-tree>
           </div>
         </div>
       </nz-card>
@@ -68,14 +68,14 @@
     <!-- 右边 card -->
     <div nz-col nzMd="24" nzLg="12">
       <nz-card>
-        <!-- <form nz-form [formGroup]="validateForm" (ngSubmit)="submitForm()">
+        <form nz-form [formGroup]="validateForm" (ngSubmit)="submitForm()">
           <nz-form-item>
-            <nz-form-label nzRequired [nzSm]="8" [nzXs]="24">项目编码</nz-form-label>
+            <nz-form-label nzRequired [nzSm]="8" [nzXs]="24">客商编码</nz-form-label>
             <nz-form-control [nzSm]="14" [nzXs]="24">
               <input
                 formControlName="code"
                 id="code"
-                [(ngModel)]="baseArchivesProjectApproval.code"
+                [(ngModel)]="baseCustomerIndustry.code"
                 name="code"
                 nz-input
                 placeholder="自动生成"
@@ -83,19 +83,19 @@
             </nz-form-control>
           </nz-form-item>
           <nz-form-item>
-            <nz-form-label nzRequired [nzSm]="8" [nzXs]="24">项目名称</nz-form-label>
+            <nz-form-label nzRequired [nzSm]="8" [nzXs]="24">客商名称</nz-form-label>
             <nz-form-control [nzSm]="14" [nzXs]="24">
               <input
                 formControlName="name"
                 id="name"
-                [(ngModel)]="baseArchivesProjectApproval.name"
+                [(ngModel)]="baseCustomerIndustry.name"
                 name="name"
                 nz-input
                 placeholder="{{ 'placeholder' | translate }}项目名称"
                 maxlength="20"
               />
-              <nz-form-explain *ngIf="validateForm.get('name')?.dirty && validateForm.get('name')?.errors">
-                请输入项目名称
+              <nz-form-explain *ngIf="validateForm.get('title')?.dirty && validateForm.get('title')?.errors">
+                请输入客商名称
               </nz-form-explain>
             </nz-form-control>
           </nz-form-item>
@@ -111,6 +111,7 @@
               ></nz-switch>
             </nz-form-control>
           </nz-form-item>
+
           <nz-form-item>
             <nz-form-label [nzSm]="8" [nzXs]="24" [nzNoColon]="true"> </nz-form-label>
             <nz-form-control [nzSm]="14" [nzXs]="24">
@@ -120,7 +121,8 @@
               <button nz-button nzType="primary">保存</button>
             </nz-form-control>
           </nz-form-item>
-        </form> -->
+
+        </form>
       </nz-card>
     </div>
   </div>

+ 169 - 8
src/app/routes/basedata/merchants-industry/merchants-industry.component.ts

@@ -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 { STColumn, STComponent } from '@delon/abc';
 import { SFSchema } from '@delon/form';
 
 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({
   selector: 'app-basedata-merchants-industry',
   templateUrl: './merchants-industry.component.html',
 })
 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;
+  searchValue = ''; //搜索框的值
+  nodes: any = []; //tree集合
+  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; //获取id
+    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',
+          // loading:this.modelSaveLoading,
+          onClick: addModel => {
+            addModel.submitForm().then(() => {
+              this.getListIndustryTree();
+            });
+          },
+        },
+      ],
+    });
+  }
 
   //右键取消
   cancel() {
     this.dropdown.close();
   }
 
+  //添加一级 弹框
   add() {
     const modalRef = this.modalService.create({
       nzTitle: '新增',
@@ -31,7 +145,7 @@ export class BasedataMerchantsIndustryComponent implements OnInit {
           label: '关闭',
           type: 'default',
           onClick: addModel => {
-            // addModel.close();
+            addModel.close();
           },
         },
         {
@@ -39,12 +153,59 @@ export class BasedataMerchantsIndustryComponent implements OnInit {
           type: 'primary',
           // loading:this.modelSaveLoading,
           onClick: addModel => {
-            // addModel.submitForm().then(() => {
-            //   // this.getListContractTree();
-            // });
+            addModel.submitForm().then(() => {
+              this.getListIndustryTree(); //新增后刷新 树
+            });
           },
         },
       ],
     });
   }
+
+  //根据id删除对应项
+  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'), '');
+        }
+      });
+    }
+  }
 }