/** * 查询仓储公司列表 * @author zhanglong * @return 仓库列表 */ @RequestMapping("/queryAllWarehouse") public ResultBasicBean<String> queryAllWarehouse() { ResultBasicBean<String> resultPOBean = new ResultBasicBean<String>(); resultPOBean = this.whCompanyService.queryAllWarehouse(); return resultPOBean; }
$(function(){ $.ajax({ type:"get", dataType:"JSON", url:"queryAllWarehouse.aj", success:function(data){ var result = $.parseJSON(data.value); var str1='<option value="">-请选择-</option>'; var str2=""; $.each(result,function(key, val){ if('${(item.companyId)!}'==val[0].companyId){ str1 += '<option value="'+val[0].companyId+'" selected>'+val[0].companyName+'</option>'; }else{ str1 += '<option value="'+val[0].companyId+'">'+val[0].companyName+'</option>'; } }); $("#company_id1").empty(); $("#company_id1").append(str1); var selectedval = $("#company_id1 option:selected").text(); var dqdata = result[selectedval]; if (typeof(dqdata) != "undefined") { $.each(dqdata,function(dqkey,dqval){ if('${(item.whId)!}'==dqval.whId){ str2 += '<option value="'+dqval.whId+'" selected>' + dqval.whName + '</option>'; }else{ str2 += '<option value="'+dqval.whId+'">' + dqval.whName + '</option>'; } }); $("#wh_id1").empty(); $("#wh_id1").append(str2); } $("#company_id1").change(function(){ str2='<option value="">-请选择-</option>'; if(this.value==''){ $("#wh_id1").html(str2); return; } var selectedval1 = $("#company_id1 option:selected").text(); var dqdata1 = result[selectedval1]; $.each(dqdata1,function(dqkey1, dqval1){ str2 += '<option value="'+dqval1.whId+'">' + dqval1.whName + '</option>'; }); $("#wh_id1").empty(); $("#wh_id1").append(str2); str2=""; App.colorbox.resize(); }); } }); });
<select id="queryWHListByCompanyID" resultMap="whInfo"> SELECT WH_ID,WH_NAME,COMPANY_ID,COMPANY_NAME,CONTACT,CONTACT_TEL,ADDRESS,NOTES,ZIP,IS_DEL,CREATE_USER,CREATE_TIME,UPDATE_USER,UPDATE_TIME,EXAM_DATE FROM T_WH_WH_INFO WHERE IS_DEL=0 <if test="f !=null and f.companyID != null"> AND COMPANY_ID = #{f.companyID} </if> <if test="f !=null and f.companyName != null"> <![CDATA[AND COMPANY_NAME LIKE CONCAT('%',#{f.companyName},'%')]]> </if> ORDER BY COMPANY_ID,WH_ID DESC <if test="f !=null and f.pageFlg != null and f.pageFlg == 1"> LIMIT #{beginCount},#{pageRows} </if> </select>
/**
* 查询所有仓储公司及仓库信息
* @return 仓储公司
* @throws LogicException 业务异常
* @see com.yunmall.warehouse.business.logic.WhCompanyLogic#queryAllWarehouse()
*/
public ResultBasicBean<String> queryAllWarehouse() throws LogicException {
ResultBasicBean<String> resultBasicBean = new ResultBasicBean<String>();
Map<String, List<WhInfo>> resultMap = new HashMap<String, List<WhInfo>>();
List<WhInfo> whInfos = whInfoSer.queryWHListByCompanyID(null);
Map<BigInteger, String> tempMap = new HashMap<BigInteger, String>();
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation() // 不导出实体中没有用@Expose注解的属性
.create();
for (int i = Constants.ZERO; i < whInfos.size(); i++) {
tempMap.put(whInfos.get(i).getCompanyId(), whInfos.get(i).getCompanyName());
}
Set set = tempMap.entrySet();
Iterator it = tempMap.entrySet().iterator();
while (it.hasNext()) {
List<WhInfo> reslutList = new ArrayList<WhInfo>();
Entry entry = (Entry) it.next();
for (WhInfo whInfo : whInfos) {
if (whInfo.getCompanyName().equals(entry.getValue())) {
reslutList.add(whInfo);
}
}
resultMap.put(entry.getValue().toString(), reslutList);
}
resultBasicBean.success(gson.toJson(resultMap));
return resultBasicBean;
}
/**
* 仓库ID
*/
@Expose
private BigInteger whId;
/**
* 仓库ID
*/
@Expose
private String whName;
/**
* 仓储公司ID
*/
@Expose
private BigInteger companyId;
/**
* 仓库名称
*/
@Expose
private String companyName;
/**
* 联系人
*/
private String contact;
/**
* 联系电话
*/
private String contactTel;
/**
* 地址
*/
private String address;
/**
* 备注
*/
private String notes;
/**
* 邮编
*/
private String zip;
/**
* 是否删除
*/
private String isDel;
/**
* 创建者
*/
private BigInteger createUser;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新者
*/
private BigInteger updateUser;
/**
* 更新时间
*/
private Date updateTime;
/**
* 月考核日期
*/
private int examDate;
public BigInteger getWhId() {
return whId;
}
public void setWhId(BigInteger whId) {
this.whId = whId;
}
public BigInteger getCompanyId() {
return companyId;
}
public void setCompanyId(BigInteger companyId) {
this.companyId = companyId;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getContact() {
return contact;
}
public void setContact(String contact) {
this.contact = contact;
}
public String getContactTel() {
return contactTel;
}
public void setContactTel(String contactTel) {
this.contactTel = contactTel;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public String getZip() {
return zip;
}
public void setZip(String zip) {
this.zip = zip;
}
public String getIsDel() {
return isDel;
}
public void setIsDel(String isDel) {
this.isDel = isDel;
}
public BigInteger getCreateUser() {
return createUser;
}
public void setCreateUser(BigInteger createUser) {
this.createUser = createUser;
}
public BigInteger getUpdateUser() {
return updateUser;
}
public void setUpdateUser(BigInteger updateUser) {
this.updateUser = updateUser;
}
public int getExamDate() {
return examDate;
}
public void setExamDate(int examDate) {
this.examDate = examDate;
}
public String getWhName() {
return whName;
}
public void setWhName(String whName) {
this.whName = whName;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
jquery二级联动
最新推荐文章于 2022-04-06 21:45:53 发布