|
@@ -0,0 +1,267 @@
|
|
|
+import { Component, OnInit, ViewChild } from '@angular/core';
|
|
|
+import { _HttpClient, ModalHelper } from '@delon/theme';
|
|
|
+import {
|
|
|
+ NzDrawerService,
|
|
|
+ NzDropdownContextComponent,
|
|
|
+ NzDropdownService,
|
|
|
+ NzFormatEmitEvent,
|
|
|
+ NzMessageService,
|
|
|
+ NzModalService,
|
|
|
+ NzTreeNode,
|
|
|
+} from 'ng-zorro-antd';
|
|
|
+import { BasedataMaterialFileAddComponent } from './add/add.component';
|
|
|
+import { Page } from 'app/entity/page';
|
|
|
+import { BaseMaterialFileClassification } from 'app/entity/basedata/base-material-file-classification';
|
|
|
+import { BaseMaterialFileClassificationService } from 'app/services/basedata/base-material-file-classification.service';
|
|
|
+import { BaseMaterialFileProductService } from 'app/services/basedata/base-material-file-product.service';
|
|
|
+import { SFSchema } from '@delon/form';
|
|
|
+import { messageShared } from '@shared/utils/message';
|
|
|
+import { I18NService } from '@core';
|
|
|
+
|
|
|
+@Component({
|
|
|
+ selector: 'app-basedata-material-file',
|
|
|
+ templateUrl: './material-file.component.html',
|
|
|
+})
|
|
|
+export class BasedataMaterialFileComponent implements OnInit {
|
|
|
+ activedNode: NzTreeNode;
|
|
|
+ dropdown: NzDropdownContextComponent;
|
|
|
+ searchValue = ''; //搜索框值
|
|
|
+ materialNodes: any; //物料分类 数据
|
|
|
+ materialId = ''; //物料分类 id
|
|
|
+ page: Page; // 物料档案分类 对象
|
|
|
+ baseMaterialFileClassification: BaseMaterialFileClassification;
|
|
|
+ product: any; //产品对象
|
|
|
+ isSpinning = false;
|
|
|
+ proListData = []; //产品数据
|
|
|
+ productPage = {
|
|
|
+ total: 0,
|
|
|
+ current: 0,
|
|
|
+ };
|
|
|
+ constructor(
|
|
|
+ private drawerService: NzDrawerService,
|
|
|
+ private baseMaterialFileClassificationService: BaseMaterialFileClassificationService,
|
|
|
+ private baseMaterialFileProductService: BaseMaterialFileProductService,
|
|
|
+ private message: NzMessageService,
|
|
|
+ private i18NService: I18NService,
|
|
|
+ private modalService: NzModalService,
|
|
|
+ ) {}
|
|
|
+
|
|
|
+ ngOnInit() {
|
|
|
+ this.getMaterialTree();
|
|
|
+ this.baseMaterialFileClassification = {
|
|
|
+ id: '', //编码
|
|
|
+ code: '', //名称
|
|
|
+ name: '', // 父级id
|
|
|
+ parentId: '',
|
|
|
+ sort: 0, //排序
|
|
|
+ key: '', //用于tree id
|
|
|
+ title: '', //name
|
|
|
+ isLeaf: false, //是否尾端true/false
|
|
|
+ children: [], //子集
|
|
|
+ };
|
|
|
+ this.page = {
|
|
|
+ pageNo: 0, //当前页码
|
|
|
+ pageSize: 6, //当前页显示的条数
|
|
|
+ };
|
|
|
+ this.product = {
|
|
|
+ code: '',
|
|
|
+ name: '',
|
|
|
+ pkOrg: '',
|
|
|
+ pageNo: 0,
|
|
|
+ };
|
|
|
+ }
|
|
|
+ //查询 物料分类 树
|
|
|
+ getMaterialTree() {
|
|
|
+ let baseMaterialFileClassification = new BaseMaterialFileClassification();
|
|
|
+ baseMaterialFileClassification.pkOrg = sessionStorage.getItem('pkOrg'); //组织
|
|
|
+ this.baseMaterialFileClassificationService.getTreeList(baseMaterialFileClassification).then(res => {
|
|
|
+ console.log('物料分类 树', res);
|
|
|
+ this.materialNodes = res.result;
|
|
|
+ console.log('materialNodes', this.materialNodes);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询按钮
|
|
|
+ query() {
|
|
|
+ this.product.pageNo = 1;
|
|
|
+ this.getProductList();
|
|
|
+ }
|
|
|
+ //查询全部产品
|
|
|
+ getProductList() {
|
|
|
+ this.isSpinning = true;
|
|
|
+ this.baseMaterialFileProductService.list(this.product).then(reponse => {
|
|
|
+ this.proListData = reponse.result.records;
|
|
|
+ this.productPage = reponse.result;
|
|
|
+ console.log(' this.productPage:', this.productPage);
|
|
|
+ this.isSpinning = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //按页码查询
|
|
|
+ pageIndexChange(event) {
|
|
|
+ // var page = new Page();
|
|
|
+ // page.pageNo = event;//当前页
|
|
|
+ // this.personnelService.getAllPersonnel(page).then((reponse) => {
|
|
|
+ // this.proListData = reponse.result.records;
|
|
|
+ // this.page = reponse.result
|
|
|
+ // })
|
|
|
+ this.product.pageNo = event;
|
|
|
+ this.getProductList();
|
|
|
+ }
|
|
|
+
|
|
|
+ //重置
|
|
|
+ rest() {
|
|
|
+ this.baseMaterialFileClassification = {}; //清空 物料对象
|
|
|
+ }
|
|
|
+ //树节点点击事件
|
|
|
+ treeClick(event) {
|
|
|
+ console.log('点击节点的内容', event);
|
|
|
+ var getMaterialId = event.node.origin; //当前点击的物料对象
|
|
|
+ console.log(getMaterialId.parentId);
|
|
|
+
|
|
|
+ //赋值给修改表单
|
|
|
+ this.baseMaterialFileClassification = {
|
|
|
+ code: getMaterialId.code,
|
|
|
+ name: getMaterialId.name,
|
|
|
+ // id: getMaterialId.key,
|
|
|
+ parentId: getMaterialId.parentId,
|
|
|
+ sort: getMaterialId.sort,
|
|
|
+ };
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //双击节点自动打开树分支
|
|
|
+ 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);
|
|
|
+ } else {
|
|
|
+ const node = data.node;
|
|
|
+ if (node) {
|
|
|
+ node.isExpanded = !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');
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //添加一级、右键添加分类分类、修改
|
|
|
+ // 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) {
|
|
|
+ this.message.success(this.i18NService.fanyi('successful.deletion'));
|
|
|
+ this.getMaterialTree();
|
|
|
+ this.getProductList();
|
|
|
+ } 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());
|
|
|
+ }
|
|
|
+}
|