var aProduct=[], iProduct;
|
var aTerritory=[], iTerritory;
|
var aTerritoryHospital=[], iTerritoryHospital;
|
var aHospital=[], iHospital, oHospital;
|
var aProvince=[], aCity=[];
|
var aHospitalApply, iHospitalApply;
|
|
$(document).ready( onDocumentReady );
|
|
function onDocumentReady() {
|
pageInit(showHospitalNew);
|
loadMaster();
|
}
|
|
function loadMaster() {
|
jsonRequest("sales", "load_master", {}, onMasterResponse);
|
}
|
|
function onMasterResponse(res) {
|
aProduct=res.product_list;
|
aHospital=res.hospital_list;
|
aDealer=res.dealer_list;
|
}
|
|
function showHospitalApplyList() {
|
menuSwitch("hospital_apply_list");
|
loadHospitalApplyList();
|
}
|
|
function loadHospitalApplyList() {
|
jsonRequest("territory", "load_hospital_apply_list", {}, onHospitalApplyListResponse, "正在获取医院申请状态信息");
|
}
|
|
function onHospitalApplyListResponse(res) {
|
aHospitalApply=res.hospital_apply_list;
|
var html="";
|
var aStatus=["已取消", "已生效", "待审核"];
|
for (var i=0; i<aHospitalApply.length; i++) {
|
var hp=aHospitalApply[i];
|
html+=div("div_hospital_item",
|
div("div_hospital_code", hp.code)+
|
div("div_hospital_name", hp.name)+
|
div("div_hospital_apply_date", hp.apply_date)+
|
div("div_hospital_apply_name", hp.apply_name+" 申请")+
|
div("div_hospital_status_"+(hp.status==2?"on":"off"), aStatus[hp.status]),
|
"showHospitalApplyDetail("+i+")");
|
}
|
$("#div_hospital_apply_sheet").html(html);
|
}
|
|
function showHospitalApplyDetail(i) {
|
iHospitalApply=i;
|
var label=["全称", "别名", "城市", "地址", "电话", "等级", "其它信息",
|
"提交人", "提交日期"];
|
var a=aHospitalApply[i];
|
var content=[a.name, a.alias, a.city, a.address, a.phone, a.level, a.info,
|
a.apply_employee_name, a.apply_date];
|
var s=property(label, content);
|
$("#div_hospital_apply_property").html(s);
|
var dm=getAccount().level=="DM";
|
$("#div_hospital_approve").toggle(dm);
|
pageGo("hospital_apply_detail");
|
}
|
|
function confirmHospitalStatus(i) {
|
var req={};
|
req.status=i;
|
req.hospital_uid=aHospitalApply[iHospitalApply].uid;
|
jsonRequest("territory", "do_hospital_status", req, onHospitalStatusResponse);
|
}
|
|
function onHospitalStatusResponse() {
|
pageBack();
|
loadHospitalApplyList();
|
}
|
|
function showHospitalNew() {
|
oHospital={level:""};
|
$("#input_hospital_name").val("");
|
$("#input_hospital_alias").val("");
|
$("#input_hospital_address").val("");
|
$("#input_hospital_phone").val("");
|
$("#input_hospital_bed_num").val("");
|
menuSwitch("hospital_new");
|
}
|
|
function setHospitalLevel(l) {
|
var levels=["", "一级", "二级", "三级"];
|
oHospital.level=levels[l];
|
for (var i=1; i<=3; i++) {
|
toggleSwitch("hospital_level", l);
|
}
|
}
|
|
function loadProvince() {
|
jsonRequest("territory", "load_geo", {}, onProvinceResponse, "正在获取省市信息……请稍候");
|
}
|
|
function onProvinceResponse(res) {
|
aProvince=res.province_list;
|
var html="";
|
for (var i in aProvince) {
|
html+=div("div_geo_item", aProvince[i].province, "selectProvince("+i+")");
|
}
|
$("#div_geo_group").html(html);
|
pageGo("geo");
|
}
|
|
function selectProvince(i) {
|
var req={};
|
req.province_uid=aProvince[i].uid;
|
jsonRequest("territory", "load_geo", req, onCityResponse, "正在获取城市信息……请稍候");
|
oHospital.province=aProvince[i].province;
|
}
|
|
function onCityResponse(res) {
|
aCity=res.city_list;
|
var html="";
|
for (var i in aCity) {
|
html+=div("div_geo_item", (aCity[i].city || "(未知区域)"), "selectCity("+i+")");
|
}
|
$("#div_geo_group").html(html);
|
}
|
|
function selectCity(i) {
|
oHospital.geo_uid=aCity[i].uid;
|
oHospital.city=aCity[i].city;
|
$("#prompt_hospital_geo").html(oHospital.province+" "+oHospital.city);
|
$("#prompt_hospital_geo").attr("class", "div_form_content");
|
pageBack();
|
}
|
|
function searchLocation() {
|
var hao=oHospital.address.indexOf("号");
|
if (hao==-1) {
|
alertMessage("地址未包含门牌号信息");
|
} else {
|
pageGo("map");
|
window.map = new BMap.Map("map_container");
|
map.centerAndZoom(oHospital.province+oHospital.city, 16);
|
map.addControl(new BMap.NavigationControl());
|
var localSearch = new BMap.LocalSearch(map);
|
localSearch.setSearchCompleteCallback(onSearchLocationResult);
|
var address=oHospital.province + oHospital.city + oHospital.address.substr(0,hao);
|
localSearch.search(address);
|
}
|
}
|
|
function onSearchLocationResult(result) {
|
if (result.getNumPois()==0) {
|
alertMessage("无法识别地址: "+result.keyword);
|
} else {
|
var poi = result.getPoi(0);
|
oHospital.longitude=poi.point.lng;
|
oHospital.latitude=poi.point.lat;
|
map.centerAndZoom(poi.point, 16);
|
var marker = new BMap.Marker(new BMap.Point(poi.point.lng, poi.point.lat));
|
map.addOverlay(marker);
|
}
|
}
|
|
function submitHospitalNew() {
|
oHospital.name=$("#input_hospital_name").val();
|
oHospital.alias=$("#input_hospital_alias").val();
|
oHospital.address=$("#input_hospital_address").val();
|
oHospital.phone=$("#input_hospital_phone").val();
|
oHospital.info=$("#input_hospital_info").val();
|
if (!oHospital.name) {
|
alertMessage("请填写全称");
|
} else if (!oHospital.geo_uid) {
|
alertMessage("请选择城市");
|
} else if (!oHospital.address) {
|
alertMessage("请填写地址");
|
} else if (!oHospital.phone) {
|
alertMessage("请填写联系电话");
|
} else {
|
searchLocation();
|
}
|
}
|
|
function confirmHospitalNew() {
|
jsonRequest("territory", "do_hospital_new", oHospital, onNewHospitalApplyResponse, "正在提交新医院申请");
|
}
|
|
function onNewHospitalApplyResponse(res) {
|
pageBack();
|
pageBack();
|
showHospitalApplyList();
|
}
|
|
function loadProduct() {
|
jsonRequest("territory", "load_product", {}, onProductResponse, "正在获取产品信息……请稍候");
|
}
|
|
function onProductResponse(res) {
|
aProduct=res.product_list;
|
var html="";
|
for (var i=0; i<aProduct.length; i++) {
|
html+=div("div_list_item",
|
div("div_list_code", aProduct[i].code)+div("div_list_name", aProduct[i].name+" ("+aProduct[i].name_en+")"),
|
"selectProduct("+i+")");
|
}
|
if (aProduct.length==0) {
|
html+=div("div_list_item", "没有产品可以选择");
|
}
|
$("#div_product_group").html(html);
|
pageGo("product");
|
}
|
|
function selectProduct(i) {
|
iProduct=i;
|
$("#div_header_product").html(aProduct[iProduct].name);
|
pageBack(loadTerritory);
|
}
|
|
function showTerritory() {
|
if (getAccount().level=="REP") {
|
alertMessage("请切换为地区经理账户");
|
} else {
|
menuSwitch("territory");
|
loadTerritory();
|
}
|
}
|
|
function loadTerritory() {
|
if (iProduct>=0) {
|
var req={};
|
req.product_uid=aProduct[iProduct].uid;
|
jsonRequest("territory", "load_territory", req, onTerritoryResponse, "正在获取辖区信息……请稍候");
|
} else {
|
loadProduct();
|
}
|
}
|
|
function onTerritoryResponse(res) {
|
aTerritory=res.territory_list;
|
var title=["地点", "辖区代码", "姓名", "医院数"];
|
var width=["25%", "30%", "30%", "15%"];
|
var f=field(title, width);
|
$("#div_territory_field").html(f);
|
|
var html="";
|
for (var i=0; i<aTerritory.length; i++) {
|
var it=aTerritory[i];
|
html+=div("div_row",
|
cell(it.geo, "25%")+
|
cell(it.code, "30%")+
|
cell(it.name, "30%")+
|
cell(it.hospital_num, "15%"),
|
"iTerritory="+i+"; showTerritoryHospital()");
|
}
|
$("#div_territory_sheet").html(html);
|
}
|
|
function showTerritoryHospital() {
|
pageGo("territory_hospital", loadTerritoryHospital);
|
}
|
|
function loadTerritoryHospital() {
|
var req={};
|
req.product_uid=aProduct[iProduct].uid;
|
req.territory_uid=aTerritory[iTerritory].uid;
|
jsonRequest("territory", "load_territory_hospital", req, onTerritoryHospitalResponse, "正在获取辖区医院列表信息");
|
}
|
|
function onTerritoryHospitalResponse(res) {
|
aTerritoryHospital=res.hospital_list;
|
var html="";
|
for (var i=0; i<aTerritoryHospital.length; i++) {
|
html+=div("div_list_item",
|
div("div_list_code", aTerritoryHospital[i].code)+
|
div("div_list_name", aTerritoryHospital[i].name)+
|
div("div_list_del", "", "promptTerritoryHospital("+i+")"));
|
}
|
if (aTerritoryHospital.length==0) {
|
html+=div("div_list_item", "没有目标医院,点右上角添加");
|
}
|
$("#div_territory_hospital_sheet").html(html);
|
}
|
|
function hideTerritoryHospital() {
|
pageBack(loadTerritory);
|
}
|
|
function addTerritoryHospital(i) {
|
var req={};
|
req.product_uid=aProduct[iProduct].uid;
|
req.territory_uid=aTerritory[iTerritory].uid;
|
req.hospital_uid=aHospital[i].uid;
|
jsonRequest("territory", "add_territory_hospital", req, hideHospital);
|
}
|
|
function promptTerritoryHospital(i) {
|
var name=aTerritoryHospital[i].name;
|
showConfirm("是否去除目标医院<br>"+name, "removeTerritoryHospital("+i+")");
|
}
|
|
function removeTerritoryHospital(i) {
|
var req={};
|
req.product_uid=aProduct[iProduct].uid;
|
req.territory_uid=aTerritory[iTerritory].uid;
|
req.hospital_uid=aTerritoryHospital[i].uid;
|
jsonRequest("territory", "remove_territory_hospital", req, loadTerritoryHospital);
|
}
|
|
function loadHospital() {
|
var req={};
|
req.product_uid=aProduct[iProduct].uid;
|
req.territory_uid=aTerritory[iTerritory].uid;
|
jsonRequest("territory", "load_hospital", req, onHospitalResponse, "正在获取医院列表");
|
}
|
|
function onHospitalResponse(res) {
|
aHospital=res.hospital_list;
|
var html="";
|
for (var i=0; i<aHospital.length; i++) {
|
html+=div("div_list_item",
|
div("div_list_code", aHospital[i].code)+
|
div("div_list_name", aHospital[i].name),
|
"addTerritoryHospital("+i+")");
|
}
|
$("#div_hospital_group").html(html);
|
pageGo("hospital");
|
}
|
|
function hideHospital() {
|
pageBack(loadTerritoryHospital);
|
}
|
|
function showMine() {
|
menuSwitch("mine", loadMine());
|
}
|
|
function loadMine() {
|
jsonRequest("territory", "load_mine", {}, onMineResponse, "正在获取我的辖区医院列表");
|
}
|
|
function onMineResponse(res) {
|
var title=["代码", "医院"];
|
var width=["30%", "70%"];
|
var f=field(title, width);
|
$("#div_mine_field").html(f);
|
|
var html="";
|
for (var i=0; i<res.product_list.length; i++) {
|
var product=res.product_list[i];
|
html+=div("div_row_blue",
|
cell(product.code, "30%")+cell(product.name, "70%"));
|
for (var j=0; j<product.hospital_list.length; j++) {
|
var hospital=product.hospital_list[j];
|
html+=div("div_row",
|
cell(hospital.code, "30%")+cell(hospital.name, "70%", "left"));
|
}
|
}
|
$("#div_mine_sheet").html(html);
|
}
|