1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- import { Component, OnInit } from '@angular/core';
- import { UserData } from '../../providers/user-data';
- import { Storage } from '@ionic/storage'
- import { Router } from '@angular/router';
- @Component({
- selector: 'app-contract',
- templateUrl: './contract.page.html',
- styleUrls: ['./contract.page.scss'],
- })
- export class ContractPage implements OnInit {
- contractInfo={
- sscContractdateGt: '',
- sscContractdateLt: '',
- sscState: '',
- sscCreator: '',
- sscCode: ''
- }
- constructor(public userData: UserData,
- private router: Router,
- private storage: Storage,) { }
- ngOnInit() {
- }
- search() {
- this.storage.set('contractForm', this.getSerchForm())
- this.router.navigateByUrl('/contract-table');
- }
- getSerchForm() {
- let queryForm = {
- query: {
- bool: {
- must: [],
- must_not: [],
- should: []
- }
- },
- from: 0,
- size: 10,
- sort: [{sscContractdate: {order: "desc"}}],
- aggs: {}
- };
- if (this.contractInfo.sscCode) {
- let prefix = {}
- prefix['sscCode.keyword'] = this.contractInfo.sscCode.toUpperCase()
- queryForm.query.bool.must.push({
- prefix: prefix
- })
- }
- if (this.contractInfo.sscContractdateGt || this.contractInfo.sscContractdateLt) {
- let range = {
- sscContractdate: {}
- }
- if (this.contractInfo.sscContractdateGt) {
- range.sscContractdate['gt'] = new Date(this.contractInfo.sscContractdateGt).getTime()
- }
- if (this.contractInfo.sscContractdateLt) {
- range.sscContractdate['lt'] = new Date(this.contractInfo.sscContractdateLt).getTime()
- }
- queryForm.query.bool.must.push({
- range: range
- })
- }
- if (this.contractInfo.sscCreator) {
- let prefix = {}
- prefix['sscCreator.keyword'] = this.contractInfo.sscCreator
- queryForm.query.bool.must.push({
- prefix: prefix
- })
- }
- return queryForm
- }
- }
|