|
@@ -12,7 +12,6 @@ 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',
|
|
@@ -36,9 +35,10 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
|
|
|
materialTree: any = []; //物料分类 (树)
|
|
|
validateForm!: FormGroup;
|
|
|
modData: any = []; // 模块列表数据
|
|
|
- aa: [];
|
|
|
- id: string; // 模块名称
|
|
|
-
|
|
|
+ // id: string; // 模块名称
|
|
|
+ id: string = ''; //接收抽屉产品 id
|
|
|
+ clickProObj: {}; //点击的产品对象
|
|
|
+ sort = 1; //默认
|
|
|
//金额格式化 (标准报价)
|
|
|
formatterDollar = (value: number) => {
|
|
|
if (value) {
|
|
@@ -71,13 +71,35 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
|
|
|
attribute: [null, [Validators.required]],
|
|
|
baseMaterialFileClassificationId: [null, [Validators.required]], //物料分类id
|
|
|
});
|
|
|
- // 修改 对象中某属性的值,在此处赋值,接收 抽屉的值
|
|
|
+ // 修改 对象中某属性的值,在此处赋值 (接收 抽屉的值 物料ID)
|
|
|
this.baseMaterialFileProduct.baseMaterialFileClassificationId = this.materialId;
|
|
|
this.getMaterialTree(); //物料分类 树
|
|
|
this.getProductList(); //产品 列表
|
|
|
- this.getmodList(); //模块列表
|
|
|
- }
|
|
|
|
|
|
+ this.baseMaterialFileProduct.id = this.id;
|
|
|
+ //不是修改
|
|
|
+ if (this.baseMaterialFileProduct.id == '') {
|
|
|
+ } else {
|
|
|
+ //修改 查询对应id 产品 回显
|
|
|
+ return new Promise(resolve => {
|
|
|
+ this.baseMaterialFileProduct.pkOrg = sessionStorage.getItem('pkOrg');
|
|
|
+ this.baseMaterialFileProductService.queryMainAndChildById(this.baseMaterialFileProduct.id).then(res => {
|
|
|
+ console.log('所有产品数据', res);
|
|
|
+ let clickProObj = res.result;
|
|
|
+ this.baseMaterialFileProduct = clickProObj;
|
|
|
+ this.baseMaterialFileProduct.status = this.baseMaterialFileProduct.status + '';
|
|
|
+ if (clickProObj.baseMaterialFileModularList) {
|
|
|
+ // 以下这种写法,只在该方法中赋值,其他地方相互不影响
|
|
|
+ // this.modData =JSON.parse(JSON.stringify(clickProObj.baseMaterialFileModularList))
|
|
|
+ this.modData = clickProObj.baseMaterialFileModularList;
|
|
|
+ this.sort = this.modData.length + 1;
|
|
|
+ }
|
|
|
+ console.log('点击的产品对象', this.baseMaterialFileProduct.baseMaterialFileModularList);
|
|
|
+ });
|
|
|
+ resolve();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
//查询 物料分类 树
|
|
|
getMaterialTree() {
|
|
|
return new Promise(resolve => {
|
|
@@ -101,79 +123,64 @@ 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;
|
|
|
- console.log('-->modList', this.aa);
|
|
|
- resolve();
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
|
|
|
// 产品 保存(新增/修改)
|
|
|
proSubForm() {
|
|
|
//根据标题判断 新增 or 修改
|
|
|
- // 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();
|
|
|
- }
|
|
|
- let valid = this.validateForm.valid;
|
|
|
- console.log('111');
|
|
|
- if (valid) {
|
|
|
- console.log('222');
|
|
|
- console.log('valid有效--->', valid);
|
|
|
+ if (this.id == '') {
|
|
|
+ console.log('空', this.baseMaterialFileProduct);
|
|
|
+ // 新增
|
|
|
+ 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);
|
|
|
+ this.baseMaterialFileProduct.pkOrg = sessionStorage.getItem('pkOrg'); //组织
|
|
|
+ // 保存 模块 数据到对象中
|
|
|
+ this.baseMaterialFileProduct.baseMaterialFileModularList = this.modData;
|
|
|
+ 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);
|
|
|
+ this.getProductList();
|
|
|
+ this.nzNotificationService.success(this.i18NService.fanyi('save.ok'), '');
|
|
|
+ this.nzDrawerRef.close(true); //关闭抽屉是否刷新列表
|
|
|
+ } else {
|
|
|
+ this.nzNotificationService.error(this.i18NService.fanyi('save.not'), '');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ resolve();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // 修改
|
|
|
+ return new Promise(resolve => {
|
|
|
this.baseMaterialFileProduct.pkOrg = sessionStorage.getItem('pkOrg'); //组织
|
|
|
- // 保存 模块 数据到对象中
|
|
|
this.baseMaterialFileProduct.baseMaterialFileModularList = this.modData;
|
|
|
- console.log(this.baseMaterialFileProduct.baseMaterialFileModularList);
|
|
|
- console.log('走这没');
|
|
|
-
|
|
|
- this.baseMaterialFileProductService.saveMainAndChild(this.baseMaterialFileProduct).then(res => {
|
|
|
+ console.log('----->', this.baseMaterialFileProduct.baseMaterialFileModularList);
|
|
|
+ this.baseMaterialFileProductService.updateMainAndChild(this.baseMaterialFileProduct).then(res => {
|
|
|
if (res.success) {
|
|
|
- console.log('out', res);
|
|
|
- this.baseMaterialFileProduct = res.result;
|
|
|
- console.log('产品对象>>>>', this.baseMaterialFileProduct);
|
|
|
+ this.clickProObj = res.result;
|
|
|
+ this.notification.success(this.i18NService.fanyi('successful.revision'), '');
|
|
|
this.getProductList();
|
|
|
- this.nzNotificationService.success(this.i18NService.fanyi('save.ok'), '');
|
|
|
this.nzDrawerRef.close(true); //关闭抽屉是否刷新列表
|
|
|
} else {
|
|
|
- this.nzNotificationService.error(this.i18NService.fanyi('save.not'), '');
|
|
|
+ this.notification.error(
|
|
|
+ this.i18NService.fanyi('modification.failed'),
|
|
|
+ messageShared(this.i18NService, res.message),
|
|
|
+ );
|
|
|
}
|
|
|
});
|
|
|
resolve();
|
|
|
- }
|
|
|
- });
|
|
|
- // }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- sort = 1;
|
|
|
-
|
|
|
//模块 新增
|
|
|
addRowMod() {
|
|
|
this.modData = [
|
|
@@ -189,24 +196,11 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
|
|
|
this.sort++;
|
|
|
}
|
|
|
// 模块 删除按钮
|
|
|
- deleteMod(data): void {
|
|
|
- if (data.id == '') {
|
|
|
- //删除点击项 获取新的模块列表数据
|
|
|
- this.modData = this.modData.filter(d => d.sort !== data.sort);
|
|
|
- } else {
|
|
|
- //修改客户档案时
|
|
|
- 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),
|
|
|
- );
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ deleteMod(data) {
|
|
|
+ console.log('模块数据', this.modData);
|
|
|
+
|
|
|
+ //删除点击项 获取新的模块列表数据
|
|
|
+ this.modData = this.modData.filter(d => d.sort !== data.sort);
|
|
|
}
|
|
|
|
|
|
//树自带方法
|