UNPKG

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

Version:

angular webapp : icpc.group.pms

99 lines 6.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ng_zorro_antd_1 = require("ng-zorro-antd"); var data_source_helper_1 = require("./../../service/data-source.helper"); var ngx_webapp_fx_1 = require("@wjya/ngx-webapp-fx"); var core_1 = require("@angular/core"); var SmsSubscribeComponent = /** @class */ (function () { function SmsSubscribeComponent(userStorageService, dataSourceHelper, _message) { this.userStorageService = userStorageService; this.dataSourceHelper = dataSourceHelper; this._message = _message; this.data = []; this.dataSource = this.dataSourceHelper.smsAccountSubs; this.smsAccountSubsTurnOnDataSource = this.dataSourceHelper.smsAccountSubsTurnOn; this.smsAccountSubsTurnOffDataSource = this.dataSourceHelper.smsAccountSubsTurnOff; this.smsAccountSubsSetTargetPhonesDataSource = this.dataSourceHelper.smsAccountSubsSetTargetPhones; } SmsSubscribeComponent.prototype.ngOnInit = function () { this.communityGroupId = this.userStorageService.getCurrentOffice().id; this.loadAll(); }; SmsSubscribeComponent.prototype.loadAll = function () { var _this = this; this.dataSource.findList({ communityGroupId: this.communityGroupId }).subscribe(function (res) { _this.data = res.body; _this.data.map(function (val) { if (val.targetPhones) { if (val.targetPhones.length === 0) { val.targetPhones = []; } else { val.phones = val.targetPhones; val.targetPhones = val.targetPhones.split(','); } } }); }); }; SmsSubscribeComponent.prototype.onSave = function (item) { var _this = this; item.edit = !item.edit; this.smsAccountSubsSetTargetPhonesDataSource.createOne(item.id, null, { communityGroupId: this.communityGroupId, targetPhones: item.phones }).subscribe(function (success) { _this.loadAll(); _this._message.success('保存成功'); }, function (error) { _this._message.error('保存失败'); }); }; SmsSubscribeComponent.prototype.turnOnOrOff = function (item) { var _this = this; if (item.hasOpen) { this.smsAccountSubsTurnOnDataSource.createOne(item.id, null, { communityGroupId: this.communityGroupId, }).subscribe(function (success) { _this._message.success(item.sub.name + '开启成功'); }, function (error) { _this._message.error(item.sub.name + '开启失败'); }); } else { this.smsAccountSubsTurnOffDataSource.createOne(item.id, null, { communityGroupId: this.communityGroupId, }).subscribe(function (success) { _this._message.success(item.sub.name + '关闭成功'); }, function (error) { _this._message.error(item.sub.name + '关闭失败'); }); } }; SmsSubscribeComponent.prototype.formatValue = function (value) { if (value) { return value.join(','); } return '(暂无短信推送手机)'; }; SmsSubscribeComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'zx-sms-subscribe', template: "<zx-header-block [title]=\"'\u77ED\u4FE1\u8BA2\u9605'\" [showBottomLine]=\"false\" [showBreadcrumb]=\"true\"><p>\u7F16\u8F91\u77ED\u4FE1\u901A\u77E5\u670D\u52A1\u5185\u5BB9</p></zx-header-block><zx-content-block><ng-template #title><div style=\"font-weight: normal\"><i class=\"anticon anticon-rocket\"></i>&nbsp; <span>\u8BA2\u9605\u7BA1\u7406</span></div></ng-template><ng-template #content><div nz-row *ngFor=\"let item of data\" class=\"row\"><div nz-col [nzSpan]=\"8\"><span style=\"vertical-align: middle;\">{{item.sub.name}}\uFF1A</span><nz-switch [(ngModel)]=\"item.hasOpen\" (ngModelChange)=\"turnOnOrOff(item)\"><span checked=\"checked\">\u5F00\u542F</span> <span unchecked>\u5173\u95ED</span></nz-switch></div><div nz-col [nzSpan]=\"11\" class=\"box\"><span style=\"vertical-align: top;\">\u77ED\u4FE1\u63A8\u9001\u624B\u673A\uFF1A</span> <span *ngIf=\"!item.edit\" style=\"word-wrap: break-word;width: calc(100% - 242px);\">{{formatValue(item.targetPhones)}}</span><nz-select [nzMode]=\"'tags'\" [nzPlaceHolder]=\"'\u8BF7\u9009\u62E9\u4EBA\u5458'\" [nzSize]=\"'large'\" [(ngModel)]=\"item.phones\" style=\"width:calc(100% - 250px)\" *ngIf=\"item.edit\"><nz-option *ngFor=\"let option of item.targetPhones\" [nzLabel]=\"option\" [nzValue]=\"option\"></nz-option></nz-select><span style=\"vertical-align: top;\"><span (click)=\"item.edit = !item.edit\" *ngIf=\"!item.edit\"><i class=\"anticon anticon-edit\"></i> <a>\u4FEE\u6539</a> </span><span (click)=\"onSave(item)\" *ngIf=\"item.edit\"><i class=\"anticon anticon-save\"></i> <a>\u4FDD\u5B58</a> </span><span (click)=\"item.edit = !item.edit\" *ngIf=\"item.edit\" style=\"margin-left:10px;\"><i class=\"anticon anticon-reload\"></i> <a>\u53D6\u6D88</a></span></span></div><div nz-col [nzSpan]=\"24\" class=\"tip\"><pre style=\"font-size: 13px;line-height: 14px;\">{{item.sub.detail}}</pre></div></div></ng-template></zx-content-block>", styles: [ "\n :host .row{\n margin-bottom:40px;\n }\n :host .row:last-child{\n margin-bottom:0;\n }\n :host .tip{\n margin-top:10px;\n color: #aaa;\n }\n :host .tip > p{\n margin:3px 0;\n }\n :host .box{\n height:32px;\n }\n :host .box > span{\n height: 32px;\n display: inline-block;\n vertical-align: bottom;\n line-height: 32px;\n }\n :host .box > span:nth-child(3) {\n color:#108ee9;\n margin-left:4px;\n }\n " ] },] }, ]; /** @nocollapse */ SmsSubscribeComponent.ctorParameters = function () { return [ { type: ngx_webapp_fx_1.UserStorageService, }, { type: data_source_helper_1.DataSourceHelper, }, { type: ng_zorro_antd_1.NzMessageService, }, ]; }; return SmsSubscribeComponent; }()); exports.SmsSubscribeComponent = SmsSubscribeComponent; //# sourceMappingURL=sms-subscribe.component.js.map