jingganjiaoyu ad55681d8d opt some
2024-08-20 19:53:47 +08:00

81 lines
2.7 KiB
Go

package gongyinglian
import (
"shylinux.com/x/ice"
kit "shylinux.com/x/toolkits"
"shylinux.com/x/enterprise/src/gongyinglian/model"
)
type Product struct {
TableView
shop Shop
warehouse Warehouse
quality quality
brand brand
models string `data:"product"`
create string `name:"create product_type*:select name* info price stock unit" role:"boss"`
modify string `name:"modify name* info price stock unit" role:"boss"`
setShop string `name:"setShop shop_uid*" role:"boss"`
setWarehouse string `name:"setWarehouse warehouse_uid*" role:"boss"`
setQuality string `name:"setQuality quality_uid*" role:"boss"`
setBrand string `name:"setBrand brand_uid*" role:"boss"`
}
func (s Product) Create(m *ice.Message, arg ...string) {
arg = kit.TransArgKeys(arg, model.PRODUCT_TYPE, model.TYPE)
s.TableView.Create(m, arg...)
}
func (s Product) List(m *ice.Message, arg ...string) {
m.Info("what %v", 123)
if m.Option(model.PRODUCT_TYPE) != kit.Format(ProductGoods) && !s.checkListRole(m, arg...) {
return
}
m.Info("what %v", 123)
if len(arg) == 0 {
m.Info("what %v", 123)
args := m.OptionSimple(model.STORE_UID)
kit.If(m.Option(model.PRODUCT_TYPE), func(p string) { args = append(args, model.TYPE, p) })
s.Select(m, args...)
return
}
s.Tables(m, s.shop, s.warehouse, s.quality, s.brand).FieldsWithCreatedAT(m, s,
s.Key(s, model.NAME), s.Key(s, model.INFO), model.PRODUCT_TYPE,
model.PRICE, model.STOCK, model.UNIT,
model.SHOP_NAME, model.WAREHOUSE_NAME, model.QUALITY_NAME, model.BRAND_NAME,
)
args := []string{s.Key(s, model.STORE_UID), arg[0]}
kit.If(m.Option(model.PRODUCT_TYPE), func(p string) { args = append(args, s.Key(s, model.TYPE), p) })
if len(arg) == 1 {
s.Select(m, args...)
kit.If(!m.IsErr() && m.Length() == 0, func() { m.EchoInfoButton("", s.Create) })
} else if len(arg) == 2 {
s.SelectDetail(m, append(args, s.Key(s, model.UID), arg[1])...)
} else {
return
}
m.PushAction(s.Modify, s.Remove).Display("")
}
func (s Product) SetShop(m *ice.Message, arg ...string) { s.TableView.Modify(m, arg...) }
func (s Product) SetWarehouse(m *ice.Message, arg ...string) { s.TableView.Modify(m, arg...) }
func (s Product) SetQuality(m *ice.Message, arg ...string) { s.TableView.Modify(m, arg...) }
func (s Product) SetBrand(m *ice.Message, arg ...string) { s.TableView.Modify(m, arg...) }
func init() { ice.TeamCtxCmd(Product{}) }
type ProductType int
const (
ProductBoth ProductType = iota
ProductGoods
ProductMaterial
)
var ProductTypeList = map[ProductType]string{
ProductBoth: "both",
ProductGoods: "goods",
ProductMaterial: "material",
}
func (s ProductType) String() string { return ProductTypeList[s] }