Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
田翔
xform
Commits
92ee2ad6
Commit
92ee2ad6
authored
Dec 09, 2024
by
杨子龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化字段类型判断
parent
bfbde65b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
71 deletions
+98
-71
process.js
src/apis/process.js
+7
-0
index.js
src/core/widgets/coord/DataTable/index.js
+41
-39
index.js
src/core/widgets/settings/groupSource/OptionRender/index.js
+0
-4
index.js
src/core/widgets/settings/groupSource/StatusOption/index.js
+50
-28
No files found.
src/apis/process.js
View file @
92ee2ad6
...
@@ -852,3 +852,10 @@ export function GetDeviceTypes () {
...
@@ -852,3 +852,10 @@ export function GetDeviceTypes () {
method
:
'GET'
method
:
'GET'
});
});
}
}
export
function
GetTableFieldsByTableName
(
params
)
{
return
request
(
`/PandaOMS/OMS/CaseManage/GetTableFieldsByTableName`
,
{
method
:
"GET"
,
params
})
}
src/core/widgets/coord/DataTable/index.js
View file @
92ee2ad6
import
React
,
{
Fragment
,
useEffect
,
useState
}
from
'react'
;
import
React
,
{
Fragment
,
useEffect
,
useState
}
from
'react'
;
import
{
Button
,
Empty
,
Table
,
Space
,
Input
}
from
'antd'
;
import
{
Button
,
Empty
,
Table
,
Space
,
Input
}
from
'antd'
;
import
{
CheckOutlined
}
from
"@ant-design/icons"
;
import
*
as
AntdIcon
from
'@ant-design/icons'
;
import
*
as
AntdIcon
from
'@ant-design/icons'
;
import
FileView
from
'../../../Account/components/TablePack/components/FileView'
;
import
FileView
from
'../../../Account/components/TablePack/components/FileView'
;
import
TagPack
from
'../../../components/TagPack'
import
TagPack
from
'../../../components/TagPack'
...
@@ -26,6 +25,7 @@ const DataTable = props => {
...
@@ -26,6 +25,7 @@ const DataTable = props => {
const
[
dataSource
,
setDataSource
]
=
useState
([]);
const
[
dataSource
,
setDataSource
]
=
useState
([]);
const
[
visible
,
setVisible
]
=
useState
(
true
);
const
[
visible
,
setVisible
]
=
useState
(
true
);
const
[
columns
,
setColumns
]
=
useState
([]);
const
hasHash
=
(
url
)
=>
{
const
hasHash
=
(
url
)
=>
{
return
url
.
includes
(
'#'
);
return
url
.
includes
(
'#'
);
...
@@ -168,11 +168,11 @@ const DataTable = props => {
...
@@ -168,11 +168,11 @@ const DataTable = props => {
</Fragment>;
</Fragment>;
};
};
// 字段栏渲染
// 字段栏
显示模式
渲染
const getFieldRender = (_, row, index , item) => {
const getFieldRender = (_, row, index , item) => {
let ele;
let ele;
switch (item.type) {
switch (item.type) {
case "
text
":
case "
文本
":
if(!item.isMapped){
if(!item.isMapped){
ele = <span style={{color: item.color}}>{_}</span>
ele = <span style={{color: item.color}}>{_}</span>
} else {
} else {
...
@@ -197,6 +197,11 @@ const DataTable = props => {
...
@@ -197,6 +197,11 @@ const DataTable = props => {
}
}
break;
break;
case "FileUpload":
ele = <FileView value={_}
download={true}
preview={true} />;
break;
}
}
return ele
return ele
...
@@ -204,7 +209,8 @@ const DataTable = props => {
...
@@ -204,7 +209,8 @@ const DataTable = props => {
const getColumns = () => {
const getColumns = () => {
const arr = [];
const arr = [];
const list = statusOption?.length !== 0 ? statusOption : fieldList;
const list = statusOption;
let isGIS = false;
let isGIS = false;
list?.forEach(item => {
list?.forEach(item => {
if(item.fieldType === "gis"){
if(item.fieldType === "gis"){
...
@@ -213,38 +219,26 @@ const DataTable = props => {
...
@@ -213,38 +219,26 @@ const DataTable = props => {
})
})
list?.forEach(item => {
list?.forEach(item => {
if (item.fieldType === '台账' && schema?.widget === 'FileUpload') {
const dataIndex = !isGIS ? item.fieldName : `
$
{
item
.
fieldType
}
-
$
{
item
.
fieldName
}
`;
arr.push({
title: item.fieldAliasName,
arr.push({
dataIndex: !isGIS ? item.fieldName : `
$
{
item
.
fieldType
}
-
$
{
item
.
fieldName
}
`,
title: item.fieldAliasName,
key: !isGIS ? item.fieldName : `
$
{
item
.
fieldType
}
-
$
{
item
.
fieldName
}
`,
dataIndex,
width: item.width || 120,
key: dataIndex,
render: (_, row) => {
width: item.width || 120,
return <FileView value={row[`
$
{
item
.
fieldType
}
-
$
{
item
.
fieldName
}
`]} {...schema} />;
render: (_, row , index) => {
},
return (
});
<Fragment>
} else {
{
const dataIndex = !isGIS ? item.fieldName : `
$
{
item
.
fieldType
}
-
$
{
item
.
fieldName
}
`;
row.isEditable ? (
<Input value={_}
arr.push({
onChange={e => changeValue(e.target.value , index , dataIndex)} />
title: item.fieldAliasName,
) : getFieldRender(_, row, index , item)
dataIndex,
}
key: dataIndex,
</Fragment>
width: item.width || 120,
)
render: (_, row , index) => {
}
return (
});
<Fragment>
{
row.isEditable ? (
<Input value={_}
onChange={e => changeValue(e.target.value , index , dataIndex)} />
) : getFieldRender(_, row, index , item)
}
</Fragment>
)
}
});
}
});
});
if (!disabled) {
if (!disabled) {
...
@@ -259,7 +253,7 @@ const DataTable = props => {
...
@@ -259,7 +253,7 @@ const DataTable = props => {
});
});
}
}
return arr
setColumns(arr);
};
};
const initRelationForm = () => {
const initRelationForm = () => {
...
@@ -313,9 +307,9 @@ const DataTable = props => {
...
@@ -313,9 +307,9 @@ const DataTable = props => {
window.relationForm.data = data;
window.relationForm.data = data;
}
}
const columns = getColumns();
useEffect(() => {
useEffect(() => {
eventEmitter.removeAllListeners(addons?.dataPath);
let list = [...dataSource];
let list = [...dataSource];
eventEmitter.on(addons?.dataPath , (res) => {
eventEmitter.on(addons?.dataPath , (res) => {
...
@@ -335,8 +329,16 @@ const DataTable = props => {
...
@@ -335,8 +329,16 @@ const DataTable = props => {
setVisible(true);
setVisible(true);
onChange(res.length)
onChange(res.length)
})
})
return () => {
eventEmitter.removeAllListeners(addons?.dataPath)
}
}, []);
}, []);
useEffect(() => {
getColumns()
} , [fieldList])
useEffect(() => {
useEffect(() => {
initRelationForm();
initRelationForm();
...
...
src/core/widgets/settings/groupSource/OptionRender/index.js
View file @
92ee2ad6
...
@@ -221,10 +221,6 @@ const OptionRender = (props) => {
...
@@ -221,10 +221,6 @@ const OptionRender = (props) => {
label
:
"删除"
,
label
:
"删除"
,
value
:
"delete"
value
:
"delete"
},
},
{
label
:
"编辑"
,
value
:
"update"
},
{
{
label
:
"自定义事件"
,
label
:
"自定义事件"
,
value
:
"selfEvent"
value
:
"selfEvent"
...
...
src/core/widgets/settings/groupSource/StatusOption/index.js
View file @
92ee2ad6
...
@@ -7,13 +7,12 @@ import { colors } from '../../../../../constant'
...
@@ -7,13 +7,12 @@ import { colors } from '../../../../../constant'
import
{
getNanoid
}
from
'../../../../../utils'
import
{
getNanoid
}
from
'../../../../../utils'
import
{
SketchPicker
}
from
'react-color'
import
{
SketchPicker
}
from
'react-color'
import
Drag
from
"../../../../components/Drag"
;
import
Drag
from
"../../../../components/Drag"
;
import
{
GetTableFieldsByTableName
}
from
"../../../../../apis/process"
;
function
getTableData
(
list
,
optionList
)
{
async
function
getTableData
(
list
,
optionList
)
{
if
(
list
){
if
(
list
){
const
arr
=
[...
list
];
const
arr
=
[...
list
];
console
.
log
(
"optionList"
,
optionList
);
list
?.
forEach
((
item
)
=>
{
list
?.
forEach
((
item
)
=>
{
item
.
type
=
"text"
;
item
.
type
=
"text"
;
})
})
...
@@ -34,18 +33,39 @@ const StatusOption = (props) => {
...
@@ -34,18 +33,39 @@ const StatusOption = (props) => {
const
[
visible
,
setVisible
]
=
useState
(
false
);
const
[
visible
,
setVisible
]
=
useState
(
false
);
const
[
parseObj
,
setParseObj
]
=
useState
(
`{"key": {"color": "" , "label": ""}}`
);
const
[
parseObj
,
setParseObj
]
=
useState
(
`{"key": {"color": "" , "label": ""}}`
);
const
data
=
value
?.
length
?
value
:
getTableData
(
fieldList
);
const
showType
=
(
t
)
=>
{
const
arr
=
[
"FileUpload"
,
"tag"
,
"文本"
]
return
arr
.
includes
(
t
);
}
const
initData
=
async
()
=>
{
const
fields
=
[];
const
initData
=
()
=>
{
fieldList
.
forEach
(
item
=>
{
fieldList
.
forEach
(
item
=>
{
const
currentItem
=
value
.
find
(
v
=>
item
.
fieldName
===
v
.
fieldName
)
if
(
item
.
fieldType
!==
"gis"
){
fields
.
push
(
item
.
fieldName
)
}
});
const
{
data
,
code
}
=
await
GetTableFieldsByTableName
({
tableName
:
addons
.
formData
.
tableName
,
fields
:
fields
.
join
(
","
)
});
fieldList
.
forEach
(
item
=>
{
const
currentItem
=
value
.
find
(
v
=>
item
.
fieldName
===
v
.
fieldName
);
const
current
=
data
.
find
(
d
=>
d
.
FieldName
===
item
.
fieldName
);
if
(
currentItem
){
if
(
currentItem
){
item
.
color
=
currentItem
.
color
;
item
.
color
=
currentItem
.
color
;
item
.
type
=
currentItem
.
type
;
item
.
parseStr
=
currentItem
.
parseStr
;
item
.
width
=
currentItem
.
width
;
item
.
type
=
showType
(
current
?.
Widget
)
?
current
?.
Widget
:
"文本"
;
item
.
editType
=
current
?.
Widget
||
"文本"
;
item
.
isMapped
=
currentItem
?.
isMapped
||
false
;
item
.
width
=
currentItem
.
width
||
120
;
}
else
{
}
else
{
item
.
type
=
"text"
;
item
.
type
=
"文本"
;
item
.
editType
=
"文本"
;
item
.
color
=
"rgb(65,68,69)"
;
item
.
color
=
"rgb(65,68,69)"
;
item
.
isMapped
=
false
;
item
.
isMapped
=
false
;
item
.
width
=
120
;
item
.
width
=
120
;
...
@@ -64,9 +84,7 @@ const StatusOption = (props) => {
...
@@ -64,9 +84,7 @@ const StatusOption = (props) => {
},
[
isMultiple
])
},
[
isMultiple
])
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
value
?.
length
!==
fieldList
?.
length
){
initData
()
initData
()
}
}
,
[
fieldList
])
}
,
[
fieldList
])
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -76,15 +94,15 @@ const StatusOption = (props) => {
...
@@ -76,15 +94,15 @@ const StatusOption = (props) => {
},
[])
},
[])
const
onPressEnter
=
(
i
)
=>
{
const
onPressEnter
=
(
i
)
=>
{
let
length
=
[...
data
].
length
let
length
=
[...
value
].
length
let
array
=
[...
data
]
let
array
=
[...
value
]
array
.
splice
(
i
+
1
,
0
,
{
key
:
getNanoid
(),
index
:
length
+
1
,
color
:
colors
[
length
%
10
],
value
:
''
})
array
.
splice
(
i
+
1
,
0
,
{
key
:
getNanoid
(),
index
:
length
+
1
,
color
:
colors
[
length
%
10
],
value
:
''
})
onChange
(
array
)
onChange
(
array
)
}
}
const
inputChange
=
(
val
,
i
,
key
,
item
)
=>
{
const
inputChange
=
(
val
,
i
,
key
,
item
)
=>
{
let
array
=
[]
let
array
=
[]
data
.
forEach
((
v
,
index
)
=>
{
value
.
forEach
((
v
,
index
)
=>
{
if
(
index
===
i
)
{
if
(
index
===
i
)
{
v
[
key
]
=
val
;
v
[
key
]
=
val
;
}
}
...
@@ -96,7 +114,7 @@ const StatusOption = (props) => {
...
@@ -96,7 +114,7 @@ const StatusOption = (props) => {
const
confirm
=
(
index
)
=>
{
const
confirm
=
(
index
)
=>
{
let
array
=
[]
let
array
=
[]
data
.
forEach
((
v
,
i
)
=>
{
value
.
forEach
((
v
,
i
)
=>
{
if
(
i
!==
index
)
{
if
(
i
!==
index
)
{
array
.
push
({
...
v
})
array
.
push
({
...
v
})
}
}
...
@@ -106,7 +124,7 @@ const StatusOption = (props) => {
...
@@ -106,7 +124,7 @@ const StatusOption = (props) => {
const
colorClick
=
(
item
,
i
)
=>
{
const
colorClick
=
(
item
,
i
)
=>
{
let
array
=
[]
let
array
=
[]
data
.
forEach
((
v
,
index
)
=>
{
value
.
forEach
((
v
,
index
)
=>
{
if
(
index
===
i
)
{
if
(
index
===
i
)
{
v
.
color
=
item
v
.
color
=
item
}
}
...
@@ -118,7 +136,7 @@ const StatusOption = (props) => {
...
@@ -118,7 +136,7 @@ const StatusOption = (props) => {
const
rest
=
(
index
)
=>
{
const
rest
=
(
index
)
=>
{
let
array
=
[]
let
array
=
[]
data
.
forEach
((
v
,
i
)
=>
{
value
.
forEach
((
v
,
i
)
=>
{
if
(
index
===
i
)
{
if
(
index
===
i
)
{
v
.
color
=
colors
[
index
%
10
]
v
.
color
=
colors
[
index
%
10
]
}
}
...
@@ -151,13 +169,17 @@ const StatusOption = (props) => {
...
@@ -151,13 +169,17 @@ const StatusOption = (props) => {
return
(
return
(
<
Select
options
=
{[
<
Select
options
=
{[
{
{
label
:
"文
字
"
,
label
:
"文
本
"
,
value
:
"
text
"
value
:
"
文本
"
},
},
{
{
label
:
"标签"
,
label
:
"标签"
,
value
:
"tag"
value
:
"tag"
},
},
{
label
:
"照片"
,
value
:
"FileUpload"
}
]}
]}
value
=
{
r
}
value
=
{
r
}
style
=
{{
style
=
{{
...
@@ -277,14 +299,14 @@ const StatusOption = (props) => {
...
@@ -277,14 +299,14 @@ const StatusOption = (props) => {
return
columns
.
filter
(
v
=>
v
.
dataIndex
!==
'color'
)
return
columns
.
filter
(
v
=>
v
.
dataIndex
!==
'color'
)
}
}
return
columns
return
columns
},
[
data
,
color
,
currentColor
])
},
[
value
,
color
,
currentColor
])
const
switchChange
=
(
checked
)
=>
{
const
switchChange
=
(
checked
)
=>
{
addons
.
setValue
(
'color'
,
checked
)
addons
.
setValue
(
'color'
,
checked
)
if
(
checked
)
{
if
(
checked
)
{
if
(
Array
.
isArray
(
data
))
{
if
(
Array
.
isArray
(
value
))
{
let
array
=
[]
let
array
=
[]
data
.
forEach
((
v
,
i
)
=>
{
value
.
forEach
((
v
,
i
)
=>
{
if
(
!
i
.
color
){
if
(
!
i
.
color
){
array
.
push
({
...
v
,
color
:
colors
[
i
%
10
]
})
array
.
push
({
...
v
,
color
:
colors
[
i
%
10
]
})
}
}
...
@@ -294,7 +316,7 @@ const StatusOption = (props) => {
...
@@ -294,7 +316,7 @@ const StatusOption = (props) => {
}
}
}
else
{
}
else
{
let
array
=
[]
let
array
=
[]
data
.
forEach
((
v
,
i
)
=>
{
value
.
forEach
((
v
,
i
)
=>
{
if
(
i
.
color
){
if
(
i
.
color
){
delete
i
.
color
delete
i
.
color
}
}
...
@@ -315,8 +337,8 @@ const StatusOption = (props) => {
...
@@ -315,8 +337,8 @@ const StatusOption = (props) => {
}
}
const
add
=
()
=>
{
const
add
=
()
=>
{
let
length
=
[...
data
].
length
let
length
=
[...
value
].
length
let
array
=
[...
data
]
let
array
=
[...
value
]
array
.
push
({
key
:
getNanoid
(),
index
:
length
+
1
,
color
:
colors
[
length
%
10
],
value
:
''
})
array
.
push
({
key
:
getNanoid
(),
index
:
length
+
1
,
color
:
colors
[
length
%
10
],
value
:
''
})
onChange
(
array
)
onChange
(
array
)
}
}
...
@@ -340,8 +362,8 @@ const StatusOption = (props) => {
...
@@ -340,8 +362,8 @@ const StatusOption = (props) => {
{
loading
?
null
:
(
{
loading
?
null
:
(
<
DragTable
<
DragTable
dataSource
=
{
dataSource
=
{
Array
.
isArray
(
data
)
Array
.
isArray
(
value
)
?
data
.
map
((
v
,
i
)
=>
{
?
value
.
map
((
v
,
i
)
=>
{
return
{
key
:
`
${
i
}
`
,
index
:
i
,
...
v
};
return
{
key
:
`
${
i
}
`
,
index
:
i
,
...
v
};
})
})
:
[]
:
[]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment