This commit is contained in:
Max 2022-01-20 21:46:25 +08:00
parent 89c2157fea
commit 89e89ab2ba
3 changed files with 6 additions and 11 deletions

View file

@ -196,18 +196,17 @@ func (imp *Importer) DataPreview(src from.Source, page int, size int, mapping *M
}
columns, rows := imp.DataGet(src, page, size, mapping)
for _, row := range rows {
for idx, row := range rows {
if len(row) != len(columns) {
exception.New("数据异常, 请联系管理员", 500).Ctx(map[string]interface{}{"row": row, "columns": columns}).Throw()
}
rs := map[string]interface{}{}
for i := range row {
key := columns[i]
value := row[i]
rs[key] = value
}
rs["id"] = idx + 1
data = append(data, rs)
}
@ -309,10 +308,6 @@ func (imp *Importer) MappingSetting(src from.Source) map[string]interface{} {
Type: "label",
Props: map[string]interface{}{"value": ":label"},
},
Edit: share.Render{
Type: "select",
Props: map[string]interface{}{"options": imp.getFieldOption(), "value": ":field"},
},
},
"数据源": {
Label: "数据源",
@ -348,12 +343,12 @@ func (imp *Importer) MappingSetting(src from.Source) map[string]interface{} {
"columns": columns,
"filters": map[string]interface{}{},
"list": share.Page{
Primary: "id",
Primary: "field",
Layout: map[string]interface{}{
"columns": []map[string]interface{}{
{"name": "字段名称"},
{"name": "数据源"},
{"name": "清洗规则"},
{"name": "清洗规则", "width": 300},
{"name": "数据示例"},
},
},

View file

@ -111,7 +111,7 @@ func TestDataPreviewSimple(t *testing.T) {
assert.Equal(t, 3, res["pagesize"])
assert.Equal(t, 1, res["prev"])
assert.Equal(t, 1, len(data))
assert.Equal(t, 11, len(data[0]))
assert.Equal(t, 12, len(data[0]))
}
func TestMappingPreviewSimple(t *testing.T) {

View file

@ -1,7 +1,7 @@
package share
// VERSION 版本号
const VERSION = "0.9.34"
const VERSION = "0.9.35"
// DOMAIN 许可域(废弃)
const DOMAIN = "*.iqka.com"