Commit 4aae4521 authored by 田翔's avatar 田翔

fix: 文件结构调整

parent 0937219f
import React, { useMemo } from 'react' import React, { useMemo, useRef } from 'react'
import { Table, Tooltip } from 'antd' import { Table, Tooltip, Button, Popconfirm, Input, Space } from 'antd'
import { SearchOutlined } from '@ant-design/icons'
import FileView from './components/FileView' import FileView from './components/FileView'
import CoordView from './components/CoordView' import CoordView from './components/CoordView'
import SelectView from './components/SelectView' import SelectView from './components/SelectView'
import IconPack from '../../../components/IconPack'
import { isJson, isObject } from '../../../../utils'
const getFileInfo = (formJson) => {
let obj = {}
let parent = formJson?.properties
if (isObject(parent)) {
for (let v in parent) {
let child = parent[v]?.properties
if (isObject(child)) {
for (let s in child) {
obj[s] = child[s]
}
}
}
}
return obj
}
const TablePack = (props) => { const TablePack = (props) => {
const { value, widget } = props const { readOnly, config, loading, dataSource, tableChange, btnsClick } = props
const searchInput = useRef(null)
const handleReset = (clearFilters, confirm) => {
clearFilters()
confirm({ closeDropdown: true })
}
const getColumnSearchProps = (dataIndex) => ({
filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters, close }) => (
<div
style={{ padding: 8 }}
onKeyDown={(e) => e.stopPropagation()}
>
<Input
ref={searchInput}
placeholder={`搜索 ${dataIndex}`}
value={selectedKeys[0]}
onChange={e => setSelectedKeys(e.target.value ? [e.target.value] : [])}
onPressEnter={() => confirm({ closeDropdown: true })}
style={{
marginBottom: 8,
display: 'block',
width: '280px',
}}
/>
<Space>
<Button
type="primary"
onClick={() => confirm({ closeDropdown: true })}
icon={<SearchOutlined />}
size="small"
style={{ width: 90 }}
>
搜索
</Button>
<Button
onClick={() => handleReset(clearFilters, confirm)}
size="small"
style={{ width: 90 }}
>
重置
</Button>
</Space>
</div>
),
filterIcon: (filtered) => (
<SearchOutlined
style={{
color: filtered ? '#1890ff' : undefined,
}}
/>
),
})
const btns = useMemo(() => {
if (readOnly) {
return [
{
title: '详情',
icon: <IconPack.XiangQing />,
},
]
}
return [
{
title: '详情',
icon: <IconPack.XiangQing />,
},
{
title: '编辑',
icon: <IconPack.BianJi />,
},
{
title: '删除',
icon: <IconPack.ShanChu />,
}
]
}, [readOnly])
const fileColumns = useMemo(() => {
const { webShowFieldGroup, formJson } = config
let showField = webShowFieldGroup ? webShowFieldGroup.split(',').filter(v => v) : []
let json = getFileInfo(formJson)
let array = []
showField.forEach(v => {
array.push({
title: json[v]?.title || v,
dataIndex: v,
width: 120,
ellipsis: true,
sorter: true,
filterSearch: true,
...getColumnSearchProps(v),
render: (value, r) => {
let props = { ...json[v], value }
const { widget } = props
if (widget === 'FileUpload') { if (widget === 'FileUpload') {
return <FileView {...props} /> return <FileView {...props} />
} }
if (['Coordinate', 'Device', 'DrawPath', 'DrawArea'].includes(widget)) { if (['Coordinate', 'Device', 'DrawPath', 'DrawArea'].includes(widget)) {
return <CoordView {...props} /> return <CoordView {...props} />
} }
if (['RadioButton', 'CheckBox'].includes(widget)) { if (['RadioButton', 'CheckBox'].includes(widget)) {
return <SelectView {...props} /> return <SelectView {...props} />
} }
return ( return (
<div>{value}</div> <div>{value}</div>
) )
}
})
})
return array
}, [config])
const columns = useMemo(() => {
return [
{
title: '序号',
dataIndex: 'r',
key: 'r',
width: 50,
align: 'center',
fixed: 'left',
},
...fileColumns,
{
title: '操作',
width: btns.length * 35 + 30,
align: 'center',
fixed: 'right',
render: (r) => {
return (
<div style={{ display: 'flex', justifyContent: 'center' }}>
{
btns.map(v => {
if (v.title === '删除') {
return (
<Popconfirm
key={v.title}
title='确定要删除数据吗?'
onConfirm={() => btnsClick(v.title, r.ID)}
okText='确定'
cancelText='取消'
>
<Button
type='link'
title='删除'
style={{ padding: '0 7px' }}
icon={v.icon}
/>
</Popconfirm>
)
}
return (
<Button
key={v.title}
type='link'
title={v.title}
icon={v.icon}
style={{ padding: '0 7px' }}
onClick={() => btnsClick(v.title, r.ID)}
>
</Button>
)
})
}
</div>
)
}
}
]
}, [btns, fileColumns])
return (
<Table
size='small'
rowKey='ID'
bordered
loading={loading}
columns={columns}
dataSource={dataSource}
pagination={false}
scroll={{ y: 'calc(100% - 40px)' }}
onChange={tableChange}
/>
)
} }
......
import React, { useEffect, useMemo, useRef, useState } from 'react' import React, { useEffect, useMemo, useRef, useState } from 'react'
import styles from './index.less' import styles from './index.less'
import { Table, Tooltip, message, Button, Pagination, Popconfirm, Space, Input } from 'antd' import { Table, Tooltip, message, Button, Pagination, Popconfirm, Space, Input } from 'antd'
import { SearchOutlined } from '@ant-design/icons'
import SearchGroup from './components/SearchGroup' import SearchGroup from './components/SearchGroup'
import TablePack from './components/TablePack' import TablePack from './components/TablePack'
import { import {
...@@ -15,25 +14,8 @@ import { ...@@ -15,25 +14,8 @@ import {
DeleteTableDataInfo, DeleteTableDataInfo,
} from '../../apis/process' } from '../../apis/process'
import { isJson, isObject } from '../../utils/index' import { isJson, isObject } from '../../utils/index'
import IconPack from '../widgets/IconPack'
import FormRender from '../FormRender' import FormRender from '../FormRender'
const getFileInfo = (formJson) => {
let obj = {}
let parent = formJson?.properties
if (isObject(parent)) {
for (let v in parent) {
let child = parent[v]?.properties
if (isObject(child)) {
for (let s in child) {
obj[s] = child[s]
}
}
}
}
return obj
}
const Account = (props) => { const Account = (props) => {
const userID = window?.globalConfig?.userInfo?.OID || 1 const userID = window?.globalConfig?.userInfo?.OID || 1
...@@ -55,168 +37,6 @@ const Account = (props) => { ...@@ -55,168 +37,6 @@ const Account = (props) => {
const [submitLoading, setSubmitLoading] = useState(false) const [submitLoading, setSubmitLoading] = useState(false)
const [operation, setOperation] = useState({ id: null, state: '添加' }) const [operation, setOperation] = useState({ id: null, state: '添加' })
const formRenderRef = useRef() const formRenderRef = useRef()
const searchInput = useRef(null)
const handleReset = (clearFilters, confirm) => {
clearFilters()
confirm({ closeDropdown: true })
}
const getColumnSearchProps = (dataIndex) => ({
filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters, close }) => (
<div
style={{ padding: 8 }}
onKeyDown={(e) => e.stopPropagation()}
>
<Input
ref={searchInput}
placeholder={`搜索 ${dataIndex}`}
value={selectedKeys[0]}
onChange={e => setSelectedKeys(e.target.value ? [e.target.value] : [])}
onPressEnter={() => confirm({ closeDropdown: true })}
style={{
marginBottom: 8,
display: 'block',
width: '280px',
}}
/>
<Space>
<Button
type="primary"
onClick={() => confirm({ closeDropdown: true })}
icon={<SearchOutlined />}
size="small"
style={{ width: 90 }}
>
搜索
</Button>
<Button
onClick={() => handleReset(clearFilters, confirm)}
size="small"
style={{ width: 90 }}
>
重置
</Button>
</Space>
</div>
),
filterIcon: (filtered) => (
<SearchOutlined
style={{
color: filtered ? '#1890ff' : undefined,
}}
/>
),
})
const fileColumns = useMemo(() => {
const { webShowFieldGroup, formJson } = config
let showField = webShowFieldGroup ? webShowFieldGroup.split(',').filter(v => v) : []
let json = getFileInfo(formJson)
let array = []
showField.forEach(v => {
array.push({
title: json[v]?.title || v,
dataIndex: v,
width: 120,
ellipsis: true,
sorter: true,
filterSearch: true,
...getColumnSearchProps(v),
render: (value, r) => {
let props = { ...json[v], value }
return (
<TablePack {...props} />
)
}
})
})
return array
}, [config])
const btns = useMemo(() => {
if (readOnly) {
return [
{
title: '详情',
icon: <IconPack.XiangQing />,
},
]
}
return [
{
title: '详情',
icon: <IconPack.XiangQing />,
},
{
title: '编辑',
icon: <IconPack.BianJi />,
},
{
title: '删除',
icon: <IconPack.ShanChu />,
}
]
}, [readOnly])
const columns = useMemo(() => {
return [
{
title: '序号',
dataIndex: 'r',
key: 'r',
width: 50,
align: 'center',
fixed: 'left',
},
...fileColumns,
{
title: '操作',
width: btns.length * 35 + 30,
align: 'center',
fixed: 'right',
render: (r) => {
return (
<div style={{ display: 'flex', justifyContent: 'center' }}>
{
btns.map(v => {
if (v.title === '删除') {
return (
<Popconfirm
key={v.title}
title='确定要删除数据吗?'
onConfirm={() => btnsClick(v.title, r.ID)}
okText='确定'
cancelText='取消'
>
<Button
type='link'
title='删除'
style={{ padding: '0 7px' }}
icon={v.icon}
/>
</Popconfirm>
)
}
return (
<Button
key={v.title}
type='link'
title={v.title}
icon={v.icon}
style={{ padding: '0 7px' }}
onClick={() => btnsClick(v.title, r.ID)}
>
</Button>
)
})
}
</div>
)
}
}
]
}, [btns, fileColumns])
const btnsClick = async (type, id) => { const btnsClick = async (type, id) => {
const { addFieldGroup, editFieldGroup, formJson } = config const { addFieldGroup, editFieldGroup, formJson } = config
...@@ -296,7 +116,7 @@ const Account = (props) => { ...@@ -296,7 +116,7 @@ const Account = (props) => {
if (type === '编辑') { if (type === '编辑') {
const { code, data } = await EditTableDataInfo({ accountTable: accountName, id: operation.id, values: formValue }) const { code, data } = await EditTableDataInfo({ accountTable: accountName, id: operation.id, values: formValue })
if (code === 0) { if (code === 0) {
message.success('修改!') message.success('修改成功!')
setSubmitLoading(false) setSubmitLoading(false)
setDetailShow(false) setDetailShow(false)
getDataSource() getDataSource()
...@@ -311,9 +131,8 @@ const Account = (props) => { ...@@ -311,9 +131,8 @@ const Account = (props) => {
const getConfig = async () => { const getConfig = async () => {
const { code, data } = await GetAccountConfigInfo(accountName) const { code, data } = await GetAccountConfigInfo(accountName)
const res = await GetTableJson(accountName) if (code === 0) {
if (code === 0 && res.code === 0) { setConfig({ ...data, formJson: isJson(data.formJson) ? JSON.parse(data.formJson) : {} })
setConfig({ ...data, formJson: isJson(res.data) ? JSON.parse(res.data) : {} })
} }
} }
...@@ -371,16 +190,13 @@ const Account = (props) => { ...@@ -371,16 +190,13 @@ const Account = (props) => {
/> />
</div> </div>
<div className={styles.bottom}> <div className={styles.bottom}>
<Table <TablePack
size='small'
rowKey='ID'
bordered
loading={loading} loading={loading}
columns={columns} readOnly={readOnly}
config={config}
dataSource={dataSource} dataSource={dataSource}
pagination={false} btnsClick={btnsClick}
scroll={{ y: 'calc(100% - 50px)' }} tableChange={tableChange}
onChange={tableChange}
/> />
</div> </div>
</div> </div>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
.tableRender { .tableRender {
width: 100%; width: 100%;
height: 100%; height: 100%;
padding-bottom: 50px; padding-bottom: 40px;
position: relative; position: relative;
.content { .content {
width: 100%; width: 100%;
...@@ -37,9 +37,7 @@ ...@@ -37,9 +37,7 @@
.ant-table-header>table { .ant-table-header>table {
border-top: 1px solid #dbe7fb; border-top: 1px solid #dbe7fb;
} }
} // .ant-table.ant-table-bordered > .ant-table-container > .ant-table-header > table { }
// border-top: 1px solid #dbe7fb;
// }
.@{ant-prefix}-table-thead>tr { .@{ant-prefix}-table-thead>tr {
height: 40px; height: 40px;
th { th {
...@@ -69,9 +67,7 @@ ...@@ -69,9 +67,7 @@
background: rgb(237, 242, 255)!important; background: rgb(237, 242, 255)!important;
} }
} }
} // .ant-table-tbody > tr > td:last-child { }
// border-left: 1px solid #dbe7fb;
// }
.@{ant-prefix}-table-body { .@{ant-prefix}-table-body {
overflow-x: scroll; overflow-x: scroll;
&::-webkit-scrollbar { &::-webkit-scrollbar {
...@@ -79,11 +75,10 @@ ...@@ -79,11 +75,10 @@
height: 12px; height: 12px;
} }
&::-webkit-scrollbar { &::-webkit-scrollbar {
width: 0; // height: 12px; width: 0;
height: 6px; height: 6px;
} }
&::-webkit-scrollbar-thumb { &::-webkit-scrollbar-thumb {
// background: #c8c8c8;
background: rgb(41, 166, 255); background: rgb(41, 166, 255);
} }
&::-webkit-scrollbar-track { &::-webkit-scrollbar-track {
...@@ -99,7 +94,7 @@ ...@@ -99,7 +94,7 @@
left: 0; left: 0;
padding: 0 20px; padding: 0 20px;
width: 100%; width: 100%;
height: 50px; height: 40px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
......
import React from 'react' import React from 'react'
import { commonSettings, switchSettings, elementSettings } from './otherSettings' import { commonSettings, switchSettings, elementSettings } from './otherSettings'
import { GroupOutlined } from '@ant-design/icons' import { GroupOutlined } from '@ant-design/icons'
import IconPack from '../../widgets/IconPack' import IconPack from '../../components/IconPack'
const disabled = '{{formData.tableTypeParent === "物联设备表" && formData.IsSystemField}}' const disabled = '{{formData.tableTypeParent === "物联设备表" && formData.IsSystemField}}'
...@@ -208,8 +208,6 @@ const textWidgets = [ ...@@ -208,8 +208,6 @@ const textWidgets = [
title: '前置标签', title: '前置标签',
type: 'string', type: 'string',
widget: 'InputAddon', widget: 'InputAddon',
displayType: 'row',
labelWidth: 80,
disabled: disabled, disabled: disabled,
dependencies: ['presetValue', 'tableTypeParent', 'IsSystemField'], dependencies: ['presetValue', 'tableTypeParent', 'IsSystemField'],
}, },
...@@ -217,8 +215,6 @@ const textWidgets = [ ...@@ -217,8 +215,6 @@ const textWidgets = [
title: '后置标签', title: '后置标签',
type: 'string', type: 'string',
widget: 'InputAddon', widget: 'InputAddon',
displayType: 'row',
labelWidth: 80,
disabled: disabled, disabled: disabled,
dependencies: ['tableTypeParent', 'IsSystemField'], dependencies: ['tableTypeParent', 'IsSystemField'],
}, },
......
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import { Input, Button } from 'antd' import { Input, Button } from 'antd'
import { CompassOutlined } from '@ant-design/icons' import { CompassOutlined } from '@ant-design/icons'
import IconPack from '../../IconPack' import IconPack from '../../../components/IconPack'
import { import {
ArcGISSceneMap, ArcGISSceneMap,
AutoCompleteSearch, AutoCompleteSearch,
......
import React, { useState, useEffect, useRef } from 'react' import React, { useState, useEffect, useRef } from 'react'
import { Input, Button } from 'antd' import { Input, Button } from 'antd'
import { CompassOutlined } from '@ant-design/icons' import { CompassOutlined } from '@ant-design/icons'
import IconPack from '../../IconPack' import IconPack from '../../../components/IconPack'
import { import {
ArcGISSceneMap, ArcGISSceneMap,
AutoCompleteSearch, AutoCompleteSearch,
......
import React, { useState, useEffect, useRef } from 'react' import React, { useState, useEffect, useRef } from 'react'
import { Input, Button } from 'antd' import { Input, Button } from 'antd'
import { CompassOutlined } from '@ant-design/icons' import { CompassOutlined } from '@ant-design/icons'
import IconPack from '../../IconPack' import IconPack from '../../../components/IconPack'
import { import {
ArcGISSceneMap, ArcGISSceneMap,
AutoCompleteSearch, AutoCompleteSearch,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment