正在显示
4 个修改的文件
包含
35 行增加
和
1 行删除
不能预览此文件类型
| @@ -12,6 +12,7 @@ type PerformanceApplicationForm struct { | @@ -12,6 +12,7 @@ type PerformanceApplicationForm struct { | ||
| 12 | Standard string //标准 | 12 | Standard string //标准 |
| 13 | Task string //任务、指标 | 13 | Task string //任务、指标 |
| 14 | Definition string //定义 | 14 | Definition string //定义 |
| 15 | + Required string // 是否必填 是 否 | ||
| 15 | } | 16 | } |
| 16 | 17 | ||
| 17 | type PerformanceDimension struct { | 18 | type PerformanceDimension struct { |
| @@ -24,6 +25,7 @@ type PerformanceModule struct { | @@ -24,6 +25,7 @@ type PerformanceModule struct { | ||
| 24 | Weight string `json:"weight"` //权重 | 25 | Weight string `json:"weight"` //权重 |
| 25 | Standard string `json:"standard"` //标准(结构化的成果描述) | 26 | Standard string `json:"standard"` //标准(结构化的成果描述) |
| 26 | Target []*PerformanceTarget `json:"performanceTarget"` //任务\指标 | 27 | Target []*PerformanceTarget `json:"performanceTarget"` //任务\指标 |
| 28 | + Required int `json:"required"` // 是否必填 | ||
| 27 | } | 29 | } |
| 28 | 30 | ||
| 29 | type PerformanceTarget struct { | 31 | type PerformanceTarget struct { |
| @@ -34,6 +36,7 @@ type PerformanceTarget struct { | @@ -34,6 +36,7 @@ type PerformanceTarget struct { | ||
| 34 | func LoadPerformanceDimensions(rows [][]string) ([]*PerformanceDimension, error) { | 36 | func LoadPerformanceDimensions(rows [][]string) ([]*PerformanceDimension, error) { |
| 35 | formRows := make([]*PerformanceApplicationForm, 0) | 37 | formRows := make([]*PerformanceApplicationForm, 0) |
| 36 | var dimensionName, moduleName, taskName, weightName, standardName string | 38 | var dimensionName, moduleName, taskName, weightName, standardName string |
| 39 | + required := "是" | ||
| 37 | for key, item := range rows { | 40 | for key, item := range rows { |
| 38 | if key < 3 { | 41 | if key < 3 { |
| 39 | continue | 42 | continue |
| @@ -80,6 +83,11 @@ func LoadPerformanceDimensions(rows [][]string) ([]*PerformanceDimension, error) | @@ -80,6 +83,11 @@ func LoadPerformanceDimensions(rows [][]string) ([]*PerformanceDimension, error) | ||
| 80 | } | 83 | } |
| 81 | } | 84 | } |
| 82 | form.Standard = standardName | 85 | form.Standard = standardName |
| 86 | + //是否必填 | ||
| 87 | + if len(item) > 9 && item[9] != "" { | ||
| 88 | + required = strings.TrimSpace(item[9]) | ||
| 89 | + } | ||
| 90 | + form.Required = required | ||
| 83 | formRows = append(formRows, form) | 91 | formRows = append(formRows, form) |
| 84 | } | 92 | } |
| 85 | dimensions := make([]*PerformanceDimension, 0) | 93 | dimensions := make([]*PerformanceDimension, 0) |
| @@ -144,11 +152,16 @@ func loadPerformanceModule(forms []*PerformanceApplicationForm) ([]*PerformanceM | @@ -144,11 +152,16 @@ func loadPerformanceModule(forms []*PerformanceApplicationForm) ([]*PerformanceM | ||
| 144 | if err != nil { | 152 | if err != nil { |
| 145 | return modules, err | 153 | return modules, err |
| 146 | } | 154 | } |
| 155 | + required, err := getRequired(item) | ||
| 156 | + if err != nil { | ||
| 157 | + return modules, err | ||
| 158 | + } | ||
| 147 | module := &PerformanceModule{ | 159 | module := &PerformanceModule{ |
| 148 | ModuleName: moduleName, | 160 | ModuleName: moduleName, |
| 149 | Weight: weightName, | 161 | Weight: weightName, |
| 150 | Standard: standardName, | 162 | Standard: standardName, |
| 151 | Target: tasks, | 163 | Target: tasks, |
| 164 | + Required: required, | ||
| 152 | } | 165 | } |
| 153 | modules = append(modules, module) | 166 | modules = append(modules, module) |
| 154 | } | 167 | } |
| @@ -201,6 +214,27 @@ func getStandard(items []*PerformanceApplicationForm) (string, error) { | @@ -201,6 +214,27 @@ func getStandard(items []*PerformanceApplicationForm) (string, error) { | ||
| 201 | return name, nil | 214 | return name, nil |
| 202 | } | 215 | } |
| 203 | 216 | ||
| 217 | +// 获取是否必填 | ||
| 218 | +func getRequired(items []*PerformanceApplicationForm) (int, error) { | ||
| 219 | + if len(items) <= 0 { | ||
| 220 | + return NodeRequiredYes, nil | ||
| 221 | + } | ||
| 222 | + var name string | ||
| 223 | + for _, item := range items { | ||
| 224 | + if name == "" { | ||
| 225 | + name = item.Required | ||
| 226 | + } | ||
| 227 | + if name != item.Required { | ||
| 228 | + return NodeRequiredYes, errors.New(item.ModuleName + " 对应的是否必填不一致") | ||
| 229 | + } | ||
| 230 | + } | ||
| 231 | + if name == "否" { | ||
| 232 | + return NodeRequiredNo, nil | ||
| 233 | + } else { | ||
| 234 | + return NodeRequiredYes, nil | ||
| 235 | + } | ||
| 236 | +} | ||
| 237 | + | ||
| 204 | // 获取任务 | 238 | // 获取任务 |
| 205 | func getTasks(items []*PerformanceApplicationForm) ([]*PerformanceTarget, error) { | 239 | func getTasks(items []*PerformanceApplicationForm) ([]*PerformanceTarget, error) { |
| 206 | tasks := make([]*PerformanceTarget, 0) | 240 | tasks := make([]*PerformanceTarget, 0) |
| @@ -121,7 +121,7 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf | @@ -121,7 +121,7 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf | ||
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | // 必填项 | 123 | // 必填项 |
| 124 | - nc.Required = domain.NodeRequiredYes | 124 | + nc.Required = module.Required |
| 125 | nodeContents = append(nodeContents, nc) | 125 | nodeContents = append(nodeContents, nc) |
| 126 | } | 126 | } |
| 127 | } | 127 | } |
templates/.~tpl_template_question.xlsx
0 → 100644
不能预览此文件类型
-
请 注册 或 登录 后发表评论