|
@@ -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() {}
|
|
|
// 保存
|