李彤
2022-09-23 d79fcb2a960e8b0e18fe039d892f98187b08866d
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import { LightningElement, api, track } from 'lwc';
import SaveData from '@salesforce/apex/TenderLostController.SaveData';
import SearchPTKS from '@salesforce/apex/TenderLostController.SearchPTKS';
// import SearchParent from '@salesforce/apex/TenderLostController.SearchParent';
import InitData from '@salesforce/apex/TenderLostController.InitData';
import LinkedHospitals from '@salesforce/apex/TenderLostController.LinkedHospitals';
 
export default class TenderLost extends LightningElement {
 
    //资金来源选项
    RelateOption=[
        {label:"政府拨款",value:"政府資金"},
        {label:"医院资金",value:"病院資金"},
        {label:"国际资金",value:"国際資金"},
        {label:"银行资金",value:"銀行資金"},
        {label:"公司/个人投资",value:"会社/個人資金"},
        {label:"融资租赁",value:"融资租赁(リース)"},
        {label:"其他",value:"その他"},
    ];
 
    //招标方式选项
    RelateOption1=[
        {label:"政府招标",value:"政府招标"},
        {label:"院内招标",value:"院内招标"},
        {label:"竟争性谈判",value:"竟争性谈判(非招标)"},
        {label:"单一来源采购",value:"单一来源采购"},
        {label:"私立医院采购",value:"私立医院采购"},
        {label:"耗材采购",value:"耗材采购"},
    ];
 
    // 页面对象
    opp = {};
    hospitals = [];
 
    //资金来源
    handleRelationFn(event){
        var value = event.target.value;
        this.opp.Fund_Basis__c = value;
    }
    
    //招标方式
    handleRelationFn1(event){
        var value = event.target.value;
        this.opp.Sales_Method__c = value;
    }
 
    //从url上取得ID
    getQueryVariable(variable)
    {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
                var pair = vars[i].split("=");
                if(pair[0] == variable){return pair[1];}
        }
        return(false);
    }
 
    //初始化
    connectedCallback(){
        this.tenId = this.getQueryVariable('id');
 
        InitData({ParamIdStr:this.tenId}).then(response=>{
            this.opp=JSON.parse(response);
        });
        LinkedHospitals({ParamIdStr:this.tenId}).then(response=>{
            this.hospitals = response;
            console.log('get linked hospital:' + this.hospitals);
        });
    }
 
    //关联普通科室
    optionPTKS = [{lableOne:"Name",lableTwo:"Acc_Record_Type__c"}];
    searchdataPTKS=[];
    
    onsearchchangePTKS(event){
    var searchContentStr = event.detail.searchContent;
    console.log('hospitals: ' + this.hospitals);
       SearchPTKS({content:searchContentStr, hospitals:this.hospitals}).then(response=>{
            var datas = JSON.parse(response);
            this.searchdataPTKS = datas;
            this.template.querySelector('[data-parent-id="lookup3"]').refreshdata(this.searchdataPTKS);
        })
    }
    PTKSId = '';
    selectedPTKS(event)
    {
        console.warn(event.detail.selectdata.Id);
        this.opp.AccountId = event.detail.selectdata.Id;
    }
 
    // InitPTKS()
    // {
    //     SearchPTKS({content:undefined}).then(response=>{
    //     var datas = JSON.parse(response);
    //         this.searchdataPTKS = datas;
    //         this.template.querySelector('[data-parent-id="lookup3"]').refreshdata(this.searchdataPTKS);
    //     })
    // }
    //关联普通科室
 
    //保存数据逻辑
    saveFn(){
        if(this.opp.Fund_Basis__c == undefined || this.opp.Sales_Method__c == undefined || this.opp.AccountId == undefined){
            this.Alert("请不要输入空哦。",false,true);
        }else{
            this.OnLoading(true);
            SaveData({JsonData:JSON.stringify(this.opp)}).then((response)=>{
                if (response != '' && response.indexOf('错误') < 0) {
                    this.OnLoading(false);
                    console.log(response);
                    this.Alert("保存成功",false,true); 
                    window.open('/apex/PCLLostReportPage?pageStatus=Create&oppId=' + response + '&lostType=失单');
                    // window.location.hash = "Refresh"+"=="+response;
                    top.window.close();
                }else{
                    this.Alert(response,true);
                }
            });
        }
    }
 
 
    //-------- 保存提示框 --------
    //提示
    SaveShowText="保存成功";//提示框的文本
    Tongzhishow=false;  //提示显示的标识
    TongzhiIcon = 'standard:account' //提示框的图标
    IsLeftStyle = "" //提示框的样式
    BgColorStyle = ""
 
    //弹框提示 content 内容 error 是否是错误提示框  left 是否居左
    Alert(content,error = false,left = false){
        this.SaveShowText = content;
        this.Tongzhishow = true;
 
        if (error) {
            this.TongzhiIcon = "standard:first_non_empty";
            this.BgColorStyle = "background-color:#f88568";
        }else{
            this.TongzhiIcon = "standard:account";
            this.BgColorStyle = "background-color:#69e669";
        }
        if (left) {
            this.IsLeftStyle = "left: 0.25rem"
        }else{
            this.IsLeftStyle = ""
        }
    }
 
    //关闭提示框
    CloseAlert(){
        this.closeOffRefresh();
    }
    closeOffRefresh(){
        if (this.Tongzhishow == true) {
            this.Tongzhishow = false;
        }
        if (this.SaveShowText != "") {
            this.SaveShowText = "";
        }
    }
    //加载
    IsLoading = false;
    OnLoading(flag) {
        this.IsLoading = flag;
    }
    //-------- 保存提示框 --------
}