Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
app-manage-console
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
ReactNative
app-manage-console
Commits
c60b339d
提交
c60b339d
authored
7月 05, 2017
作者:
vipcxj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
临时提交
上级
5b1795fc
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
111 行增加
和
25 行删除
+111
-25
model.js
src/components/table/dstable/model.js
+65
-4
datasource.js
src/services/datasource.js
+42
-19
jsencrypt.js
src/utils/jsencrypt.js
+1
-1
request.js
src/utils/request.js
+3
-1
没有找到文件。
src/components/table/dstable/model.js
浏览文件 @
c60b339d
import
moment
from
'moment'
;
import
uuid
from
'uuid/v4'
;
import
_
from
'lodash'
;
import
{
}
from
'../../../services/modules
'
;
import
{
datasourceApi
}
from
'../../../services/datasource
'
;
import
{
countTasks
,
fetchTasks
}
from
'../../../services/bpm'
;
import
config
from
'../../../utils/config'
;
const
prefix
=
uuid
();
const
getMeta
=
(
property
,
name
,
parsed
=
false
,
defaultValue
)
=>
{
if
(
!
property
)
{
return
defaultValue
;
}
const
names
=
_
.
castArray
(
name
);
const
result
=
[];
_
.
some
(
names
,
(
v
)
=>
{
const
ret
=
property
[
v
];
if
(
!
_
.
isUndefined
(
ret
))
{
result
.
push
(
parsed
?
JSON
.
parse
(
ret
)
:
ret
);
return
true
;
}
return
false
;
});
return
result
.
length
>
0
?
result
[
0
]
:
defaultValue
;
};
const
makeColumns
=
(
meta
)
=>
{
return
(
meta
.
properties
||
[])
.
filter
(
property
=>
!
property
.
skip
)
.
map
((
property
,
idx
)
=>
({
title
:
getMeta
(
property
,
[
'label'
,
'title'
],
false
,
property
.
name
),
dataIndex
:
idx
,
key
:
property
.
name
,
filterType
:
getMeta
(
property
,
'filterType'
),
filterEnums
:
getMeta
(
property
,
'filterEnums'
,
true
),
order
:
_
.
toNumber
(
getMeta
(
property
,
'order'
,
false
,
0
)),
group
:
getMeta
(
property
,
'group'
),
}));
};
const
getArrayData
=
({
dataType
,
arrayData
,
singularData
},
meta
)
=>
{
if
(
dataType
===
'TABLE'
)
{
return
arrayData
||
[];
}
else
if
(
dataType
===
'PROPERTIES'
)
{
const
data
=
[];
(
meta
.
properties
||
[])
.
filter
(
property
=>
!
property
.
skip
)
.
forEach
((
property
)
=>
{
data
.
push
((
singularData
||
{})[
property
.
name
]);
});
return
[
data
];
}
else
{
throw
new
Error
(
`Unsupported data type:
${
dataType
}
`
);
}
};
const
modelCreator
=
()
=>
{
const
name
=
'task'
;
const
namespace
=
_
.
uniqueId
(
prefix
);
...
...
@@ -15,10 +62,17 @@ const modelCreator = () => {
model
:
{
namespace
,
state
:
{
columns
:
[],
num
:
0
,
list
:
[],
},
reducers
:
{
queryMetaSuccess
(
state
,
{
payload
:
columns
})
{
return
{
...
state
,
columns
,
}
},
queryCountSuccess
(
state
,
{
payload
:
num
})
{
return
{
...
state
,
...
...
@@ -33,9 +87,16 @@ const modelCreator = () => {
},
},
effects
:
{
// *fetchData({ payload: { coordinate, pst, psz, params, filters} }, { put, call }) {
//
// }
*
fetchData
({
payload
:
{
coordinate
,
pst
,
psz
,
params
,
filters
}
},
{
put
,
call
})
{
const
options
=
{
pst
,
psz
,
params
,
filters
};
const
api
=
datasourceApi
(
coordinate
);
const
meta
=
api
.
meta
();
yield
put
({
type
:
'queryMetaSuccess'
,
payload
:
makeColumns
(
meta
)
});
const
num
=
yield
call
(
api
.
count
,
options
);
yield
put
({
type
:
'queryCountSuccess'
,
payload
:
num
});
const
dsb
=
yield
call
(
api
.
query
,
options
);
yield
put
({
type
:
'queryTasksSuccess'
,
payload
:
getArrayData
(
dsb
,
meta
)
});
},
*
fetchTasks
({
payload
:
{
pst
,
psz
,
filters
}
},
{
put
,
call
})
{
const
num
=
Number
.
parseInt
(
yield
call
(
countTasks
,
filters
),
10
);
yield
put
({
type
:
'queryCountSuccess'
,
payload
:
num
});
...
...
src/services/datasource.js
浏览文件 @
c60b339d
import
{
mapKeys
,
toPairs
,
isUndefined
}
from
'lodash'
;
import
{
mapKeys
,
toPairs
,
isUndefined
,
isString
,
curry
}
from
'lodash'
;
import
request
,
{
normParams
}
from
'../utils/request'
;
import
{
split
}
from
'../utils/filter'
;
import
{
is
}
from
'../utils/helper'
;
const
parseFilters
=
filtersIn
=>
(
filtersIn
||
[]).
map
(({
key
,
filter
})
=>
[
`f-
${
split
(
key
).
map
(
value
=>
value
.
replace
(
/#/g
,
'##'
).
replace
(
/|/g
,
'#|'
)).
join
(
'|'
)}
`
,
filter
,
]);
// const parseCoordinate = (coordinate) => {
// if (is(coordinate, 'String')) {
// return {
// query:
// }
// }
// }
export
const
datasourceApi
=
(
coordinate
)
=>
{
const
{
containerType
,
containerName
,
datasourceName
}
=
isString
(
coordinate
)
?
{
containerType
:
'global'
,
moduleName
:
coordinate
,
}
:
(
coordinate
||
{});
if
(
containerType
===
'global'
)
{
return
{
query
:
curry
(
calcGlobalDatasource
)(
datasourceName
),
count
:
curry
(
countGlobalDatasource
)(
datasourceName
),
meta
:
curry
(
getGlobalDatasourceMeta
)(
datasourceName
),
};
}
else
if
(
containerType
===
'module'
)
{
return
{
query
:
curry
(
calcModuleDatasource
)(
containerName
,
datasourceName
),
count
:
curry
(
countModuleDatasource
)(
containerName
,
datasourceName
),
meta
:
curry
(
getModuleDatasourceMeta
)(
containerName
,
datasourceName
),
};
}
else
{
throw
new
Error
(
`Unsupported containerType:
${
containerType
}
`
);
}
};
export
async
function
calcDatasource
(
coordinate
,
{
pst
,
psz
,
filters
=
[],
params
=
{}
})
{
const
queryParams
=
[
const
makeQueryParams
=
({
pst
,
psz
,
filters
=
[],
params
=
{}
})
=>
{
return
[
...
toPairs
({
pst
,
psz
}),
...
parseFilters
(
filters
),
...
normParams
(
mapKeys
(
params
,
(
v
,
k
)
=>
`p-
${
k
}
`
)),
].
filter
(
isUndefined
);
return
request
(
`/api/datasource/
${
name
}
`
,
queryParams
);
};
export
async
function
calcGlobalDatasource
(
name
,
{
pst
,
psz
,
filters
=
[],
params
=
{}
})
{
return
request
(
`/api/datasource/
${
name
}
`
,
makeQueryParams
({
pst
,
psz
,
filters
,
params
}));
}
export
async
function
countDatasource
(
name
,
{
filters
=
[],
params
=
{}
})
{
const
queryParams
=
[
...
parseFilters
(
filters
),
...
normParams
(
mapKeys
(
params
,
(
v
,
k
)
=>
`p-
${
k
}
`
)),
].
filter
(
isUndefined
);
return
request
(
`/api/datasource/
${
name
}
/count`
,
queryParams
);
export
async
function
countGlobalDatasource
(
name
,
{
filters
=
[],
params
=
{}
})
{
return
request
(
`/api/datasource/
${
name
}
/count`
,
makeQueryParams
({
filters
,
params
}));
}
export
async
function
getDatasourceMeta
(
name
)
{
export
async
function
get
Global
DatasourceMeta
(
name
)
{
return
request
(
`/api/datasource/
${
name
}
`
);
}
export
async
function
calcModuleDatasource
(
mdName
,
dsName
,
{
pst
,
psz
,
filters
=
[],
params
=
{}
})
{
return
request
(
`/api/modules/module/
${
mdName
}
/datasource/
${
dsName
}
`
,
makeQueryParams
({
pst
,
psz
,
filters
,
params
}));
}
export
async
function
countModuleDatasource
(
mdName
,
dsName
,
{
filters
=
[],
params
=
{}
})
{
return
request
(
`/api/modules/module/
${
mdName
}
/datasource/
${
dsName
}
/count`
,
makeQueryParams
({
filters
,
params
}));
}
export
async
function
getModuleDatasourceMeta
(
mdName
,
dsName
)
{
return
request
(
`/api/modules/module/
${
mdName
}
/datasource/
${
dsName
}
/meta`
);
}
src/utils/jsencrypt.js
浏览文件 @
c60b339d
...
...
@@ -1935,7 +1935,7 @@ if (typeof window === 'undefined') {
},
ua
=
agent
||
(
navigator
&&
navigator
.
userAgent
),
ua
=
agent
||
(
typeof
navigator
!==
'undefined'
&&
navigator
&&
navigator
.
userAgent
),
loc
=
typeof
window
!==
'undefined'
&&
window
.
location
,
href
=
loc
&&
loc
.
href
,
m
;
...
...
src/utils/request.js
浏览文件 @
c60b339d
import
fetch
from
'dva/fetch'
;
import
_
from
'lodash'
;
import
{
Resolver
}
from
'fastjson_ref_resolver'
;
import
{
getCookie
,
encrypt
}
from
'../utils/helper'
;
import
{
cookie
}
from
'../utils/config'
;
import
{
errors
}
from
'../utils/error'
;
...
...
@@ -56,7 +57,8 @@ function parseObject(response, { num2str = true, bool2str = true, nul2str = fals
};
const
mapValue
=
_
.
curry
(
mapObj
)(
_
,
mapArr
);
if
(
contentType
.
indexOf
(
'json'
)
!==
-
1
)
{
return
needMap
?
response
.
json
().
then
(
mapValue
)
:
response
.
json
();
const
json
=
needMap
?
response
.
json
().
then
(
mapValue
)
:
response
.
json
();
return
new
Resolver
(
json
).
resolve
();
}
else
if
(
contentType
.
indexOf
(
'xml'
)
!==
-
1
)
{
return
response
.
text
().
then
((
text
)
=>
{
return
require
.
ensure
([],
(
require
)
=>
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论