New file |
| | |
| | | import { Component, Input } from '@angular/core'; |
| | | import { HttpClient } from 'kl/core'; |
| | | |
| | | /** |
| | | * Generated class for the InputComponent component. |
| | | + +* |
| | | * See https://angular.io/docs/ts/latest/api/core/index/ComponentMetadata-class.html |
| | | * for more info on Angular Components. |
| | | */ |
| | | @Component({ |
| | | selector: 'test-dropdownlist', |
| | | templateUrl: 'dropdownlist.html' |
| | | }) |
| | | export class DropdownlistComponent { |
| | | |
| | | @Input() |
| | | id = ''; |
| | | @Input() |
| | | data = { |
| | | id: '0', |
| | | name: 'err', |
| | | type: 1, |
| | | max: '', |
| | | minx: '' |
| | | }; |
| | | public exhibition: boolean = false; |
| | | public selectAll: boolean = false; |
| | | public fullSelection:boolean = false; |
| | | public selectDatas = []; |
| | | public searchValue = ""; |
| | | public assdsd; |
| | | public search = []; |
| | | public medata = [ |
| | | { "name": "key", "code": "C0001", "value": "孙悟空" }, |
| | | { "name": "ke2", "code": "C0002", "value": "唐僧" }, |
| | | { "name": "ke3", "code": "C0003", "value": "沙和尚" }, |
| | | { "name": "ke4", "code": "C0004", "value": "猪八戒" }, |
| | | { "name": "key", "code": "C0005", "value": "孙悟空" }, |
| | | { "name": "ke2", "code": "C0006", "value": "唐僧" }, |
| | | { "name": "ke3", "code": "C0007", "value": "沙和尚" }, |
| | | { "name": "ke4", "code": "C0008", "value": "猪八戒" }, |
| | | { "name": "key", "code": "C0009", "value": "孙悟空" }, |
| | | { "name": "ke2", "code": "C00010", "value": "唐僧" }, |
| | | { "name": "ke3", "code": "C00011", "value": "沙和尚" }, |
| | | { "name": "ke4", "code": "C00012", "value": "猪八戒" }, |
| | | { "name": "ke2", "code": "C00013", "value": "唐僧" }, |
| | | { "name": "ke3", "code": "C00014", "value": "沙和尚" }, |
| | | { "name": "ke4", "code": "C00015", "value": "猪八戒" }, |
| | | { "name": "ke2", "code": "C00016", "value": "唐僧" }, |
| | | { "name": "ke3", "code": "C00017", "value": "沙和尚" }, |
| | | { "name": "ke4", "code": "C00018", "value": "猪八戒" }, |
| | | { "name": "ke2", "code": "C00019", "value": "唐僧" }, |
| | | { "name": "ke3", "code": "C00020", "value": "沙和尚" }, |
| | | { "name": "ke4", "code": "C00021", "value": "猪八戒" }, |
| | | { "name": "ke2", "code": "C00022", "value": "唐僧" }, |
| | | { "name": "ke3", "code": "C00023", "value": "沙和尚" }, |
| | | { "name": "ke4", "code": "C00024", "value": "猪八戒" } |
| | | ] |
| | | constructor(private http: HttpClient) { } |
| | | |
| | | |
| | | ngOnInit(): void { |
| | | this.search = this.medata.map(i=>i); |
| | | console.log(this.id); |
| | | } |
| | | contentShow() { |
| | | this.exhibition = true; |
| | | } |
| | | checkedAll() { |
| | | if (this.fullSelection) { |
| | | this.selectDatas = []; |
| | | this.fullSelection = false; |
| | | this.selectAll = false; |
| | | } else { |
| | | this.selectDatas = this.medata.map(i=>i); |
| | | // this.selectDatas = this.medata.concat([]); |
| | | this.selectAll = false; |
| | | setTimeout(() => { |
| | | this.selectAll = true; |
| | | }, 0.0000000000000000000000000000000001); |
| | | this.fullSelection = true; |
| | | } |
| | | } |
| | | selectOne(code) { |
| | | let selectData |
| | | let num = 0; |
| | | let dataCode = code.path[2].id |
| | | for (var i = 0; i < this.medata.length; i++) { |
| | | if (this.medata[i].code == dataCode) { |
| | | selectData = this.medata[i]; |
| | | } |
| | | } |
| | | for (var i = 0; i < this.selectDatas.length; i++) { |
| | | if (dataCode == this.selectDatas[i].code) { |
| | | num++ |
| | | } |
| | | } |
| | | if (num == 0) { |
| | | this.selectDatas.push(selectData); |
| | | } else { |
| | | this.fullSelection = false; |
| | | this.selectDatas = this.removeAaary(this.selectDatas,selectData); |
| | | } |
| | | } |
| | | confirm(){ |
| | | console.log(this.selectDatas); |
| | | this.exhibition = false; |
| | | } |
| | | getItems(val){ |
| | | console.log(this.assdsd); |
| | | if(val.data){ |
| | | this.searchValue+=val.data; |
| | | }else{ |
| | | this.searchValue = this.searchValue.substring(0,this.searchValue.length - 1); |
| | | } |
| | | console.log(this.searchValue); |
| | | for(var i=0;i<this.medata.length;i++){ |
| | | if(this.medata[i].name.indexOf(this.searchValue)==-1){ |
| | | this.removeAaary(this.medata,this.medata[i]); |
| | | } |
| | | } |
| | | } |
| | | removeAaary(_arr, _obj) { |
| | | var length = _arr.length; |
| | | for (var i = 0; i < length; i++) { |
| | | if (_arr[i] == _obj) { |
| | | if (i == 0) { |
| | | _arr.shift(); |
| | | return _arr; |
| | | } |
| | | else if (i == length - 1) { |
| | | _arr.pop(); |
| | | return _arr; |
| | | } |
| | | else { |
| | | _arr.splice(i, 1); |
| | | return _arr; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |