Exemple #1
0
func (this *ProductController) UiAdd() {
	item := s.Product
	oItemDef, _ := itemDef.EntityDefMap[item]
	this.Data["Service"] = "/item/add/" + oItemDef.Name
	this.FillFormElement(ui.BuildFormElement(oItemDef, t.Params{s.Sn: u.TUId()}, map[string]string{}))
	_, categorys := svc.GetAll(s.Category)
	this.Data["CategoryOptions"] = ui.BuildSelectOptions(categorys, "", s.Key, s.Name, s.Flag)
	this.TplNames = "product/add.tpl"
}
Exemple #2
0
func (this *ProductController) UiUpdate() {
	item := s.Product
	oItemDef, _ := itemDef.EntityDefMap[item]
	sn := this.GetString(s.Sn)
	if sn == "" {
		beego.Error("UiUpdate error: ", stat.ParamSnIsNone)
		this.Ctx.WriteString(stat.ParamSnIsNone)
		return
	}
	params := t.Params{s.Sn: sn}
	code, oldValueMap := svc.Get(item, params)
	if code == "success" {
		oldValueMap = transProductMap(oldValueMap)
		this.FillFormElement(ui.BuildFormElement(oItemDef, oldValueMap, map[string]string{}))
		_, suppliers := supplierMgr.GetSupplierListByProductSn(sn)
		this.Data["supplierList"] = suppliers
		_, categorys := svc.GetAll(s.Category)
		this.Data["CategoryOptions"] = ui.BuildSelectOptions(categorys, "", s.Key, s.Name, s.Flag)
		this.TplNames = "product/update.tpl"
	} else {
		this.Ctx.WriteString(stat.ItemNotFound)
	}
}