Browse Source

[物料档案产品] 基本完成 (模块无)

liangyan0105 3 years ago
parent
commit
47402ebcd8

+ 6 - 2
src/app/routes/basedata/basedata-routing.module.ts

@@ -29,7 +29,9 @@ import { BasedataSalesStatusComponent } from './sales-status/sales-status.compon
 import { BasedataSalesStatusAddComponent } from './sales-status/add/add.component';
 import { BasedataCustomerModalTableComponent } from './customer/modal-table/modal-table.component';
 import { BasedataMaterialFileComponent } from './material-file/material-file.component';
-import { BasedataMaterialFileAddComponent } from './material-file/add/add.component';
+import { BasedataMaterialFileAddComponent } from './material-file/add/add.component';
+import { BasedataMaterialFileProductAddComponent } from './material-file/product-add/product-add.component';
+import { BasedataMaterialFileModuleAddComponent } from './material-file/module-add/module-add.component';
 
 
 const routes: Routes = [
@@ -60,7 +62,9 @@ const routes: Routes = [
   { path: 'add', component: BasedataSalesStatusAddComponent },
   { path: 'modalTable', component: BasedataCustomerModalTableComponent },
   { path: 'material-file', component: BasedataMaterialFileComponent },
-  { path: 'add', component: BasedataMaterialFileAddComponent }];
+  { path: 'add', component: BasedataMaterialFileAddComponent },
+  { path: 'productAdd', component: BasedataMaterialFileProductAddComponent },
+  { path: 'module-add', component: BasedataMaterialFileModuleAddComponent }];
 @NgModule({
   imports: [RouterModule.forChild(routes)],
   exports: [RouterModule]

+ 6 - 2
src/app/routes/basedata/basedata.module.ts

@@ -41,7 +41,9 @@ import { BasedataSalesStatusComponent } from './sales-status/sales-status.compon
 import { BasedataSalesStatusAddComponent } from './sales-status/add/add.component';
 import { BasedataCustomerModalTableComponent } from './customer/modal-table/modal-table.component';
 import { BasedataMaterialFileComponent } from './material-file/material-file.component';
-import { BasedataMaterialFileAddComponent } from './material-file/add/add.component';
+import { BasedataMaterialFileAddComponent } from './material-file/add/add.component';
+import { BasedataMaterialFileProductAddComponent } from './material-file/product-add/product-add.component';
+import { BasedataMaterialFileModuleAddComponent } from './material-file/module-add/module-add.component';
 
 
 const COMPONENTS = [
@@ -73,7 +75,9 @@ const COMPONENTS = [
   BasedataSalesStatusAddComponent,
   BasedataCustomerModalTableComponent,
   BasedataMaterialFileComponent,
-  BasedataMaterialFileAddComponent];
+  BasedataMaterialFileAddComponent,
+  BasedataMaterialFileProductAddComponent,
+  BasedataMaterialFileModuleAddComponent];
 const COMPONENTS_NOROUNT = [BasedataCustomerEditComponent,
   BasedataCustomerIsAbbreviationComponent,
   BasedataPostAddComponent,

+ 0 - 10
src/app/routes/basedata/material-file/add/add.component.html

@@ -50,14 +50,4 @@
       />
     </nz-form-control>
   </nz-form-item>
-
-  <!-- 底部 -->
-  <!-- <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> -->
 </form>

+ 53 - 44
src/app/routes/basedata/material-file/material-file.component.html

@@ -1,15 +1,25 @@
 <!-- 头部导航 -->
 <page-header [action]="phActionTpl">
   <ng-template #phActionTpl>
-    <!-- 新增物料分类弹框 标题 -->
-    <span id="materialTitAdd" hidden="true">
+    <!-- 新增分类 标题 -->
+    <span id="titleAdd" hidden="true">
       {{ 'button.add' | translate }}{{ 'material.classification' | translate }}
     </span>
-    <!-- 修改物料分类 标题 -->
-    <span id="materialTitUpdate" hidden="true">
+    <!-- 修改分类 -->
+    <span id="titleUpdate" hidden="true">
       {{ 'table.update' | translate }}{{ 'material.classification' | translate }}
     </span>
-    <button nz-button nzType="primary" (click)="editProduct('')">
+    <!-- 产品新增 标题-->
+    <span id="proTitAdd" hidden="true">
+      {{ 'button.add' | translate }}{{ 'product' | translate }}
+    </span>
+    <!-- 产品修改 -->
+    <span id="proTitUpdate" hidden="true">
+      {{ 'table.update' | translate }}{{ 'product' | translate }}
+    </span>
+
+    <!-- 按钮 新增产品 -->
+    <button nz-button nzType="primary" (click)="addProduct('')">
       {{ 'button.add' | translate }}{{ 'product' | translate }}
     </button>
   </ng-template>
@@ -77,23 +87,24 @@
       </div>
     </nz-card>
   </div>
+
   <!-- 右边 列表 -->
   <div nz-col nzMd="24" nzLg="18">
     <nz-card>
-      <form >
+      <form>
         <!--查询条件-->
         <div nz-row nzGutter="24">
           <div nz-col nzMd="24" nzLg="3">
             <nz-form-label>产品编码</nz-form-label>
           </div>
           <div nz-col nzMd="24" nzLg="6">
-            <input nz-input [(ngModel)]="product.code" name="code" />
+            <input nz-input [(ngModel)]="proObj.code" name="code" />
           </div>
           <div nz-col nzMd="24" nzLg="3">
             <nz-form-label>产品名称</nz-form-label>
           </div>
           <div nz-col nzMd="24" nzLg="6">
-            <input nz-input [(ngModel)]="product.name" name="name" />
+            <input nz-input [(ngModel)]="proObj.name" name="name" />
           </div>
           <!-- 列表查询重置 -->
           <div nz-col nzMd="24" nzLg="6">
@@ -106,73 +117,71 @@
       <div nz-row nzGutter="24">
         <div nz-col nzMd="24" nzLg="24">
           <nz-table
+            nzBordered
             class="tableTdPadding"
             #basicTable
-            [nzData]="proListData"
+            [nzData]="proTable"
             [nzFrontPagination]="false"
             [nzTotal]="page.total"
             [nzPageIndex]="page.current"
             (nzPageIndexChange)="pageIndexChange($event)"
             [nzLoading]="isSpinning"
-            [nzScroll]="{ x: '70vw' }"
           >
             <thead>
               <tr>
-                <th nzWidth="8vw" nzLeft="0px" nzAlign="center">编号</th>
-                <th nzAlign="center" nzLeft="8vw">名称</th>
-                <th nzAlign="center">组织</th>
-                <th nzAlign="center">排序</th>
-                <th nzAlign="center">状态</th>
-                <th nzAlign="center">属性</th>
-                <!-- <th nzAlign="center"></th>
-                <th nzAlign="center"></th> -->
-                <th nzAlign="center" nzRight="0px">操作</th>
+                <!-- 产品编码 -->
+                <th nzWidth="8vw" nzLeft="0px" nzAlign="center">
+                  {{ 'product' | translate }}{{ 'table.thead.code' | translate }}
+                </th>
+                <!-- 名称 -->
+                <th nzAlign="center" nzLeft="8vw">{{ 'contract.name' | translate }}</th>
+                <!-- 排序 -->
+                <th nzAlign="center">{{ 'sort' | translate }}</th>
+                <!-- 状态 -->
+                <th nzAlign="center">{{ 'state' | translate }}</th>
+                <!-- 属性 -->
+                <th nzAlign="center">{{ 'property' | translate }}</th>
+                <!-- 操作 -->
+                <th nzAlign="center" nzRight="0px">{{ 'table.operation' | translate }}</th>
               </tr>
             </thead>
             <tbody>
               <tr *ngFor="let data of basicTable.data">
                 <td style="width: 8vw" nzAlign="center" nzLeft="0px">{{ data.code }}</td>
                 <td nzAlign="center" nzLeft="8vw">{{ data.name }}</td>
-                <td nzAlign="center">{{ data.pkOrg }}</td>
                 <td nzAlign="center">{{ data.sort }}</td>
+                <!-- 状态 0未启用    1启用-->
                 <td nzAlign="center">
-                  <ng-container *ngIf="data.status == 1">
-                    {{ 'state.stay' | translate }}
+                  <ng-container *ngIf="data.status == 0">
+                    {{ 'enabled.not' | translate }}
                   </ng-container>
-                  <ng-container *ngIf="data.status == 2">
-                    {{ 'state.leave' | translate }}
-                  </ng-container>
-                  <ng-container *ngIf="data.status == 3">
-                    {{ 'state.vacation' | translate }}
+                  <ng-container *ngIf="data.status == 1">
+                    {{ 'enabled' | translate }}
                   </ng-container>
                 </td>
-                <td nzAlign="center">{{ data.attribute }}</td>
-                <!-- 是否停用 -->
+                <!-- 属性  1采购   2销售 -->
                 <td nzAlign="center">
-                  <!-- 否 -->
-                  <nz-tag *ngIf="data.enable === '0'" [nzColor]="'green'">{{ 'no' | translate }}</nz-tag>
-                  <!-- 是 -->
-                  <nz-tag *ngIf="data.enable === '1'" [nzColor]="'red'">{{ 'yes' | translate }}</nz-tag>
-                  <!-- <ng-container *ngIf="data.enable==0">
-                    {{'no'| translate}}
+                  <ng-container *ngIf="data.attribute == 1">
+                    {{ 'procurement' | translate }}
+                  </ng-container>
+                  <ng-container *ngIf="data.attribute == 2">
+                    {{ 'sales' | translate }}
                   </ng-container>
-                  <ng-container *ngIf="data.enable==1">
-                    {{'yes'| translate}}
-                  </ng-container> -->
                 </td>
+
                 <!-- 列表操作按钮内 -->
                 <td nzAlign="center" nzRight="0px" style="width: 10%;">
-                  <a href="javascript:void(0);" (click)="openDetailsComponent(data.id)">{{
-                    'table.view' | translate
-                  }}</a>
+                  <a href="javascript:void(0);" (click)="openDetailsComponent(data.id)">
+                    {{ 'table.view' | translate }}</a
+                  >
                   <nz-divider nzType="vertical"></nz-divider>
                   <nz-dropdown>
                     <a nz-dropdown>&nbsp;{{ 'hospital.operation.more' | translate }}<i nz-icon type="down"></i> </a>
                     <ul nz-menu nzSelectable>
                       <li nz-menu-item>
-                        <a href="javascript:void(0);" (click)="editPersonnel(data.id)">{{
-                          'table.update' | translate
-                        }}</a>
+                        <a href="javascript:void(0);" (click)="editPersonnel(data.id)">
+                          {{ 'table.update' | translate }}</a
+                        >
                       </li>
                       <li nz-menu-item>
                         <a

+ 95 - 45
src/app/routes/basedata/material-file/material-file.component.ts

@@ -10,29 +10,36 @@ import {
   NzTreeNode,
 } from 'ng-zorro-antd';
 import { BasedataMaterialFileAddComponent } from './add/add.component';
-import { Page } from 'app/entity/page';
+import { Page } from 'app/entity/page'; //分页
 import { BaseMaterialFileClassification } from 'app/entity/basedata/base-material-file-classification';
 import { BaseMaterialFileClassificationService } from 'app/services/basedata/base-material-file-classification.service';
 import { BaseMaterialFileProductService } from 'app/services/basedata/base-material-file-product.service';
 import { SFSchema } from '@delon/form';
 import { messageShared } from '@shared/utils/message';
 import { I18NService } from '@core';
+import { BasedataMaterialFileProductAddComponent } from './product-add/product-add.component';
+import { BaseMaterialFileProduct } from 'app/entity/basedata/base-material-file-product';
 
 @Component({
   selector: 'app-basedata-material-file',
   templateUrl: './material-file.component.html',
 })
 export class BasedataMaterialFileComponent implements OnInit {
+  baseMaterialFileClassification: BaseMaterialFileClassification; //  物料档案分类 对象
+  baseMaterialFileProduct: BaseMaterialFileProduct; //物料产品 对象
   activedNode: NzTreeNode;
   dropdown: NzDropdownContextComponent;
+  isSpinning = false;
+
   searchValue = ''; //搜索框值
   materialNodes: any; //物料分类 数据
   materialId = ''; //物料分类 id
-  page: Page; //  物料档案分类 对象
-  baseMaterialFileClassification: BaseMaterialFileClassification;
-  product: any; //产品对象
-  isSpinning = false;
-  proListData = []; //产品数据
+  page: Page; //分页对象
+
+  proTable = []; //产品数据
+  proObj: any; //产品对象
+  proId = ''; //点击产品id
+
   productPage = {
     total: 0,
     current: 0,
@@ -48,85 +55,104 @@ export class BasedataMaterialFileComponent implements OnInit {
   ) {}
 
   ngOnInit() {
-    this.getProductList(); // 产品数据
-    this.getMaterialTree(); //物料分类树
-
     // 物料分类
     this.baseMaterialFileClassification = {
       id: '',
       code: '',
       name: '',
       parentId: '',
+      pkOrg: '',
       sort: 0,
       key: '', //用于tree id
       title: '', //name
       isLeaf: false, //是否尾端true/false
       children: [], //子集
     };
-
-    // 页码
-    this.page = {
-      pageNo: 0, //当前页码
-      pageSize: 6, //当前页显示的条数
+    this.baseMaterialFileProduct = {
+      id: '',
+      code: '',
+      name: '',
+      pkOrg: '',
+      sort: 0,
+      status: '',
+      attribute: '',
+      baseMaterialFileClassificationId: '',
+      /**模块子表数据*/
+      // baseMaterialFileModularList?:BaseMaterialFileModular[];
     };
-
-    //产品
-    this.product = {
+    //产品 对象
+    this.proObj = {
+      id: '',
       code: '',
       name: '',
       pkOrg: '',
-      pageNo: 0,
+      sort: 0,
+      status: '',
+      attribute: '',
+      baseMaterialFileClassificationId: '',
+      // baseMaterialFileModularList?:BaseMaterialFileModular[]; //模块子表数据
     };
+    // 页码
+    this.page = {
+      pageNo: 0, //当前页码
+      pageSize: 6, //当前页显示的条数
+    };
+    this.getMaterialTree(); //物料分类树
+    this.getProductList(); // 产品数据
   }
   //查询 物料分类 树
   getMaterialTree() {
     let baseMaterialFileClassification = new BaseMaterialFileClassification();
     baseMaterialFileClassification.pkOrg = sessionStorage.getItem('pkOrg'); //组织
     this.baseMaterialFileClassificationService.getTreeList(baseMaterialFileClassification).then(res => {
-      console.log('物料分类 树', res);
       this.materialNodes = res.result;
-      console.log('materialNodes', this.materialNodes);
+      console.log('物料分类 树', this.materialNodes);
     });
   }
-
-  //查询按钮
+  //右侧查询按钮
   query() {
-    this.product.pageNo = 1;
-    this.getProductList();
+    this.proObj.pageNo = 1;
+    this.getProductList(); //所有产品
   }
-  //查询全部产品
+
+  //查询产品 列表
   getProductList() {
-    this.isSpinning = true;
-    this.baseMaterialFileProductService.list(this.product).then(reponse => {
-      this.proListData = reponse.result.records;
-      this.productPage = reponse.result;
-      // console.log(' this.productPage:', this.productPage);
-      this.isSpinning = false;
+    return new Promise(resolve => {
+      this.isSpinning = true;
+      let baseMaterialFileProduct = new BaseMaterialFileProduct();
+      baseMaterialFileProduct.pkOrg = sessionStorage.getItem('pkOrg'); //组织
+      this.baseMaterialFileProductService.list(this.proObj).then(res => {
+        console.log('产品列表接口返回数据', res);
+        this.proTable = res.result.records;
+        this.productPage = res.result;
+        console.log('产品', this.proTable);
+        this.isSpinning = false;
+      });
     });
   }
 
-  //添加一级、右键添加分类分类、修改
+  //添加、修改一级(涵右键) ( 对话框 add )
   addMaterial(isOne: number) {
     var title = '';
     if (isOne == 0) {
       //新增一级
       this.materialId = '';
-      title = document.getElementById('materialTitAdd').textContent;
+      title = document.getElementById('titleAdd').textContent;
     } else if (isOne == 1) {
       //新增 某分级 下的产品
-      title = document.getElementById('materialTitAdd').textContent;
+      title = document.getElementById('titleAdd').textContent;
     } else {
       //修改
-      title = document.getElementById('materialTitUpdate').textContent;
+      title = document.getElementById('titleUpdate').textContent;
     }
-    //打开弹框
+    //分类 弹框
     const modalRef = this.modalService.create({
       nzTitle: title,
       nzContent: BasedataMaterialFileAddComponent,
       nzWidth: 800,
       //对话框传参
       nzComponentParams: {
-        isOne: isOne,
+        isOne: isOne, //判断修改 or 新增
         materialId: this.materialId, //物料分类id
       },
       nzFooter: [
@@ -149,21 +175,50 @@ export class BasedataMaterialFileComponent implements OnInit {
       ],
     });
   }
+  //新增产品 /修改  ( 抽屉 product-add)
+  addProduct(id) {
+    var title = '';
+    //判断是抽屉标题是 新增 还是 修改
+    if (id) {
+      title = document.getElementById('proTitUpdate').textContent;
+    } else {
+      this.proId = '';
+      title = document.getElementById('proTitAdd').textContent;
+    }
+
+    //产品 抽屉
+    const drawerAddPro = this.drawerService.create<BasedataMaterialFileProductAddComponent, { proId: string }, string>({
+      nzTitle: title,
+      nzWidth: 1200,
+      nzContent: BasedataMaterialFileProductAddComponent,
+      nzContentParams: {
+        proId: this.proId, //物料分类id
+      },
+    });
+    //回调 添加完关闭抽屉
+    drawerAddPro.afterClose.subscribe(clo => {
+      if (clo) {
+        //判断是否刷新树列表数据
+        this.getMaterialTree();
+        this.getProductList();
+      }
+    });
+  }
   //按页码查询
   pageIndexChange(event) {
     // var page = new Page();
     // page.pageNo = event;//当前页
     // this.personnelService.getAllPersonnel(page).then((reponse) => {
-    //   this.proListData = reponse.result.records;
+    //   this.proTable = reponse.result.records;
     //   this.page = reponse.result
     // })
-    this.product.pageNo = event;
+    this.proObj.pageNo = event;
     this.getProductList();
   }
 
   //重置
   rest() {
-    this.baseMaterialFileClassification = {}; //清空 物料对象
+    this.proObj = {}; //清空 物料对象
   }
   //树节点点击事件
   treeClick(event) {
@@ -190,8 +245,6 @@ export class BasedataMaterialFileComponent implements OnInit {
       const node = data.node;
       if (node) {
         node.isExpanded = !node.isExpanded;
-        // console.log('11', node);
-        // console.log('22', node.isExpanded);
       }
     }
   }
@@ -202,9 +255,6 @@ export class BasedataMaterialFileComponent implements OnInit {
     this.dropdown = this.nzDropdownService.create($event, template);
     // console.log('右击对象', this.dropdown);
   }
-
-  //修改产品
-  editProduct() {}
   //右击删除
   delMaterial() {
     this.baseMaterialFileClassificationService.delete(this.materialId).then(response => {

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

@@ -0,0 +1,9 @@
+<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>

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

@@ -0,0 +1,24 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { BasedataMaterialFileModuleAddComponent } from './module-add.component';
+
+describe('BasedataMaterialFileModuleAddComponent', () => {
+  let component: BasedataMaterialFileModuleAddComponent;
+  let fixture: ComponentFixture<BasedataMaterialFileModuleAddComponent>;
+
+  beforeEach(async(() => {
+    TestBed.configureTestingModule({
+      declarations: [ BasedataMaterialFileModuleAddComponent ]
+    })
+    .compileComponents();
+  }));
+
+  beforeEach(() => {
+    fixture = TestBed.createComponent(BasedataMaterialFileModuleAddComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  });
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 45 - 0
src/app/routes/basedata/material-file/module-add/module-add.component.ts

@@ -0,0 +1,45 @@
+import { Component, OnInit, ViewChild } from '@angular/core';
+import { _HttpClient, ModalHelper } from '@delon/theme';
+import { STColumn, STComponent } from '@delon/abc';
+import { SFSchema } from '@delon/form';
+
+@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' },
+      ]
+    }
+  ];
+
+  constructor(private http: _HttpClient, private modal: ModalHelper) { }
+
+  ngOnInit() { }
+
+  add() {
+    // this.modal
+    //   .createStatic(FormEditComponent, { i: { id: 0 } })
+    //   .subscribe(() => this.st.reload());
+  }
+
+}

+ 120 - 0
src/app/routes/basedata/material-file/product-add/product-add.component.html

@@ -0,0 +1,120 @@
+<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-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-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-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></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>
+</form>

+ 24 - 0
src/app/routes/basedata/material-file/product-add/product-add.component.spec.ts

@@ -0,0 +1,24 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { BasedataMaterialFileProductAddComponent } from './product-add.component';
+
+describe('BasedataMaterialFileProductAddComponent', () => {
+  let component: BasedataMaterialFileProductAddComponent;
+  let fixture: ComponentFixture<BasedataMaterialFileProductAddComponent>;
+
+  beforeEach(async(() => {
+    TestBed.configureTestingModule({
+      declarations: [ BasedataMaterialFileProductAddComponent ]
+    })
+    .compileComponents();
+  }));
+
+  beforeEach(() => {
+    fixture = TestBed.createComponent(BasedataMaterialFileProductAddComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  });
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 155 - 0
src/app/routes/basedata/material-file/product-add/product-add.component.ts

@@ -0,0 +1,155 @@
+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';
+import { BaseMaterialFileClassificationService } from 'app/services/basedata/base-material-file-classification.service';
+import { BaseMaterialFileProductService } from 'app/services/basedata/base-material-file-product.service';
+import { FormBuilder, Validators, FormGroup } from '@angular/forms';
+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';
+
+@Component({
+  selector: 'app-basedata-material-file-product-add',
+  templateUrl: './product-add.component.html',
+})
+export class BasedataMaterialFileProductAddComponent implements OnInit {
+  isOne = 0; //标题
+  page: Page; //分页对象
+  baseMaterialFileClassification: BaseMaterialFileClassification; //  物料档案分类 对象
+  baseMaterialFileProduct: BaseMaterialFileProduct = {
+    // //产品 对象
+    // code: '',
+    // name: '',
+    // pkorg: '',
+    // // sort: '',
+    // status: '',
+    // attribute: '',
+    // baseMaterialFileClassificationId: '',
+    // baseMaterialFileModularList: [], //子表模块  todo
+  };
+  aa = {
+    code: '',
+    name: '',
+    pkorg: '',
+    sort: '',
+    status: '',
+    attribute: '',
+    baseMaterialFileClassificationId: '',
+    // baseMaterialFileModularList: [], //子表模块  todo
+  };
+  proTable = []; //产品数据
+  productPage = {
+    total: 0,
+    current: 0,
+  };
+  materialTree: any = []; //物料分类 (树)
+  validateForm!: FormGroup;
+  constructor(
+    private baseMaterialFileProductService: BaseMaterialFileProductService,
+    private baseMaterialFileClassificationService: BaseMaterialFileClassificationService,
+    private fb: FormBuilder,
+    private i18NService: I18NService,
+    private notification: NzNotificationService,
+    private nzNotificationService: NzNotificationService,
+    private nzDrawerRef: NzDrawerRef, //抽屉
+  ) {}
+
+  ngOnInit() {
+    //初始化表单
+    this.validateForm = this.fb.group({
+      code: [null, [Validators.required]],
+      name: [null, [Validators.required]],
+      sort: ['number', [Validators.required]], //数字输入框
+      status: [null, [Validators.required]],
+      attribute: [null, [Validators.required]],
+      baseMaterialFileClassificationId: [null, [Validators.required]], //物料分类id
+    });
+    this.getMaterialTree(); //物料分类  树
+    this.getProductList(); //产品 列表
+  }
+
+  //查询 物料分类 树
+  getMaterialTree() {
+    let baseMaterialFileClassification = new BaseMaterialFileClassification();
+    baseMaterialFileClassification.pkOrg = sessionStorage.getItem('pkOrg'); //组织
+    this.baseMaterialFileClassificationService.getTreeList(baseMaterialFileClassification).then(res => {
+      this.materialTree = res.result;
+      console.log('物料分类 树', this.materialTree);
+    });
+  }
+  //查询产品 列表
+  getProductList() {
+    return new Promise(resolve => {
+      var page = new Page();
+      page.pageSize = 500;
+      this.baseMaterialFileProductService.list(page).then(response => {
+        this.proTable = response.result.records;
+      });
+    });
+  }
+
+  // 产品 报错(新增/修改)
+  proSubForm() {
+    //根据标题判断 新增 or 修改
+    if (this.isOne == 2) {
+      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 {
+      //新增
+      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'), '');
+            }
+          });
+        }
+      });
+    }
+  }
+  //树自带方法
+  materialChange() {}
+  // 保存
+  save(value: any) {
+    this.proSubForm();
+  }
+
+  //关闭
+  close() {
+    this.nzDrawerRef.close(false); //关闭抽屉是否刷新列表
+  }
+}

+ 6 - 1
src/assets/tmp/i18n/zh-CN.json

@@ -1860,6 +1860,11 @@
   "date": "时间",
   "product": "产品",
   "material.classification":"物料分类",
-  "material.classification.name":"物料分类名称"
+  "material.classification.name":"物料分类名称",
+  "enabled.not":"未启用",
+  "enabled":"启用",
+  "procurement":"采购",
+  "sales":"销售"
+  
 
 }