import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs/Rx';
import {Injectable} from '@angular/core';
import {SERVER_API_URL} from '../app.constants';
import {CommonService} from '../shared/common/common.service';
import {LocalStorageService, SessionStorageService} from 'ngx-webstorage';

@Injectable()
export class SystemChangeService {

    headers;
    options;

    constructor(private http: HttpClient, private commonSer: CommonService,
                private localStorage: LocalStorageService, private sessionStorage: SessionStorageService) {
    }

    //分页查询
    sysChangePage(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/sysChange/page', data);
    }

    //发起变更
    sysChangeSave(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/sysChange/save', data);
    }

    //审核
    sysChangeCheck(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/sysChange/check', data);
    }

    //数据导出
    sysChangeExport(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/sysChange/export', this.commonSer.toFormData(data), {responseType: 'blob'});
    }

    //查询变更跟踪信息
    findMsg(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/sysChange/findMsg/' + params);
    }

    //根据ID查询
    find(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/sysChange/find/' + params);
    }

    //编辑或提交审核
    sysChangeUpdate(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/sysChange/update', data);
    }

    //转派
    sysChangeTransfer(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/sysChange/transfer', data);
    }

    //处理变更
    sysChangeFinish(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/sysChange/finish', data);
    }

    //删除变更
    sysChangeDelete(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/sysChange/delete', data);
    }

    //变更参数-修改
    sysdictUpdate(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/sysdict/update', data);
    }

    //根据类型查找
    findByType(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/sysdict/findByType/' + params);
    }

    //变更参数-添加
    sysdictAdd(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/sysdict/add', data);
    }

    //删除
    sysdictDelete(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/sysdict/delete', data);
    }
}
