81,095
社区成员
发帖
与我相关
我的任务
分享
function LoadForm(baseUrl)
{
var fpProductSearch = new Ext.FormPanel({
renderTo: 'searchDiv',
id:"fpProductSearch",
labelWidth: 75,
frame:true,
title: '产品搜索',
bodyStyle:'padding:5px 5px 0',
width: 350,
defaults: {width: 230},
defaultType: 'textfield',
items: [{
fieldLabel: '产品名称',
emptyText:'B-5538(YAS023400)',
name: 'product.productname'
}],
buttons: [{
id:"btnSearch",
text: '查找',
handler: function(){
var baseParams = fpProductSearch.form.getValues();
fpProduct.getForm().reset();
Ext.Ajax.request({
url : baseUrl + '/productAction!SearchProduct',
method:"post",
params: baseParams,
success: function (response,options) {
obj = Ext.decode(response.responseText);
if(obj.success)
{
fpProduct.getForm().setValues(obj.message);
}else
{
Ext.Msg.alert('错误', obj.message);
}
},
failure: function(response,options) {
Ext.Msg.alert('错误', response.statusText);
}
});
}
},{
id:"btnSReset",
text: '清空',
handler: function(){
fpProductSearch.getForm().reset();
}
}]
});
var fpProduct = new Ext.FormPanel({
renderTo: 'resultDiv',
labelAlign: 'top',
frame:true,
title: '产品信息编辑',
bodyStyle:'padding:5px 5px 0',
width: 960,
items: [{
layout:'column',
items:[{
columnWidth:.25,
layout: 'form',
items: [{
xtype:'textfield',
fieldLabel: '产品名称',
name: 'productname',
anchor:'95%'
}, {
xtype:'textfield',
fieldLabel: '创建人',
name: 'creator',
anchor:'95%'
}
, {
xtype:'textfield',
fieldLabel: '客户',
name: 'customeruid',
anchor:'95%'
}
, {
xtype:'textfield',
fieldLabel: '拼板数量',
name: 'panelnum',
anchor:'95%'
}
, {
xtype:'textfield',
fieldLabel: '备注',
name: 'description',
anchor:'95%'
}]
},{
columnWidth:.25,
layout: 'form',
items: [{
xtype:'textfield',
fieldLabel: '物料号',
name: 'productpartnumber',
anchor:'95%'
},{
xtype:'textfield',
fieldLabel: '创建时间',
name: 'createDateStr',
anchor:'95%'
}, {
xtype:'textfield',
fieldLabel: '位号图',
name: 'drawuid',
anchor:'95%'
}, {
xtype:'textfield',
fieldLabel: 'B面点数',
name: 'bottomplaneqty',
anchor:'95%'
}, {
xtype:'combo',
fieldLabel: '状态',
store:productStatusStore,
name: 'productstatus',
hiddenName:'productstatus',
mode : 'local',
valueField: 'accountType',
displayField: 'accountTypeName',
triggerAction: "all",
editable:false,
anchor:'95%'
}]
}
,{
columnWidth:.25,
layout: 'form',
items: [{
xtype:'textfield',
fieldLabel: '版本',
name: 'productversion',
anchor:'95%'
},{
xtype:'textfield',
fieldLabel: '最后修改人',
name: 'modifier',
anchor:'95%'
}, {
xtype:'textfield',
fieldLabel: '工艺',
name: 'proroutinguid',
anchor:'95%'
}, {
xtype:'textfield',
fieldLabel: 'T面点数',
name: 'topplaneqty',
anchor:'95%'
}]
}
,{
columnWidth:.25,
layout: 'form',
items: [{
xtype:'textfield',
fieldLabel: '产品型号',
name: 'productcode',
anchor:'95%'
},{
xtype:'textfield',
fieldLabel: '最后修改时间',
name: 'updateDateStr',
anchor:'95%'
}, {
xtype:'textfield',
fieldLabel: 'BOM',
name: 'bomuid',
anchor:'95%'
}, {
xtype:'textfield',
fieldLabel: '变更号',
name: 'ecn',
anchor:'95%'
}]
}]
}],
buttons: [{
text: '提交',
handler: function(){
var pros=fpProduct.form.getValues();
Ext.Ajax.request({
url : baseUrl + '/productAction!UpdateProduct',
params: pros,
success: function (response, option) {
obj = Ext.decode(response.responseText);
fpProduct.getForm().setValues(obj);
}})
}
},{
text: '清空',
handler: function(){
fpProduct.getForm().reset();
}
}]
});
}
package dmes.action;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import net.sf.json.JSONObject;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import dmes.po.Product;
import dmes.service.ProductService;
/**
* @author James.Lu
* @date:2012-5-23 下午09:30:57
* @version : 0.1
*
*/
public class ProductAction extends BaseAction {
/**
*
*/
private static final long serialVersionUID = -3370426361991359641L;
private Product product = null;
@Resource
private ProductService productService =null;
public ProductAction()
{
dataMap = new HashMap<String, Object>();
}
public String SearchProduct()
{
dataMap.clear();
if(product==null)
{
dataMap.put("message","产品名称不能为空!");
dataMap.put("success", false);
}
Product result = productService.SearchProduct(product);
if(result!=null)
{
dataMap.put("message",result);
dataMap.put("success", true);
}
else
{
dataMap.put("message","没有找到相关产品信息!");
dataMap.put("success", false);
}
return SUCCESS;
}
public String UpdateProduct()
{
dataMap.clear();
Map objMap = getRequest().getParameterMap();
JSONObject json = JSONObject.fromObject(objMap);
if(product==null)
{
dataMap.put("message","产品名称不能为空!");
dataMap.put("success", false);
}
Product result = productService.SearchProduct(product);
if(result!=null)
{
dataMap.put("message",result);
dataMap.put("success", true);
}
else
{
dataMap.put("message","没有找到相关产品信息!");
dataMap.put("success", false);
}
return SUCCESS;
}
/**
* @param product the product to set
*/
public void setProduct(Product product) {
this.product = product;
}
/**
* @return the product
*/
public Product getProduct() {
return product;
}
/**
* @param productService the productService to set
*/
public void setProductService(ProductService productService) {
this.productService = productService;
}
/**
* @return the productService
*/
public ProductService getProductService() {
return productService;
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.i18n.encoding" value="UTF-8" />
<package name="json" namespace="/" extends="json-default">
<action name="login" class="dmes.action.LoginAction" method="login">
<result type="json">
<param name="root">dataMap</param>
</result>
</action>
<action name="productAction" class="dmes.action.ProductAction" method="SearchProduct">
<result type="json">
<param name="root">dataMap</param>
</result>
</action>
<action name="productAction" class="dmes.action.ProductAction" method="UpdateProduct">
<result type="json">
<param name="root">dataMap</param>
</result>
</action>
</package>
</struts>