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

对接后端

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