Commit e8229e69 authored by 田翔's avatar 田翔

fix: 配置SQL问题

parent d502d22e
...@@ -3468,7 +3468,7 @@ const Test = (props) => { ...@@ -3468,7 +3468,7 @@ const Test = (props) => {
return ( return (
<div style={{ width: '100%', height: '100%' }}> <div style={{ width: '100%', height: '100%' }}>
{/* <FormDesigner ref={formDesignerRef} extra={true} tableName='事件工单_测试一键布局' /> */} {/* <FormDesigner ref={formDesignerRef} extra={true} tableName='事件_形态测试WY' /> */}
{/* <FormRender ref={formRenderRef} schemaValues={schemaValues} /> */} {/* <FormRender ref={formRenderRef} schemaValues={schemaValues} /> */}
{/* <div onClick={submit}>提交</div> */} {/* <div onClick={submit}>提交</div> */}
<Account accountName={'形态测试台账WY'} /> <Account accountName={'形态测试台账WY'} />
......
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "4.0.3", "version": "4.0.4",
"description": "4.0.3: 台账列表增加人员id,SQL过滤增加变量配置", "description": "4.0.4: 配置SQL问题",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
import React, { useEffect, useMemo, 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 } from 'antd' import { Table, Tooltip, message, Button, Pagination } from 'antd'
import SearchGroup from './components/SearchGroup' import SearchGroup from './components/SearchGroup'
import TablePack from './components/TablePack' import TablePack from './components/TablePack'
import { GetAccountConfigInfo, GetAccountPageList, getStationListByUserID, GetTableJson } from '../../apis/process' import { GetAccountConfigInfo, GetAccountPageList, getStationListByUserID, GetTableJson, SaveTableDataInfo } from '../../apis/process'
import { isJson, isObject } from '../../utils/index' import { isJson, isObject } from '../../utils/index'
import IconPack from '../widgets/IconPack' import IconPack from '../widgets/IconPack'
import FormRender from '../FormRender' import FormRender from '../FormRender'
...@@ -32,8 +32,11 @@ const TableRender = (props) => { ...@@ -32,8 +32,11 @@ const TableRender = (props) => {
const [detailShow, setDetailShow] = useState(false) const [detailShow, setDetailShow] = useState(false)
const [params, setParams] = useState({ userID: userID, accountName, direction: 'desc', timeField: '录入时间', total: 0, pageIndex: 1, pageSize: 100 }) const [params, setParams] = useState({ userID: userID, accountName, direction: 'desc', timeField: '录入时间', total: 0, pageIndex: 1, pageSize: 100 })
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
const [config, setConfig] = useState({ webShowFieldGroup: '', formJson: '', values: [] })
const [dataSource, setDataSource] = useState([]) const [dataSource, setDataSource] = useState([])
const [config, setConfig] = useState({ webShowFieldGroup: '', addFieldGroup: '', formJson: {} })
const [schemaValues, setSchemaValues] = useState({ formJson: {}, values: [] })
const [submitLoading, setSubmitLoading] = useState(false)
const formRenderRef = useRef()
const fileColumns = useMemo(() => { const fileColumns = useMemo(() => {
const { webShowFieldGroup, formJson } = config const { webShowFieldGroup, formJson } = config
...@@ -112,8 +115,51 @@ const TableRender = (props) => { ...@@ -112,8 +115,51 @@ const TableRender = (props) => {
}, [fileColumns]) }, [fileColumns])
const btnsClick = (type, row) => { const btnsClick = (type, row) => {
if (['添加', '详情', '编辑'].includes(type)) { const { addFieldGroup, editFieldGroup, formJson } = config
setDetailShow(true) const addField = addFieldGroup ? addFieldGroup.split(',').filter(v => v) : []
if (type === '添加') {
addClick(addField, formJson)
}
// if (['添加', '详情', '编辑'].includes(type)) {
// setDetailShow(true)
// }
}
const addClick = (addField, formJson) => {
let json = JSON.parse(JSON.stringify(formJson))
let parent = json?.properties
if (isObject(parent)) {
for (let v in parent) {
let hidden = true
let child = parent[v]?.properties
if (isObject(child)) {
for (let s in child) {
if (addField.includes(s)) {
child[s].hidden = false
hidden = false
} else {
child[s].hidden = true
}
}
}
parent[v].hidden = hidden
}
}
setSchemaValues({ formJson: json, values: [] })
setDetailShow(true)
}
const submit = async () => {
const { formValue, relationForm, errors } = await formRenderRef.current.getValues()
if (errors.length) {
return message.error('请完善表单内容')
}
setSubmitLoading(true)
const { code, data } = await SaveTableDataInfo({ accountTable: accountName, id: null, values: formValue })
if (code === 0) {
message.success('保存成功!')
setSubmitLoading(false)
setDetailShow(false)
} }
} }
...@@ -126,7 +172,7 @@ const TableRender = (props) => { ...@@ -126,7 +172,7 @@ const TableRender = (props) => {
const { code, data } = await GetAccountConfigInfo(accountName) const { code, data } = await GetAccountConfigInfo(accountName)
const res = await GetTableJson(accountName) const res = await GetTableJson(accountName)
if (code === 0 && res.code === 0) { if (code === 0 && res.code === 0) {
setConfig({ ...data, formJson: res.data }) setConfig({ ...data, formJson: isJson(res.data) ? JSON.parse(res.data) : {} })
} }
} }
...@@ -194,7 +240,7 @@ const TableRender = (props) => { ...@@ -194,7 +240,7 @@ const TableRender = (props) => {
</div> </div>
<div className={styles.tableDetail} style={{ display: detailShow ? 'block' : 'none' }}> <div className={styles.tableDetail} style={{ display: detailShow ? 'block' : 'none' }}>
<div className={styles.formBox}> <div className={styles.formBox}>
<FormRender schemaValues={config} /> <FormRender ref={formRenderRef} schemaValues={schemaValues} />
</div> </div>
<div className={styles.formBtns}> <div className={styles.formBtns}>
<Button <Button
...@@ -202,6 +248,13 @@ const TableRender = (props) => { ...@@ -202,6 +248,13 @@ const TableRender = (props) => {
> >
返回 返回
</Button> </Button>
<Button
type='primary'
loading={submitLoading}
onClick={submit}
>
提交
</Button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -31,6 +31,7 @@ const SqlFilter = (props) => { ...@@ -31,6 +31,7 @@ const SqlFilter = (props) => {
const onOk = () => { const onOk = () => {
onChange(inputValue) onChange(inputValue)
setVisible(false)
} }
const fnListRender = ( const fnListRender = (
......
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