|
@@ -1,4 +1,4 @@
|
|
|
-import { Component, OnInit, ViewChild } from '@angular/core';
|
|
|
+import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
|
|
|
import { _HttpClient, ModalHelper } from '@delon/theme';
|
|
|
import {
|
|
|
NzDrawerService,
|
|
@@ -44,25 +44,34 @@ export class BasedataMaterialFileComponent implements OnInit {
|
|
|
private message: NzMessageService,
|
|
|
private i18NService: I18NService,
|
|
|
private modalService: NzModalService,
|
|
|
+ private nzDropdownService: NzDropdownService,
|
|
|
) {}
|
|
|
|
|
|
ngOnInit() {
|
|
|
- this.getMaterialTree();
|
|
|
+ this.getProductList(); // 产品生育金
|
|
|
+ //客商行业数 树
|
|
|
+ this.getMaterialTree(); //物料分类树
|
|
|
+
|
|
|
+ // 物料分类
|
|
|
this.baseMaterialFileClassification = {
|
|
|
- id: '', //编码
|
|
|
- code: '', //名称
|
|
|
- name: '', // 父级id
|
|
|
+ id: '',
|
|
|
+ code: '',
|
|
|
+ name: '',
|
|
|
parentId: '',
|
|
|
- sort: 0, //排序
|
|
|
+ sort: 0,
|
|
|
key: '', //用于tree id
|
|
|
title: '', //name
|
|
|
isLeaf: false, //是否尾端true/false
|
|
|
children: [], //子集
|
|
|
};
|
|
|
+
|
|
|
+ // 页码
|
|
|
this.page = {
|
|
|
pageNo: 0, //当前页码
|
|
|
pageSize: 6, //当前页显示的条数
|
|
|
};
|
|
|
+
|
|
|
+ //产品
|
|
|
this.product = {
|
|
|
code: '',
|
|
|
name: '',
|
|
@@ -92,10 +101,55 @@ export class BasedataMaterialFileComponent implements OnInit {
|
|
|
this.baseMaterialFileProductService.list(this.product).then(reponse => {
|
|
|
this.proListData = reponse.result.records;
|
|
|
this.productPage = reponse.result;
|
|
|
- console.log(' this.productPage:', this.productPage);
|
|
|
+ // console.log(' this.productPage:', this.productPage);
|
|
|
this.isSpinning = false;
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ //添加一级、右键添加分类分类、修改
|
|
|
+ addMaterial(isOne: number) {
|
|
|
+ var title = '';
|
|
|
+ if (isOne == 0) {
|
|
|
+ //新增一级
|
|
|
+ this.materialId = '';
|
|
|
+ title = document.getElementById('materialTitAdd').textContent;
|
|
|
+ } else if (isOne == 1) {
|
|
|
+ //新增 某分级 下的产品
|
|
|
+ title = document.getElementById('materialTitAdd').textContent;
|
|
|
+ } else {
|
|
|
+ //修改
|
|
|
+ title = document.getElementById('materialTitUpdate').textContent;
|
|
|
+ }
|
|
|
+ //打开弹框
|
|
|
+ const modalRef = this.modalService.create({
|
|
|
+ nzTitle: title,
|
|
|
+ nzContent: BasedataMaterialFileAddComponent,
|
|
|
+ nzWidth: 800,
|
|
|
+ //对话框传参
|
|
|
+ nzComponentParams: {
|
|
|
+ isOne: isOne,
|
|
|
+ materialId: this.materialId, //物料分类id
|
|
|
+ },
|
|
|
+ nzFooter: [
|
|
|
+ {
|
|
|
+ label: '关闭',
|
|
|
+ type: 'default',
|
|
|
+ onClick: addModel => {
|
|
|
+ addModel.close();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '确定',
|
|
|
+ type: 'primary',
|
|
|
+ onClick: addModel => {
|
|
|
+ addModel.submitForm();
|
|
|
+ this.getMaterialTree();
|
|
|
+ this.getProductList();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ });
|
|
|
+ }
|
|
|
//按页码查询
|
|
|
pageIndexChange(event) {
|
|
|
// var page = new Page();
|
|
@@ -114,19 +168,16 @@ export class BasedataMaterialFileComponent implements OnInit {
|
|
|
}
|
|
|
//树节点点击事件
|
|
|
treeClick(event) {
|
|
|
- console.log('点击节点的内容', event);
|
|
|
- var getMaterialId = event.node.origin; //当前点击的物料对象
|
|
|
- console.log(getMaterialId.parentId);
|
|
|
-
|
|
|
+ // console.log('点击节点的内容', event);
|
|
|
+ var materialObj = event.node.origin; //当前点击的物料对象
|
|
|
+ // console.log(materialObj.parentId);
|
|
|
//赋值给修改表单
|
|
|
this.baseMaterialFileClassification = {
|
|
|
- code: getMaterialId.code,
|
|
|
- name: getMaterialId.name,
|
|
|
- // id: getMaterialId.key,
|
|
|
- parentId: getMaterialId.parentId,
|
|
|
- sort: getMaterialId.sort,
|
|
|
+ code: materialObj.code,
|
|
|
+ name: materialObj.name,
|
|
|
+ parentId: materialObj.parentId,
|
|
|
+ sort: materialObj.sort,
|
|
|
};
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//双击节点自动打开树分支
|
|
@@ -140,128 +191,37 @@ export class BasedataMaterialFileComponent implements OnInit {
|
|
|
const node = data.node;
|
|
|
if (node) {
|
|
|
node.isExpanded = !node.isExpanded;
|
|
|
- console.log('11', node);
|
|
|
- console.log('22', node.isExpanded);
|
|
|
+ // console.log('11', node);
|
|
|
+ // console.log('22', node.isExpanded);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //添加一级 弹框
|
|
|
- addMaterial() {
|
|
|
- const modalRef = this.modalService.create({
|
|
|
- nzTitle: '新增物料分类',
|
|
|
- nzContent: BasedataMaterialFileAddComponent,
|
|
|
- nzWidth: 800,
|
|
|
- nzFooter: [
|
|
|
- {
|
|
|
- label: '关闭',
|
|
|
- type: 'default',
|
|
|
- onClick: addModel => {
|
|
|
- addModel.close();
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- label: '确定',
|
|
|
- type: 'primary',
|
|
|
- onClick: addModel => {
|
|
|
- addModel.submitForm().then(() => {
|
|
|
- console.log('000');
|
|
|
- this.getMaterialTree(); //新增后刷新 树
|
|
|
- console.log('1111');
|
|
|
- });
|
|
|
- },
|
|
|
- },
|
|
|
- ],
|
|
|
- });
|
|
|
+ //右键树节点
|
|
|
+ contextMenu(Fid, $event: MouseEvent, template: TemplateRef<void>): void {
|
|
|
+ this.materialId = Fid;
|
|
|
+ this.dropdown = this.nzDropdownService.create($event, template);
|
|
|
+ // console.log('右击对象', this.dropdown);
|
|
|
}
|
|
|
- //添加一级、右键添加分类分类、修改
|
|
|
- // addMaterial(isOne: number) {
|
|
|
- // var title = '';
|
|
|
- // if (isOne == 0) {
|
|
|
- // //新增一级
|
|
|
- // this.materialId = '';
|
|
|
- // title = document.getElementById('materialTitAdd').textContent;
|
|
|
- // } else if (isOne == 1) {
|
|
|
- // //新增 某分级 下的产品
|
|
|
- // title = document.getElementById('materialTitAdd').textContent;
|
|
|
- // } else {
|
|
|
- // //修改
|
|
|
- // title = document.getElementById('materialTitUpdate').textContent;
|
|
|
- // }
|
|
|
|
|
|
- // //打开抽屉
|
|
|
- // const drawerAddMaterialy = this.drawerService.create<
|
|
|
- // BasedataMaterialFileAddComponent,
|
|
|
- // { isOne: number; materialId: string },
|
|
|
- // string
|
|
|
- // >({
|
|
|
- // nzTitle: title,
|
|
|
- // nzWidth: '800',
|
|
|
- // nzContent: BasedataMaterialFileAddComponent,
|
|
|
- // nzContentParams: {
|
|
|
- // isOne: isOne,
|
|
|
- // materialId: this.materialId, //产品id
|
|
|
- // },
|
|
|
- // });
|
|
|
- // //回调 添加完关闭抽屉
|
|
|
- // drawerAddMaterialy.afterClose.subscribe(clo => {
|
|
|
- // if (clo) {
|
|
|
- // //判断是否刷新树列表数据
|
|
|
- // this.getMaterialTree()
|
|
|
- // this.getProductList();
|
|
|
- // }
|
|
|
- // });
|
|
|
- // // this.dropdown.close();
|
|
|
- // }
|
|
|
- //右键删除
|
|
|
- deleteDepart() {
|
|
|
- this.baseMaterialFileClassificationService.delete(this.materialId).then(res => {
|
|
|
- if (res.success) {
|
|
|
+ //修改产品
|
|
|
+ editProduct() {}
|
|
|
+ //右击删除
|
|
|
+ delMaterial() {
|
|
|
+ this.baseMaterialFileClassificationService.delete(this.materialId).then(response => {
|
|
|
+ if (response.success) {
|
|
|
this.message.success(this.i18NService.fanyi('successful.deletion'));
|
|
|
this.getMaterialTree();
|
|
|
this.getProductList();
|
|
|
+ this.dropdown.close();
|
|
|
+ //弹框消失
|
|
|
} else {
|
|
|
this.message.error(this.i18NService.fanyi('delete.failed'));
|
|
|
}
|
|
|
});
|
|
|
- // this.dropdown.close();
|
|
|
}
|
|
|
- editProduct() {
|
|
|
- //抽屉title
|
|
|
- // var title = '';
|
|
|
- // if (id == '') {
|
|
|
- // title = document.getElementById('titleAdd').textContent;
|
|
|
- // } else {
|
|
|
- // title = document.getElementById('titleUpdate').textContent;
|
|
|
- // }
|
|
|
- // //打开抽屉
|
|
|
- // const drawerAddMaterialy = this.drawerService.create<BasedataMaterialFileAddComponent, { id: string }, string>({
|
|
|
- // nzTitle: title,
|
|
|
- // nzWidth: 1200,
|
|
|
- // nzContent: BasedataMaterialFileAddComponent,
|
|
|
- // nzContentParams: {
|
|
|
- // id: id,
|
|
|
- // },
|
|
|
- // });
|
|
|
- // //回调 添加完关闭抽屉
|
|
|
- // drawerAddMaterialy.afterClose.subscribe(clo => {
|
|
|
- // if (clo) {
|
|
|
- // //判断是否刷新树列表数据
|
|
|
- // this.getProductList();
|
|
|
- // }
|
|
|
- // });
|
|
|
- }
|
|
|
- //右击修改
|
|
|
- updateMaterial() {}
|
|
|
- //右击删除
|
|
|
- delMaterial() {}
|
|
|
//右键取消
|
|
|
cancel() {
|
|
|
this.dropdown.close();
|
|
|
}
|
|
|
- add() {
|
|
|
- // this.modal
|
|
|
- // .createStatic(FormEditComponent, { i: { id: 0 } })
|
|
|
- // .subscribe(() => this.st.reload());
|
|
|
- }
|
|
|
}
|