|
|
@@ -1184,3 +1184,58 @@ func (r *WrHoldLB) GetDataEx() (interface{}, error) {
|
|
|
}
|
|
|
return sData, err
|
|
|
}
|
|
|
+
|
|
|
+// WrFilterItem 筛选框列表项
|
|
|
+type WrFilterItem struct {
|
|
|
+ ITEMTYPE int32 `json:"itemtype" xorm:"'ITEMTYPE'"` // 类型 1-品种 2-品类(商品) 3-仓库
|
|
|
+ ITEMNAME string `json:"itemname" xorm:"'ITEMNAME'"` // 名称
|
|
|
+ ITEMCODE string `json:"itemcode" xorm:"'ITEMCODE'"` // 代码
|
|
|
+ ITEMID int64 `json:"itemid" xorm:"'ITEMID'"` // 项id
|
|
|
+
|
|
|
+ IType string `json:"-" form:"itype"` // 类型 逗号隔开, 如 1,2
|
|
|
+}
|
|
|
+
|
|
|
+func (r *WrFilterItem) calc() {
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func (r *WrFilterItem) buildSql() string {
|
|
|
+ if r.IType == "" {
|
|
|
+ r.IType = "1, 2, 3"
|
|
|
+ }
|
|
|
+ r.IType = strings.ReplaceAll(r.IType, " ", "")
|
|
|
+ sType := strings.Split(r.IType, ",")
|
|
|
+ sqls := make([]string, 0)
|
|
|
+ for _, v := range sType {
|
|
|
+ switch v {
|
|
|
+ case "1":
|
|
|
+ sqls = append(sqls, "select 1 itemtype, t.deliverygoodsid itemid, t.deliverygoodscode itemcode, to_char(t.deliverygoodsname) itemname from deliverygoods t")
|
|
|
+ case "2":
|
|
|
+ sqls = append(sqls, "select 2 itemtype, t.wrstandardid itemid, to_char(t.wrstandardcode) itemcode, to_char(t.wrstandardname) itemname from wrstandard t")
|
|
|
+ case "3":
|
|
|
+ sqls = append(sqls, "select 3 itemtype, t.autoid itemid, t.warehousecode itemcode, to_char(t.warehousename) itemname from warehouseinfo t")
|
|
|
+ default:
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var sqlId string
|
|
|
+ for _, v := range sqls {
|
|
|
+ if len(sqlId) > 0 {
|
|
|
+ sqlId += " union all " + v
|
|
|
+ } else {
|
|
|
+ sqlId = v
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sqlId += " order by itemtype, itemid"
|
|
|
+ return sqlId
|
|
|
+}
|
|
|
+
|
|
|
+// GetDataEx 获取筛选框列表项
|
|
|
+func (r *WrFilterItem) GetDataEx() (interface{}, error) {
|
|
|
+ sData := make([]WrFilterItem, 0)
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
+ for i := range sData {
|
|
|
+ sData[i].calc()
|
|
|
+ }
|
|
|
+ return sData, err
|
|
|
+}
|