UNPKG

@wjya/ngx-webapp-icpc.group.pms

Version:

angular webapp : icpc.group.pms

140 lines 9.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var data_source_helper_1 = require("./../../service/data-source.helper"); var core_1 = require("@angular/core"); var forms_1 = require("@angular/forms"); var ngx_webapp_fx_1 = require("@wjya/ngx-webapp-fx"); var GroupInfoLogoComponent = /** @class */ (function () { function GroupInfoLogoComponent(fb, authServerProvider, config, dataSourceHelper, appSettingService, userStorageService) { var _this = this; this.fb = fb; this.authServerProvider = authServerProvider; this.config = config; this.dataSourceHelper = dataSourceHelper; this.appSettingService = appSettingService; this.userStorageService = userStorageService; this.isEdit = false; this.data = {}; this.fileList1 = []; this.fileList2 = []; this.previewImage = ''; this.previewVisible = false; this.handlePreview = function (file) { _this.previewImage = file.url || file.thumbUrl; _this.previewVisible = true; }; this.removeImagePhoto1 = function (file) { if (file.status === 'removed') { _this.validateForm.patchValue({ logo: null }); } return true; }; this.removeImagePhoto2 = function (file) { if (file.status === 'removed') { _this.validateForm.patchValue({ icon: null }); } return true; }; this.dataSource = this.dataSourceHelper.settingSet; this.settingsToMapDataSource = this.dataSourceHelper.settingsToMap; this.photoBaseUrl = this.appSettingService.photoBaseUrl; this.validateForm = this.fb.group({ logo: [null], icon: [null], }); } GroupInfoLogoComponent.prototype.ngOnInit = function () { this.communityGroupId = this.userStorageService.getCurrentOffice().id; this.loadAll(); }; GroupInfoLogoComponent.prototype.loadAll = function () { var _this = this; this.settingsToMapDataSource.findList({ communityGroupId: this.communityGroupId, scope: 'WEB', prefix: 'app.web.common' }).subscribe(function (res) { _this.data.logo = res.body['app.web.common.logo_header']; _this.data.icon = res.body['app.web.common.logo_header_icon']; if (_this.data.logo) { _this.fileList1 = [{ uid: -1, name: 'logo.png', status: 'done', url: _this.photoBaseUrl + _this.data.logo, }]; _this.validateForm.patchValue({ logo: _this.data.logo }); } if (_this.data.icon) { _this.fileList2 = [{ uid: -1, name: 'icon.png', status: 'done', url: _this.photoBaseUrl + _this.data.icon, }]; _this.validateForm.patchValue({ icon: _this.data.icon }); } }); }; GroupInfoLogoComponent.prototype.getFormControl = function (name) { return this.validateForm.controls[name]; }; GroupInfoLogoComponent.prototype.getAuthToken = function () { return this.authServerProvider.getToken(); }; Object.defineProperty(GroupInfoLogoComponent.prototype, "uploadUrl", { get: function () { return this.config.apiUrls.uploadPic; }, enumerable: true, configurable: true }); GroupInfoLogoComponent.prototype.getImageStatus1 = function (e) { if (e.file.status === 'done') { this.validateForm.patchValue({ logo: e.file.response.info.md5 }); } }; GroupInfoLogoComponent.prototype.getImageStatus2 = function (e) { if (e.file.status === 'done') { this.validateForm.patchValue({ icon: e.file.response.info.md5 }); } }; GroupInfoLogoComponent.prototype.onSave = function () { var _this = this; if (!this.validateForm.valid) { return; } else { this.isEdit = !this.isEdit; var entity = {}; entity['app.web.common.logo_header'] = this.validateForm.value['logo']; entity['app.web.common.logo_header_icon'] = this.validateForm.value['icon']; this.dataSource.create(entity, { communityGroupId: this.communityGroupId }).subscribe(function (success) { _this.loadAll(); }); } }; GroupInfoLogoComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'zx-group-info-logo', template: "<zx-content-block><nz-card nzNoHovering nzBordered=\"false\"><ng-template #title><h4>\u9875\u9762\u8BBE\u7F6E</h4></ng-template><ng-template #extra><div *ngIf=\"!isEdit&&data\" class=\"extra\"><span><i class=\"anticon anticon-edit\"></i> <a (click)=\"isEdit = !isEdit\">\u4FEE\u6539</a></span></div><div *ngIf=\"isEdit\" class=\"extra\"><span><i class=\"anticon anticon-save\"></i> <a (click)=\"onSave()\">\u4FDD\u5B58</a> </span><span><i class=\"anticon anticon-reload\"></i> <a (click)=\"isEdit = !isEdit\">\u53D6\u6D88</a></span></div></ng-template><ng-template #body><div nz-row><form nz-form [formGroup]=\"validateForm\" class=\"ant-advanced-search-form\"><div nz-row><div nz-col [nzSpan]=\"8\"><div nz-form-item nz-row class=\"row\"><div nz-form-label nz-col [nzSpan]=\"4\"><label>\u96C6\u56E2logo</label></div><div nz-form-control nz-col *ngIf=\"isEdit\"><nz-upload class=\"logo\" [nzAction]=\"uploadUrl\" [nzHeaders]=\"{ 'Authorization':'Bearer '+getAuthToken() }\" nzListType=\"picture-card\" [(nzFileList)]=\"fileList1\" [nzShowButton]=\"fileList1.length < 1\" [nzPreview]=\"handlePreview\" (nzChange)=\"getImageStatus1($event)\" [nzRemove]=\"removeImagePhoto1\"><i class=\"anticon anticon-plus\"></i><div class=\"ant-upload-text\">\u4E0A\u4F20</div></nz-upload><nz-modal [nzVisible]=\"previewVisible\" [nzContent]=\"modalContent\" [nzFooter]=\"null\" (nzOnCancel)=\"previewVisible=false\"><ng-template #modalContent><img [src]=\"previewImage\" [ngStyle]=\"{ 'width': '100%' }\"/></ng-template></nz-modal></div><div nz-form-control nz-col *ngIf=\"!isEdit\"><img [src]=\"photoBaseUrl + data.logo\" alt=\"\" style=\"width:200px;height:48px\" *ngIf=\"data.logo\"></div><div nz-col [nzSpan]=\"24\" style=\"margin-left: 110px;color: #ccc\"><p>\u8BF7\u4E0A\u4F20\u5C3A\u5BF8\u4E3A200px*48px\u7684\u4F01\u4E1Alogo\uFF0Clogo\u53F3\u4FA7\u6587\u5B57\u63A8\u8350\u4F7F\u7528\u767D\u8272</p></div></div></div></div><div nz-row><div nz-col [nzSpan]=\"8\"><div nz-form-item nz-row class=\"row\"><div nz-form-label nz-col [nzSpan]=\"4\"><label>\u96C6\u56E2\u56FE\u6807</label></div><div nz-form-control nz-col *ngIf=\"isEdit\"><nz-upload class=\"icon\" [nzAction]=\"uploadUrl\" [nzHeaders]=\"{ 'Authorization':'Bearer '+getAuthToken() }\" nzListType=\"picture-card\" [(nzFileList)]=\"fileList2\" [nzShowButton]=\"fileList2.length < 1\" [nzPreview]=\"handlePreview\" (nzChange)=\"getImageStatus2($event)\" [nzRemove]=\"removeImagePhoto2\"><i class=\"anticon anticon-plus\"></i><div class=\"ant-upload-text\">\u4E0A\u4F20</div></nz-upload><nz-modal [nzVisible]=\"previewVisible\" [nzContent]=\"modalContent\" [nzFooter]=\"null\" (nzOnCancel)=\"previewVisible=false\"><ng-template #modalContent><img [src]=\"previewImage\" [ngStyle]=\"{ 'width': '100%' }\"/></ng-template></nz-modal></div><div nz-form-control nz-col *ngIf=\"!isEdit\"><img [src]=\"photoBaseUrl + data.icon\" alt=\"\" style=\"width:68px;height:68px\" *ngIf=\"data.icon\"></div><div nz-col [nzSpan]=\"24\" style=\"margin-left: 110px;color: #ccc\"><p>\u8BF7\u4E0A\u4F20\u5C3A\u5BF8\u4E3A68px*68px\u7684\u4F01\u4E1A\u56FE\u6807</p></div></div></div></div></form></div></ng-template></nz-card></zx-content-block>", styles: [ "\n :host .extra {\n color: #108ee9;\n }\n :host .extra > span:nth-child(2) {\n margin-left:16px;\n }\n :host .row > div:nth-child(1) {\n width:110px;\n display: inline-block;\n float: left;\n }\n :host .row > div:nth-child(2) {\n width:calc(100% - 110px);\n display: inline-block;\n }\n :host ::ng-deep .logo nz-upload-list > div{\n width:216px;\n height:64px;\n }\n :host ::ng-deep .icon nz-upload-list > div{\n width:84px;\n height:84px;\n }\n " ] },] }, ]; /** @nocollapse */ GroupInfoLogoComponent.ctorParameters = function () { return [ { type: forms_1.FormBuilder, }, { type: ngx_webapp_fx_1.AuthServerProvider, }, { type: ngx_webapp_fx_1.CoreConfigService, }, { type: data_source_helper_1.DataSourceHelper, }, { type: ngx_webapp_fx_1.AppSettingService, }, { type: ngx_webapp_fx_1.UserStorageService, }, ]; }; return GroupInfoLogoComponent; }()); exports.GroupInfoLogoComponent = GroupInfoLogoComponent; //# sourceMappingURL=group-info-logo.component.js.map