Commit 147b8035 authored by reedmi's avatar reedmi

完善商品分类

parent e7aeabf1
...@@ -11,6 +11,7 @@ import javax.servlet.http.HttpSession; ...@@ -11,6 +11,7 @@ import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.originspark.drp.models.User;
import com.originspark.drp.service.projects.invoices.StockInInvoiceService; import com.originspark.drp.service.projects.invoices.StockInInvoiceService;
import com.originspark.drp.service.projects.invoices.StockOutInvoiceService; import com.originspark.drp.service.projects.invoices.StockOutInvoiceService;
import com.originspark.drp.service.resources.VendorService; import com.originspark.drp.service.resources.VendorService;
...@@ -72,6 +73,10 @@ public class BaseController extends HandlerInterceptorAdapter { ...@@ -72,6 +73,10 @@ public class BaseController extends HandlerInterceptorAdapter {
return request().getSession(); return request().getSession();
} }
public User getCurrentUser() {
return (User)session().getAttribute("user");
}
// 一般用于create、update、delete的返回值 // 一般用于create、update、delete的返回值
protected final static String ok(String message) { protected final static String ok(String message) {
Map<String, Object> modelMap = new HashMap<String, Object>(2); Map<String, Object> modelMap = new HashMap<String, Object>(2);
......
...@@ -5,6 +5,7 @@ import java.util.List; ...@@ -5,6 +5,7 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
...@@ -30,23 +31,22 @@ public class VendorController extends BaseController { ...@@ -30,23 +31,22 @@ public class VendorController extends BaseController {
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
@ResponseBody @ResponseBody
public String create(@RequestBody Vendor vendor,HttpServletRequest request) { public String create(@RequestBody Vendor vendor) {
String name = vendor.getName(); String contactMan = vendor.getContactMan();
if (name == null || name.trim().equals("")) { if (contactMan == null || contactMan.trim().equals("")) {
logger.warn(">添加失败:商品名称不能为空"); return failure("联系人不能为空");
return failure("供应商名称不能为空");
} }
if (vendorService.findByName(name) != null) { String name = vendor.getName();
logger.warn(">添加失败:该供应商已经存在,不可重复添加"); if (!StringUtils.isEmpty(name) && vendorService.findByName(name) != null) {
return failure("该供应商已经存在,不可重复添加"); return failure("该供应商已经存在,不可重复添加");
} }
vendor.setCreatedBy(SessionUtil.getCurrentUserName(request)); vendor.setCreatedBy(getCurrentUser().getName());
vendorService.save(vendor); vendorService.save(vendor);
logger.info(">添加成功:"+vendor.toString()); logger.info(">添加成功:"+vendor.toString());
return ok("创建成功"); return ok("创建成功");
} }
......
...@@ -44,7 +44,7 @@ public class WareController extends BaseController { ...@@ -44,7 +44,7 @@ public class WareController extends BaseController {
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
@ResponseBody @ResponseBody
public String create(@RequestBody Ware ware,HttpServletRequest request) { public String create(@RequestBody Ware ware) {
//validation //validation
String name = ware.getName(); String name = ware.getName();
...@@ -64,10 +64,9 @@ public class WareController extends BaseController { ...@@ -64,10 +64,9 @@ public class WareController extends BaseController {
return failure("该商品已存在,不能重复添加"); return failure("该商品已存在,不能重复添加");
} }
//save ware.setCreatedBy(SessionUtil.getCurrentUserName(request()));
ware.setCreatedBy(SessionUtil.getCurrentUserName(request));
Ware savedWare = wareService.save(ware); Ware savedWare = wareService.save(ware);
logger.info(">添加成功:"+savedWare.toString()); logger.info(">添加成功:"+savedWare.toString());
return ok("创建成功"); return ok("创建成功");
} }
......
...@@ -19,9 +19,10 @@ import com.originspark.drp.models.AbstractModel; ...@@ -19,9 +19,10 @@ import com.originspark.drp.models.AbstractModel;
public class Vendor extends AbstractModel{ public class Vendor extends AbstractModel{
/** /**
* 名称 * 联系人
*/ */
private String name; @Column(name="contactMan")
private String contactMan;
/** /**
* 联系电话 * 联系电话
...@@ -29,15 +30,14 @@ public class Vendor extends AbstractModel{ ...@@ -29,15 +30,14 @@ public class Vendor extends AbstractModel{
private String phone; private String phone;
/** /**
* 地址 * 公司名称
*/ */
private String address; private String name;
/** /**
* 联系人 * 公司地址
*/ */
@Column(name="contactMan") private String address;
private String contactMan;
/** /**
* 备注 * 备注
......
...@@ -62,6 +62,9 @@ public class Ware extends AbstractModel { ...@@ -62,6 +62,9 @@ public class Ware extends AbstractModel {
*/ */
private String note; private String note;
@ManyToOne
private WareCategory category;
/** /**
* 供应商 * 供应商
*/ */
...@@ -140,6 +143,14 @@ public class Ware extends AbstractModel { ...@@ -140,6 +143,14 @@ public class Ware extends AbstractModel {
this.note = note; this.note = note;
} }
public WareCategory getCategory() {
return category;
}
public void setCategory(WareCategory category) {
this.category = category;
}
public Vendor getVendor() { public Vendor getVendor() {
return vendor; return vendor;
} }
......
...@@ -7,6 +7,7 @@ import javax.persistence.ManyToOne; ...@@ -7,6 +7,7 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.originspark.drp.models.AbstractModel; import com.originspark.drp.models.AbstractModel;
/** /**
...@@ -27,6 +28,10 @@ public class WareCategory extends AbstractModel { ...@@ -27,6 +28,10 @@ public class WareCategory extends AbstractModel {
@OneToMany(mappedBy = "parent") @OneToMany(mappedBy = "parent")
private List<WareCategory> chidren; private List<WareCategory> chidren;
@JsonIgnore
@OneToMany(mappedBy = "category")
private List<Ware> wares;
public String getName() { public String getName() {
return name; return name;
} }
...@@ -59,6 +64,14 @@ public class WareCategory extends AbstractModel { ...@@ -59,6 +64,14 @@ public class WareCategory extends AbstractModel {
this.chidren = chidren; this.chidren = chidren;
} }
public List<Ware> getWares() {
return wares;
}
public void setWares(List<Ware> wares) {
this.wares = wares;
}
public boolean getLoaded() { public boolean getLoaded() {
if (getChidren().isEmpty()) { if (getChidren().isEmpty()) {
return true; return true;
......
...@@ -48,7 +48,7 @@ Ext.define("drp.app.controller.resources.VendorController", { ...@@ -48,7 +48,7 @@ Ext.define("drp.app.controller.resources.VendorController", {
}, },
showCreateVendorForm : function(btn) { showCreateVendorForm : function(btn) {
var vendorForm = Ext.widget("vendorviewform"); var vendorForm = Ext.widget("vendorviewform");
AlertWin.alert('新增供应商', null, vendorForm, 500, 370); AlertWin.alert('新增供应商', null, vendorForm, 500, 220);
}, },
showUpdateVendorForm : function(grid, record, item, index, e, eopts) { showUpdateVendorForm : function(grid, record, item, index, e, eopts) {
...@@ -58,7 +58,7 @@ Ext.define("drp.app.controller.resources.VendorController", { ...@@ -58,7 +58,7 @@ Ext.define("drp.app.controller.resources.VendorController", {
return; return;
} else { } else {
vendorForm.down('form').loadRecord(record); vendorForm.down('form').loadRecord(record);
AlertWin.alert('修改供应商', null, vendorForm, 500, 370); AlertWin.alert('修改供应商', null, vendorForm, 500, 220);
} }
}, },
......
...@@ -116,7 +116,7 @@ Ext.define("drp.app.controller.resources.WareController", { ...@@ -116,7 +116,7 @@ Ext.define("drp.app.controller.resources.WareController", {
showCreateWareForm : function(btn) { showCreateWareForm : function(btn) {
var wareForm = Ext.widget("wareviewform"); var wareForm = Ext.widget("wareviewform");
AlertWin.alert('新增商品', null, wareForm, 500, 280); AlertWin.alert('新增商品', null, wareForm, 500, 320);
}, },
showUpdateWareForm : function(grid, record, item, index, e, eopts) { showUpdateWareForm : function(grid, record, item, index, e, eopts) {
...@@ -126,7 +126,7 @@ Ext.define("drp.app.controller.resources.WareController", { ...@@ -126,7 +126,7 @@ Ext.define("drp.app.controller.resources.WareController", {
return; return;
} else { } else {
wareForm.down('form').loadRecord(record); wareForm.down('form').loadRecord(record);
AlertWin.alert('修改商品', null, wareForm, 500, 280); AlertWin.alert('修改商品', null, wareForm, 500, 320);
} }
}, },
...@@ -194,6 +194,14 @@ Ext.define("drp.app.controller.resources.WareController", { ...@@ -194,6 +194,14 @@ Ext.define("drp.app.controller.resources.WareController", {
id : formBean['vendor.id'] id : formBean['vendor.id']
}); });
} }
var categoryField = null;
if(formBean['category.id']){
categoryField = new Ext.data.Field({name:'category'});
model.fields.add(categoryField);
model.set("category",{
id : formBean['category.id']
});
}
//save model //save model
me.saveModel(model, wareGrid); me.saveModel(model, wareGrid);
...@@ -202,6 +210,9 @@ Ext.define("drp.app.controller.resources.WareController", { ...@@ -202,6 +210,9 @@ Ext.define("drp.app.controller.resources.WareController", {
if(vendorField != null){ if(vendorField != null){
model.fields.remove(vendorField); model.fields.remove(vendorField);
} }
if(categoryField != null){
model.fields.remove(categoryField);
}
} }
}, },
...@@ -231,8 +242,7 @@ Ext.define("drp.app.controller.resources.WareController", { ...@@ -231,8 +242,7 @@ Ext.define("drp.app.controller.resources.WareController", {
}]); }]);
}, },
models : [ "drp.app.model.resources.WareModel" ], models : [ "drp.app.model.resources.WareModel", "drp.app.model.resources.WareCategoryModel" ],
stores : [ "drp.app.store.resources.WareStore", "drp.app.store.resources.VendorStore"], stores : [ "drp.app.store.resources.WareStore", "drp.app.store.resources.VendorStore"],
views : [ "drp.app.view.resources.WareView", views : [ "drp.app.view.resources.WareView", "drp.app.view.resources.WareViewForm","drp.widget.UploadFileForm" ]
"drp.app.view.resources.WareViewForm","drp.widget.UploadFileForm" ]
}); });
\ No newline at end of file
...@@ -12,29 +12,11 @@ Ext.define("drp.app.model.resources.VendorModel", { ...@@ -12,29 +12,11 @@ Ext.define("drp.app.model.resources.VendorModel", {
}, { }, {
name : "phone",// 联系电话 name : "phone",// 联系电话
type : "string" type : "string"
}, {
name : "registrationNumber",//注册编号
type : "string"
}, {
name : 'registrationRange',// 承包范围
type : 'string'
}, {
name : 'registrationBank',// 开户行
type : 'string'
}, {
name : 'taxNumber',// 税号
type : 'string'
}, {
name : 'orgCodeCertificate',// 组织机构代码证
type : 'string'
}, {
name : 'note',// 备注
type : 'string'
}, { }, {
name : 'countOfWares',// 产品供应数量 name : 'countOfWares',// 产品供应数量
type : 'int', type : 'int',
persist : false persist : false
} ], }],
proxy : { proxy : {
type : 'rest', type : 'rest',
url : 'vendor', url : 'vendor',
......
...@@ -12,6 +12,12 @@ Ext.define("drp.app.model.resources.WareModel", { ...@@ -12,6 +12,12 @@ Ext.define("drp.app.model.resources.WareModel", {
name : 'produceOn'// 生产日期 name : 'produceOn'// 生产日期
}, { }, {
name : 'storage'// 保质期 name : 'storage'// 保质期
}, {
name : "category.id",
persist : false
}, {
name : "category.name",
persist : false
}, { }, {
name : "vendor.id", name : "vendor.id",
persist : false persist : false
......
...@@ -106,39 +106,9 @@ Ext.define('drp.app.view.resources.VendorView', { ...@@ -106,39 +106,9 @@ Ext.define('drp.app.view.resources.VendorView', {
width : 100, width : 100,
dataIndex : 'countOfWares', dataIndex : 'countOfWares',
text : '供应商品数量' text : '供应商品数量'
},{
xtype : 'gridcolumn',
text : '营业执照',
width : 600,
columns : [{
xtype : 'gridcolumn',
width : 125,
dataIndex : 'registrationNumber',
text : '注册编号'
}, {
xtype : 'gridcolumn',
width : 125,
dataIndex : 'registrationBank',
text : '开户行'
}, {
xtype : 'gridcolumn',
width : 125,
dataIndex : 'registrationRange',
text : '承包范围'
}, {
xtype : 'gridcolumn',
width : 125,
dataIndex : 'taxNumber',
text : '税号'
}, {
xtype : 'gridcolumn',
width : 125,
dataIndex : 'orgCodeCertificate',
text : '组织机构代码证'
}]
}, { }, {
xtype : 'gridcolumn', xtype : 'gridcolumn',
width : 150, width : 200,
dataIndex : 'note', dataIndex : 'note',
text : '备注' text : '备注'
}, { }, {
......
...@@ -12,65 +12,33 @@ Ext.define("drp.app.view.resources.VendorViewForm", { ...@@ -12,65 +12,33 @@ Ext.define("drp.app.view.resources.VendorViewForm", {
}, { }, {
xtype : 'textfield', xtype : 'textfield',
anchor : '60%', anchor : '60%',
margin : '5 0 0 5', margin : '20 0 0 10',
name : 'name', name : 'contactMan',
allowBlank : false,
fieldLabel : '名称<font color="red">*</font>'
}, {
xtype : 'textfield',
anchor : '60%',
margin : '5 0 0 5',
name : 'address',
allowBlank : false, allowBlank : false,
fieldLabel : '地址名称<font color="red">*</font>' fieldLabel : '联系人<font color="red">*</font>'
}, { }, {
xtype : 'textfield', xtype : 'textfield',
anchor : '60%', anchor : '60%',
margin : '5 0 0 5', margin : '5 0 0 10',
name : 'phone', name : 'phone',
allowBlank : false, allowBlank : false,
fieldLabel : '联系电话<font color="red">*</font>' fieldLabel : '联系电话<font color="red">*</font>'
}, { }, {
xtype : 'textfield', xtype : 'textfield',
anchor : '75%', anchor : '60%',
margin : '5 0 0 5', margin : '5 0 0 10',
name : 'contactMan', name : 'name',
allowBlank : false, fieldLabel : '公司名称'
fieldLabel : '联系人名称<font color="red">*</font>'
}, {
xtype : 'textfield',
anchor : '75%',
margin : '5 0 0 5',
name : 'registrationNumber',
fieldLabel : '注册编号'
}, {
xtype : 'textfield',
anchor : '75%',
margin : '5 0 0 5',
name : 'registrationRange',
fieldLabel : '承包范围'
}, {
xtype : 'textfield',
anchor : '75%',
margin : '5 0 0 5',
name : 'registrationBank',
fieldLabel : '开户行'
}, {
xtype : 'textfield',
anchor : '75%',
margin : '5 0 0 5',
name : 'orgCodeCertificate',
fieldLabel : '组织机构代码证'
}, { }, {
xtype : 'textfield', xtype : 'textfield',
anchor : '75%', anchor : '60%',
margin : '5 0 0 5', margin : '5 0 0 10',
name : 'taxNumber', name : 'address',
fieldLabel : '税号' fieldLabel : '公司地址'
}, { }, {
xtype : 'textarea', xtype : 'textarea',
anchor : '90%', anchor : '90%',
margin : '5 0 0 5', margin : '5 0 0 10',
name : 'note', name : 'note',
fieldLabel : '备注' fieldLabel : '备注'
}, { }, {
......
...@@ -94,7 +94,10 @@ Ext.define('drp.app.view.resources.WareView', { ...@@ -94,7 +94,10 @@ Ext.define('drp.app.view.resources.WareView', {
xtype : 'gridcolumn', xtype : 'gridcolumn',
width : 160, width : 160,
dataIndex : 'name', dataIndex : 'name',
text : '品名' text : '品名',
renderer : function(value, mate, record) {
return record.data['category.name'] + '-' + value;
}
}, { }, {
xtype : 'gridcolumn', xtype : 'gridcolumn',
width : 160, width : 160,
......
...@@ -12,6 +12,16 @@ Ext.define("drp.app.view.resources.WareViewForm", { ...@@ -12,6 +12,16 @@ Ext.define("drp.app.view.resources.WareViewForm", {
xtype : 'textfield', xtype : 'textfield',
hidden : true, hidden : true,
name : 'id' name : 'id'
}, {
xtype : 'treecombobox',
anchor : '60%',
margin : '5 0 0 5',
name : 'category.id',
valueField : 'id',
displayField : 'name',
editable : false,
model : 'drp.app.model.resources.WareCategoryModel',
fieldLabel : '产品种类'
}, { }, {
xtype : 'textfield', xtype : 'textfield',
anchor : '60%', anchor : '60%',
...@@ -27,7 +37,8 @@ Ext.define("drp.app.view.resources.WareViewForm", { ...@@ -27,7 +37,8 @@ Ext.define("drp.app.view.resources.WareViewForm", {
fieldLabel : '规格' fieldLabel : '规格'
}, { }, {
xtype : 'combobox', xtype : 'combobox',
fieldLabel : '单位', fieldLabel : '单位<font color="red">*</font>',
allowBlank : false,
anchor : '60%', anchor : '60%',
margin : '5 0 0 5', margin : '5 0 0 5',
name : 'unit', name : 'unit',
...@@ -37,7 +48,10 @@ Ext.define("drp.app.view.resources.WareViewForm", { ...@@ -37,7 +48,10 @@ Ext.define("drp.app.view.resources.WareViewForm", {
fields : ['value', 'name'], fields : ['value', 'name'],
data : [{ data : [{
"value" : "", "value" : "",
"name" : "吨/T" "name" : ""
}, {
"value" : "",
"name" : ""
}, { }, {
"value" : "", "value" : "",
"name" : "" "name" : ""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment