|
@@ -953,7 +953,7 @@ func (this *TargetController) ExportDataList() {
|
|
|
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
- //分类ID
|
|
|
+ // 指标名称
|
|
|
if keyWord != "" {
|
|
|
condition += ` AND a.SEC_NAME LIKE '%` + keyWord + `%'`
|
|
|
}
|
|
@@ -975,10 +975,43 @@ func (this *TargetController) ExportDataList() {
|
|
|
// condition += ` AND a.frequency = ? `
|
|
|
// pars = append(pars, frequency)
|
|
|
//}
|
|
|
+ permissionUserId := sysUser.AdminId
|
|
|
+ if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN {
|
|
|
+ permissionUserId = 0
|
|
|
+ }
|
|
|
+ // 所属分类
|
|
|
if classifyId > 0 {
|
|
|
- condition += ` AND a.classify_id = ? `
|
|
|
- pars = append(pars, classifyId)
|
|
|
+ // 获取有用权限的分类
|
|
|
+ classifyList, err := models.GetEdbdataClassify(int64(permissionUserId))
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var isParent bool
|
|
|
+ classifyIdList := make([]int, 0)
|
|
|
+ for _, v := range classifyList {
|
|
|
+ if v.ClassifyId == classifyId {
|
|
|
+ isParent = true
|
|
|
+ classifyIdList = append(classifyIdList, v.ClassifyId)
|
|
|
+ if v.Child != nil && len(v.Child) > 0 {
|
|
|
+ for _, vv := range v.Child {
|
|
|
+ classifyIdList = append(classifyIdList, vv.ClassifyId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ num := len(classifyIdList)
|
|
|
+ if num > 0 && isParent {
|
|
|
+ condition += ` AND a.classify_id in (` + utils.GetOrmInReplace(num) + `) `
|
|
|
+ pars = append(pars, classifyIdList)
|
|
|
+ } else {
|
|
|
+ condition += ` AND a.classify_id = ? `
|
|
|
+ pars = append(pars, classifyId)
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
if mobile != "" {
|
|
|
condition += ` AND d.mobile=? `
|
|
|
pars = append(pars, mobile)
|
|
@@ -999,7 +1032,7 @@ func (this *TargetController) ExportDataList() {
|
|
|
dir, _ := os.Executable()
|
|
|
exPath := filepath.Dir(dir)
|
|
|
|
|
|
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
|
|
|
+ downloadFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
|
|
|
xlsxFile := xlsx.NewFile()
|
|
|
if err != nil {
|
|
|
br.Msg = "生成文件失败"
|
|
@@ -1129,7 +1162,7 @@ func (this *TargetController) ExportDataList() {
|
|
|
|
|
|
}
|
|
|
|
|
|
- err = xlsxFile.Save(downLoadnFilePath)
|
|
|
+ err = xlsxFile.Save(downloadFilePath)
|
|
|
if err != nil {
|
|
|
//有指标无数据时先导出一遍空表
|
|
|
sheet, err := xlsxFile.AddSheet("无数据")
|
|
@@ -1141,7 +1174,7 @@ func (this *TargetController) ExportDataList() {
|
|
|
rowSecName := sheet.AddRow()
|
|
|
celSecName := rowSecName.AddCell()
|
|
|
celSecName.SetValue("")
|
|
|
- err = xlsxFile.Save(downLoadnFilePath)
|
|
|
+ err = xlsxFile.Save(downloadFilePath)
|
|
|
if err != nil {
|
|
|
br.Msg = "保存文件失败"
|
|
|
br.ErrMsg = "保存文件失败"
|
|
@@ -1150,9 +1183,9 @@ func (this *TargetController) ExportDataList() {
|
|
|
}
|
|
|
|
|
|
fileName += time.Now().Format("06.01.02") + `.xlsx` //文件名称
|
|
|
- this.Ctx.Output.Download(downLoadnFilePath, fileName)
|
|
|
+ this.Ctx.Output.Download(downloadFilePath, fileName)
|
|
|
defer func() {
|
|
|
- os.Remove(downLoadnFilePath)
|
|
|
+ os.Remove(downloadFilePath)
|
|
|
}()
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|