anxiao_web/pages/workInClock/js/schoolSearch.js

37 lines
1.2 KiB
JavaScript

import {layuiObj,clockStationsInfoArr} from "./index.js"
import {showSchoolBaseInfo} from "./marker/schoolMarker.js"
//初始化快速搜索的
function initClockSchoolSearchSelect(){
$("#mainContentC_schoolSelect").html(getSchoolOptions());
layuiObj.layuiForm.render("select","mainContentC_schoolForm");
$("#mainContentC_schoolSelect").siblings("div.layui-form-select").find("div.layui-select-title").find("input").attr("onfocus","this.select()");
schoolSearchSelectChange();
}
//获取所有的设备
function getSchoolOptions(){
var options="<option value='000'>请选择学校</option>"
for(var i=0;i<clockStationsInfoArr.length;i++){
var name=clockStationsInfoArr[i]["name"];
options+=`<option value="${name}">${name}</option>`
}
return options;
}
//监听select变化
function schoolSearchSelectChange(){
layuiObj.layuiForm.on('select(mainContentC_schoolSelect)', function(data){
var name=data["value"];
for(var i=0;i<clockStationsInfoArr.length;i++){
if(name==clockStationsInfoArr[i]["name"]){
showSchoolBaseInfo(clockStationsInfoArr[i]);
break;
}
}
})
}
export {initClockSchoolSearchSelect,getSchoolOptions}