| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 | 
							- package controllers
 
- import (
 
- 	`gdsm/models/dict`
 
- 	"gdsm/models/ec"
 
- 	"github.com/astaxie/beego"
 
- 	_ "github.com/mattn/go-sqlite3"
 
- 	"wb/cc"
 
- 	"wb/ctrl"
 
- 	"wb/ctrl/uibuilder"
 
- 	"wb/ii"
 
- 	"wb/om"
 
- 	"wb/st"
 
- 	"wb/ut"
 
- )
 
- type ProductController struct {
 
- 	ctrl.ItemController
 
- }
 
- func (this *ProductController) NestPrepare() {
 
- 	this.CtxItemInfo, _ = ii.ItemInfoMap["product"]
 
- }
 
- func (this *ProductController) UiAdd() {
 
- 	sn := ut.TUId()
 
- 	this.Data["sn"] = sn
 
- 	this.FillFormElement(uibuilder.BuildFormElement(this.CtxItemInfo, map[string]interface{}{"sn": sn}, map[string]string{}))
 
- 	this.UiAddItem(this.CtxItemInfo)
 
- 	this.TplName = "product/add.tpl"
 
- }
 
- func (this *ProductController) UiBomAdd() {
 
- 	sn := ut.TUId()
 
- 	this.Data["sn"] = sn
 
- 	this.FillFormElement(uibuilder.BuildFormElement(this.CtxItemInfo, map[string]interface{}{"sn": sn}, map[string]string{}))
 
- 	this.UiAddItem(this.CtxItemInfo)
 
- 	this.TplName = "product/bomadd.tpl"
 
- }
 
- func (this *ProductController) UiUpdate() {
 
- 	itemName := this.CtxItemInfo.Name
 
- 	sn := this.GetString(cc.Col.Sn)
 
- 	if sn == "" {
 
- 		beego.Error("ui.Update", st.ParamSnIsNone)
 
- 		this.Ctx.WriteString(st.ParamSnIsNone)
 
- 		return
 
- 	}
 
- 	params := om.Params{ec.Col.Sn: sn}
 
- 	code, oldValueMap := om.Table(itemName).Get(params)
 
- 	if code == st.Success {
 
- 		this.SetDataWithoutDefaultStr(cc.UrlService, this.UrlItemUpdate, "/item/update/"+itemName)
 
- 		sn := oldValueMap.GetString("sn")
 
- 		this.Data["sn"] = sn
 
- 		statusMap := map[string]string{}
 
- 		this.FillValue(oldValueMap)
 
- 		this.FillFormElement(uibuilder.BuildFormElement(this.CtxItemInfo, oldValueMap, statusMap))
 
- 		this.TplName = "product/update.tpl"
 
- 	} else {
 
- 		beego.Error("UiUpdateItem error", st.ItemNotFound)
 
- 		this.Ctx.WriteString(st.ItemNotFound)
 
- 	}
 
- }
 
- func (this *ProductController) UiList() {
 
- 	this.TplName = "product/list.tpl"
 
- }
 
- func (this *ProductController) UiCostList() {
 
- 	this.TplName = "product/costlist.tpl"
 
- }
 
- func (this *ProductController) ItemList() {
 
- 	tableResult := this.GetTableList(this.CtxItemInfo, om.Params{})
 
- 	attList := dict.GetAttachmentList()
 
- 	for _, vm := range tableResult.Rows {
 
- 		sn := vm.GetString(ec.Col.Sn)
 
- 		if ut.IsStrInSlice(attList, sn) {
 
- 			vm["atmt"] = true
 
- 		} else {
 
- 			vm["atmt"] = false
 
- 		}
 
- 	}
 
- 	this.SendJson(&tableResult)
 
- }
 
 
  |