|
|
package service
|
|
|
|
|
|
type DataFieldOptions struct {
|
|
|
EnName string `json:"enName"`
|
|
|
CnName string `json:"cnName"`
|
|
|
IsDefault bool `json:"isDefault"`
|
|
|
}
|
|
|
|
|
|
//
|
|
|
//// ExportCompanyUserData 导出公司用户数据
|
|
|
//type ExportCompanyUserData struct {
|
|
|
// SourceData []allied_creation_user.UserDetail
|
|
|
// SelectedField []string
|
|
|
//}
|
|
|
//
|
|
|
//var _ excel.ExcelMaker = (*ExportCompanyUserData)(nil)
|
|
|
//
|
|
|
//func (data ExportCompanyUserData) AllFields() []DataFieldOptions {
|
|
|
// return []DataFieldOptions{
|
|
|
// {EnName: "UserCode", CnName: "用户编码"},
|
|
|
// {EnName: "UserName", CnName: "用户姓名"},
|
|
|
// {EnName: "Phone", CnName: "手机号"},
|
|
|
// {EnName: "DepartmentName", CnName: "所属部门"},
|
|
|
// {EnName: "EnableStatus", CnName: "状态"},
|
|
|
// {EnName: "OrgName", CnName: "组织机构"},
|
|
|
// }
|
|
|
//}
|
|
|
//
|
|
|
//func (data ExportCompanyUserData) DataFieldList() []excel.DataField {
|
|
|
// fields := []excel.DataField{}
|
|
|
// allFields := data.AllFields()
|
|
|
// for _, value2 := range allFields {
|
|
|
// if len(data.SelectedField) == 0 || value2.IsDefault {
|
|
|
// fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
|
|
|
// continue
|
|
|
// }
|
|
|
// for _, value3 := range data.SelectedField {
|
|
|
// if value2.EnName == value3 {
|
|
|
// fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// return fields
|
|
|
//}
|
|
|
//
|
|
|
//func (data ExportCompanyUserData) CellValue(index int, enName string) (value interface{}) {
|
|
|
// if index > data.DataListLen() {
|
|
|
// return ""
|
|
|
// }
|
|
|
// switch enName {
|
|
|
// case "UserCode":
|
|
|
// return data.SourceData[index].UserCode
|
|
|
// case "UserName":
|
|
|
// return data.SourceData[index].UserInfo.UserName
|
|
|
// case "Phone":
|
|
|
// return data.SourceData[index].UserInfo.Phone
|
|
|
// case "DepartmentName":
|
|
|
// if data.SourceData[index].Department != nil {
|
|
|
// return data.SourceData[index].Department.DepartmentName
|
|
|
// } else {
|
|
|
// return ""
|
|
|
// }
|
|
|
// case "EnableStatus":
|
|
|
// status := data.SourceData[index].EnableStatus
|
|
|
// statusName := ""
|
|
|
// // 状态(1:启用 2:禁用 3:注销)
|
|
|
// switch status {
|
|
|
// case 1:
|
|
|
// statusName = "启用"
|
|
|
// case 2:
|
|
|
// statusName = "禁用"
|
|
|
// case 3:
|
|
|
// statusName = "注销"
|
|
|
// }
|
|
|
// return statusName
|
|
|
// case "OrgName":
|
|
|
// if data.SourceData[index].Org != nil {
|
|
|
// return data.SourceData[index].Org.OrgName
|
|
|
// } else {
|
|
|
// return ""
|
|
|
// }
|
|
|
// }
|
|
|
// return nil
|
|
|
//}
|
|
|
//
|
|
|
//func (data ExportCompanyUserData) DataListLen() int {
|
|
|
// return len(data.SourceData)
|
|
|
//}
|
|
|
//
|
|
|
//func (data ExportCompanyUserData) TableTitle() []string {
|
|
|
// return nil
|
|
|
//}
|
|
|
//
|
|
|
////ExportCooperationUserData 导出共创用户数据
|
|
|
//type ExportCooperationUserData struct {
|
|
|
// SourceData []allied_creation_user.UserDetail
|
|
|
// SelectedField []string
|
|
|
//}
|
|
|
//
|
|
|
//var _ excel.ExcelMaker = (*ExportCooperationUserData)(nil)
|
|
|
//
|
|
|
//func (data ExportCooperationUserData) AllFields() []DataFieldOptions {
|
|
|
// return []DataFieldOptions{
|
|
|
// {EnName: "UserCode", CnName: "用户编码"},
|
|
|
// {EnName: "UserName", CnName: "用户姓名"},
|
|
|
// {EnName: "Phone", CnName: "手机号"},
|
|
|
// {EnName: "CooperationCompany", CnName: "共创公司"},
|
|
|
// {EnName: "CooperationDeadline", CnName: "共创到期"},
|
|
|
// {EnName: "EnableStatus", CnName: "状态"},
|
|
|
// }
|
|
|
//}
|
|
|
//
|
|
|
//func (data ExportCooperationUserData) DataFieldList() []excel.DataField {
|
|
|
// fields := []excel.DataField{}
|
|
|
// allFields := data.AllFields()
|
|
|
// for _, value2 := range allFields {
|
|
|
// if len(data.SelectedField) == 0 || value2.IsDefault {
|
|
|
// fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
|
|
|
// continue
|
|
|
// }
|
|
|
// for _, value3 := range data.SelectedField {
|
|
|
// if value2.EnName == value3 {
|
|
|
// fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// return fields
|
|
|
//}
|
|
|
//
|
|
|
//func (data ExportCooperationUserData) CellValue(index int, enName string) (value interface{}) {
|
|
|
// if index > data.DataListLen() {
|
|
|
// return ""
|
|
|
// }
|
|
|
// switch enName {
|
|
|
// case "UserCode":
|
|
|
// return data.SourceData[index].UserCode
|
|
|
// case "UserName":
|
|
|
// return data.SourceData[index].UserInfo.UserName
|
|
|
// case "CooperationCompany":
|
|
|
// return data.SourceData[index].CooperationInfo.CooperationCompany
|
|
|
// case "CooperationDeadline":
|
|
|
// if data.SourceData[index].CooperationInfo.CooperationDeadline.IsZero() || data.SourceData[index].CooperationInfo.CooperationDeadline.Unix() == 0 {
|
|
|
// return ""
|
|
|
// }
|
|
|
// return data.SourceData[index].CooperationInfo.CooperationDeadline.Format("2006-01-02")
|
|
|
// case "Phone":
|
|
|
// return data.SourceData[index].UserInfo.Phone
|
|
|
// case "Email":
|
|
|
// return data.SourceData[index].UserInfo.Email
|
|
|
// case "EnableStatus":
|
|
|
// status := data.SourceData[index].EnableStatus
|
|
|
// statusName := ""
|
|
|
// // 状态(1:启用 2:禁用 3:注销)
|
|
|
// switch status {
|
|
|
// case 1:
|
|
|
// statusName = "启用"
|
|
|
// case 2:
|
|
|
// statusName = "禁用"
|
|
|
// case 3:
|
|
|
// statusName = "注销"
|
|
|
// }
|
|
|
// return statusName
|
|
|
// }
|
|
|
// return nil
|
|
|
//}
|
|
|
//
|
|
|
//func (data ExportCooperationUserData) DataListLen() int {
|
|
|
// return len(data.SourceData)
|
|
|
//}
|
|
|
//
|
|
|
//func (data ExportCooperationUserData) TableTitle() []string {
|
|
|
// return nil
|
|
|
//} |
...
|
...
|
|