|
@@ -73,17 +73,80 @@ func SupplyOrderApiRegistRouters() {
|
73
|
73
|
|
74
|
74
|
//获取供应商列表GetSupplyList
|
75
|
75
|
func (this *SupplyOrderApiController) GetSupplyList() {
|
76
|
|
- ctype, _ := this.GetInt64("ctype")
|
77
|
|
- page, _ := this.GetInt64("page")
|
78
|
|
- limit, _ := this.GetInt64("limit")
|
79
|
|
- code := this.GetString("code")
|
80
|
|
- sname := this.GetString("sname")
|
81
|
|
- cname := this.GetString("cname")
|
82
|
|
- //var tmp map[interface{}]interface{}
|
|
76
|
+ ctype, _ := this.GetInt64("ctype") //供应商类别
|
|
77
|
+ page, _ := this.GetInt64("page") //页码
|
|
78
|
+ limit, _ := this.GetInt64("limit") //
|
|
79
|
+ code := this.GetString("code") //供应商编号
|
|
80
|
+ sname := this.GetString("sname") //供应商名称
|
|
81
|
+ cname := this.GetString("cname") //联系人名子
|
|
82
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
83
|
+ //获取分页的数据
|
83
|
84
|
list, total, err := service.GetSupplyList(ctype, page, limit, code, sname, cname)
|
|
85
|
+ //获取供应商类别
|
|
86
|
+ costClassify := "供应商类别"
|
|
87
|
+ drugTypeParent, _ := service.GetDrugDataConfig(0, costClassify)
|
|
88
|
+ drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
|
|
89
|
+ tmpmap := make(map[int64]string) //储存供应商类别
|
|
90
|
+ namemap := make(map[string]string) //储存首要联系人
|
|
91
|
+ for i := 0; i < len(drugTypeList); i++ {
|
|
92
|
+ k := int64(drugTypeList[i].Value)
|
|
93
|
+ v := drugTypeList[i].Name
|
|
94
|
+ tmpmap[k] = v
|
|
95
|
+ }
|
84
|
96
|
if err == nil {
|
|
97
|
+ for i := 0; i < len(list); i++ {
|
|
98
|
+ code := list[i].SupplierCode
|
|
99
|
+ fistname, errs := service.FindName(code)
|
|
100
|
+ if errs != nil && errs.Error() != "record not found" {
|
|
101
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
102
|
+ return
|
|
103
|
+ }
|
|
104
|
+ namemap[code] = fistname.Name
|
|
105
|
+ }
|
|
106
|
+ type SpSupplierNameList struct { //基于SpSupplierName结构体修改的,为了方便前端取数据整合了一下,删除了几个用不到的字段,添加了联系人名字和供应商类别两个字段
|
|
107
|
+ ID int64
|
|
108
|
+ SupplierCode string
|
|
109
|
+ SupplierName string
|
|
110
|
+ SupplierType int64
|
|
111
|
+ VatRate float64
|
|
112
|
+ Number string
|
|
113
|
+ Bank string
|
|
114
|
+ BankAccount string
|
|
115
|
+ UserOrgId int64
|
|
116
|
+ Status int64
|
|
117
|
+ ContactsId int64
|
|
118
|
+ ConName string //供应商主要联系人名字
|
|
119
|
+ TypeName string //供应商类别
|
|
120
|
+ }
|
|
121
|
+ //初始化该结构体
|
|
122
|
+ tmplist := []*SpSupplierNameList{}
|
|
123
|
+ for i := 0; i < len(list); i++ {
|
|
124
|
+ var typename string //类别名称
|
|
125
|
+ if list[i].SupplierType == 0 {
|
|
126
|
+ typename = ""
|
|
127
|
+ } else {
|
|
128
|
+ typename = tmpmap[list[i].SupplierType]
|
|
129
|
+ }
|
|
130
|
+ tlist := &SpSupplierNameList{
|
|
131
|
+ list[i].ID,
|
|
132
|
+ list[i].SupplierCode,
|
|
133
|
+ list[i].SupplierName,
|
|
134
|
+ list[i].SupplierType,
|
|
135
|
+ list[i].VatRate,
|
|
136
|
+ list[i].Number,
|
|
137
|
+ list[i].Bank,
|
|
138
|
+ list[i].BankAccount,
|
|
139
|
+ list[i].UserOrgId,
|
|
140
|
+ list[i].Status,
|
|
141
|
+ list[i].ContactsId,
|
|
142
|
+ namemap[list[i].SupplierCode],
|
|
143
|
+ typename,
|
|
144
|
+ }
|
|
145
|
+ tmplist = append(tmplist, tlist)
|
|
146
|
+
|
|
147
|
+ }
|
85
|
148
|
this.ServeSuccessJSON(map[string]interface{}{
|
86
|
|
- "list": list,
|
|
149
|
+ "list": tmplist,
|
87
|
150
|
"total": total,
|
88
|
151
|
})
|
89
|
152
|
} else {
|