예제 #1
0
파일: ui.go 프로젝트: zixinjian/webo_dev
func (this *UiController) Update() {
	item, ok := this.Ctx.Input.Params[":hi"]
	if !ok {
		beego.Error(stat.ParamItemError)
		this.Ctx.WriteString(stat.ParamItemError)
		return
	}
	oItemDef, ok := itemDef.EntityDefMap[item]
	if !ok {
		beego.Error(fmt.Sprintf("Item %s not define", item))
		this.Ctx.WriteString(stat.ItemNotDefine)
		return
	}
	sn := this.GetString(s.Sn)
	if sn == "" {
		beego.Error("ui.Update", stat.ParamSnIsNone)
		this.Ctx.WriteString(stat.ParamSnIsNone)
		return
	}
	params := t.Params{s.Sn: sn}
	code, oldValueMap := svc.Get(item, params)
	if code == "success" {
		this.Data["Service"] = "/item/update/" + item
		this.Data["Form"] = ui.BuildUpdatedForm(oItemDef, oldValueMap)
		this.Data["Onload"] = ui.BuildUpdateOnLoadJs(oItemDef)
		this.TplNames = "item/update.tpl"
	} else {
		this.Ctx.WriteString(stat.ItemNotFound)
	}
}
예제 #2
0
func (this *SupplierController) UiUpdate() {
	item := s.Supplier
	oItemDef, _ := itemDef.EntityDefMap[item]
	sn := this.GetString(s.Sn)
	if sn == "" {
		beego.Error("ui.Update", stat.ParamSnIsNone)
		this.Ctx.WriteString(stat.ParamSnIsNone)
		return
	}
	params := t.Params{s.Sn: sn}
	code, oldValueMap := svc.Get(item, params)
	if code == "success" {
		this.Data["Service"] = "/item/update/" + item
		oItemDef.FillEnum(s.Category, getCategoryEnumList())
		this.Data["Form"] = ui.BuildUpdatedForm(oItemDef, oldValueMap)
		this.Data["Onload"] = ui.BuildUpdateOnLoadJs(oItemDef)
		this.TplNames = "item/update.tpl"
	} else {
		this.Ctx.WriteString(stat.ItemNotFound)
	}
}
예제 #3
0
func (this *TravelController) UiUpdate() {
	if this.GetCurRole() == s.RoleUser {
		this.Ctx.WriteString("没有权限")
		return
	}
	item := s.Travel
	oItemDef, _ := itemDef.EntityDefMap[item]
	sn := this.GetString(s.Sn)
	if sn == "" {
		beego.Error("TravelController.UiUpdate", stat.ParamSnIsNone)
		this.Ctx.WriteString(stat.ParamSnIsNone)
		return
	}
	params := t.Params{s.Sn: sn}
	code, oldValueMap := svc.Get(item, params)
	if code == "success" {
		this.Data["Service"] = "/item/update/" + item
		this.Data["Form"] = ui.BuildUpdatedForm(extendUserField(oItemDef, s.Approver), expandTravelMapForUpdate(oldValueMap))
		this.Data["Onload"] = ui.BuildUpdateOnLoadJs(oItemDef)
		this.TplNames = "travel/update.tpl"
	} else {
		this.Ctx.WriteString(stat.ItemNotFound)
	}
}