Ejemplo n.º 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"
}
Ejemplo n.º 2
0
func getCategoryEnumList() []itemDef.EnumValue {
	_, categorys := svc.GetAll(s.Category)
	enumList := make([]itemDef.EnumValue, len(categorys))
	for idx, category := range categorys {
		key := category[s.Key].(string)
		label := category[s.Name].(string)
		enumList[idx] = itemDef.EnumValue{key, key, label}
	}
	return enumList
}
Ejemplo n.º 3
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)
	}
}