@wjya/ngx-webapp-icpc.group.pms
Version:
angular webapp : icpc.group.pms
171 lines • 8.68 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var ngx_webapp_fx_1 = require("@wjya/ngx-webapp-fx");
var data_source_helper_1 = require("../../service/data-source.helper");
var ng_zorro_antd_1 = require("ng-zorro-antd");
var department_dialog_component_1 = require("./department-dialog.component");
var def = {
data: null,
showOperations: true,
fields: {
id: {
label: 'id',
hidden: true,
sort: { enabled: false, value: 'descend' },
query: {},
filter: { enabled: false }
},
code: {
label: '部门编码',
sort: { enabled: true },
query: {},
filter: { enabled: false }
},
name: {
label: '部门名称',
sort: { enabled: true },
query: {},
filter: { enabled: false }
},
remarks: {
label: '部门描述',
sort: { enabled: false },
query: {},
filter: { enabled: false }
},
employeeNames: {
label: '岗位职员',
sort: { enabled: false },
query: {},
filter: { enabled: false },
dataTemplateEnabled: true
}
}
};
var DepartmentComponent = /** @class */ (function () {
function DepartmentComponent(dataSourceHelper, userStorageService, injector, confirmServ) {
this.dataSourceHelper = dataSourceHelper;
this.userStorageService = userStorageService;
this.injector = injector;
this.confirmServ = confirmServ;
this.parentId = -1;
this.dataSource = dataSourceHelper.departments;
}
DepartmentComponent.prototype.ngOnInit = function () {
this.listView = new ngx_webapp_fx_1.ListView(def, this.injector);
this.communityGroupId = this.userStorageService.getCurrentOffice().id;
this.treeViewDataUrl = '/uaa/api/departments?&size=9999&parentId=-1&communityGroupId=' + this.communityGroupId;
this.loadAll();
};
DepartmentComponent.prototype.loadAll = function () {
var _this = this;
this.dataSource.findList({
communityGroupId: this.communityGroupId,
parentId: this.parentId,
page: this.listView.pageIndex - 1,
size: this.listView.pageSize,
query: this.listView.params.queryString,
sort: this.listView.sortValueToQueryStatement
}).subscribe(function (res) {
_this.listView.data = res.body;
_this.listView.setTotal(res.headers);
});
};
DepartmentComponent.prototype.insert = function () {
this.departmentDialog.setFormValue({ parentId: this.parentId === -1 ? this.departmentDialog.options[0].id : this.parentId });
this.departmentDialog.loadAll();
};
DepartmentComponent.prototype.dialog = function (dataRow) {
dataRow.parentId = this.parentId === -1 ? this.departmentDialog.options[0].id : this.parentId;
this.departmentDialog.loadAll();
this.departmentDialog.setFormValue(dataRow);
};
DepartmentComponent.prototype.delete = function (dataRow) {
var _self = this;
this.confirmServ.confirm({
title: '您确定要删除这条记录?',
onOk: function () {
_self.dataSource.delete(dataRow.id, { communityGroupId: _self.communityGroupId }).subscribe(function (success) {
_self.loadAll();
});
}
});
};
DepartmentComponent.prototype.onSave = function (entity) {
var _this = this;
if (entity.id === null) {
this.dataSource.create(entity, { communityGroupId: this.communityGroupId }).subscribe(function (success) {
_this.departmentDialog.modalIsVisible = false;
_this.loadAll();
});
}
else {
this.dataSource.update(entity, { communityGroupId: this.communityGroupId }).subscribe(function (success) {
_this.departmentDialog.modalIsVisible = false;
_this.loadAll();
});
}
};
DepartmentComponent.prototype.treeViewDataLoaded = function (data) {
this.setTreeNodeAttributes(Array.isArray(data) ? { children: data } : data);
};
DepartmentComponent.prototype.setTreeNodeAttributes = function (data) {
var _this = this;
if (data.children == null) {
return;
}
data.children.forEach(function (child) {
child.icon = null;
child.visible = true;
child.childrenUrl = '/uaa/api/departments?parentId=${data.id}&size=9999&communityGroupId=' + _this.communityGroupId;
_this.setTreeNodeAttributes(child);
});
};
DepartmentComponent.prototype.treeViewHeaderClick = function (treeView) {
this.parentId = -1;
this.loadAll();
};
DepartmentComponent.prototype.treeViewSelectChange = function (node) {
if (node.selected) {
this.parentId = node.data.id;
this.loadAll();
}
};
DepartmentComponent.prototype.search = function (query) {
this.listView.params.queryString = query;
this.loadAll();
};
DepartmentComponent.prototype.formateEmployeeNames = function (employeeNames) {
if (employeeNames.length > 0) {
if (employeeNames.length > 10) {
employeeNames = employeeNames.slice(0, 10);
return employeeNames.join(',') + '...';
}
return employeeNames.join(',');
}
return '';
};
DepartmentComponent.decorators = [
{ type: core_1.Component, args: [{
selector: 'zx-department',
template: "<zx-header-block [title]=\"'\u90E8\u95E8\u8BBE\u7F6E'\" [showBottomLine]=\"false\" [showBreadcrumb]=\"true\"><p>\u672C\u673A\u6784\u90E8\u95E8\u8BBE\u7F6E</p></zx-header-block><zx-content-block><ng-template #sider><zx-tree-view [dataUrl]=\"treeViewDataUrl\" (dataLoaded)=\"treeViewDataLoaded($event)\" (headerClicked)=\"treeViewHeaderClick($event)\" [accordion]=\"true\" [enableCheckbox]=\"false\" [enableHeader]=\"true\" [headerText]=\"'\u90E8\u95E8'\" [headerIcon]=\"'anticon anticon-layout ng-star-inserted'\" (selectChange)=\"treeViewSelectChange($event)\"></zx-tree-view></ng-template><ng-template #operations><button nz-button [nzType]=\"'primary'\" (click)=\"insert()\"><i class=\"anticon anticon-plus\"></i> <span>\u6DFB\u52A0\u90E8\u95E8</span></button></ng-template><ng-template #extra><nz-input [nzType]=\"'search'\" [(ngModel)]=\"listView.params.queryString\" [nzPlaceHolder]=\"'\u8BF7\u8F93\u5165\u90E8\u95E8\u7F16\u7801\u6216\u540D\u79F0\u641C\u7D22'\" style=\"width: 250px;\" (nzOnSearch)=\"search($event)\" [nzSize]=\"'large'\"></nz-input></ng-template><ng-template #content><zx-list-view [listView]=\"listView\" (loadData)=\"loadAll()\"><ng-template #dataColumn let-dataRow=\"dataRow\" let-field=\"field\" let-value=\"value\"><div *ngIf=\"field.name == 'employeeNames'\"><nz-tooltip [nzTitle]=\"dataRow.employeeNames.join('\uFF0C')\" [nzPlacement]=\"'top'\"><span nz-tooltip>{{formateEmployeeNames(dataRow.employeeNames)}}</span></nz-tooltip></div></ng-template><ng-template #dataOperations let-dataRow=\"dataRow\"><div class=\"operation\"><a (click)=\"dialog(dataRow)\">\u4FEE\u6539</a> <a (click)=\"delete(dataRow)\">\u5220\u9664</a></div></ng-template></zx-list-view></ng-template></zx-content-block><zx-department-dialog #departmentDialog (clickSave)=\"onSave($event)\"></zx-department-dialog>",
styles: [
"\n :host ::ng-deep .ant-select-dropdown-menu-item{\n font-size:0 !important;\n }\n "
]
},] },
];
/** @nocollapse */
DepartmentComponent.ctorParameters = function () { return [
{ type: data_source_helper_1.DataSourceHelper, },
{ type: ngx_webapp_fx_1.UserStorageService, },
{ type: core_1.Injector, },
{ type: ng_zorro_antd_1.NzModalService, },
]; };
DepartmentComponent.propDecorators = {
"departmentDialog": [{ type: core_1.ViewChild, args: ['departmentDialog',] },],
};
return DepartmentComponent;
}());
exports.DepartmentComponent = DepartmentComponent;
//# sourceMappingURL=department.component.js.map