Commit 2a012baa authored by 田翔's avatar 田翔

对接后端

parent 79b905ae
{
"name": "panda-xform",
"version": "1.4.1",
"description": "1.4.1: 附件控件优化",
"version": "1.4.2",
"description": "1.4.2: 对接后端",
"keywords": [
"panda-xform"
],
......
......@@ -178,6 +178,15 @@ export function EditTableDataInfo(data) {
});
}
export function DeleteTableDataInfo(data) {
return request({
url: `${BASEURL}/DeleteTableDataInfo`,
method: 'post',
data,
});
}
//获取表
export function LoadLedgers() {
return request({
url: `PandaOMS/OMS/WorkOrderCenter/GetCM_Ledger_LoadLedgers`,
......@@ -185,10 +194,35 @@ export function LoadLedgers() {
})
}
export function DeleteTableDataInfo(data) {
//获取表字段
export function LoadTableFields(paramas) {
return request({
url: `${BASEURL}/DeleteTableDataInfo`,
url: `PandaOMS/OMS/CaseManage/LoadTableFields?tableName=${paramas.tableName}`,
method: 'get'
})
}
//获取所有表
export function LoadUnattachedTables() {
return request({
url: `PandaOMS/OMS/CaseManage/LoadUnattachedTables`,
method: 'get'
})
}
//获取附加表信息中的JSON配置
export function GetTableConfigJson(paramas) {
return request({
url: `PandaOMS/OMS/CaseManage/GetTableConfigJson?tableName=${paramas.tableName}`,
method: 'get'
})
}
//保存附加表信息,支持台账6.0
export function saveTableConfig(data) {
return request({
url: `PandaOMS/OMS/CaseManage/SaveTableConfig `,
method: 'post',
data,
});
data
})
}
\ No newline at end of file
......@@ -107,11 +107,11 @@ const globalSettings = {
tableName: {
title: '表名',
type: 'string',
widget: 'select',
widget: 'TableNames',
default: '事件_测试02',
required: true,
displayType: 'row',
labelWidth: 70,
default: '我是表名',
},
tableAlias: {
title: '别名',
......@@ -136,9 +136,9 @@ const globalSettings = {
column: {
title: '整体布局',
type: 'number',
enum: [1, 2, 3],
enum: [1, 2, 3, 4, 5],
default: 3,
enumNames: ['一行一列', '一行两列', '一行三列'],
enumNames: ['一行一列', '一行两列', '一行三列', '一行四列', '一行五列'],
widget: 'select',
props: {
placeholder: '默认一行一列',
......
......@@ -12,7 +12,7 @@ const base = {
type: 'object',
properties: {}
},
fieldName: {
$id: {
title: '字段名称',
type: 'string',
widget: 'FieldNames',
......@@ -55,7 +55,6 @@ const groupStyle = {
title: '元素宽度',
type: 'string',
widget: 'percentSlider',
// default: '100%',
},
labelWidth: {
title: '标签宽度',
......@@ -122,10 +121,11 @@ const textWidgets = [
collapsed: true,
properties: {}
},
fieldName: {
$id: {
title: '字段名称',
type: 'string',
widget: 'FieldNames',
tableName: "{{JSON.stringify(rootValue.tableName)}}",
required: true,
displayType: 'row',
labelWidth: 80,
......@@ -272,7 +272,7 @@ const textWidgets = [
type: 'object',
properties: {}
},
fieldName: {
$id: {
title: '字段名称',
type: 'string',
widget: 'FieldNames',
......@@ -401,7 +401,7 @@ const textWidgets = [
type: 'object',
properties: {}
},
fieldName: {
$id: {
title: '字段名称',
type: 'string',
widget: 'FieldNames',
......@@ -511,7 +511,7 @@ const textWidgets = [
type: 'object',
properties: {}
},
fieldName: {
$id: {
title: '字段名称',
type: 'string',
widget: 'FieldNames',
......@@ -590,7 +590,7 @@ const selectWidgets = [
collapsed: true,
properties: {}
},
fieldName: {
$id: {
title: '字段名称',
type: 'string',
widget: 'FieldNames',
......@@ -751,7 +751,7 @@ const selectWidgets = [
require: true,
},
setting: {
fieldName: {
$id: {
title: '字段名称',
type: 'string',
widget: 'FieldNames',
......@@ -763,7 +763,7 @@ const selectWidgets = [
title: '基础信息',
type: 'object',
properties: {
fieldName: {
$id: {
title: '字段名称',
type: 'string',
widget: 'FieldNames',
......@@ -893,7 +893,7 @@ const fileWidgets = [
type: 'object',
properties: {}
},
fieldName: {
$id: {
title: '字段名称',
type: 'string',
widget: 'FieldNames',
......@@ -1117,7 +1117,7 @@ const settings = [
width: '100%',
},
setting: {
fieldName: {
$id: {
title: '字段名称',
type: 'string',
widget: 'FieldNames',
......
import React, { useRef, useMemo, useEffect, useState, useContext, createContext } from 'react'
import { ConfigProvider, message } from 'antd'
import Generator from 'fr-generator'
import Generator, { } from 'fr-generator'
import { settings, baseSettings, globalSettings } from './config'
import widgets from '../widgets'
import { saveTableConfig, GetTableConfigJson } from '../../apis/process'
export const GlobalStore = createContext(null)
......@@ -29,22 +30,39 @@ const FormDesigner = (props) => {
}
useEffect(() => {
if (tableName) {
getTable()
const getTableConfig = async () => {
const { code, data } = await GetTableConfigJson({ tableName: '事件_测试02' })
if (code === 0) {
console.log(ref, data)
if (typeof data === 'string') {
setTimeout(() => {
ref && ref.current && ref.current.setValue && ref.current.setValue(JSON.parse(data))
}, 1000)
}
} else {
message.error('获取表单配置失败')
}
}, [tableName])
}
useEffect(() => {
getTableConfig()
}, [])
const extraButtons = [
{
text: '提交',
onClick: (value) => {
onClick: async (value) => {
const errors = ref.current.getErrorFields()
props.setSchema(ref.current.getValue())
if (errors.length) {
return message.error('请按照提示完善表单内容')
}
console.log('ref.current', ref.current)
props.setSchema && props.setSchema(ref.current.getValue())
const { code, data, msg } = await saveTableConfig(ref.current.getValue())
if (code === 0) {
message.info('保存成功')
} else {
message.error(msg)
}
}
}
]
......@@ -70,7 +88,9 @@ const FormDesigner = (props) => {
return (
<GlobalStore.Provider
value={{}}
value={{
tableName: '123'
}}
>
<div className={prefixCls}>
<Generator
......
......@@ -25,7 +25,7 @@ const XRender = (props, ref) => {
const form = useForm()
const onClick = () => {
console.log('form', form)
console.log('form', form, form.getValues())
}
return (
......
import React, { useMemo } from 'react'
import { Input, Select } from 'antd'
import style from '../../style'
import React, { useContext, useMemo, useState } from 'react'
import { Input, Select, message } from 'antd'
import { LoadTableFields } from '../../../../../apis/process'
// import { GlobalStore } from '../../../../FormDesigner'
const field = [
"处理站点",
......@@ -80,20 +81,35 @@ const field = [
const FieldNames = (props) => {
const { value, onChange } = props
const { value, onChange, addons } = props
const valueShow = useMemo(() => {
return value
}, [value])
const [fieldName, setFieldName] = useState([])
const change = (value) => {
onChange(value)
}
const onFocus = async () => {
// if (!tableName) {
// return message.info('请在表单配置中选择表名!')
// }
const { data } = await LoadTableFields({ tableName: '事件_测试02' })
if (Array.isArray(data.root)) {
setFieldName(data.root)
}
}
return (
<Select onChange={change} style={{ ...style, maxWidth: '208px' }} value={valueShow}>
<Select
onFocus={onFocus}
onChange={change}
style={{ maxWidth: '208px' }}
showSearch
optionFilterProp='children'
value={value}
>
{
field.map(v => <Select.Option key={v} value={v}>{v}</Select.Option>)
fieldName.map(v => <Select.Option key={v.fieldName} value={v.fieldName}>{v.fieldName}</Select.Option>)
}
</Select>
)
......
......@@ -6,8 +6,6 @@ const Placeholder = (props) => {
const { value, addons, onChange } = props
const { title } = addons.formData
console.log('props', props)
const inputChange = (e) => {
onChange(e.target.value)
}
......
import InputDefault from './InputDefault'
import Placeholder from './Placeholder'
import FieldNames from './FieldNames'
const base = {
FieldNames,
InputDefault,
Placeholder,
}
......
import React, { useEffect, useState } from 'react'
import { Select } from 'antd'
import { LoadUnattachedTables } from '../../../../../apis/process'
const TableNames = (props) => {
console.log('props', props)
const { value, schema, onChange } = props
const [options, setOptions] = useState([])
// useEffect(() => {
// if (options.length && !value) {
// onChange(options[0].text)
// }
// }, [options])
const onFocus = async () => {
const { data } = await LoadUnattachedTables()
if (Array.isArray(data.root)) {
setOptions(data.root)
}
}
const onSelect = (value) => {
onChange(value)
}
return (
<Select
disabled={true}
onFocus={onFocus}
// showSearch
value={value}
onChange={onSelect}
optionFilterProp="children"
>
{
options.map(v => {
return (
<Select.Option value={v.text} key={v.text}>{v.text}</Select.Option>
)
})
}
</Select>
)
}
export default TableNames
\ No newline at end of file
import TableNames from './TableNames'
const form = {
TableNames,
}
export default form
\ No newline at end of file
import base from './base'
import form from './form'
import BooleanSwitch from './BooleanSwitch'
import EnumOptions from './EnumOptions'
import FieldNames from './FieldNames'
import InputAddon from './InputAddon'
import CascadeField from './CascadeField'
import DateSelect from './DateSelect'
......@@ -10,9 +10,9 @@ import VerifyTextInput from './VerifyTextInput'
const settings = {
...base,
...form,
BooleanSwitch,
EnumOptions,
FieldNames,
InputAddon,
CascadeField,
DateSelect,
......
......@@ -3,13 +3,11 @@ import { Input } from 'antd'
const TextArea = ({ value, onChange, schema }) => {
console.log('多行文本', schema)
const { disabled, placeholder, presetValue, maxLength, rows } = schema
const valueShow = useMemo(() => {
return presetValue || value
}, [presetValue, value])
useEffect(() => {
onChange(presetValue)
}, [presetValue])
const handleChange = (e) => {
onChange(e.target.value)
......@@ -20,7 +18,7 @@ const TextArea = ({ value, onChange, schema }) => {
<Input.TextArea
maxLength={maxLength}
disabled={disabled}
value={valueShow}
value={value}
rows={rows}
placeholder={placeholder}
onChange={handleChange}
......
......@@ -12,22 +12,22 @@ const TextInput = (props) => {
const { value, onChange, schema } = props
const { disabled, placeholder, presetValue, prefix, suffix, maxLength, rules } = schema
const valueShow = useMemo(() => {
return value || presetValue
}, [value, presetValue])
useEffect(() => {
onChange(presetValue)
}, [presetValue])
const style = useMemo(() => {
let paths = ['【本人姓名】', '【本人部门】']
if (paths.includes(presetValue)) {
if (presetValue === '【本人姓名】') {
if (paths.includes(value)) {
if (value === '【本人姓名】') {
onChange(userInfo.fullName)
} else if (presetValue === '【本人部门】') {
} else if (value === '【本人部门】') {
onChange(userInfo.depart.name)
}
return { color: 'blue' }
}
return null
}, [presetValue])
}, [value])
const handleChange = (e) => {
onChange(e.target.value)
......@@ -38,7 +38,7 @@ const TextInput = (props) => {
style={style}
rules={rules}
disabled={disabled}
value={valueShow}
value={value}
maxLength={maxLength}
placeholder={disabled ? null : placeholder}
onChange={handleChange}
......
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