JAVAEE工程筆記2

入庫管理列表中的查看界面數據顯示:

1.打開HTML界面,找到查看入庫部分javascript

<div id="showDiv" class="mini-window" style="width:1000px;height:500px;" title="查看入庫"><!--查看---->
	 <fieldset style="border:solid 1px #aaa;position:relative;margin:5px 2px 0px 2px;">
            <legend>
                基本信息
            </legend>
            <div id="dataform2" style="padding-top:5px;">
                <table style="width:100%;height:95%;" class="mini-form-table">
                    <tr>
                        <td>
                            單據號:               
                        </td>
                        <td colspan="1">
                            <input class="mini-textbox" name="orderNum" />
                        </td>
                        <td>
                            單據日期:
                        </td>
                        <td colspan="1">
                            <input class="mini-datepicker" name="orderDate" id="datepicker"/>
                        </td>
                   
                        <td>
                            儲存性質:
                        </td>
                        <td colspan="1">
                            <input class="mini-textbox" name="typeName"  />
                        </td>
                         </tr>
                    <tr>
                    <td>
                           倉庫:
                        </td>
                        <td colspan="1">
                            <input class="mini-textbox" name="warehouseName"/>
                        </td>
                        <td>
                            到貨日期:
                        </td>
                        <td colspan="1">
                            <input class="mini-datepicker" name="arriveDate" />
                        </td>
                           <td>
                           供應商:
                        </td>
                        <td colspan="1">
                            <input class="mini-textbox" name="supplyId" />
                        </td>
                        <td>
                            狀態:
                        </td>
                        <td colspan="1">
                            <input class="mini-textbox" name="statusName" />
                        </td>
                    </tr>
                    <tr>
                        <td >
                            備註:
                        </td>
                        <td colspan="5">
                            <textarea class="mini-textarea" name="remark" style="width:84.4%"></textarea>
                        </td>
                    </tr>
                </table>
            </div>
        </fieldset>
        <!-- 從表的修改 -->
        <div style="margin:0px 2px 0px 2px;" >
            <div class="mini-tabs" activeIndex="0" style="width:100%;height:100%;">
                <div title="入庫明細">
                    <div id="grid_1" class="mini-datagrid" url="/inventoryIn.do?method=getInventoryInDetailById" style="width:100%;height:150px;" showPager="false" sortMode="client" allowCellEdit="true" 
                    allowCellSelect="true" multiSelect="true" editNextOnEnterKey="true" showPageInfo="true" >
                        <div property="columns">
                            <div type="indexcolumn">
                            </div>
                            <div type="checkcolumn">
                            </div>
                            <div field="materialId" allowSort="true" align="left" headerAlign="center" width="" visible="false">
                            </div>
                            <div field="materialCode" allowSort="true" align="left" headerAlign="center" width="">
                                品號
                            </div>
                            <div field="materialName" allowSort="true" align="left" headerAlign="center" width="">
                                品名
                            </div>
                            <div field="spec" allowSort="true" align="left" headerAlign="center" width="">
                                規格
                            </div>
                            <div field="unitId" allowSort="true" align="left" headerAlign="center" width="" visible="false">
                                單位
                            </div>
                            <div field="unitName" allowSort="true" align="left" headerAlign="center" width="">
                                單位
                            </div>
                            <div field="quantity" allowSort="true" align="left" headerAlign="center" width="">
                                數量
                            </div>
                            <div field="price" allowSort="true" align="left" headerAlign="center" width="">
                                含稅單價
                            </div>
                            <div field="amount" allowSort="true" align="left" headerAlign="center" width="">
                               含稅金額
                            </div>
                            <div field="warehouseLocationId" allowSort="true" align="left" headerAlign="center" width="">
                                垛位
                            </div>
                            <div field="beginDate" allowSort="true" align="left" headerAlign="center" width="" dateFormat= "yyyy-MM-dd">
                                生產日期
                            </div>
                            <div field="endDate" allowSort="true" align="left" headerAlign="center" width="" dateFormat= "yyyy-MM-dd">
                                有效期
                            </div>
                            <div field="inventoryInDetailRemark" allowSort="true" align="left" headerAlign="center" width="">
                                備註
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
</div>

找到點擊查看時調用的JS代碼html

//操做
function onActionRenderer(e) {
	var s =  ' <a href="javascript:view()">查看</a>';
    return s;
}

//查看
function view(){
	var row = grid.getSelected();
	if(row){
		form1.setData(row);
		grid1.load({id:row.id});
		showDiv.show();
	}else{
		mini.alert("請選擇一條記錄", "系統提示");
	}
}

當點擊查看時   grid1.load({id:row.id});  觸發 grid1 中的 java

url="/inventoryIn.do?method=getInventoryInDetailById"sql

inventoryIn.do ===inventoryIn.controlle.java 中的  getInventoryInDetailById方法數據庫

/**
	 * 根據入庫主表id獲取從表信息(查看)
	 */
	@NotLogging
	public ModelAndView getInventoryInDetailById(HttpServletRequest request,
			HttpServletResponse response) {

		String p = request.getParameter("page");
		String limit = request.getParameter("limit");
		int toLimit = NumberUtils.toInt(limit, Constants.VALUE_PAGE_SIZE);
		int toStart = (NumberUtils.toInt(p, 0) - 1) * toLimit;

		String inventoryInId = request.getParameter("id");
		List<InventoryInDto> inventoryInDetail = inventoryInDetailManager
				.getInventoryInDetailDtoList(toStart, toLimit, inventoryInId);

		this.renderText(response, JsonUtil.toJsonString(inventoryInDetail));
		return null;
	}

}

List<InventoryInDto> inventoryInDetail = inventoryInDetailManager
                .getInventoryInDetailDtoList(toStart, toLimit, inventoryInId);app

查找 getInventoryInDetailDtoList 函數 函數

/**
	 * 根據入庫單主表id獲取內容【帶分頁】
	 * 
	 * @return
	 */
	public List<InventoryInDto> getInventoryInDetailDtoList(int start,
			int pageSize, String inventoryInId) {

		StringBuffer sb = new StringBuffer();
		sb.append(" SELECT iiid.ID AS IID,iiid.IID_MATERIAL_CODE,iiid.IID_MATERIAL_NAME,iiid.IID_SPEC,iiid.IID_UNIT_ID,iiid.IID_QUANTITY,iiid.IID_PRICE,iiid.IID_AMOUNT,iiid.IID_WAREHOUSE_LOCATION_ID,iiid.IID_BEGIN_DATE,iiid.IID_END_DATE,iiid.IID_REMARK, ");
		sb.append(" sp.SP_NAME as 'UNIT_NAME'");

		sb.append(" from inv_inventory_in_detail iiid,sys_param sp");
		sb.append(" where iiid.IID_UNIT_ID=sp.ID");
		// sb.append(" AND sp.SP_FLAG='1'");

		if (inventoryInId != null && !inventoryInId.equalsIgnoreCase("")) {
			sb.append(" AND iiid.IID_INVENTORY_IN_ID='" + inventoryInId + "'");
		}
		sb.append(" ORDER BY iiid.CREATE_TIME desc");

		Query query = this.getSqlQuery(sb.toString());
		query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);

		Page page = this.pageSqlQuery(query, sb.toString(), start, pageSize,
				super.COUNT_MODE, null);

		InventoryInDto inventoryInDto = null;
		List<InventoryInDto> InventoryInDtoList = new ArrayList<InventoryInDto>();
		for (Map<String, Object> map : (List<Map<String, Object>>) page
				.getData()) {
			inventoryInDto = new InventoryInDto();

			inventoryInDto.setInventoryInDetailId(Long.parseLong(String
					.valueOf(map.get("IID"))));
			inventoryInDto.setMaterialCode(String.valueOf(map
					.get("IID_MATERIAL_CODE")));
			inventoryInDto.setMaterialName(String.valueOf(map
					.get("IID_MATERIAL_NAME")));
			inventoryInDto.setSpec(String.valueOf(map.get("IID_SPEC")));

			inventoryInDto.setUnitId(Long.parseLong(String.valueOf(map
					.get("IID_UNIT_ID"))));
			inventoryInDto.setUnitName(String.valueOf(map.get("UNIT_NAME")));

			inventoryInDto.setQuantity(String.valueOf(map.get("IID_QUANTITY")));
			inventoryInDto.setPrice(String.valueOf(map.get("IID_PRICE")));
			inventoryInDto.setAmount(String.valueOf(map.get("IID_AMOUNT")));
			inventoryInDto.setWarehouseLocationId(Long.parseLong(String.valueOf(map
					.get("IID_WAREHOUSE_LOCATION_ID"))));
			inventoryInDto.setBeginDate(String.valueOf(map
					.get("IID_BEGIN_DATE")));
			inventoryInDto.setEndDate(String.valueOf(map.get("IID_END_DATE")));
			inventoryInDto.setInventoryInDetailRemark(String.valueOf(map
					.get("IID_REMARK")));
			InventoryInDtoList.add(inventoryInDto);

		}
		page.setData(InventoryInDtoList);
		return InventoryInDtoList;
	}
}

修改sql語句 與數據庫中字段對應this

相關文章
相關標籤/搜索