commit
fd207dac15
9 changed files with 21 additions and 20 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -20,6 +20,7 @@ dist
|
||||||
ui
|
ui
|
||||||
^ui/index.html
|
^ui/index.html
|
||||||
tests/data/*
|
tests/data/*
|
||||||
|
!tests/data/assets
|
||||||
debug.log
|
debug.log
|
||||||
yao-test
|
yao-test
|
||||||
dev.sh
|
dev.sh
|
||||||
|
|
|
||||||
|
|
@ -59,10 +59,11 @@ func Open(name string) from.Source {
|
||||||
ext := strings.ToLower(strings.TrimPrefix(filepath.Ext(name), "."))
|
ext := strings.ToLower(strings.TrimPrefix(filepath.Ext(name), "."))
|
||||||
switch ext {
|
switch ext {
|
||||||
case "xlsx":
|
case "xlsx":
|
||||||
fullpath := name
|
// fullpath := name
|
||||||
if !strings.HasPrefix(fullpath, "/") {
|
fullpath := filepath.Join(xfs.Stor.Root, name)
|
||||||
fullpath = filepath.Join(xfs.Stor.Root, name)
|
// if !strings.HasPrefix(fullpath, "/") {
|
||||||
}
|
// fullpath = filepath.Join(xfs.Stor.Root, name)
|
||||||
|
// }
|
||||||
return xlsx.Open(fullpath)
|
return xlsx.Open(fullpath)
|
||||||
}
|
}
|
||||||
exception.New("暂不支持: %s 文件导入", 400, ext).Throw()
|
exception.New("暂不支持: %s 文件导入", 400, ext).Throw()
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ func TestLoad(t *testing.T) {
|
||||||
assert.IsType(t, &Importer{}, Select("order"))
|
assert.IsType(t, &Importer{}, Select("order"))
|
||||||
}
|
}
|
||||||
func TestFingerprintSimple(t *testing.T) {
|
func TestFingerprintSimple(t *testing.T) {
|
||||||
simple := filepath.Join(config.Conf.Root, "imports", "assets", "simple.xlsx")
|
simple := filepath.Join(config.Conf.Root, "data", "assets", "simple.xlsx")
|
||||||
file := xlsx.Open(simple)
|
file := xlsx.Open(simple)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
imp := Select("order")
|
imp := Select("order")
|
||||||
|
|
@ -24,7 +24,7 @@ func TestFingerprintSimple(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAutoMappingSimple(t *testing.T) {
|
func TestAutoMappingSimple(t *testing.T) {
|
||||||
simple := filepath.Join(config.Conf.Root, "imports", "assets", "simple.xlsx")
|
simple := filepath.Join(config.Conf.Root, "data", "assets", "simple.xlsx")
|
||||||
file := xlsx.Open(simple)
|
file := xlsx.Open(simple)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
|
|
@ -48,7 +48,7 @@ func TestAutoMappingSimple(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDataGetSimple(t *testing.T) {
|
func TestDataGetSimple(t *testing.T) {
|
||||||
simple := filepath.Join(config.Conf.Root, "imports", "assets", "simple.xlsx")
|
simple := filepath.Join(config.Conf.Root, "data", "assets", "simple.xlsx")
|
||||||
file := xlsx.Open(simple)
|
file := xlsx.Open(simple)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
|
|
@ -69,7 +69,7 @@ func TestDataGetSimple(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDataChunkSimple(t *testing.T) {
|
func TestDataChunkSimple(t *testing.T) {
|
||||||
simple := filepath.Join(config.Conf.Root, "imports", "assets", "simple.xlsx")
|
simple := filepath.Join(config.Conf.Root, "data", "assets", "simple.xlsx")
|
||||||
file := xlsx.Open(simple)
|
file := xlsx.Open(simple)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
|
|
@ -83,7 +83,7 @@ func TestDataChunkSimple(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRunSimple(t *testing.T) {
|
func TestRunSimple(t *testing.T) {
|
||||||
simple := filepath.Join(config.Conf.Root, "imports", "assets", "simple.xlsx")
|
simple := filepath.Join(config.Conf.Root, "data", "assets", "simple.xlsx")
|
||||||
file := xlsx.Open(simple)
|
file := xlsx.Open(simple)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
|
|
@ -97,7 +97,7 @@ func TestRunSimple(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDataPreviewSimple(t *testing.T) {
|
func TestDataPreviewSimple(t *testing.T) {
|
||||||
simple := filepath.Join(config.Conf.Root, "imports", "assets", "simple.xlsx")
|
simple := filepath.Join(config.Conf.Root, "data", "assets", "simple.xlsx")
|
||||||
file := xlsx.Open(simple)
|
file := xlsx.Open(simple)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
imp := Select("order")
|
imp := Select("order")
|
||||||
|
|
@ -116,7 +116,7 @@ func TestDataPreviewSimple(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMappingPreviewSimple(t *testing.T) {
|
func TestMappingPreviewSimple(t *testing.T) {
|
||||||
simple := filepath.Join(config.Conf.Root, "imports", "assets", "simple.xlsx")
|
simple := filepath.Join(config.Conf.Root, "data", "assets", "simple.xlsx")
|
||||||
file := xlsx.Open(simple)
|
file := xlsx.Open(simple)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
|
|
@ -140,7 +140,7 @@ func TestMappingPreviewSimple(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMappingSetting(t *testing.T) {
|
func TestMappingSetting(t *testing.T) {
|
||||||
simple := filepath.Join(config.Conf.Root, "imports", "assets", "simple.xlsx")
|
simple := filepath.Join(config.Conf.Root, "data", "assets", "simple.xlsx")
|
||||||
file := xlsx.Open(simple)
|
file := xlsx.Open(simple)
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,10 @@ import (
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/yaoapp/gou"
|
"github.com/yaoapp/gou"
|
||||||
"github.com/yaoapp/yao/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestProcessMapping(t *testing.T) {
|
func TestProcessMapping(t *testing.T) {
|
||||||
simple := filepath.Join(config.Conf.Root, "imports", "assets", "simple.xlsx")
|
simple := filepath.Join("assets", "simple.xlsx")
|
||||||
args := []interface{}{"order", simple}
|
args := []interface{}{"order", simple}
|
||||||
response := gou.NewProcess("xiang.import.Mapping", args...).Run()
|
response := gou.NewProcess("xiang.import.Mapping", args...).Run()
|
||||||
_, ok := response.(*Mapping)
|
_, ok := response.(*Mapping)
|
||||||
|
|
@ -18,7 +17,7 @@ func TestProcessMapping(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProcessMappingSetting(t *testing.T) {
|
func TestProcessMappingSetting(t *testing.T) {
|
||||||
simple := filepath.Join(config.Conf.Root, "imports", "assets", "simple.xlsx")
|
simple := filepath.Join("assets", "simple.xlsx")
|
||||||
args := []interface{}{"order", simple}
|
args := []interface{}{"order", simple}
|
||||||
response := gou.NewProcess("xiang.import.MappingSetting", args...).Run()
|
response := gou.NewProcess("xiang.import.MappingSetting", args...).Run()
|
||||||
_, ok := response.(map[string]interface{})
|
_, ok := response.(map[string]interface{})
|
||||||
|
|
@ -26,7 +25,7 @@ func TestProcessMappingSetting(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProcessData(t *testing.T) {
|
func TestProcessData(t *testing.T) {
|
||||||
simple := filepath.Join(config.Conf.Root, "imports", "assets", "simple.xlsx")
|
simple := filepath.Join("assets", "simple.xlsx")
|
||||||
mapping := gou.NewProcess("xiang.import.Mapping", "order", simple).Run()
|
mapping := gou.NewProcess("xiang.import.Mapping", "order", simple).Run()
|
||||||
args := []interface{}{"order", simple, 1, 2, mapping}
|
args := []interface{}{"order", simple, 1, 2, mapping}
|
||||||
response := gou.NewProcess("xiang.import.Data", args...).Run()
|
response := gou.NewProcess("xiang.import.Data", args...).Run()
|
||||||
|
|
@ -49,7 +48,7 @@ func TestProcessSetting(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProcessRun(t *testing.T) {
|
func TestProcessRun(t *testing.T) {
|
||||||
simple := filepath.Join(config.Conf.Root, "imports", "assets", "simple.xlsx")
|
simple := filepath.Join("assets", "simple.xlsx")
|
||||||
mapping := gou.NewProcess("xiang.import.Mapping", "order", simple).Run()
|
mapping := gou.NewProcess("xiang.import.Mapping", "order", simple).Run()
|
||||||
args := []interface{}{"order", simple, mapping}
|
args := []interface{}{"order", simple, mapping}
|
||||||
response := gou.NewProcess("xiang.import.Run", args...).Run()
|
response := gou.NewProcess("xiang.import.Run", args...).Run()
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ func (layout *LayoutDSL) BindModel(m *gou.Model, formID string, fields *FieldsDS
|
||||||
Icon: "icon-trash-2",
|
Icon: "icon-trash-2",
|
||||||
Style: "danger",
|
Style: "danger",
|
||||||
Action: map[string]component.ParamsDSL{
|
Action: map[string]component.ParamsDSL{
|
||||||
"Table.delete": {"model": formID},
|
"Form.delete": {"model": formID},
|
||||||
},
|
},
|
||||||
Confirm: &component.ConfirmActionDSL{
|
Confirm: &component.ConfirmActionDSL{
|
||||||
Title: "::Confirm",
|
Title: "::Confirm",
|
||||||
|
|
@ -108,7 +108,7 @@ func (layout *LayoutDSL) BindTable(tab *table.DSL, formID string, fields *Fields
|
||||||
Icon: "icon-trash-2",
|
Icon: "icon-trash-2",
|
||||||
Style: "danger",
|
Style: "danger",
|
||||||
Action: map[string]component.ParamsDSL{
|
Action: map[string]component.ParamsDSL{
|
||||||
"Table.delete": {"model": formID},
|
"Form.delete": {"model": formID},
|
||||||
},
|
},
|
||||||
Confirm: &component.ConfirmActionDSL{
|
Confirm: &component.ConfirmActionDSL{
|
||||||
Title: "::Confirm",
|
Title: "::Confirm",
|
||||||
|
|
@ -135,7 +135,7 @@ func (layout *LayoutDSL) BindTable(tab *table.DSL, formID string, fields *Fields
|
||||||
}
|
}
|
||||||
|
|
||||||
name := column.Key
|
name := column.Key
|
||||||
if col, has := fields.Form[name]; has {
|
if col, has := fields.Form[name]; has && column.Bind != "deleted_at" {
|
||||||
width := 12
|
width := 12
|
||||||
columns = append(columns, Column{InstanceDSL: component.InstanceDSL{Name: col.Key, Width: width}})
|
columns = append(columns, Column{InstanceDSL: component.InstanceDSL{Name: col.Key, Width: width}})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue