Commit 79b905ae authored by 田翔's avatar 田翔

附件控件优化

parent 6905ba0b
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "1.4.0", "version": "1.4.1",
"description": "1.4.0: 统一表单配置信息", "description": "1.4.1: 附件控件优化",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -137,7 +137,7 @@ const globalSettings = { ...@@ -137,7 +137,7 @@ const globalSettings = {
title: '整体布局', title: '整体布局',
type: 'number', type: 'number',
enum: [1, 2, 3], enum: [1, 2, 3],
default: 1, default: 3,
enumNames: ['一行一列', '一行两列', '一行三列'], enumNames: ['一行一列', '一行两列', '一行三列'],
widget: 'select', widget: 'select',
props: { props: {
...@@ -167,8 +167,6 @@ const globalSettings = { ...@@ -167,8 +167,6 @@ const globalSettings = {
}, },
}, },
}, },
} }
export { export {
......
...@@ -6,6 +6,70 @@ const allSetting = { ...@@ -6,6 +6,70 @@ const allSetting = {
...elementSettings ...elementSettings
} }
const base = {
groupBase: {
title: '基础信息',
type: 'object',
properties: {}
},
fieldName: {
title: '字段名称',
type: 'string',
widget: 'FieldNames',
required: true,
displayType: 'row',
labelWidth: 80,
},
title: {
title: '标题',
required: true,
type: 'string',
widget: 'htmlInput',
displayType: 'row',
labelWidth: 80,
},
placeholder: {
title: '提示语',
type: 'string',
// widget: 'Placeholder',
displayType: 'row',
labelWidth: 80,
// dependencies: ['title']
},
presetValue: {
title: '默认值',
type: 'string',
widget: 'InputDefault',
displayType: 'row',
labelWidth: 80,
},
}
const groupStyle = {
groupStyle: {
title: '控件样式',
type: 'object',
properties: {}
},
width: {
title: '元素宽度',
type: 'string',
widget: 'percentSlider',
// default: '100%',
},
labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
},
}
const layoutWidgets = [ const layoutWidgets = [
{ {
text: '分组名称', text: '分组名称',
...@@ -24,7 +88,6 @@ const layoutWidgets = [ ...@@ -24,7 +88,6 @@ const layoutWidgets = [
title: { title: {
title: '标题', title: '标题',
type: 'string', type: 'string',
widget: 'FieldNames',
required: true, required: true,
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 80,
...@@ -51,11 +114,6 @@ const textWidgets = [ ...@@ -51,11 +114,6 @@ const textWidgets = [
title: '文本', title: '文本',
type: 'string', type: 'string',
widget: 'TextInput', widget: 'TextInput',
props: {
style: {
color: 'pink'
}
}
}, },
setting: { setting: {
groupBase: { groupBase: {
...@@ -83,10 +141,10 @@ const textWidgets = [ ...@@ -83,10 +141,10 @@ const textWidgets = [
placeholder: { placeholder: {
title: '提示语', title: '提示语',
type: 'string', type: 'string',
widget: 'Placeholder', // widget: 'Placeholder',
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 80,
dependencies: ['title'] // dependencies: ['title']
}, },
presetValue: { presetValue: {
title: '默认值', title: '默认值',
...@@ -95,21 +153,6 @@ const textWidgets = [ ...@@ -95,21 +153,6 @@ const textWidgets = [
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 80,
}, },
// groupSource: {
// title: '数据来源',
// type: 'object',
// properties: {}
// },
// source: {
// title: '数据来源',
// name: '数据来源',
// type: 'string',
// widget: 'select',
// displayType: 'row',
// labelWidth: 80,
// enum: [1, 2, 3],
// enumNames: ['一行一列', '一行两列', '一行三列'],
// },
groupVerify: { groupVerify: {
title: '数据校验', title: '数据校验',
type: 'object', type: 'object',
...@@ -175,14 +218,20 @@ const textWidgets = [ ...@@ -175,14 +218,20 @@ const textWidgets = [
type: 'string', type: 'string',
widget: 'InputAddon', widget: 'InputAddon',
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 60,
}, },
suffix: { suffix: {
title: '后缀', title: '后缀',
type: 'string', type: 'string',
widget: 'InputAddon', widget: 'InputAddon',
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 60,
},
width: {
title: '元素宽度',
type: 'string',
widget: 'percentSlider',
// default: '100%',
}, },
labelWidth: { labelWidth: {
title: '标签宽度', title: '标签宽度',
...@@ -206,7 +255,7 @@ const textWidgets = [ ...@@ -206,7 +255,7 @@ const textWidgets = [
widget: 'UniqueValue' widget: 'UniqueValue'
}, },
setting: { setting: {
// ...allSetting
}, },
}, },
{ {
...@@ -218,7 +267,124 @@ const textWidgets = [ ...@@ -218,7 +267,124 @@ const textWidgets = [
widget: 'TextArea' widget: 'TextArea'
}, },
setting: { setting: {
...allSetting groupBase: {
title: '基础信息',
type: 'object',
properties: {}
},
fieldName: {
title: '字段名称',
type: 'string',
widget: 'FieldNames',
required: true,
displayType: 'row',
labelWidth: 80,
},
title: {
title: '标题',
required: true,
type: 'string',
widget: 'htmlInput',
displayType: 'row',
labelWidth: 80,
},
placeholder: {
title: '提示语',
type: 'string',
// widget: 'Placeholder',
displayType: 'row',
labelWidth: 80,
// dependencies: ['title']
},
presetValue: {
title: '默认值',
type: 'string',
displayType: 'row',
labelWidth: 80,
},
groupVerify: {
title: '数据校验',
type: 'object',
properties: {}
},
required: {
title: '必填',
type: 'boolean',
widget: 'BooleanSwitch',
default: false,
displayType: 'row',
labelWidth: 100,
},
maxLength: {
title: '最大长度',
type: 'number',
widget: 'number',
default: 500,
displayType: 'row',
labelWidth: 100,
description: '可输入最大字节长度'
},
groupSetting: {
title: '控件设置',
type: 'object',
properties: {}
},
disabled: {
title: '只读',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
},
hidden: {
title: '隐藏',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
},
emphasis: {
title: '强调',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
},
groupStyle: {
title: '控件样式',
type: 'object',
properties: {}
},
rows: {
title: '高度',
description: '多行文本占据的行数',
type: 'number',
widget: 'number',
max: 10,
default: 5,
widget: 'slider',
props: {
hideNumber: true,
},
},
width: {
title: '元素宽度',
description: '默认值100%',
type: 'string',
widget: 'percentSlider',
// default: '100%',
},
labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
},
}, },
}, },
{ {
...@@ -230,6 +396,11 @@ const textWidgets = [ ...@@ -230,6 +396,11 @@ const textWidgets = [
widget: 'number' widget: 'number'
}, },
setting: { setting: {
groupBase: {
title: '基础信息',
type: 'object',
properties: {}
},
fieldName: { fieldName: {
title: '字段名称', title: '字段名称',
type: 'string', type: 'string',
...@@ -249,37 +420,66 @@ const textWidgets = [ ...@@ -249,37 +420,66 @@ const textWidgets = [
placeholder: { placeholder: {
title: '提示语', title: '提示语',
type: 'string', type: 'string',
widget: 'Placeholder', // widget: 'Placeholder',
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 80,
dependencies: ['title'] // dependencies: ['title']
}, },
presetValue: {
title: '默认值',
type: 'string',
displayType: 'row',
labelWidth: 80,
}, },
groupVerify: {
title: '数据校验',
type: 'object',
properties: {}
}, },
{ required: {
text: '本人部门', title: '必填',
name: '本人部门', type: 'boolean',
schema: { widget: 'BooleanSwitch',
title: '本人部门', default: false,
type: 'string', displayType: 'row',
name: '本人部门', labelWidth: 100,
widget: 'SelfInfo'
}, },
setting: { // maxLength: {
...allSetting // title: '最大长度',
// type: 'number',
// widget: 'number',
// default: 500,
// displayType: 'row',
// labelWidth: 100,
// description: '可输入最大字节长度'
// },
groupSetting: {
title: '控件设置',
type: 'object',
properties: {}
}, },
disabled: {
title: '只读',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
}, },
{ hidden: {
text: '本人姓名', title: '隐藏',
name: '本人姓名', type: 'boolean',
schema: { widget: 'checkbox',
title: '本人姓名', default: false,
name: '本人姓名', width: '33%',
type: 'string',
widget: 'SelfInfo'
}, },
setting: { emphasis: {
...allSetting title: '强调',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
},
...groupStyle,
}, },
}, },
{ {
...@@ -292,7 +492,7 @@ const textWidgets = [ ...@@ -292,7 +492,7 @@ const textWidgets = [
widget: 'SelfInfo' widget: 'SelfInfo'
}, },
setting: { setting: {
...allSetting
}, },
}, },
{ {
...@@ -302,17 +502,72 @@ const textWidgets = [ ...@@ -302,17 +502,72 @@ const textWidgets = [
title: '富文本', title: '富文本',
name: '富文本', name: '富文本',
type: 'string', type: 'string',
widget: 'RichText' widget: 'RichText',
width: '100%',
}, },
setting: { setting: {
...allSetting, groupBase: {
width: { title: '基础信息',
title: '元素宽度', type: 'object',
properties: {}
},
fieldName: {
title: '字段名称',
type: 'string', type: 'string',
hidden: true, widget: 'FieldNames',
widget: 'percentSlider', required: true,
default: '100%', displayType: 'row',
labelWidth: 80,
},
title: {
title: '标题',
required: true,
type: 'string',
widget: 'htmlInput',
displayType: 'row',
labelWidth: 80,
},
presetValue: {
title: '默认值',
type: 'string',
displayType: 'row',
labelWidth: 80,
},
// placeholder: {
// title: '提示语',
// type: 'string',
// // widget: 'Placeholder',
// displayType: 'row',
// labelWidth: 80,
// // dependencies: ['title']
// },
groupSetting: {
title: '控件设置',
type: 'object',
properties: {}
},
disabled: {
title: '只读',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
},
hidden: {
title: '隐藏',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
},
emphasis: {
title: '强调',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
}, },
...groupStyle,
}, },
}, },
] ]
...@@ -354,9 +609,9 @@ const selectWidgets = [ ...@@ -354,9 +609,9 @@ const selectWidgets = [
placeholder: { placeholder: {
title: '提示语', title: '提示语',
type: 'string', type: 'string',
// widget: 'Placeholder',
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 80,
default: '123'
}, },
presetValue: { presetValue: {
title: '默认值', title: '默认值',
...@@ -412,9 +667,10 @@ const selectWidgets = [ ...@@ -412,9 +667,10 @@ const selectWidgets = [
required: { required: {
title: '必填', title: '必填',
type: 'boolean', type: 'boolean',
widget: 'checkbox', widget: 'BooleanSwitch',
default: false, default: false,
width: '33%', displayType: 'row',
labelWidth: 70,
}, },
'控件设置': { '控件设置': {
title: '控件设置', title: '控件设置',
...@@ -621,6 +877,134 @@ const selectWidgets = [ ...@@ -621,6 +877,134 @@ const selectWidgets = [
}, },
] ]
const fileWidgets = [
{
text: '附件',
name: '附件',
schema: {
title: '附件',
type: 'string',
widget: 'FileUpload',
width: '100%'
},
setting: {
groupBase: {
title: '基础信息',
type: 'object',
properties: {}
},
fieldName: {
title: '字段名称',
type: 'string',
widget: 'FieldNames',
required: true,
displayType: 'row',
labelWidth: 80,
},
title: {
title: '标题',
required: true,
type: 'string',
widget: 'htmlInput',
displayType: 'row',
labelWidth: 80,
},
placeholder: {
title: '提示语',
type: 'string',
displayType: 'row',
labelWidth: 80,
},
groupSetting: {
title: '控件设置',
type: 'object',
properties: {}
},
fileType: {
title: '文件类型',
type: 'string',
required: true,
widget: 'select',
enum: ['全部', '图片', '文档', '音频', '视频'],
enumNames: ['全部', '图片', '文档', '音频', '视频'],
default: '全部',
displayType: 'row',
labelWidth: 80,
},
disabled: {
title: '只读',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
},
required: {
title: '必填',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
},
hidden: {
title: '隐藏',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
},
preview: {
title: '预览',
type: 'boolean',
widget: 'checkbox',
default: true,
width: '33%',
},
download: {
title: '下载',
type: 'boolean',
widget: 'checkbox',
default: true,
width: '33%',
},
photo: {
title: '允许从相册选取',
type: 'boolean',
widget: 'checkbox',
default: false,
hidden: "{{formData.fileType !== '图片'}}"
},
groupStyle: {
title: '控件样式',
type: 'object',
properties: {}
},
showType: {
title: '显示方式',
type: 'string',
default: 'picture',
enum: ['picture', 'text', 'picture-card'],
enumNames: ['列表_详细', '列表_省略', '卡片'],
},
// width: {
// title: '元素宽度',
// type: 'string',
// widget: 'percentSlider',
// default: '100%',
// },
labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
},
},
},
]
const settings = [ const settings = [
{ {
...@@ -701,49 +1085,7 @@ const settings = [ ...@@ -701,49 +1085,7 @@ const settings = [
title: '附件控件', title: '附件控件',
show: true, show: true,
useCommon: true, useCommon: true,
widgets: [ widgets: fileWidgets,
{
text: '附件',
name: '附件',
schema: {
title: '附件',
type: 'string',
widget: 'FileUpload',
},
setting: {
...commonSettings,
presetValue: {},
fileType: {
title: '文件类型',
type: 'string',
required: true,
widget: 'select',
enum: ['图片', '文档', '音频', '视频'],
enumNames: ['图片', '文档', '音频', '视频'],
default: '图片',
displayType: 'row',
labelWidth: 80,
},
listType: {
title: '显示样式',
type: 'string',
default: 'picture',
enum: ['picture', 'text', 'picture-card'],
enumNames: ['列表', '文本', '卡片'],
displayType: 'row',
labelWidth: 80,
},
...switchSettings,
width: {
title: '元素宽度',
type: 'string',
widget: 'percentSlider',
default: '100%',
},
...elementSettings,
},
},
],
}, },
{ {
title: '地图控件', title: '地图控件',
...@@ -772,6 +1114,7 @@ const settings = [ ...@@ -772,6 +1114,7 @@ const settings = [
name: '关联表单', name: '关联表单',
type: 'string', type: 'string',
widget: 'RelationForm', widget: 'RelationForm',
width: '100%',
}, },
setting: { setting: {
fieldName: { fieldName: {
...@@ -809,7 +1152,7 @@ const settings = [ ...@@ -809,7 +1152,7 @@ const settings = [
title: '元素宽度', title: '元素宽度',
type: 'string', type: 'string',
widget: 'percentSlider', widget: 'percentSlider',
default: '100%', // default: '100%',
}, },
...elementSettings, ...elementSettings,
}, },
......
import React, { useEffect, useMemo, useState } from 'react' import React, { useEffect, useMemo, useState } from 'react'
import styles from './index.less' import styles from './index.less'
import { Upload, Button, message, Modal } from 'antd' import { Upload, Button, message, Modal } from 'antd'
import { UploadOutlined, FileOutlined } from '@ant-design/icons' import { UploadOutlined, FileOutlined, ArrowDownOutlined } from '@ant-design/icons'
import FileViewer from 'react-file-viewer' import FileViewer from 'react-file-viewer'
import { uploadFileUrl, downloadFileUrl, downloadFile } from '../../../../apis/process' import { uploadFileUrl, downloadFileUrl, downloadFile } from '../../../../apis/process'
import { downloadFunc, filenameVerification } from '../../../../utils/utils' import { downloadFunc, filenameVerification } from '../../../../utils/utils'
const accepts = { const accepts = {
'全部': [],
'图片': ['.bmp', '.gif', '.jpeg', 'tiff', '.png', '.svg', '.jpg'], '图片': ['.bmp', '.gif', '.jpeg', 'tiff', '.png', '.svg', '.jpg'],
// '文档': ['.docx', '.xlsx', '.pdf'], '文档': ['.docx', '.xlsx', '.pdf'],
'文档': [],
'视频': ['.mp4'], '视频': ['.mp4'],
'音频': ['.mp3'], '音频': ['.mp3'],
} }
...@@ -51,7 +51,7 @@ const getFileType = (fileName) => { ...@@ -51,7 +51,7 @@ const getFileType = (fileName) => {
const FileUpload = (props) => { const FileUpload = (props) => {
const { value, schema, onChange } = props const { value, schema, onChange } = props
const { disabled, fileType, listType, presetValue, placeholder } = schema const { disabled, fileType, showType, presetValue, placeholder, preview, download } = schema
const [showList, setShowList] = useState('') const [showList, setShowList] = useState('')
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false)
...@@ -60,8 +60,13 @@ const FileUpload = (props) => { ...@@ -60,8 +60,13 @@ const FileUpload = (props) => {
const option = { const option = {
name: 'file', name: 'file',
action: `${window.location.origin}${uploadFileUrl}`, action: `${window.location.origin}${uploadFileUrl}`,
listType: listType, listType: showType,
withCredentials: true, withCredentials: true,
showUploadList: download ?
{
showDownloadIcon: '下载',
downloadIcon: <ArrowDownOutlined />,
} : {},
beforeUpload(file, fileList) { beforeUpload(file, fileList) {
/** @Tips: 解决提交文件中存在特殊字符的问题 */ /** @Tips: 解决提交文件中存在特殊字符的问题 */
let _continueUpload = true; let _continueUpload = true;
...@@ -104,6 +109,7 @@ const FileUpload = (props) => { ...@@ -104,6 +109,7 @@ const FileUpload = (props) => {
} }
}, },
onPreview: (file) => { onPreview: (file) => {
if (!preview) return message.info('该附件禁止预览')
let fileType = getFileType(file.name) let fileType = getFileType(file.name)
if (fileType) { if (fileType) {
setShowFile({ name: file.name, fileType: fileType, filePath: file.url }) setShowFile({ name: file.name, fileType: fileType, filePath: file.url })
...@@ -161,7 +167,11 @@ const FileUpload = (props) => { ...@@ -161,7 +167,11 @@ const FileUpload = (props) => {
iconRender={iconRender} iconRender={iconRender}
{...option} {...option}
> >
{listType !== 'picture-card' ? <Button icon={<UploadOutlined />}>{placeholder || '上传'}</Button> : (disabled ? null : (placeholder || '+ 上传'))} {
showType !== 'picture-card' ?
<Button icon={<UploadOutlined />}>{placeholder || '上传'}</Button>
: (disabled ? null : (placeholder || '+ 上传'))
}
</Upload> </Upload>
<Modal <Modal
width={'70%'} width={'70%'}
......
...@@ -33,12 +33,12 @@ const VerifyTextInput = (props) => { ...@@ -33,12 +33,12 @@ const VerifyTextInput = (props) => {
}, [value]) }, [value])
const selectChange = (value) => { const selectChange = (value) => {
if (value) {
const item = options.find(v => v.value === value) const item = options.find(v => v.value === value)
onChange([{ pattern: value, message: item.message }])
onChange([{ } else {
pattern: value, onChange([])
message: item.message, }
}])
} }
return ( return (
......
...@@ -9,34 +9,29 @@ const options = [ ...@@ -9,34 +9,29 @@ const options = [
const InputDefault = (props) => { const InputDefault = (props) => {
console.log('props', props)
const { value, onChange } = props const { value, onChange } = props
const [visible, setVisible] = useState(false)
const style = useMemo(() => { const style = useMemo(() => {
let paths = ['【本人姓名】', '【本人部门】']
},) if (paths.includes(value)) {
return { color: 'blue' }
const iconClick = () => {
setVisible(true)
} }
return null
}, [value])
const onOk = () => { const selectChange = (value) => {
onChange(value)
} }
const onCancel = () => {
setVisible(false)
}
const selectChange = (value) => { const inputChange = (e) => {
onChange(value) onChange(e.target.value)
} }
const content = ( const content = (
<Select <Select
allowClear
placeholder='请选择环境变量'
style={{ width: '100%' }} style={{ width: '100%' }}
options={options} options={options}
onChange={selectChange} onChange={selectChange}
...@@ -48,13 +43,13 @@ const InputDefault = (props) => { ...@@ -48,13 +43,13 @@ const InputDefault = (props) => {
<div className='InputDefault'> <div className='InputDefault'>
<Input <Input
value={value} value={value}
onChange={(e) => onChange(e.target.value)} onChange={inputChange}
style={style} style={style}
addonAfter={ addonAfter={
<Popover <Popover
placement="topRight" placement="topRight"
content={content} content={content}
title="数据将从环境变量读取" title="环境变量"
trigger="click" trigger="click"
> >
<EllipsisOutlined /> <EllipsisOutlined />
......
...@@ -6,6 +6,8 @@ const Placeholder = (props) => { ...@@ -6,6 +6,8 @@ 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'
const base = { const base = {
InputDefault, InputDefault,
Placeholder,
} }
export default base export default base
\ No newline at end of file
...@@ -3,7 +3,6 @@ import BooleanSwitch from './BooleanSwitch' ...@@ -3,7 +3,6 @@ import BooleanSwitch from './BooleanSwitch'
import EnumOptions from './EnumOptions' import EnumOptions from './EnumOptions'
import FieldNames from './FieldNames' import FieldNames from './FieldNames'
import InputAddon from './InputAddon' import InputAddon from './InputAddon'
import Placeholder from './Placeholder'
import CascadeField from './CascadeField' import CascadeField from './CascadeField'
import DateSelect from './DateSelect' import DateSelect from './DateSelect'
import DataSource from './DataSource' import DataSource from './DataSource'
...@@ -15,7 +14,6 @@ const settings = { ...@@ -15,7 +14,6 @@ const settings = {
EnumOptions, EnumOptions,
FieldNames, FieldNames,
InputAddon, InputAddon,
Placeholder,
CascadeField, CascadeField,
DateSelect, DateSelect,
DataSource, DataSource,
......
...@@ -4,7 +4,7 @@ import style from '../../style' ...@@ -4,7 +4,7 @@ import style from '../../style'
const NumberInput = ({ value, onChange, schema }) => { const NumberInput = ({ value, onChange, schema }) => {
const { disabled, presetValue } = schema const { disabled, presetValue, placeholder } = schema
const valueShow = useMemo(() => { const valueShow = useMemo(() => {
return presetValue || value return presetValue || value
...@@ -12,6 +12,7 @@ const NumberInput = ({ value, onChange, schema }) => { ...@@ -12,6 +12,7 @@ const NumberInput = ({ value, onChange, schema }) => {
return ( return (
<InputNumber <InputNumber
placeholder={placeholder}
disabled={disabled} disabled={disabled}
value={valueShow} value={valueShow}
onChange={value => onChange(value)} onChange={value => onChange(value)}
......
...@@ -25,31 +25,6 @@ const RichText = forwardRef(({ schema, onChange, value }, ref) => { ...@@ -25,31 +25,6 @@ const RichText = forwardRef(({ schema, onChange, value }, ref) => {
return value || presetValue return value || presetValue
}, [presetValue, value]) }, [presetValue, value])
// 图片上传
const uploadImg = file => {
const formData = new FormData();
formData.append('file', file);
setLoading(true);
request({
url: uploadFileAPI,
method: 'POST',
data: formData,
})
.then(res => {
if (!res.data) return;
// eslint-disable-next-line no-useless-escape
const img = res.data.replace(/[\\ \/=]/g, '/');
const imgHtml = `
<img contenteditable="false" style="display: block;" width="50%" src="${downFileAPI}?filePath=${img}" >
`;
editor.cmd.do('insertHTML', imgHtml);
setLoading(false);
})
.catch(err => {
setLoading(false);
});
}
const editorChange = (editor) => { const editorChange = (editor) => {
onChange(editor.getHtml()) onChange(editor.getHtml())
} }
......
...@@ -5,7 +5,7 @@ const TextArea = ({ value, onChange, schema }) => { ...@@ -5,7 +5,7 @@ const TextArea = ({ value, onChange, schema }) => {
console.log('多行文本', schema) console.log('多行文本', schema)
const { disabled, placeholder, presetValue } = schema const { disabled, placeholder, presetValue, maxLength, rows } = schema
const valueShow = useMemo(() => { const valueShow = useMemo(() => {
return presetValue || value return presetValue || value
...@@ -18,9 +18,10 @@ const TextArea = ({ value, onChange, schema }) => { ...@@ -18,9 +18,10 @@ const TextArea = ({ value, onChange, schema }) => {
return ( return (
<Input.TextArea <Input.TextArea
maxLength={maxLength}
disabled={disabled} disabled={disabled}
value={valueShow} value={valueShow}
rows={5} rows={rows}
placeholder={placeholder} placeholder={placeholder}
onChange={handleChange} onChange={handleChange}
/> />
......
...@@ -7,21 +7,35 @@ const iconList = Object.keys(icons).filter((item) => typeof icons[item] === 'obj ...@@ -7,21 +7,35 @@ const iconList = Object.keys(icons).filter((item) => typeof icons[item] === 'obj
const TextInput = (props) => { const TextInput = (props) => {
const userInfo = window?.globalConfig?.userInfo || { fullName: '【本人姓名】', depart: { name: '【本人部门】' } }
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(() => { const valueShow = useMemo(() => {
return presetValue || value return value || presetValue
}, [presetValue, value]) }, [value, presetValue])
const style = useMemo(() => {
let paths = ['【本人姓名】', '【本人部门】']
if (paths.includes(presetValue)) {
if (presetValue === '【本人姓名】') {
onChange(userInfo.fullName)
} else if (presetValue === '【本人部门】') {
onChange(userInfo.depart.name)
}
return { color: 'blue' }
}
return null
}, [presetValue])
const handleChange = (e) => { const handleChange = (e) => {
onChange(e.target.value) onChange(e.target.value)
} }
console.log('rules', rules)
return ( return (
<Input <Input
style={style}
rules={rules} rules={rules}
disabled={disabled} disabled={disabled}
value={valueShow} value={valueShow}
......
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