tom
2023-12-06 9e968679ed2e6937aeb7b50a6c450d5d19251f42
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
var aLead, iLead, oLead, aPerson, iPerson;
 
$(document).ready( onDocumentReady );
 
function onDocumentReady() {
    Origami.fastclick(document.body);
    if (isAgent("micromessenger")) {
        weixinShare("绩效达人 推广进度管理", 
                    "登记潜在客户 跟踪推广进度 管理推广资源",
                    "http://localhost:8080/sfez/lead.html",
                    "http://localhost:8080/sfez/icon/geggee_logo.png");
        weixinInit();
        weixinGuide();
        $("#page_splash").fadeIn();
    } else {
        showLeadList();
    }
}
 
function showAccountList() {
    pageGo("account_list");
    loadAccountList();
}
 
function loadAccountList() {
    jsonRequest("lead", "load_account_list", {}, onAccountListResponse, "正在获取体验用户名单……请稍候");
}
 
function onAccountListResponse(res) {
    var aAccount=res.account_list;
    var title=["手机号", "公司", "姓名", "邀请码"];
    var width=["30%", "30%", "25%", "15%"];
    var f=field(title, width);
    $("#div_account_field").html(f);
 
    var html="";
    for (var i=0; i<aAccount.length; i++) {
        var acc=aAccount[i];
        html+=div("div_row", 
                cell(acc.phone, "30%")+
                cell(acc.company, "30%")+
                cell(acc.name, "25%")+
                cell(acc.inviter, "15%"));
    }
    $("#div_account_sheet").html(html);
}
 
function showLeadList() {
    aPage=['lead_list'];
    $("#page_lead_list").fadeIn();
    loadLeadList();
}
 
function loadLeadList() {
    jsonRequest("lead", "load_lead_list", {}, onLeadListResponse, "正在获取推广状态……请稍候");
}
 
function onLeadListResponse(res) {
    aLead=res.lead_list;
    var title=["公司", "客户", "用户数"];
    var width=["60%", "20%", "20%"];
    var f=field(title, width);
    $("#div_lead_field").html(f);
 
    var html="";
    for (var i=0; i<aLead.length; i++) {
        var lead=aLead[i];
        html+=div("div_row", 
                cell(lead.hospital_name, "60%", "left")+
                cell(lead.person_name, "20%", "center")+
                cell(lead.users, "18%", "right"),
                    "iLead="+i+"; showLeadInfo()");
    }
    $("#div_lead_sheet").html(html);
}
 
function showLeadAdd() {
    pageGo("lead_edit");
    oLead={present:"", deploy:"", module:""};
    initLeadEdit();
}
 
function showLeadInfo() {
    pageGo("lead_edit");
    jsonRequest("lead", "load_lead_info", {lead_uid:aLead[iLead].uid}, onLeadInfoResponse, "正在获取详情……请稍候");
}
 
function onLeadInfoResponse(res) {
    oLead=res;
    initLeadEdit();
}
 
function initLeadEdit() {
    $("#row_department_name").hide();
    $("#row_hospital_name").hide();
    $("#row_create").hide();
    $("#row_update").hide();
    $("#row_update").hide();
    $("#prompt_person_name").html("请选择");
    $("#prompt_meet_date").html("请选择");
    promptSelection("person_name", oLead.person_name);
    promptSelection("hospital_name", oLead.hospital_name);
    promptSelection("department_name", oLead.department_name);
    promptSelection("meet_date", oLead.meet_date);
    $("#input_phone").val(oLead.phone);
    $("#input_requirement").val(oLead.requirement);
    $("#input_users").val(oLead.users);
    $("#input_timeline").val(oLead.timeline);
    $("#input_budget").val(oLead.budget);
    $("#input_systems").val(oLead.systems);
    $("#input_infotech").val(oLead.infotech);
    $("#input_info").val(oLead.info);
    promptSelection("create", oLead.create);
    if (oLead.update) {
        promptSelection("update", oLead.update);
    }
    toggleInit("present", 3, oLead.present);
    toggleInit("deploy", 3, oLead.deploy);
    for (var i=1; i<10; i++) {
        $("#module_"+i).attr("class", "div_form_check_off");
        var s=$("#module_"+i).html()+" ";
        if (oLead.module.indexOf(s)>=0) {
            setModule(i);
            oLead.module=oLead.module.replace(s,"");
        }
    }
    $("#input_module").val(oLead.module);
    $("#row_close").toggle(oLead.owner==1);
}
 
function toggleInit(series, n, val) {
    for (var i=1; i<=n; i++) {
        var s=$("#switch_"+series+"_"+i).html();
        if (val.indexOf(s)>=0) {
            toggleSwitch(series, i);
        }
    }
}
 
function promptSelection(field, content) {
    if (content) {
        var p=$("#prompt_"+field);
        p.html(content);
        p.attr("class", "div_form_content");
        $("#row_"+field).show();
    }
}
 
function selectPerson() {
    var person=aPerson[iPerson];
    oLead.person_uid=person.uid;
    promptSelection("person_name", person.name);
    promptSelection("department_name", person.department_name);
    promptSelection("hospital_name", person.hospital_name);
    pageBack();
    if ($("#row_meet_objective").is(":visible")) {
        $("#input_meet_objective").focus();
    } else {
        $("#input_meet_content").focus();
    }
}
 
function promptDate() {
    var html="";
    var di0=getDateInfo();
    var ms=di0.ms-1000*60*60*24*(di0.day-1);
    var di=getDateInfo(ms);
            
    for (var m=0; m<2; m++) {
        html+=div("div_date_month", di.year+"年"+di.month+"月");
        for (var w=0; w<di.week; w++) {
            var b=(w==0)?"off":"on";
            html+=div("div_date_item_"+b);
        }
        var m1=di.month;
        while (m1==di.month) {
            var b=(di.week==0 || di.week==6)?"off":"on";
            var today=(di.str==di0.str)?" div_date_today":"";
            html+=div("div_date_item_"+b+today, di.day, "selectDate('"+di.str+"');");
            ms+=1000*60*60*24;
            di=getDateInfo(ms);
        }
        for (var w=di.week; w<7; w++) {
            var b=w==6?"off":"on";
            html+=div("div_date_item_"+b);
        }
    }
    $("#div_date_group").html(html);
    pageGo("date_selection");
}
 
function getDateInfo(ms) {
    var di={};
    di.date=ms?new Date(ms):new Date();
    di.year=di.date.getFullYear();
    di.month=di.date.getMonth()+1;
    di.day=di.date.getDate();
    di.week=di.date.getDay();
    di.str=di.year+(di.month<10?"-0":"-")+di.month+(di.day<10?"-0":"-")+di.day;
    di.ms=Date.parse(di.date)
    return di;
}
 
function selectDate(s) {
    promptSelection("meet_date", s);
    oLead.meet_date=s;
    pageBack();
}
 
function promptPerson() {
    pageGo("person_selection");
    loadPersonList();
}
 
function loadPersonList() {
    var req={};
    jsonRequest("lead", "load_person_list", req, onPersonListResponse, "正在获取客户列表……请稍候");
}
 
function onPersonListResponse(res) {
    aPerson=res.person_list;
    var html="", code="";
    for (var i=0; i<aPerson.length; i++) {
        var person=aPerson[i];
        if (person.hospital_code != code) {
            html+=div("div_person_hospital", person.hospital_name+" ("+person.hospital_code+") ");
            code=person.hospital_code;
        }
        html+=div("div_person_item",
                div("div_person_doctor_"+person.gender, "")+
                div("div_person_name", person.name)+
                div("div_person_title", person.title)+
                div("div_person_department_name", person.department_name),
                    "selectPerson("+i+")");
    }
    $("#div_person_group").html(html);
}
 
function selectPerson(i) {
    iPerson=i;
    oLead.person_uid=aPerson[iPerson].uid;
    promptSelection("person_name", aPerson[iPerson].name);
    promptSelection("department_name", aPerson[iPerson].department_name);
    promptSelection("hospital_name", aPerson[iPerson].hospital_name);
    pageBack();
}
 
function setPresent(i) {
    oLead.present=$("#switch_present_"+i).html();
    toggleSwitch("present", i);
}
 
function setDeploy(i) {
    oLead.deploy=$("#switch_deploy_"+i).html();
    toggleSwitch("deploy", i);
}
 
function setModule(i) {
    if ($("#module_"+i).attr("class")=="div_form_check_on") {
        $("#module_"+i).attr("class", "div_form_check_off");
    } else {
        $("#module_"+i).attr("class", "div_form_check_on");
    }    
}
 
function confirmLeadEdit() {
    oLead.users=$("#input_users").val();
    if (!oLead.uid && !oLead.person_uid) {
        alertMessage("请选择客户");
    } else if (!oLead.meet_date) {
        alertMessage("请选择最近会谈日期");
    } else if (!oLead.users) {
        alertMessage("请填写预估用户数规模");
    } else {
        oLead.phone=$("#input_phone").val();
        var module="";
        for (var i=1; i<10; i++) {
            if ($("#module_"+i).attr("class")=="div_form_check_on") {
                module+=$("#module_"+i).html()+" ";
            }
        }
        oLead.module=module+$("#input_module").val();
        oLead.requirement=$("#input_requirement").val();
        oLead.timeline=$("#input_timeline").val();
        oLead.budget=$("#input_budget").val();
        oLead.systems=$("#input_systems").val();
        oLead.infotech=$("#input_infotech").val();
        oLead.info=$("#input_info").val();
        if (oLead.uid) {
            jsonRequest("lead", "do_lead_update", oLead, onLeadUpdate, "正在更新信息……请稍候");
        } else {
            jsonRequest("lead", "do_lead_add", oLead, onLeadUpdate, "正在创建信息……请稍候");
        }        
    }
}
 
function promptLeadClose() {
    showConfirm("是否删除推广信息?", "confirmLeadClose()");
}
 
function confirmLeadClose() {
    jsonRequest("lead", "do_lead_close", {lead_uid:oLead.uid}, onLeadUpdate, "正在删除信息……请稍候");
}
 
function onLeadUpdate() {
    pageBack();
    loadLeadList();
}