import { Injectable,Input } from "@angular/core";
|
import { Dispatcher } from "../../core/Dispatcher";
|
import { Component, OnInit } from '@angular/core';
|
import { HttpService } from "../../core/HttpService";
|
import { industryCategoryActionType } from "./IndustryCategoryActionType";
|
import { AppConfig } from '../../config/AppConfig';
|
import { UserService } from '../../core/UserService';
|
import { StorageService } from "../../core/StorageService";
|
import { Config } from "../../core/config.service";
|
import { CookieService } from 'angular2-cookie/services/cookies.service';
|
@Injectable()
|
export class IndustryCategoryAction {
|
constructor(private dispatcher: Dispatcher,private config:Config,private _cookieService:CookieService, private httpService: HttpService, private storage: StorageService, private user: UserService) {
|
}
|
// 初期化
|
public init(item) {
|
if(this._cookieService.get('tenantId')){
|
let tenantID = this._cookieService.get('tenantId');
|
let observableCode = this.httpService.get(AppConfig.GETSYSCODELIST,{"codeDiv":"001", "subCodeDiv":"000"})
|
observableCode.subscribe(
|
(code) => {
|
let observableCodeDiv = this.httpService.get(AppConfig.GETSYSCODELISTBYDIV,{"codeDivFirst":"002", "codeDivSecond":"003"})
|
observableCodeDiv.subscribe(
|
(codeDiv) => {
|
let observable = this.httpService.post(AppConfig.GETBUSINESSCATEGORYLIST, { "tenantID": tenantID, "industryCategorycode": item.industrycode,"industrysubCategorycode":item.industrysubCode,"diffUserFlag":"1"});
|
observable.subscribe(
|
(response) => {
|
this.dispatcher.dispatch(industryCategoryActionType.INIT,{code:code,codeDiv:codeDiv,response:response,busCate:item})
|
}
|
);
|
}
|
)
|
}
|
)
|
}else{
|
this._cookieService.removeAll();
|
localStorage.clear();
|
window.location.href = this.config.LOGOUT_URL
|
}
|
}
|
ngOnInit(){
|
let tokens=this.httpService.post('/getToken')
|
tokens.subscribe((res)=>{
|
this.storage.store("openId",res.openId);
|
this.storage.store("processToken",res.processToken);
|
})
|
}
|
//查询业务分类管理数据
|
public getBusCate(item) {
|
let tenantID = this.storage.get('tenantID').tenantID;
|
let observable = this.httpService.post(AppConfig.GETBUSINESSCATEGORYLIST,
|
{
|
"tenantID": tenantID,
|
"industryCategorycode": item.industrycode,
|
"industrysubCategorycode":item. industrysubCode,
|
"diffUserFlag":"1"
|
}
|
);
|
observable.subscribe(
|
(response) => {
|
this.dispatcher.dispatch(industryCategoryActionType.GET_BUS_CATE,response)
|
}
|
);
|
}
|
//行业分类
|
public getIndCate(item) {
|
this.dispatcher.dispatch(industryCategoryActionType.GET_IND_CATE, item)
|
}
|
//行业分类明细
|
public getIndSubCate(item) {
|
this.dispatcher.dispatch(industryCategoryActionType.GET_IND_SUB_CATE, item)
|
}
|
//搜索模板
|
public search(name) {
|
this.dispatcher.dispatch(industryCategoryActionType.SEARCH, name)
|
}
|
}
|