Quellcode durchsuchen

[产品] [模块] 雏形完成

liangyan0105 vor 3 Jahren
Ursprung
Commit
2069bf7d2a

+ 13 - 12
src/app/routes/basedata/material-file/material-file.component.html

@@ -2,21 +2,15 @@
 <page-header [action]="phActionTpl">
   <ng-template #phActionTpl>
     <!-- 新增分类 标题 -->
-    <span id="titleAdd" hidden="true">
-      {{ 'button.add' | translate }}{{ 'material.classification' | translate }}
-    </span>
+    <span id="titleAdd" hidden="true"> {{ 'button.add' | translate }}{{ 'material.classification' | translate }} </span>
     <!-- 修改分类 -->
     <span id="titleUpdate" hidden="true">
       {{ 'table.update' | translate }}{{ 'material.classification' | translate }}
     </span>
     <!-- 产品新增 标题-->
-    <span id="proTitAdd" hidden="true">
-      {{ 'button.add' | translate }}{{ 'product' | translate }}
-    </span>
+    <span id="proTitAdd" hidden="true"> {{ 'button.add' | translate }}{{ 'product' | translate }} </span>
     <!-- 产品修改 -->
-    <span id="proTitUpdate" hidden="true">
-      {{ 'table.update' | translate }}{{ 'product' | translate }}
-    </span>
+    <span id="proTitUpdate" hidden="true"> {{ 'table.update' | translate }}{{ 'product' | translate }} </span>
 
     <!-- 按钮 新增产品 -->
     <button nz-button nzType="primary" (click)="addProduct('')">
@@ -65,9 +59,16 @@
             <!-- 右击 树节点  下拉菜单 4个按钮 -->
             <ng-template #contextTemplate>
               <ul nz-menu nzInDropDown>
-                <li nz-menu-item (click)="addMaterial(1)">{{ 'button.add' | translate }}</li>
-                <li nz-menu-item (click)="addMaterial(2)">{{ 'table.update' | translate }}</li>
-                <li nz-menu-item (click)="delMaterial()">{{ 'table.delete' | translate }}</li>
+                <li nz-menu-item (click)="addMaterial(1)">
+                  {{ 'button.add' | translate }}{{ 'material.classification' | translate }}
+                </li>
+                <li nz-menu-item (click)="addMaterial(2)">
+                  {{ 'table.update' | translate }}{{ 'material.classification' | translate }}
+                </li>
+                <li nz-menu-item (click)="delMaterial()">
+                  {{ 'table.delete' | translate }}{{ 'material.classification' | translate }}
+                </li>
+                <li nz-menu-item (click)="addProduct(e)">{{ 'button.add' | translate }}{{ 'product' | translate }}</li>
                 <li nz-menu-item (click)="cancel()">{{ 'button.cancel' | translate }}</li>
               </ul>
             </ng-template>

+ 79 - 63
src/app/routes/basedata/material-file/material-file.component.ts

@@ -25,8 +25,8 @@ import { BaseMaterialFileProduct } from 'app/entity/basedata/base-material-file-
   templateUrl: './material-file.component.html',
 })
 export class BasedataMaterialFileComponent implements OnInit {
-  baseMaterialFileClassification: BaseMaterialFileClassification; //  物料档案分类 对象
-  baseMaterialFileProduct: BaseMaterialFileProduct; //物料产品 对象
+  baseMaterialFileClassification: BaseMaterialFileClassification = {}; //  物料档案分类 对象
+  baseMaterialFileProduct: BaseMaterialFileProduct = {}; //物料产品 对象
   activedNode: NzTreeNode;
   dropdown: NzDropdownContextComponent;
   isSpinning = false;
@@ -34,10 +34,11 @@ export class BasedataMaterialFileComponent implements OnInit {
   searchValue = ''; //搜索框值
   materialNodes: any; //物料分类 数据
   materialId = ''; //物料分类 id
+  // materialname = ''; //物料分类 名  传值用
   page: Page; //分页对象
 
   proTable = []; //产品数据
-  proObj: any; //产品对象
+  proObj: any = {}; //产品对象
   proId = ''; //点击产品id
 
   productPage = {
@@ -56,42 +57,42 @@ export class BasedataMaterialFileComponent implements OnInit {
 
   ngOnInit() {
     // 物料分类
-    this.baseMaterialFileClassification = {
-      id: '',
-      code: '',
-      name: '',
-      parentId: '',
-      pkOrg: '',
-      sort: 0,
-      key: '', //用于tree id
-      title: '', //name
-      isLeaf: false, //是否尾端true/false
-      children: [], //子集
-    };
-    this.baseMaterialFileProduct = {
-      id: '',
-      code: '',
-      name: '',
-      pkOrg: '',
-      sort: 0,
-      status: '',
-      attribute: '',
-      baseMaterialFileClassificationId: '',
-      /**模块子表数据*/
-      // baseMaterialFileModularList?:BaseMaterialFileModular[];
-    };
+    // this.baseMaterialFileClassification = {
+    //   id: '',
+    //   code: '',
+    //   name: '',
+    //   parentId: '',
+    //   pkOrg: '',
+    //   sort: 0,
+    //   key: '', //用于tree id
+    //   title: '', //name
+    //   isLeaf: false, //是否尾端true/false
+    //   children: [], //子集
+    // };
+    // this.baseMaterialFileProduct = {
+    //   id: '',
+    //   code: '',
+    //   name: '',
+    //   pkOrg: '',
+    //   sort: 0,
+    //   status: '',
+    //   attribute: '',
+    //   baseMaterialFileClassificationId: '',
+    //   /**模块子表数据*/
+    //   // baseMaterialFileModularList?:BaseMaterialFileModular[];
+    // };
     //产品 对象
-    this.proObj = {
-      id: '',
-      code: '',
-      name: '',
-      pkOrg: '',
-      sort: 0,
-      status: '',
-      attribute: '',
-      baseMaterialFileClassificationId: '',
-      // baseMaterialFileModularList?:BaseMaterialFileModular[]; //模块子表数据
-    };
+    // this.proObj = {
+    //   id: '',
+    //   code: '',
+    //   name: '',
+    //   pkOrg: '',
+    //   sort: 0,
+    //   status: '',
+    //   attribute: '',
+    //   baseMaterialFileClassificationId: '',
+    // baseMaterialFileModularList?:BaseMaterialFileModular[]; //模块子表数据
+    // };
     // 页码
     this.page = {
       pageNo: 0, //当前页码
@@ -100,16 +101,20 @@ export class BasedataMaterialFileComponent implements OnInit {
     this.getMaterialTree(); //物料分类树
     this.getProductList(); // 产品数据
   }
+
   //查询 物料分类 树
   getMaterialTree() {
-    let baseMaterialFileClassification = new BaseMaterialFileClassification();
-    baseMaterialFileClassification.pkOrg = sessionStorage.getItem('pkOrg'); //组织
-    this.baseMaterialFileClassificationService.getTreeList(baseMaterialFileClassification).then(res => {
-      this.materialNodes = res.result;
-      console.log('物料分类 树', this.materialNodes);
+    return new Promise(resolve => {
+      let baseMaterialFileClassification = new BaseMaterialFileClassification();
+      baseMaterialFileClassification.pkOrg = sessionStorage.getItem('pkOrg'); //组织
+      this.baseMaterialFileClassificationService.getTreeList(baseMaterialFileClassification).then(res => {
+        this.materialNodes = res.result;
+        console.log('物料分类 树', this.materialNodes);
+        resolve();
+      });
     });
   }
-  //右侧查询按钮
+  //右查询按钮
   query() {
     this.proObj.pageNo = 1;
     this.getProductList(); //所有产品
@@ -127,6 +132,7 @@ export class BasedataMaterialFileComponent implements OnInit {
         this.productPage = res.result;
         console.log('产品', this.proTable);
         this.isSpinning = false;
+        resolve()
       });
     });
   }
@@ -176,23 +182,31 @@ export class BasedataMaterialFileComponent implements OnInit {
     });
   }
   //新增产品 /修改  ( 抽屉 product-add)
-  addProduct(id) {
+  addProduct(id, materialId) {
     var title = '';
     //判断是抽屉标题是 新增 还是 修改
     if (id) {
       title = document.getElementById('proTitUpdate').textContent;
+    }
+    if (materialId) {
+      title = document.getElementById('proTitAdd').textContent;
     } else {
       this.proId = '';
+      // this.materialId = '';
       title = document.getElementById('proTitAdd').textContent;
     }
 
-    //产品 抽屉
-    const drawerAddPro = this.drawerService.create<BasedataMaterialFileProductAddComponent, { proId: string }, string>({
+    const drawerAddPro = this.drawerService.create<
+      BasedataMaterialFileProductAddComponent,
+      { proId: string; materialId: string },
+      string
+    >({
       nzTitle: title,
       nzWidth: 1200,
       nzContent: BasedataMaterialFileProductAddComponent,
       nzContentParams: {
-        proId: this.proId, //物料分类id
+        proId: this.proId, //产品id
+        materialId: this.materialId, //物料分类id
       },
     });
     //回调 添加完关闭抽屉
@@ -204,6 +218,19 @@ export class BasedataMaterialFileComponent implements OnInit {
       }
     });
   }
+  //树节点点击事件
+  treeClick(event) {
+    // console.log('点击节点的内容', event);
+    var materialObj = event.node.origin; //当前点击的物料对象
+    // console.log(materialObj.parentId);
+    //赋值给修改表单
+    // this.baseMaterialFileClassification = {
+    //   code: materialObj.code,
+    //   name: materialObj.name,
+    //   parentId: materialObj.parentId,
+    //   sort: materialObj.sort,
+    // };
+  }
   //按页码查询
   pageIndexChange(event) {
     // var page = new Page();
@@ -220,19 +247,6 @@ export class BasedataMaterialFileComponent implements OnInit {
   rest() {
     this.proObj = {}; //清空 物料对象
   }
-  //树节点点击事件
-  treeClick(event) {
-    // console.log('点击节点的内容', event);
-    var materialObj = event.node.origin; //当前点击的物料对象
-    // console.log(materialObj.parentId);
-    //赋值给修改表单
-    this.baseMaterialFileClassification = {
-      code: materialObj.code,
-      name: materialObj.name,
-      parentId: materialObj.parentId,
-      sort: materialObj.sort,
-    };
-  }
 
   //双击节点自动打开树分支
   openFolder(data: NzTreeNode | Required<NzFormatEmitEvent>): void {
@@ -250,9 +264,11 @@ export class BasedataMaterialFileComponent implements OnInit {
   }
 
   //右键树节点
-  contextMenu(Fid, $event: MouseEvent, template: TemplateRef<void>): void {
+  contextMenu(Fid, event: MouseEvent, template: TemplateRef<void>): void {
     this.materialId = Fid;
-    this.dropdown = this.nzDropdownService.create($event, template);
+    console.log('...', this.materialId);
+    // console.log('...', template);
+    this.dropdown = this.nzDropdownService.create(event, template);
     // console.log('右击对象', this.dropdown);
   }
   //右击删除

+ 43 - 9
src/app/routes/basedata/material-file/module-add/module-add.component.html

@@ -1,9 +1,43 @@
-<page-header [action]="phActionTpl">
-  <ng-template #phActionTpl>
-    <button (click)="add()" nz-button nzType="primary">新建</button>
-  </ng-template>
-</page-header>
-<nz-card>
-  <sf mode="search" [schema]="searchSchema" (formSubmit)="st.reset($event)" (formReset)="st.reset($event)"></sf>
-  <st #st [data]="url" [columns]="columns"></st>
-</nz-card>
+<!-- <form nz-form [formGroup]="validateForm"> -->
+  <!-- <nz-form-item> -->
+    <!-- 模块编码 -->
+    <!-- <nz-form-label nzRequired [nzSm]="3" [nzXs]="24" nzRequired>{{ 'module.code' | translate }}</nz-form-label>
+    <nz-form-control [nzSm]="8" [nzXs]="24">
+      <input
+        nz-input
+        [(ngModel)]="modObj.code"
+        formControlName="code"
+        placeholder="{{ 'please.input.contacts' | translate }}"
+      />
+    </nz-form-control>
+  </nz-form-item>
+
+  <nz-form-item> -->
+    <!-- 模块名称 -->
+    <!-- <nz-form-label [nzSm]="3" [nzXs]="24">{{ 'module.name' | translate }}</nz-form-label>
+    <nz-form-control [nzSm]="8" [nzXs]="24">
+      <input
+        [(ngModel)]="modObj.name"
+        formControlName="name"
+        nz-input
+        placeholder="{{ 'placeholder' | translate }}{{ 'customer.contacts.telephone' | translate }}"
+      />
+    </nz-form-control>
+  </nz-form-item> -->
+
+  <!-- <nz-form-item> -->
+    <!-- 标准报价 -->
+    <!-- <nz-form-label [nzSm]="3" [nzXs]="24">{{ 'standard.quotation' | translate }}</nz-form-label>
+    <nz-form-control [nzSm]="8" [nzXs]="24">
+      <nz-input-number
+        [(ngModel)]="modObj.standardQuotation"
+        formControlName="standardQuotation"
+        [nzMin]="0"
+        [nzParser]="parserDollar"
+        [nzFormatter]="formatterDollar"
+        [nzMax]="100000000000000000"
+        [nzStep]="10"
+      ></nz-input-number>
+    </nz-form-control>
+  </nz-form-item> -->
+<!-- </form> -->

+ 24 - 32
src/app/routes/basedata/material-file/module-add/module-add.component.ts

@@ -2,44 +2,36 @@ import { Component, OnInit, ViewChild } from '@angular/core';
 import { _HttpClient, ModalHelper } from '@delon/theme';
 import { STColumn, STComponent } from '@delon/abc';
 import { SFSchema } from '@delon/form';
+import { BaseMaterialFileModular } from 'app/entity/basedata/base-material-file-modular';
+import { FormBuilder, Validators, FormGroup } from '@angular/forms';
+import { NzModalRef, NzNotificationService } from 'ng-zorro-antd';
 
 @Component({
   selector: 'app-basedata-material-file-module-add',
   templateUrl: './module-add.component.html',
 })
 export class BasedataMaterialFileModuleAddComponent implements OnInit {
-  url = `/user`;
-  searchSchema: SFSchema = {
-    properties: {
-      no: {
-        type: 'string',
-        title: '编号'
-      }
-    }
-  };
-  @ViewChild('st') st: STComponent;
-  columns: STColumn[] = [
-    { title: '编号', index: 'no' },
-    { title: '调用次数', type: 'number', index: 'callNo' },
-    { title: '头像', type: 'img', width: '50px', index: 'avatar' },
-    { title: '时间', type: 'date', index: 'updatedAt' },
-    {
-      title: '',
-      buttons: [
-        // { text: '查看', click: (item: any) => `/form/${item.id}` },
-        // { text: '编辑', type: 'static', component: FormEditComponent, click: 'reload' },
-      ]
-    }
-  ];
+  // baseMaterialFileModular: BaseMaterialFileModular = {
+  //   id: '',
+  //   code: '',
+  //   name: '',
+  //   standardQuotation: 0,
+  //   pkOrg: '',
+  // }; //模块 实体
+  // //模块对象
+  // modObj = {};
+  // //金额格式化 (公司注册资金)
+  // formatterDollar = (value: number) => {
+  //   if (value) {
+  //     return `$ ${value}`;
+  //   } else {
+  //     return `$ `;
+  //   }
+  // };
 
-  constructor(private http: _HttpClient, private modal: ModalHelper) { }
-
-  ngOnInit() { }
-
-  add() {
-    // this.modal
-    //   .createStatic(FormEditComponent, { i: { id: 0 } })
-    //   .subscribe(() => this.st.reload());
-  }
+  parserDollar = (value: string) => value.replace('$ ', '');
+  constructor(private modal: NzModalRef) {}
 
+  ngOnInit() {}
+  addRowMod() {}
 }

+ 180 - 109
src/app/routes/basedata/material-file/product-add/product-add.component.html

@@ -1,120 +1,191 @@
-<form nz-form [formGroup]="validateForm" (ngSubmit)="proSubForm()">
-  <nz-form-item>
-    <!-- 产品编码 -->
-    <nz-form-label nzRequired [nzSm]="3" [nzXs]="24">
-      {{ 'product' | translate }}{{ 'table.thead.code' | translate }}
-    </nz-form-label>
-    <nz-form-control [nzSm]="8" [nzXs]="12">
-      <input
-        [(ngModel)]="baseMaterialFileProduct.code"
-        formControlName="code"
-        nz-input
-        placeholder="{{ 'placeholder' | translate }}"
-        maxlength="10"
-      />
-    </nz-form-control>
+<nz-spin [nzSpinning]="isLoading">
+  <form nz-form [formGroup]="validateForm" (ngSubmit)="proSubForm()">
+    <!-- 产品编码  名称 -->
+    <nz-form-item>
+      <nz-form-label nzRequired [nzSm]="3" [nzXs]="24">
+        {{ 'product' | translate }}{{ 'table.thead.code' | translate }}
+      </nz-form-label>
+      <nz-form-control [nzSm]="8" [nzXs]="12">
+        <input
+          [(ngModel)]="baseMaterialFileProduct.code"
+          formControlName="code"
+          nz-input
+          placeholder="{{ 'placeholder' | translate }}"
+          maxlength="10"
+        />
+      </nz-form-control>
+      <nz-form-label nzRequired [nzSm]="3" [nzXs]="24">{{ 'Name' | translate }}</nz-form-label>
+      <nz-form-control [nzSm]="8" [nzXs]="12">
+        <input
+          [(ngModel)]="baseMaterialFileProduct.name"
+          formControlName="name"
+          nz-input
+          placeholder="{{ 'placeholder' | translate }}"
+          maxlength="10"
+        />
+      </nz-form-control>
+    </nz-form-item>
 
-    <!-- 产品名称 -->
-    <nz-form-label nzRequired [nzSm]="3" [nzXs]="24">{{ 'Name' | translate }}</nz-form-label>
-    <nz-form-control [nzSm]="8" [nzXs]="12">
-      <input
-        [(ngModel)]="baseMaterialFileProduct.name"
-        formControlName="name"
-        nz-input
-        placeholder="{{ 'placeholder' | translate }}"
-        maxlength="10"
-      />
-    </nz-form-control>
-  </nz-form-item>
-
-  <!-- 排序 -->
-  <nz-form-item>
-    <nz-form-label [nzSm]="3" [nzXs]="24" nzRequired>{{ 'depart.sort' | translate }}</nz-form-label>
-    <nz-form-control [nzSm]="8" [nzXs]="12">
-      <input
-        [(ngModel)]="baseMaterialFileProduct.sort"
-        formControlName="sort"
-        nz-input
-        maxlength="100"
-        placeholder="{{ 'placeholder' | translate }}"
-      />
-    </nz-form-control>
-
-    <!-- 状态  -->
-    <nz-form-label nzRequired [nzSm]="3" [nzXs]="24">{{ 'state' | translate }}</nz-form-label>
-    <nz-form-control [nzSm]="8" [nzXs]="12">
-      <nz-select
-        nzShowSearch
-        nzPlaceHolder="{{ 'select.please.choose' | translate }}"
-        [nzDisabled]="false"
-        [(ngModel)]="baseMaterialFileProduct.status"
-        formControlName="status"
-      >
-        <!-- 第一条请选择       *ngIf="baseMaterialFileProduct.status == ''"-->
-        <nz-option nzLabel="{{ 'select.please.choose' | translate }}" nzValue="" selected="selected"></nz-option>
-        <!-- 0未启用, 1 启用 --------------------------------
+    <!-- 排序 状态 -->
+    <nz-form-item>
+      <nz-form-label [nzSm]="3" [nzXs]="24" nzRequired>{{ 'depart.sort' | translate }}</nz-form-label>
+      <nz-form-control [nzSm]="8" [nzXs]="12">
+        <input
+          [(ngModel)]="baseMaterialFileProduct.sort"
+          formControlName="sort"
+          nz-input
+          maxlength="100"
+          placeholder="{{ 'placeholder' | translate }}"
+        />
+      </nz-form-control>
+      <nz-form-label nzRequired [nzSm]="3" [nzXs]="24">{{ 'state' | translate }}</nz-form-label>
+      <nz-form-control [nzSm]="8" [nzXs]="12">
+        <nz-select
+          nzShowSearch
+          nzPlaceHolder="{{ 'select.please.choose' | translate }}"
+          [nzDisabled]="false"
+          [(ngModel)]="baseMaterialFileProduct.status"
+          formControlName="status"
+        >
+          <!-- 第一条请选择       *ngIf="baseMaterialFileProduct.status == ''"-->
+          <nz-option nzLabel="{{ 'select.please.choose' | translate }}" nzValue="" selected="selected"></nz-option>
+          <!-- 0未启用, 1 启用 --------------------------------
               *ngIf="baseMaterialFileProduct.status == '0" 
               *ngIf="baseMaterialFileProduct.status == '1'"
             ---------------------------------------------------->
-        <nz-option nzLabel="{{ 'enabled.not' | translate }}" nzValue="0"></nz-option>
-        <nz-option nzLabel="{{ 'enabled' | translate }}" nzValue="1"></nz-option>
-      </nz-select>
-    </nz-form-control>
-  </nz-form-item>
+          <nz-option nzLabel="{{ 'enabled.not' | translate }}" nzValue="0"></nz-option>
+          <nz-option nzLabel="{{ 'enabled' | translate }}" nzValue="1"></nz-option>
+        </nz-select>
+      </nz-form-control>
+    </nz-form-item>
 
-  <!-- 产品属性 -->
-  <nz-form-item>
-    <nz-form-label nzRequired [nzSm]="3" [nzXs]="24">{{ 'property' | translate }}</nz-form-label>
-    <nz-form-control [nzSm]="8" [nzXs]="12">
-      <nz-select
-        nzShowSearch
-        nzPlaceHolder="{{ 'select.please.choose' | translate }}"
-        [nzDisabled]="false"
-        [(ngModel)]="baseMaterialFileProduct.attribute"
-        formControlName="attribute"
-      >
-        <nz-option
-          *ngIf="baseMaterialFileProduct.attribute == ''"
-          nzLabel="{{ 'select.please.choose' | translate }}"
-          nzValue=""
-          selected="selected"
-        ></nz-option>
-        <!-- 1采购    2销售----------------------------------
+    <!-- 产品属性 分类树-->
+    <nz-form-item>
+      <nz-form-label nzRequired [nzSm]="3" [nzXs]="24">{{ 'property' | translate }}</nz-form-label>
+      <nz-form-control [nzSm]="8" [nzXs]="12">
+        <nz-select
+          nzShowSearch
+          nzPlaceHolder="{{ 'select.please.choose' | translate }}"
+          [nzDisabled]="false"
+          [(ngModel)]="baseMaterialFileProduct.attribute"
+          formControlName="attribute"
+        >
+          <nz-option
+            *ngIf="baseMaterialFileProduct.attribute == ''"
+            nzLabel="{{ 'select.please.choose' | translate }}"
+            nzValue=""
+            selected="selected"
+          ></nz-option>
+          <!-- 1采购    2销售----------------------------------
          *ngIf="baseMaterialFileProduct.attribute == '1"
          *ngIf="baseMaterialFileProduct.attribute == '2'"
         ---------------------------------------------------->
-        <nz-option nzLabel="{{ 'procurement' | translate }}" nzValue="0"></nz-option>
-        <nz-option nzLabel="{{ 'sales' | translate }}" nzValue="1"></nz-option>
-      </nz-select>
-    </nz-form-control>
+          <nz-option nzLabel="{{ 'procurement' | translate }}" nzValue="0"></nz-option>
+          <nz-option nzLabel="{{ 'sales' | translate }}" nzValue="1"></nz-option>
+        </nz-select>
+      </nz-form-control>
+
+      <nz-form-label [nzSm]="3" [nzXs]="24" nzNoColon="true" nzRequired>
+        {{ 'cost.item.category' | translate }}
+      </nz-form-label>
+
+      <nz-form-control [nzSm]="8" [nzXs]="12">
+        <nz-tree-select
+          nzAllowClear="false"
+          [nzNodes]="materialTree"
+          nzShowSearch
+          nzPlaceHolder="{{ 'select.please.choose' | translate }}"
+          [(ngModel)]="baseMaterialFileProduct.baseMaterialFileClassificationId"
+          formControlName="baseMaterialFileClassificationId"
+          (ngModelChange)="materialChange($event)"
+        >
+        </nz-tree-select>
+        <!-- </span>  -->
+      </nz-form-control>
+    </nz-form-item>
+  </form>
+  <!-- 新增 模块 子表-->
+  <div>
+    <span id="modTitAdd" hidden="true"> {{ 'button.add' | translate }}{{ 'customer.contacts.name' | translate }} </span>
+    <span id="modTitUpdate" hidden="true">
+      {{ 'table.update' | translate }}{{ 'customer.contacts.name' | translate }}
+    </span>
 
-    <!-- 产品分类  分类 树-->
-    <nz-form-label [nzSm]="3" [nzXs]="24" nzNoColon="true" nzRequired>
-      {{ 'cost.item.category' | translate }}
-    </nz-form-label>
-    <nz-form-control [nzSm]="8" [nzXs]="12">
-      <nz-tree-select
-        nzAllowClear="false"
-        [nzNodes]="materialTree"
-        nzShowSearch
-        nzPlaceHolder="{{ 'select.please.choose' | translate }}"
-        [(ngModel)]="baseMaterialFileProduct.baseMaterialFileClassificationId"
-        formControlName="baseMaterialFileClassificationId"
-        (ngModelChange)="materialChange($event)"
-      >
-      </nz-tree-select>
-    </nz-form-control>
-  </nz-form-item>
+    <!-- 按钮 -->
+    <div nz-row nzGutter="24" style="margin-bottom:6px;">
+      <div nz-col nzMd="24" nzLg="24">
+        <button (click)="addRowMod()" nz-button nzType="primary">{{ 'button.add' | translate }}</button>
+      </div>
+    </div>
 
-  <!-- 子表   物料模块 -->
-  <div></div>
-  <!-- 底部 -->
-  <div class="footer">
-    <button type="button" (click)="close()" class="ant-btn" style="margin-right: 8px;">
-      <span>{{ 'button.close' | translate }}</span>
-    </button>
-    <button type="button" (click)="save('')" class="ant-btn ant-btn-primary">
-      <span>{{ 'button.save' | translate }}</span>
-    </button>
+    <!-- 模块表 -->
+    <div nz-row nzGutter="24">
+      <div nz-col nzMd="18" nzLg="24">
+        <nz-table nzSize="small" #basicTable [nzData]="modData" [nzFrontPagination]="false" [nzShowPagination]="false">
+          <thead>
+            <tr>
+              <th style="width:150px;" nzAlign="center">{{ 'module.code' | translate }}</th>
+              <th style="width:150px;" nzAlign="center">{{ 'module.name' | translate }}</th>
+              <th style="width:150px;" nzAlign="center">{{ 'standard.quotation' | translate }}</th>
+              <th style="width:150px;" nzAlign="center">{{ 'table.operation' | translate }}</th>
+            </tr>
+          </thead>
+
+          <tbody>
+            <tr *ngFor="let data of basicTable.data">
+              <!-- 模块编码 -->
+              <td>
+                <input type="text" [(ngModel)]="data.code" nz-input maxlength="20" />
+              </td>
+              <!-- 模块名称 -->
+              <td>
+                <input type="text" [(ngModel)]="data.name" nz-input maxlength="20" />
+              </td>
+              <!-- 标准报价 -->
+              <td>
+                <input type="text" [(ngModel)]="data.standardQuotation" nz-input maxlength="20" />
+                <!-- 金额格式 -->
+                <!-- <nz-input-number
+                    [(ngModel)]="data.standardQuotation"
+                    formControlName="standardQuotation"
+                    [nzMin]="0"
+                    [nzParser]="parserDollar"
+                    [nzFormatter]="formatterDollar"
+                    [nzMax]="100000000000000000"
+                    [nzStep]="10"
+                  ></nz-input-number> -->
+              </td>
+              <td nzAlign="center">
+                <a
+                  nz-popconfirm
+                  nzTitle="{{ 'confirm.to.delete' | translate }}?"
+                  nzOkText="{{ 'yes' | translate }}"
+                  nzCancelText="{{ 'no' | translate }}"
+                  (nzOnConfirm)="deleteMod(data)"
+                >
+                  {{ 'table.delete' | translate }}
+                </a>
+              </td>
+            </tr>
+          </tbody>
+        </nz-table>
+      </div>
+    </div>
   </div>
-</form>
+</nz-spin>
+
+<!-- 底部 -->
+<div class="footer">
+  <a
+    nz-popconfirm
+    style="margin-right: 2%"
+    nzTitle="{{ 'pm.contract.contract.add.button.cancel' | translate }}"
+    (nzOnConfirm)="close()"
+  >
+    <button nz-button>{{ 'button.close' | translate }}</button>
+  </a>
+
+  <button type="button" (click)="save('')" class="ant-btn ant-btn-primary">
+    <span>{{ 'button.save' | translate }}</span>
+  </button>
+</div>

+ 127 - 52
src/app/routes/basedata/material-file/product-add/product-add.component.ts

@@ -1,7 +1,5 @@
 import { Component, OnInit, ViewChild } from '@angular/core';
 import { _HttpClient, ModalHelper } from '@delon/theme';
-// import { STColumn, STComponent } from '@delon/abc';
-// import { SFSchema } from '@delon/form';
 import { Page } from 'app/entity/page'; //分页
 import { BaseMaterialFileProduct } from 'app/entity/basedata/base-material-file-product';
 import { BaseMaterialFileClassification } from 'app/entity/basedata/base-material-file-classification';
@@ -12,6 +10,9 @@ import { I18NService } from '@core';
 import { NzDrawerRef, NzNotificationService } from 'ng-zorro-antd';
 import { messageShared } from '@shared/utils/message';
 import { resolveComponentResources } from '@angular/core/src/metadata/resource_loading';
+import { BaseMaterialFileModularService } from 'app/services/basedata/base-material-file-modular.service';
+import { BaseMaterialFileModular } from 'app/entity/basedata/base-material-file-modular';
+import { log } from 'console';
 
 @Component({
   selector: 'app-basedata-material-file-product-add',
@@ -19,29 +20,23 @@ import { resolveComponentResources } from '@angular/core/src/metadata/resource_l
 })
 export class BasedataMaterialFileProductAddComponent implements OnInit {
   isOne = 0; //标题
-  page: Page; //分页对象
-  baseMaterialFileClassification: BaseMaterialFileClassification; //  物料档案分类 对象
+  page: Page = {}; //分页对象
+  materialId: string = ''; //接收物料id
+  baseMaterialFileClassification: BaseMaterialFileClassification; //  物料分类 对象
   baseMaterialFileProduct: BaseMaterialFileProduct = {
-    // //产品 对象
+    // 产品 对象
     // code: '',
     // name: '',
     // pkorg: '',
     // // sort: '',
     // status: '',
     // attribute: '',
-    // baseMaterialFileClassificationId: '',
-    // baseMaterialFileModularList: [], //子表模块  todo
-  };
-  aa = {
-    code: '',
-    name: '',
-    pkorg: '',
-    sort: '',
-    status: '',
-    attribute: '',
-    baseMaterialFileClassificationId: '',
+    // baseMaterialFileClassificationId: this.materialId,
     // baseMaterialFileModularList: [], //子表模块  todo
   };
+  baseMaterialFileModular: BaseMaterialFileModular = {}; //模块 对象
+  modObj = {};
+
   proTable = []; //产品数据
   productPage = {
     total: 0,
@@ -49,9 +44,25 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
   };
   materialTree: any = []; //物料分类 (树)
   validateForm!: FormGroup;
+  modData: any = []; // 模块表
+  aa: [];
+  id: string; // 模块名称
+
+  //金额格式化 (公司注册资金)
+  formatterDollar = (value: number) => {
+    if (value) {
+      return `$ ${value}`;
+    } else {
+      return `$ `;
+    }
+  };
+
+  parserDollar = (value: string) => value.replace('$ ', '');
+
   constructor(
     private baseMaterialFileProductService: BaseMaterialFileProductService,
     private baseMaterialFileClassificationService: BaseMaterialFileClassificationService,
+    private baseMaterialFileModularService: BaseMaterialFileModularService,
     private fb: FormBuilder,
     private i18NService: I18NService,
     private notification: NzNotificationService,
@@ -60,17 +71,22 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
   ) {}
 
   ngOnInit() {
+    // 接收抽屉参数
+    this.baseMaterialFileProduct.baseMaterialFileClassificationId = this.materialId;
     //初始化表单
     this.validateForm = this.fb.group({
       code: [null, [Validators.required]],
       name: [null, [Validators.required]],
-      sort: ['number', [Validators.required]], //数字输入框
+      sort: ['number', [Validators.required]], //排序
       status: [null, [Validators.required]],
       attribute: [null, [Validators.required]],
       baseMaterialFileClassificationId: [null, [Validators.required]], //物料分类id
+      // standardQuotation:[null, [Validators.required]],
+      // baseMaterialFileModularList: [null, [Validators.required]], //模块子表数据、
     });
     this.getMaterialTree(); //物料分类  树
     this.getProductList(); //产品 列表
+    this.getmodList(); //模块列表
   }
 
   //查询 物料分类 树
@@ -93,54 +109,113 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
     });
   }
 
-  // 产品 报错(新增/修改)
+  // 产品 保存(新增/修改)
   proSubForm() {
+    console.log('产品最后的保存');
     //根据标题判断 新增 or 修改
-    if (this.isOne == 2) {
-      return new Promise(resolve => {
-        //修改
+    // if (this.isOne == 2) {
+    // console.log('000');
+
+    // return new Promise(resolve => {
+    //修改
+    //   this.baseMaterialFileProduct.pkOrg = sessionStorage.getItem('pkOrg'); //组织
+    //   this.baseMaterialFileClassificationService.update(this.baseMaterialFileClassification).then(res => {
+    //     if (res.success) {
+    //       this.notification.success(this.i18NService.fanyi('successful.revision'), '');
+    //       this.nzDrawerRef.close(true); //关闭抽屉是否刷新列表
+    //     } else {
+    //       this.notification.error(
+    //         this.i18NService.fanyi('modification.failed'),
+    //         messageShared(this.i18NService, res.message),
+    //       );
+    //     }
+    //   });
+    // });
+    // } else {
+    // 新增
+    // console.log('111');
+    return new Promise(resolve => {
+      for (const i in this.validateForm.controls) {
+        this.validateForm.controls[i].markAsDirty();
+        this.validateForm.controls[i].updateValueAndValidity();
+      }
+      console.log('000');
+
+      let valid = this.validateForm.valid;
+      console.log('111');
+      if (valid) {
+        console.log('222');
+        console.log('valid有效--->', valid);
+        // let baseMaterialFileProduct = new BaseMaterialFileProduct();
         this.baseMaterialFileProduct.pkOrg = sessionStorage.getItem('pkOrg'); //组织
-        this.baseMaterialFileClassificationService.update(this.baseMaterialFileClassification).then(res => {
+        this.baseMaterialFileProduct.baseMaterialFileModularList = this.modData;
+        console.log(this.baseMaterialFileProduct.baseMaterialFileModularList);
+
+        console.log('走这没');
+        this.baseMaterialFileProductService.add(this.baseMaterialFileProduct).then(res => {
           if (res.success) {
-            this.notification.success(this.i18NService.fanyi('successful.revision'), '');
+            console.log('out', res);
+            this.nzNotificationService.success(this.i18NService.fanyi('save.ok'), '');
+            console.log('产品对象>>>>', this.baseMaterialFileProduct);
             this.nzDrawerRef.close(true); //关闭抽屉是否刷新列表
+            resolve();
           } else {
-            this.notification.error(
-              this.i18NService.fanyi('modification.failed'),
-              messageShared(this.i18NService, res.message),
-            );
+            //保存失败
+            this.nzNotificationService.error(this.i18NService.fanyi('save.not'), '');
           }
         });
-      });
+      }
+    });
+    // }
+  }
+
+  sort = 1;
+
+  //模块 新增
+  addRowMod() {
+    this.modData = [
+      ...this.modData,
+      {
+        id: '',
+        code: '',
+        name: '',
+        standardQuotation: '',
+        sort: this.sort,
+      },
+    ];
+    this.sort++;
+  }
+  //删除模块
+  deleteMod(data): void {
+    if (data.id == '') {
+      //新增客户档案时
+      // this.listOfData = this.listOfData.filter(d => d.contactPsn !== data.contactPsn);
+      this.modData = this.modData.filter(d => d.sort !== data.sort);
     } else {
-      //新增
-      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);
-          // let baseMaterialFileClassification = new BaseMaterialFileClassification();
-          this.baseMaterialFileProduct.pkOrg = sessionStorage.getItem('pkOrg'); //组织
-          this.baseMaterialFileProductService.add(this.baseMaterialFileProduct).then(res => {
-            if (res.success) {
-              //保存成功
-              this.nzNotificationService.success(this.i18NService.fanyi('save.ok'), '');
-              console.log('产品对象>>>>', this.baseMaterialFileProduct);
-              this.nzDrawerRef.close(true); //关闭抽屉是否刷新列表
-              // this.modal.destroy();
-              resolve();
-            } else {
-              //保存失败
-              this.nzNotificationService.error(this.i18NService.fanyi('save.not'), '');
-            }
-          });
+      //修改客户档案时
+      this.baseMaterialFileModularService.delete(data.id).then(response => {
+        if (response.success) {
+          this.notification.success(this.i18NService.fanyi('successful.deletion'), '');
+          this.getmodList();
+        } else {
+          this.notification.error(
+            this.i18NService.fanyi('delete.failed'),
+            messageShared(this.i18NService, response.message),
+          );
         }
       });
     }
   }
+  //模块列表
+  getmodList() {
+    return new Promise(resolve => {
+      let baseMaterialFileModular = new BaseMaterialFileModular();
+      baseMaterialFileModular.pkOrg = sessionStorage.getItem('pkOrg');
+      this.baseMaterialFileModularService.list(baseMaterialFileModular).then(res => {
+        this.aa = res.result.records;
+      });
+    });
+  }
   //树自带方法
   materialChange() {}
   // 保存

+ 9 - 8
src/assets/tmp/i18n/zh-CN.json

@@ -1859,12 +1859,13 @@
   "billing.bank": "开票银行",
   "date": "时间",
   "product": "产品",
-  "material.classification":"物料分类",
-  "material.classification.name":"物料分类名称",
-  "enabled.not":"未启用",
-  "enabled":"启用",
-  "procurement":"采购",
-  "sales":"销售"
-  
-
+  "material.classification": "物料分类",
+  "material.classification.name": "物料分类名称",
+  "enabled.not": "未启用",
+  "enabled": "启用",
+  "procurement": "采购",
+  "sales": "销售",
+  "module.code": "模块编码",
+  "module.name": "模块名称",
+  "standard.quotation": "标准报价"
 }