bhq@iemsoft.cn
2018-11-06 0693e4dbd75a8c23a7e6dd34aa9a9ecee0a3a7b3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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)
     }
}