1.在Controller中查询到数据加载到页面中
@RequiresPermissions ( "wms:quality:wmsIqcInspect:view" )
@RequestMapping ( value = { "getInspect" , "" } )
public String getInspect ( WmsIqcInspect wmsIqcInspect, HttpServletRequest request, HttpServletResponse response, Model model) {
Page < WmsIqcInspect > page = wmsIqcInspectService. getInspect ( new Page < WmsIqcInspect > ( request, response) , wmsIqcInspect) ;
model. addAttribute ( "page" , page) ;
List < WmsMaterialManage > wmmList = wmsMaterialManageService. getItemCategory ( ) ;
model. addAttribute ( "itemCategoryList" , wmmList) ;
List < WmsHumidityElement > humidityElementList = wmsHumidityElementService. getItemHumidityElement ( ) ;
model. addAttribute ( "humidityElementList" , humidityElementList) ;
return "modules/wms/quality/wmsIqcInspectList" ;
}
2.在Service中对应的方法
public List < WmsMaterialManage > getItemCategory ( ) {
User user = UserUtils . getUser ( ) ;
return dao. getItemCategory ( user. getFactoryId ( ) ) ;
}
3.在Dao中对应的方法
public List < WmsMaterialManage > getItemCategory ( @Param ( "factoryId" ) String factoryId) ;
4.在xml中对应的方法,给查询出来的字段封装成属性
< select id= "getItemCategory" resultType= "WmsMaterialManage" >
SELECT
ITEM_CATEGORY AS "itemCategory" ,
( CASE WHEN STORAGE_CYCLE IS NOT NULL THEN to_number ( STORAGE_CYCLE ) * 30 ELSE to_number ( STORAGE_CYCLE_DAY ) END ) AS "storageCycle"
FROM
WMS_RECHECK_CATEGORY
< where>
del_flag = '0'
< if test= "factoryId != null and factoryId != ''" >
AND factory_id = #{ factoryId }
< / if >
< / where>
< / select>
5.在对应的页面中进行数据展示
< script type= "text/javascript" >
var list_map = new Array ( ) ;
$ ( document) . ready ( function ( ) {
< c: forEach items= "${itemCategoryList}" var = "itemAndCycle" >
list_map. push ( { itemCategory : "${itemAndCycle.itemCategory}" , storageCycle : "${itemAndCycle.storageCycle}" } ) ;
< / c: forEach>
function getExpirationDate ( ) {
if ( reelmount== "" ) {
$. jBox. info ( "<spring:message code=" jsp. wmsIqcInspectList. p46"/>" ) ; < ! -- - 请先选择单列表的数据"," 系统提示-- - >
return false ;
}
var itemCategoryStyle = $ ( "#itemCategory" ) . find ( "option:selected" ) . text ( ) ;
$ ( "#expirationDate" ) . val ( "" ) ;
if ( list_map != null && list_map. length > 0 ) {
for ( var i = 0 ; i < list_map. length; i++ ) {
if ( list_map[ i] . itemCategory == itemCategoryStyle) {
$ ( "#expirationDate" ) . val ( list_map[ i] . storageCycle) ;
}
}
}
}
} ) ;
< / script>
< tr>
< td class = "tit" > < spring: message code= "jsp.wmsMaterialManageForm.p37" / > < / td> < ! -- 超期物料类别 -- >
< td>
< select id= "itemCategory" class = "select-medium" onchange= "getExpirationDate()" >
< option value= "" > < / option>
< c: forEach items= "${itemCategoryList}" var = "itemCategoryList" >
< option value= "${itemCategoryList.itemCategory}" > ${ itemCategoryList. itemCategory} < / option>
< / c: forEach>
< / select>
< / td>
< td class = "tit" > < spring: message code= "jsp.wmsMaterialManageForm.p17" / > < / td> < ! -- 保质期 ( 天) -- >
< td>
< input id= "expirationDate" class = "input-medium " readOnly= "readOnly" / >
< / td>
< / tr>