UNPKG

@angular-jz/jz

Version:

jim jz

158 lines 7.05 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var forms_1 = require("@angular/forms"); var ng_bootstrap_1 = require("@ng-bootstrap/ng-bootstrap"); var utility_1 = require("../../utility"); var jz_user_picker_dialog_component_1 = require("./jz-user-picker-dialog.component"); var JZUserPickerComponent = /** @class */ (function () { function JZUserPickerComponent(modalService) { this.modalService = modalService; this.placeholder = "请选择用户"; this.multiple = true; this.idField = "id"; this.textField = "text"; this.maxCount = 10; this._value = null; this.propagateChange = function (_) { }; this.selectedValueChange = new core_1.EventEmitter(); } JZUserPickerComponent_1 = JZUserPickerComponent; Object.defineProperty(JZUserPickerComponent.prototype, "value", { get: function () { return this._value; }, set: function (value) { if (this._value != value) { this._value = value; this.propagateChange(this.value); } }, enumerable: true, configurable: true }); JZUserPickerComponent.prototype.registerOnChange = function (fn) { this.propagateChange = fn; }; JZUserPickerComponent.prototype.registerOnTouched = function (fn) { }; JZUserPickerComponent.prototype.writeValue = function (value) { //if (value) this.value = value; }; Object.defineProperty(JZUserPickerComponent.prototype, "selectedValue", { get: function () { return this.selectedValueValue; }, //外面的值变了调用set方法 set: function (val) { this.selectedValueValue = val; this.selectedValueChange.emit(this.selectedValueValue); }, enumerable: true, configurable: true }); JZUserPickerComponent.prototype.ngOnInit = function () { }; JZUserPickerComponent.prototype.showDialog = function () { var _this = this; var modalRef = this.modalService.open(jz_user_picker_dialog_component_1.JZUserPickerDialogComponent, { backdrop: 'static', size: 'lg' }); modalRef.componentInstance.isDialog = true; //if (!modalRef.componentInstance.item) modalRef.componentInstance.item = {}; //if (item) modalRef.componentInstance.item = { ...item }; modalRef.componentInstance.selectedUsers = this.selectedValueValue ? this.selectedValueValue.slice() : []; modalRef.componentInstance.maxCount = this.multiple ? this.maxCount : 1; modalRef.result.then(function (result) { if (result.success) { if (_this.multiple) { _this.selectedValueValue = result.data.slice(); _this.selectedValueChange.emit(_this.selectedValueValue); _this.value = [_this.selectedValueValue.map(function (value) { return value[_this.idField]; })]; } else { _this.selectedValueValue = result.data && result.data.length > 0 ? result.data[0] : null; _this.selectedValueChange.emit(_this.selectedValueValue); _this.value = _this.selectedValueValue ? _this.selectedValueValue[_this.idField] : null; } } }); }; Object.defineProperty(JZUserPickerComponent.prototype, "displayText", { get: function () { if (this.multiple) { if (!this.selectedValueValue || this.selectedValueValue.length == 0) return ''; return utility_1.ArrayUtility.join(this.selectedValueValue, "userName"); } else { if (!this.selectedValueValue) return ''; else return this.selectedValueValue["userName"]; } }, enumerable: true, configurable: true }); __decorate([ core_1.Input(), __metadata("design:type", String) ], JZUserPickerComponent.prototype, "placeholder", void 0); __decorate([ core_1.Input(), __metadata("design:type", Boolean) ], JZUserPickerComponent.prototype, "multiple", void 0); __decorate([ core_1.Input(), __metadata("design:type", String) ], JZUserPickerComponent.prototype, "idField", void 0); __decorate([ core_1.Input(), __metadata("design:type", String) ], JZUserPickerComponent.prototype, "textField", void 0); __decorate([ core_1.Input(), __metadata("design:type", Number) ], JZUserPickerComponent.prototype, "maxCount", void 0); __decorate([ core_1.Input(), __metadata("design:type", Object) ], JZUserPickerComponent.prototype, "_value", void 0); __decorate([ core_1.Output(), __metadata("design:type", Object) ], JZUserPickerComponent.prototype, "selectedValueChange", void 0); __decorate([ core_1.Input(), __metadata("design:type", Object), __metadata("design:paramtypes", [Object]) ], JZUserPickerComponent.prototype, "selectedValue", null); JZUserPickerComponent = JZUserPickerComponent_1 = __decorate([ core_1.Component({ selector: 'jz-user-picker', templateUrl: './jz-user-picker.component.html', providers: [{ provide: forms_1.NG_VALUE_ACCESSOR, /* tslint:disable */ useExisting: core_1.forwardRef(function () { return JZUserPickerComponent_1; }), /* tslint:enable */ multi: true }], }), __metadata("design:paramtypes", [ng_bootstrap_1.NgbModal]) ], JZUserPickerComponent); return JZUserPickerComponent; var JZUserPickerComponent_1; }()); exports.JZUserPickerComponent = JZUserPickerComponent; //# sourceMappingURL=jz-user-picker.component.js.map