|
@@ -23,9 +23,9 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
|
|
|
baseMaterialFileProduct: BaseMaterialFileProduct = {};
|
|
|
baseMaterialFileModular: BaseMaterialFileModular = {};
|
|
|
|
|
|
- isOne = 0;
|
|
|
+ isOne = 0;
|
|
|
page: Page = {};
|
|
|
- materialId: string = '';
|
|
|
+ materialId: string = '';
|
|
|
|
|
|
proTable = [];
|
|
|
productPage = {
|
|
@@ -35,11 +35,11 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
|
|
|
materialTree: any = [];
|
|
|
validateForm!: FormGroup;
|
|
|
modData: any = [];
|
|
|
-
|
|
|
+
|
|
|
id: string = '';
|
|
|
clickProObj: {};
|
|
|
sort = 1;
|
|
|
- status = false;
|
|
|
+ status = true;
|
|
|
|
|
|
formatterDollar = (value: number) => {
|
|
|
if (value) {
|
|
@@ -48,7 +48,6 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
|
|
|
return `$ `;
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
parserDollar = (value: string) => value.replace('$ ', '');
|
|
|
|
|
|
constructor(
|
|
@@ -67,37 +66,35 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
|
|
|
this.validateForm = this.fb.group({
|
|
|
code: [null, [Validators.required]],
|
|
|
name: [null, [Validators.required]],
|
|
|
- sort: ['number', [Validators.required]],
|
|
|
+ sort: ['number', [Validators.required]],
|
|
|
status: [],
|
|
|
attribute: [null, [Validators.required]],
|
|
|
- baseMaterialFileClassificationId: [null, [Validators.required]],
|
|
|
+ baseMaterialFileClassificationId: [null, [Validators.required]],
|
|
|
});
|
|
|
|
|
|
this.baseMaterialFileProduct.baseMaterialFileClassificationId = this.materialId;
|
|
|
- this.getMaterialTree();
|
|
|
+ this.getMaterialTree();
|
|
|
this.getProductList();
|
|
|
|
|
|
- this.baseMaterialFileProduct.id = this.id;
|
|
|
-
|
|
|
- if (!this.id) {
|
|
|
- } else {
|
|
|
-
|
|
|
+ this.baseMaterialFileProduct.id = this.id;
|
|
|
+
|
|
|
+ if (this.baseMaterialFileProduct.id) {
|
|
|
return new Promise(resolve => {
|
|
|
this.baseMaterialFileProduct.pkOrg = sessionStorage.getItem('pkOrg');
|
|
|
this.baseMaterialFileProductService.queryMainAndChildById(this.baseMaterialFileProduct.id).then(res => {
|
|
|
this.baseMaterialFileProduct = res.result;
|
|
|
console.log('点击的产品数据', this.baseMaterialFileProduct);
|
|
|
+
|
|
|
if (this.baseMaterialFileProduct.status == '0') {
|
|
|
this.status = false;
|
|
|
} else {
|
|
|
this.status = true;
|
|
|
}
|
|
|
-
|
|
|
this.baseMaterialFileProduct.status = this.baseMaterialFileProduct.status + '';
|
|
|
if (this.baseMaterialFileProduct.baseMaterialFileModularList) {
|
|
|
|
|
|
|
|
|
- this.modData = this.baseMaterialFileProduct.baseMaterialFileModularList;
|
|
|
+ this.modData = this.baseMaterialFileProduct.baseMaterialFileModularList;
|
|
|
this.sort = this.modData.length + 1;
|
|
|
}
|
|
|
console.log('模块列表', this.baseMaterialFileProduct.baseMaterialFileModularList);
|
|
@@ -106,41 +103,19 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- getMaterialTree() {
|
|
|
- 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();
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- getProductList() {
|
|
|
- return new Promise(resolve => {
|
|
|
- var page = new Page();
|
|
|
- page.pageSize = 500;
|
|
|
- this.baseMaterialFileProductService.list(page).then(response => {
|
|
|
- this.proTable = response.result.records;
|
|
|
- resolve();
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
|
|
|
|
|
|
proSubForm() {
|
|
|
if (this.status) {
|
|
|
- this.baseMaterialFileProduct.status = '0';
|
|
|
- } else {
|
|
|
+
|
|
|
this.baseMaterialFileProduct.status = '1';
|
|
|
+ console.log('what');
|
|
|
+ } else {
|
|
|
+ this.baseMaterialFileProduct.status = '0';
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (this.id == '') {
|
|
|
- console.log('空', this.baseMaterialFileProduct);
|
|
|
-
|
|
|
+ console.log('新增产品', this.baseMaterialFileProduct);
|
|
|
return new Promise(resolve => {
|
|
|
for (const i in this.validateForm.controls) {
|
|
|
this.validateForm.controls[i].markAsDirty();
|
|
@@ -148,16 +123,16 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
|
|
|
}
|
|
|
let valid = this.validateForm.valid;
|
|
|
if (valid) {
|
|
|
- console.log('valid有效--->', valid);
|
|
|
- this.baseMaterialFileProduct.pkOrg = sessionStorage.getItem('pkOrg');
|
|
|
+
|
|
|
+ this.baseMaterialFileProduct.pkOrg = sessionStorage.getItem('pkOrg');
|
|
|
|
|
|
this.baseMaterialFileProduct.baseMaterialFileModularList = this.modData;
|
|
|
- console.log('----->', this.baseMaterialFileProduct.baseMaterialFileModularList);
|
|
|
+ console.log('新增保存的模块列表', this.baseMaterialFileProduct.baseMaterialFileModularList);
|
|
|
this.baseMaterialFileProductService.saveMainAndChild(this.baseMaterialFileProduct).then(res => {
|
|
|
if (res.success) {
|
|
|
- console.log('out', res);
|
|
|
+
|
|
|
this.baseMaterialFileProduct = res.result;
|
|
|
- console.log('产品对象>>>>', this.baseMaterialFileProduct);
|
|
|
+ console.log('新增的产品对象>>', this.baseMaterialFileProduct);
|
|
|
this.getProductList();
|
|
|
this.nzNotificationService.success(this.i18NService.fanyi('save.ok'), '');
|
|
|
this.nzDrawerRef.close(true);
|
|
@@ -170,14 +145,16 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
|
|
|
});
|
|
|
} else {
|
|
|
|
|
|
- return new Promise(resolve => {
|
|
|
- this.baseMaterialFileProduct.pkOrg = sessionStorage.getItem('pkOrg');
|
|
|
+ this.baseMaterialFileProduct.pkOrg = sessionStorage.getItem('pkOrg');
|
|
|
+ if (this.modData) {
|
|
|
this.baseMaterialFileProduct.baseMaterialFileModularList = this.modData;
|
|
|
-
|
|
|
+ }
|
|
|
+ return new Promise(resolve => {
|
|
|
this.baseMaterialFileProductService.updateMainAndChild(this.baseMaterialFileProduct).then(res => {
|
|
|
if (res.success) {
|
|
|
-
|
|
|
this.clickProObj = res.result;
|
|
|
+ console.log('this.clickProObj', this.clickProObj);
|
|
|
+ console.log('this.baseMaterialFileProduct', this.baseMaterialFileProduct);
|
|
|
this.notification.success(this.i18NService.fanyi('successful.revision'), '');
|
|
|
this.getProductList();
|
|
|
this.nzDrawerRef.close(true);
|
|
@@ -192,6 +169,29 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ getMaterialTree() {
|
|
|
+ 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();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ getProductList() {
|
|
|
+ return new Promise(resolve => {
|
|
|
+ var page = new Page();
|
|
|
+ page.pageSize = 500;
|
|
|
+ this.baseMaterialFileProductService.list(page).then(response => {
|
|
|
+ this.proTable = response.result.records;
|
|
|
+ resolve();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
|
|
|
addRowMod() {
|
|
@@ -209,8 +209,7 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
deleteMod(data) {
|
|
|
- console.log('模块数据', this.modData);
|
|
|
-
|
|
|
+
|
|
|
|
|
|
this.modData = this.modData.filter(d => d.sort !== data.sort);
|
|
|
}
|