From 5ae8e447c55f61508546e00559f54eb623a5c803 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 31 七月 2020 19:23:38 +0800 Subject: [PATCH] 2020-07-31 --- src/templates/subtableconfig/index.jsx | 42 ++++++++++++++++++++++++++++++++---------- 1 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx index 282f7a6..b079e6c 100644 --- a/src/templates/subtableconfig/index.jsx +++ b/src/templates/subtableconfig/index.jsx @@ -951,17 +951,39 @@ * @description 鏍¢獙閰嶇疆淇℃伅鐨勫悎娉曟�� */ verifyconfig = (config) => { - let charterr = '' - config.charts.forEach(chart => { - if (!charterr && ['line', 'bar', 'pie'].includes(chart.chartType) && !chart.Xaxis) { - charterr = '鍥捐〃' + (chart.title ? '銆�' + chart.title + '銆�' : '') + '鍧愭爣杞存湭璁剧疆锛屼笉鍙惎鐢紒' + let hasKey = false + let chartcols = [] + config.columns.forEach(col => { + if (col.field) { + chartcols.push(col.field) + } + if (config.setting.primaryKey === col.field) { + hasKey = true } }) - let hasKey = false - config.columns.forEach(col => { - if (config.setting.primaryKey === col.field) { - hasKey = true + let chartError = '' + config.charts && config.charts.forEach((chart, index) => { + if (chartError) return + if (chart.Hide === 'true') return + if (!['line', 'bar', 'pie'].includes(chart.chartType)) return + + if (!chart.Xaxis) { + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛皻鏈缃紝涓嶅彲鍚敤锛乣 + } else if (['line', 'bar'].includes(chart.chartType) && chart.datatype !== 'statistics' && (!chart.Yaxis || chart.Yaxis.length === 0)) { // query 鏌ヨ鏁版嵁 + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛皻鏈缃紝涓嶅彲鍚敤锛乣 + } else if (['line', 'bar'].includes(chart.chartType) && chart.datatype === 'statistics' && (!chart.InfoType || !chart.InfoValue)) { // statistics 缁熻鏁版嵁 + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛皻鏈缃紝涓嶅彲鍚敤锛乣 + } else if (chart.chartType === 'pie' && !chart.Yaxis) { + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛皻鏈缃紝涓嶅彲鍚敤锛乣 + } else if (!chartcols.includes(chart.Xaxis)) { + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛湪鏄剧ず鍒椾腑涓嶅瓨鍦紝涓嶅彲鍚敤锛乣 + } else if (chart.chartType === 'pie' && !chartcols.includes(chart.Yaxis)) { + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛湪鏄剧ず鍒椾腑涓嶅瓨鍦紝涓嶅彲鍚敤锛乣 + } else if (['line', 'bar'].includes(chart.chartType) && chart.datatype === 'statistics' && (!chartcols.includes(chart.InfoType) || !chartcols.includes(chart.InfoValue))) { // statistics 缁熻鏁版嵁 + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛湪鏄剧ず鍒椾腑涓嶅瓨鍦紝涓嶅彲鍚敤锛乣 + } else if (['line', 'bar'].includes(chart.chartType) && chart.datatype !== 'statistics' && chart.Yaxis.filter(yaxis => !chartcols.includes(yaxis)).length > 0) { + chartError = `鍥捐〃${chart.title ? '銆�' + chart.title + '銆�' : index + 1}鍧愭爣杞村瓧娈靛湪鏄剧ず鍒椾腑涓嶅瓨鍦紝涓嶅彲鍚敤锛乣 } }) @@ -971,8 +993,8 @@ return '鑿滃崟灏氭湭璁剧疆涓婚敭锛屼笉鍙惎鐢紒' } else if (!hasKey) { return '鏄剧ず鍒椾腑涓嶅瓨鍦ㄤ富閿瓧娈碉紝涓嶅彲鍚敤锛�' - } else if (charterr) { - return charterr + } else if (chartError) { + return chartError } else { return true } -- Gitblit v1.8.0