Bladeren bron

add:管理规则添加

zqbao 6 maanden geleden
bovenliggende
commit
272dc18df3
2 gewijzigde bestanden met toevoegingen van 62 en 2 verwijderingen
  1. 1 1
      controllers/data_manage/excel/excel_info.go
  2. 61 1
      services/data/excel/excel_info.go

+ 1 - 1
controllers/data_manage/excel/excel_info.go

@@ -3139,7 +3139,7 @@ func (c *ExcelInfoController) AddExcelRule() {
 		br.Msg = "条件值不能为空"
 		return
 	}
-	err = excel2.AddExcelRule(req.LeftValue, req.RightValue, req.LeftValueType, req.RightValueType, req.RuleType, req.Scope, req.FontColor, req.BackGroundColor, req.Remark)
+	err = excel2.AddExcelRule(req.LeftValue, req.RightValue, req.LeftValueType, req.RightValueType, req.RuleType, req.Scope, req.FontColor, req.BackGroundColor, req.Remark, c.Lang)
 	if err != nil {
 		br.Msg = "规则添加失败"
 		br.ErrMsg = "规则添加失败,Err:" + err.Error()

+ 61 - 1
services/data/excel/excel_info.go

@@ -650,6 +650,66 @@ func GetCustomAnalysisOpButton(sysUser *system.Admin, belongUserId int, permissi
 	return
 }
 
-func AddExcelRule(leftValue, rightValue string, leftValueType, rightValueType, ruleType int, scope, fontColor, backGroundColor, remark string) (err error) {
+func AddExcelRule(leftValue, rightValue string, leftValueType, rightValueType, ruleType int, scope, fontColor, backgroundColor, remark, lang string) (err error) {
+	// 发生日期
+	tmpExcelRule := new(excel.ExcelInfoRuleMapping)
+	switch ruleType {
+	// 大于
+	case 1:
+		tmpExcelRule.LeftValueShow = "大于" + leftValue
+	// 小于
+	case 2:
+		tmpExcelRule.LeftValueShow = "小于" + leftValue
+	// 介于
+	case 3:
+		tmpExcelRule.LeftValueShow = "介于" + leftValue + "到" + rightValue
+		tmpExcelRule.RightValueShow = rightValue
+	// 等于
+	case 4:
+		tmpExcelRule.LeftValueShow = "等于" + leftValue
+	// 发生日期
+	case 5:
+		switch leftValue {
+		case "today":
+			tmpExcelRule.LeftValueShow = "今天"
+		// 明天
+		case "tomorrow":
+			tmpExcelRule.LeftValueShow = "明天"
+		// 最近7天
+		case "last7days":
+			tmpExcelRule.LeftValueShow = "最近7天"
+		// 上周
+		case "lastweek":
+			tmpExcelRule.LeftValueShow = "上周"
+		// 本周
+		case "thisweek":
+			tmpExcelRule.LeftValueShow = "本周"
+		// 下周
+		case "nextweek":
+			tmpExcelRule.LeftValueShow = "下周"
+		// 上月
+		case "lastmonth":
+			tmpExcelRule.LeftValueShow = "上月"
+		// 本月
+		case "thismonth":
+			tmpExcelRule.LeftValueShow = "本月"
+		// 下月
+		case "nextmonth":
+			tmpExcelRule.LeftValueShow = "下月"
+		default:
+			err = errors.New("发生日期规则错误")
+			return
+		}
+
+	}
+	tmpExcelRule.LeftValueType = leftValueType
+	tmpExcelRule.FontColor = fontColor
+	tmpExcelRule.BackgroundColor = backgroundColor
+	tmpExcelRule.Remark = remark
+	tmpExcelRule.RemarkEn = remark
+	tmpExcelRule.ScopeShow = scope
+
+	tmpExcelRule.CreateTime = time.Now()
+	_, err = tmpExcelRule.Insert()
 	return
 }