Переглянути джерело

【产品】 列表完成

liangyan0105 3 роки тому
батько
коміт
744b968724

+ 26 - 27
src/app/routes/basedata/basedata-routing.module.ts

@@ -21,23 +21,21 @@ import { BasedataSleepTypeComponent } from './sleep-type/sleep-type.component';
 import { BasedataUnitSizeComponent } from './unit-size/unit-size.component';
 import { BasedataCustomerRelationshipComponent } from './customer-relationship/customer-relationship.component';
 import { BasedataValueLevelComponent } from './value-level/value-level.component';
-import { BasedataMerchantsIndustryComponent } from './merchants-industry/merchants-industry.component';
-import { BasedataMerchantsIndustryAddComponent } from './merchants-industry/add/add.component';
-import { BasedataPersonnelSizeComponent } from './personnel-size/personnel-size.component';
-import { BasedataRegisteredCapitalComponent } from './registered-capital/registered-capital.component';
-import { BasedataSalesStatusComponent } from './sales-status/sales-status.component';
-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 { BasedataMaterialFileProductAddComponent } from './material-file/product-add/product-add.component';
-import { BasedataMaterialFileModuleAddComponent } from './material-file/module-add/module-add.component';
-
+import { BasedataMerchantsIndustryComponent } from './merchants-industry/merchants-industry.component';
+import { BasedataMerchantsIndustryAddComponent } from './merchants-industry/add/add.component';
+import { BasedataPersonnelSizeComponent } from './personnel-size/personnel-size.component';
+import { BasedataRegisteredCapitalComponent } from './registered-capital/registered-capital.component';
+import { BasedataSalesStatusComponent } from './sales-status/sales-status.component';
+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 { BasedataMaterialFileProductAddComponent } from './material-file/product-add/product-add.component';
 
 const routes: Routes = [
   { path: 'customer', component: BasedataCustomerComponent },
   { path: 'customerAdd', component: BasedataCustomerCustomerAddComponent },
-  { path: "material", component: BasedataMaterialComponent },
+  { path: 'material', component: BasedataMaterialComponent },
   { path: 'details', component: BasedataCustomerDetailsComponent },
   { path: 'post', component: BasedataPostComponent },
   { path: 'project-approval', component: BasedataProjectApprovalComponent },
@@ -45,7 +43,8 @@ const routes: Routes = [
   { path: 'base-archives-collection-line', component: BasedataBaseArchivesCollectionLineComponent },
   { path: 'base-archives-cost', component: BasedataBaseArchivesCostComponent },
   { path: 'milestone-category', component: BasedataMilestoneCategoryComponent },
-  { path: 'test', component: BasedataTestComponent },{path:'test/add',component:TestAddComponent},
+  { path: 'test', component: BasedataTestComponent },
+  { path: 'test/add', component: TestAddComponent },
   { path: 'customer-classification', component: BasedataCustomerClassificationComponent },
   { path: 'information-sources', component: BasedataInformationSourcesComponent },
   { path: 'business-relations', component: BasedataBusinessRelationsComponent },
@@ -54,19 +53,19 @@ const routes: Routes = [
   { path: 'unit-size', component: BasedataUnitSizeComponent },
   { path: 'customer-relationship', component: BasedataCustomerRelationshipComponent },
   { path: 'value-level', component: BasedataValueLevelComponent },
-  { path: 'merchants-industry', component: BasedataMerchantsIndustryComponent },
-  { path: 'add', component: BasedataMerchantsIndustryAddComponent },
-  { path: 'personnel-size', component: BasedataPersonnelSizeComponent },
-  { path: 'registered-capital', component: BasedataRegisteredCapitalComponent },
-  { path: 'sales-status', component: BasedataSalesStatusComponent },
-  { path: 'add', component: BasedataSalesStatusAddComponent },
-  { path: 'modalTable', component: BasedataCustomerModalTableComponent },
-  { path: 'material-file', component: BasedataMaterialFileComponent },
-  { path: 'add', component: BasedataMaterialFileAddComponent },
-  { path: 'productAdd', component: BasedataMaterialFileProductAddComponent },
-  { path: 'module-add', component: BasedataMaterialFileModuleAddComponent }];
+  { path: 'merchants-industry', component: BasedataMerchantsIndustryComponent },
+  { path: 'add', component: BasedataMerchantsIndustryAddComponent },
+  { path: 'personnel-size', component: BasedataPersonnelSizeComponent },
+  { path: 'registered-capital', component: BasedataRegisteredCapitalComponent },
+  { path: 'sales-status', component: BasedataSalesStatusComponent },
+  { path: 'add', component: BasedataSalesStatusAddComponent },
+  { path: 'modalTable', component: BasedataCustomerModalTableComponent },
+  { path: 'material-file', component: BasedataMaterialFileComponent },
+  { path: 'add', component: BasedataMaterialFileAddComponent },
+  { path: 'productAdd', component: BasedataMaterialFileProductAddComponent },
+];
 @NgModule({
   imports: [RouterModule.forChild(routes)],
-  exports: [RouterModule]
+  exports: [RouterModule],
 })
-export class BasedataRoutingModule { }
+export class BasedataRoutingModule {}

+ 32 - 38
src/app/routes/basedata/basedata.module.ts

@@ -33,32 +33,30 @@ import { BasedataSleepTypeComponent } from './sleep-type/sleep-type.component';
 import { BasedataUnitSizeComponent } from './unit-size/unit-size.component';
 import { BasedataCustomerRelationshipComponent } from './customer-relationship/customer-relationship.component';
 import { BasedataValueLevelComponent } from './value-level/value-level.component';
-import { BasedataMerchantsIndustryComponent } from './merchants-industry/merchants-industry.component';
-import { BasedataMerchantsIndustryAddComponent } from './merchants-industry/add/add.component';
-import { BasedataPersonnelSizeComponent } from './personnel-size/personnel-size.component';
-import { BasedataRegisteredCapitalComponent } from './registered-capital/registered-capital.component';
-import { BasedataSalesStatusComponent } from './sales-status/sales-status.component';
-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 { BasedataMaterialFileProductAddComponent } from './material-file/product-add/product-add.component';
-import { BasedataMaterialFileModuleAddComponent } from './material-file/module-add/module-add.component';
-
+import { BasedataMerchantsIndustryComponent } from './merchants-industry/merchants-industry.component';
+import { BasedataMerchantsIndustryAddComponent } from './merchants-industry/add/add.component';
+import { BasedataPersonnelSizeComponent } from './personnel-size/personnel-size.component';
+import { BasedataRegisteredCapitalComponent } from './registered-capital/registered-capital.component';
+import { BasedataSalesStatusComponent } from './sales-status/sales-status.component';
+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 { BasedataMaterialFileProductAddComponent } from './material-file/product-add/product-add.component';
 
 const COMPONENTS = [
   BasedataCustomerComponent,
   BasedataCustomerCustomerAddComponent,
   BasedataMaterialComponent,
   BasedataCustomerDetailsComponent,
-  BasedataPostComponent
-  ,
+  BasedataPostComponent,
   BasedataProjectApprovalComponent,
   BasedataBaseArchivesMilestoneComponent,
   BasedataBaseArchivesCollectionLineComponent,
   BasedataBaseArchivesCostComponent,
   BasedataMilestoneCategoryComponent,
-  BasedataTestComponent,TestAddComponent,
+  BasedataTestComponent,
+  TestAddComponent,
   BasedataCustomerClassificationComponent,
   BasedataInformationSourcesComponent,
   BasedataBusinessRelationsComponent,
@@ -67,18 +65,19 @@ const COMPONENTS = [
   BasedataUnitSizeComponent,
   BasedataCustomerRelationshipComponent,
   BasedataValueLevelComponent,
-  BasedataMerchantsIndustryComponent,
-  BasedataMerchantsIndustryAddComponent,
-  BasedataPersonnelSizeComponent,
-  BasedataRegisteredCapitalComponent,
-  BasedataSalesStatusComponent,
-  BasedataSalesStatusAddComponent,
-  BasedataCustomerModalTableComponent,
-  BasedataMaterialFileComponent,
-  BasedataMaterialFileAddComponent,
-  BasedataMaterialFileProductAddComponent,
-  BasedataMaterialFileModuleAddComponent];
-const COMPONENTS_NOROUNT = [BasedataCustomerEditComponent,
+  BasedataMerchantsIndustryComponent,
+  BasedataMerchantsIndustryAddComponent,
+  BasedataPersonnelSizeComponent,
+  BasedataRegisteredCapitalComponent,
+  BasedataSalesStatusComponent,
+  BasedataSalesStatusAddComponent,
+  BasedataCustomerModalTableComponent,
+  BasedataMaterialFileComponent,
+  BasedataMaterialFileAddComponent,
+  BasedataMaterialFileProductAddComponent,
+];
+const COMPONENTS_NOROUNT = [
+  BasedataCustomerEditComponent,
   BasedataCustomerIsAbbreviationComponent,
   BasedataPostAddComponent,
   BasedataProjectApprovalAddComponent,
@@ -87,17 +86,12 @@ const COMPONENTS_NOROUNT = [BasedataCustomerEditComponent,
   BasedataBaseArchivesCostAddComponent,
   BasedataMilestoneCategoryEditComponent,
   BasedataBaseArchivesCollectionLineViewComponent,
-  BasedataBaseArchivesCostViewComponent];
+  BasedataBaseArchivesCostViewComponent,
+];
 
 @NgModule({
-  imports: [
-    SharedModule,
-    BasedataRoutingModule,
-  ],
-  declarations: [
-    ...COMPONENTS,
-    ...COMPONENTS_NOROUNT,
-  ],
-  entryComponents: COMPONENTS_NOROUNT
+  imports: [SharedModule, BasedataRoutingModule],
+  declarations: [...COMPONENTS, ...COMPONENTS_NOROUNT],
+  entryComponents: COMPONENTS_NOROUNT,
 })
-export class BasedataModule { }
+export class BasedataModule {}

+ 4 - 10
src/app/routes/basedata/material-file/add/add.component.ts

@@ -17,14 +17,7 @@ export class BasedataMaterialFileAddComponent implements OnInit {
   @Input() isOne = 0; //标题
   @Input() materialId = ''; //分类id
 
-  //初始化 物料分类对象  里面内容不写也可
-  baseMaterialFileClassification: BaseMaterialFileClassification = {
-    id: '',
-    code: '',
-    name: '',
-    parentId: '',
-    // sort:'number',
-  };
+  baseMaterialFileClassification: BaseMaterialFileClassification = {}; //物料分类对象
 
   validateForm!: FormGroup;
   sort: '';
@@ -62,7 +55,7 @@ export class BasedataMaterialFileAddComponent implements OnInit {
       this.baseMaterialFileClassification = res.result;
     });
   }
-  //弹框 确定按钮
+  //物料分类 新增 修改 确定按钮
   submitForm() {
     //根据标题判断 新增 or 修改
     if (this.isOne == 2) {
@@ -78,9 +71,9 @@ export class BasedataMaterialFileAddComponent implements OnInit {
               messageShared(this.i18NService, res.message),
             );
           }
+          resolve();
         });
       });
-      // resolve();
     } else {
       //新增
       return new Promise(resolve => {
@@ -97,6 +90,7 @@ export class BasedataMaterialFileAddComponent implements OnInit {
               //保存成功
               this.nzNotificationService.success(this.i18NService.fanyi('save.ok'), '');
               console.log('>>>>', this.baseMaterialFileClassification);
+
               this.modal.destroy();
               resolve();
             } else {

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

@@ -54,8 +54,6 @@
             (nzClick)="treeClick($event)"
             (nzDblClick)="openFolder($event)"
           >
-            <!-- 树 动态数据 -->
-
             <!-- 右击 树节点  下拉菜单 4个按钮 -->
             <ng-template #contextTemplate>
               <ul nz-menu nzInDropDown>
@@ -63,12 +61,14 @@
                   {{ 'button.add' | translate }}{{ 'material.classification' | translate }}
                 </li>
                 <li nz-menu-item (click)="addMaterial(2)">
-                  {{ 'table.update' | translate }}{{ 'material.classification' | translate }}
+                  {{ 'table.update' | translate }}
                 </li>
                 <li nz-menu-item (click)="delMaterial()">
-                  {{ 'table.delete' | translate }}{{ 'material.classification' | translate }}
+                  {{ 'table.delete' | translate }}
+                </li>
+                <li nz-menu-item (click)="addProduct(e)">
+                  {{ 'button.add' | translate }}{{ 'product' | 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>
@@ -93,19 +93,19 @@
   <div nz-col nzMd="24" nzLg="18">
     <nz-card>
       <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)]="proObj.code" name="code" />
+            <input nz-input [(ngModel)]="baseMaterialFileProduct.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)]="proObj.name" name="name" />
+            <input nz-input [(ngModel)]="baseMaterialFileProduct.name" name="name" />
           </div>
           <!-- 列表查询重置 -->
           <div nz-col nzMd="24" nzLg="6">

+ 34 - 83
src/app/routes/basedata/material-file/material-file.component.ts

@@ -34,17 +34,13 @@ export class BasedataMaterialFileComponent implements OnInit {
   searchValue = ''; //搜索框值
   materialNodes: any; //物料分类 数据
   materialId = ''; //物料分类 id
-  // materialname = ''; //物料分类 名  传值用
+
   page: Page; //分页对象
 
   proTable = []; //产品数据
-  proObj: any = {}; //产品对象
+
   proId = ''; //点击产品id
 
-  productPage = {
-    total: 0,
-    current: 0,
-  };
   constructor(
     private drawerService: NzDrawerService,
     private baseMaterialFileClassificationService: BaseMaterialFileClassificationService,
@@ -56,47 +52,10 @@ 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.proObj = {
-    //   id: '',
-    //   code: '',
-    //   name: '',
-    //   pkOrg: '',
-    //   sort: 0,
-    //   status: '',
-    //   attribute: '',
-    //   baseMaterialFileClassificationId: '',
-    // baseMaterialFileModularList?:BaseMaterialFileModular[]; //模块子表数据
-    // };
-    // 页码
+    // 初始化显示
     this.page = {
-      pageNo: 0, //当前页码
-      pageSize: 6, //当前页显示的条数
+      pageNo: 1, //当前页码
+      pageSize: 10, //当前页显示的条数
     };
     this.getMaterialTree(); //物料分类树
     this.getProductList(); // 产品数据
@@ -114,30 +73,30 @@ export class BasedataMaterialFileComponent implements OnInit {
       });
     });
   }
-  //右边查询按钮
-  query() {
-    this.proObj.pageNo = 1;
-    this.getProductList(); //所有产品
-  }
 
   //查询产品 列表
   getProductList() {
     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);
+      var page = new Page();
+      page.pageSize = 500;
+      this.baseMaterialFileProduct.pkOrg = sessionStorage.getItem('pkOrg'); //组织
+      // 根据页面绑定的查询条件进行查询
+      this.baseMaterialFileProductService.list(this.baseMaterialFileProduct).then(res => {
+        // console.log(res);
         this.proTable = res.result.records;
-        this.productPage = res.result;
-        console.log('产品', this.proTable);
-        this.isSpinning = false;
-        resolve()
+        console.log('产品列表', this.proTable);
+        resolve();
       });
     });
   }
 
-  //添加、修改一级(涵右键) ( 对话框 add )
+  //右边查询按钮
+  query() {
+    this.baseMaterialFileProduct.pageNo = 1;
+    this.getProductList(); //所有产品
+  }
+
+  //物料分类 新增、修改 (对话框)
   addMaterial(isOne: number) {
     var title = '';
     if (isOne == 0) {
@@ -151,12 +110,11 @@ export class BasedataMaterialFileComponent implements OnInit {
       //修改
       title = document.getElementById('titleUpdate').textContent;
     }
-    //分类 弹框
+    // --------------------------------------------------------------
     const modalRef = this.modalService.create({
       nzTitle: title,
       nzContent: BasedataMaterialFileAddComponent,
       nzWidth: 800,
-      //对话框传参
       nzComponentParams: {
         isOne: isOne, //判断修改 or 新增
         materialId: this.materialId, //物料分类id
@@ -173,15 +131,16 @@ export class BasedataMaterialFileComponent implements OnInit {
           label: '确定',
           type: 'primary',
           onClick: addModel => {
-            addModel.submitForm();
-            this.getMaterialTree();
-            this.getProductList();
+            addModel.submitForm().then(res => {
+              this.getMaterialTree();
+              this.getProductList();
+            });
           },
         },
       ],
     });
   }
-  //新增产品 /修改  ( 抽屉 product-add)
+  //产品 新增、修改 (抽屉)
   addProduct(id, materialId) {
     var title = '';
     //判断是抽屉标题是 新增 还是 修改
@@ -192,7 +151,6 @@ export class BasedataMaterialFileComponent implements OnInit {
       title = document.getElementById('proTitAdd').textContent;
     } else {
       this.proId = '';
-      // this.materialId = '';
       title = document.getElementById('proTitAdd').textContent;
     }
 
@@ -206,7 +164,7 @@ export class BasedataMaterialFileComponent implements OnInit {
       nzContent: BasedataMaterialFileProductAddComponent,
       nzContentParams: {
         proId: this.proId, //产品id
-        materialId: this.materialId, //物料分类id
+        materialId: this.materialId, //物料分类id (给抽屉的回显树)
       },
     });
     //回调 添加完关闭抽屉
@@ -221,9 +179,9 @@ export class BasedataMaterialFileComponent implements OnInit {
   //树节点点击事件
   treeClick(event) {
     // console.log('点击节点的内容', event);
-    var materialObj = event.node.origin; //当前点击的物料对象
+    // var materialObj = event.node.origin; //当前点击的物料对象
     // console.log(materialObj.parentId);
-    //赋值给修改表单
+    //赋值给修改表单   不用接口回显数据
     // this.baseMaterialFileClassification = {
     //   code: materialObj.code,
     //   name: materialObj.name,
@@ -231,27 +189,22 @@ export class BasedataMaterialFileComponent implements OnInit {
     //   sort: materialObj.sort,
     // };
   }
+
   //按页码查询
   pageIndexChange(event) {
-    // var page = new Page();
-    // page.pageNo = event;//当前页
-    // this.personnelService.getAllPersonnel(page).then((reponse) => {
-    //   this.proTable = reponse.result.records;
-    //   this.page = reponse.result
-    // })
-    this.proObj.pageNo = event;
+    console.log('当前页码', event);
+    this.baseMaterialFileProduct.pageNo = event;
     this.getProductList();
   }
 
   //重置
   rest() {
-    this.proObj = {}; //清空 物料对象
+    this.baseMaterialFileProduct = {}; //清空 查询条件
   }
 
   //双击节点自动打开树分支
   openFolder(data: NzTreeNode | Required<NzFormatEmitEvent>): void {
     console.log(data);
-    // do something if u want
     if (data instanceof NzTreeNode) {
       data.isExpanded = !data.isExpanded;
       console.log('00', data);
@@ -266,10 +219,8 @@ export class BasedataMaterialFileComponent implements OnInit {
   //右键树节点
   contextMenu(Fid, event: MouseEvent, template: TemplateRef<void>): void {
     this.materialId = Fid;
-    console.log('...', this.materialId);
-    // console.log('...', template);
+    // console.log('点击项 ID', this.materialId);
     this.dropdown = this.nzDropdownService.create(event, template);
-    // console.log('右击对象', this.dropdown);
   }
   //右击删除
   delMaterial() {

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

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

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

@@ -1,24 +0,0 @@
-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();
-  });
-});

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

@@ -1,37 +0,0 @@
-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 {
-  // baseMaterialFileModular: BaseMaterialFileModular = {
-  //   id: '',
-  //   code: '',
-  //   name: '',
-  //   standardQuotation: 0,
-  //   pkOrg: '',
-  // }; //模块 实体
-  // //模块对象
-  // modObj = {};
-  // //金额格式化 (公司注册资金)
-  // formatterDollar = (value: number) => {
-  //   if (value) {
-  //     return `$ ${value}`;
-  //   } else {
-  //     return `$ `;
-  //   }
-  // };
-
-  parserDollar = (value: string) => value.replace('$ ', '');
-  constructor(private modal: NzModalRef) {}
-
-  ngOnInit() {}
-  addRowMod() {}
-}

+ 4 - 7
src/app/routes/basedata/material-file/product-add/product-add.component.html

@@ -100,7 +100,6 @@
           (ngModelChange)="materialChange($event)"
         >
         </nz-tree-select>
-        <!-- </span>  -->
       </nz-form-control>
     </nz-form-item>
   </form>
@@ -143,17 +142,16 @@
               </td>
               <!-- 标准报价 -->
               <td>
-                <input type="text" [(ngModel)]="data.standardQuotation" nz-input maxlength="20" />
+                <!-- <input type="text" [(ngModel)]="data.standardQuotation" nz-input maxlength="20" /> -->
                 <!-- 金额格式 -->
-                <!-- <nz-input-number
+                <nz-input-number
                     [(ngModel)]="data.standardQuotation"
-                    formControlName="standardQuotation"
                     [nzMin]="0"
                     [nzParser]="parserDollar"
                     [nzFormatter]="formatterDollar"
                     [nzMax]="100000000000000000"
                     [nzStep]="10"
-                  ></nz-input-number> -->
+                  ></nz-input-number>
               </td>
               <td nzAlign="center">
                 <a
@@ -161,8 +159,7 @@
                   nzTitle="{{ 'confirm.to.delete' | translate }}?"
                   nzOkText="{{ 'yes' | translate }}"
                   nzCancelText="{{ 'no' | translate }}"
-                  (nzOnConfirm)="deleteMod(data)"
-                >
+                  (nzOnConfirm)="deleteMod(data)">
                   {{ 'table.delete' | translate }}
                 </a>
               </td>

+ 41 - 48
src/app/routes/basedata/material-file/product-add/product-add.component.ts

@@ -19,23 +19,14 @@ import { log } from 'console';
   templateUrl: './product-add.component.html',
 })
 export class BasedataMaterialFileProductAddComponent implements OnInit {
+  // 如果想某对象中的值是死数据,在 ngOnInit 中赋值,此处赋值无效!!!!!!!!
+  baseMaterialFileClassification: BaseMaterialFileClassification; //物料分类 对象
+  baseMaterialFileProduct: BaseMaterialFileProduct = {}; //产品对象
+  baseMaterialFileModular: BaseMaterialFileModular = {}; //模块 对象
+
   isOne = 0; //标题
   page: Page = {}; //分页对象
-  materialId: string = ''; //接收物料id
-  baseMaterialFileClassification: BaseMaterialFileClassification; //  物料分类 对象
-  baseMaterialFileProduct: BaseMaterialFileProduct = {
-    // 产品 对象
-    // code: '',
-    // name: '',
-    // pkorg: '',
-    // // sort: '',
-    // status: '',
-    // attribute: '',
-    // baseMaterialFileClassificationId: this.materialId,
-    // baseMaterialFileModularList: [], //子表模块  todo
-  };
-  baseMaterialFileModular: BaseMaterialFileModular = {}; //模块 对象
-  modObj = {};
+  materialId: string = ''; //接收抽屉的物料id (在产品中回显所属物料分类)
 
   proTable = []; //产品数据
   productPage = {
@@ -44,11 +35,11 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
   };
   materialTree: any = []; //物料分类 (树)
   validateForm!: FormGroup;
-  modData: any = []; // 模块表
+  modData: any = []; // 模块数据
   aa: [];
   id: string; // 模块名称
 
-  //金额格式化 (公司注册资金
+  //金额格式化 (标准报价
   formatterDollar = (value: number) => {
     if (value) {
       return `$ ${value}`;
@@ -71,8 +62,6 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
   ) {}
 
   ngOnInit() {
-    // 接收抽屉参数
-    this.baseMaterialFileProduct.baseMaterialFileClassificationId = this.materialId;
     //初始化表单
     this.validateForm = this.fb.group({
       code: [null, [Validators.required]],
@@ -81,9 +70,9 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
       status: [null, [Validators.required]],
       attribute: [null, [Validators.required]],
       baseMaterialFileClassificationId: [null, [Validators.required]], //物料分类id
-      // standardQuotation:[null, [Validators.required]],
-      // baseMaterialFileModularList: [null, [Validators.required]], //模块子表数据、
     });
+    // 修改 对象中某属性的值,在此处赋值,接收 抽屉的值
+    this.baseMaterialFileProduct.baseMaterialFileClassificationId = this.materialId;
     this.getMaterialTree(); //物料分类  树
     this.getProductList(); //产品 列表
     this.getmodList(); //模块列表
@@ -91,11 +80,14 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
 
   //查询 物料分类 树
   getMaterialTree() {
-    let baseMaterialFileClassification = new BaseMaterialFileClassification();
-    baseMaterialFileClassification.pkOrg = sessionStorage.getItem('pkOrg'); //组织
-    this.baseMaterialFileClassificationService.getTreeList(baseMaterialFileClassification).then(res => {
-      this.materialTree = res.result;
-      console.log('物料分类 树', this.materialTree);
+    return new Promise(resolve => {
+      let baseMaterialFileClassification = new BaseMaterialFileClassification();
+      baseMaterialFileClassification.pkOrg = sessionStorage.getItem('pkOrg'); //组织
+      this.baseMaterialFileClassificationService.getTreeList(baseMaterialFileClassification).then(res => {
+        this.materialTree = res.result;
+        console.log('物料分类 树', this.materialTree);
+        resolve();
+      });
     });
   }
   //查询产品 列表
@@ -105,13 +97,25 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
       page.pageSize = 500;
       this.baseMaterialFileProductService.list(page).then(response => {
         this.proTable = response.result.records;
+        resolve();
+      });
+    });
+  }
+  //模块列表
+  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;
+        console.log('-->modList', this.aa);
+        resolve();
       });
     });
   }
 
   // 产品 保存(新增/修改)
   proSubForm() {
-    console.log('产品最后的保存');
     //根据标题判断 新增 or 修改
     // if (this.isOne == 2) {
     // console.log('000');
@@ -139,31 +143,30 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
         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.baseMaterialFileProduct.baseMaterialFileModularList = this.modData;
         console.log(this.baseMaterialFileProduct.baseMaterialFileModularList);
-
         console.log('走这没');
-        this.baseMaterialFileProductService.add(this.baseMaterialFileProduct).then(res => {
+
+        this.baseMaterialFileProductService.saveMainAndChild(this.baseMaterialFileProduct).then(res => {
           if (res.success) {
             console.log('out', res);
-            this.nzNotificationService.success(this.i18NService.fanyi('save.ok'), '');
+            this.baseMaterialFileProduct = res.result;
             console.log('产品对象>>>>', this.baseMaterialFileProduct);
+            this.getProductList();
+            this.nzNotificationService.success(this.i18NService.fanyi('save.ok'), '');
             this.nzDrawerRef.close(true); //关闭抽屉是否刷新列表
-            resolve();
           } else {
-            //保存失败
             this.nzNotificationService.error(this.i18NService.fanyi('save.not'), '');
           }
         });
+        resolve();
       }
     });
     // }
@@ -185,11 +188,10 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
     ];
     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 {
       //修改客户档案时
@@ -206,16 +208,7 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
       });
     }
   }
-  //模块列表
-  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() {}
   // 保存