Commit 5cd150f7 authored by 田翔's avatar 田翔

fix: 配置表名字段名支持下拉框,下拉框配置数据来源必填信息校验,时间配置改为支持单选,可编辑配置根据数据来源进行控制,下拉框增加搜索选项

parent a9f4e41a
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "1.6.2", "version": "1.6.3",
"description": "1.6.2: 防止出现死循环", "description": "1.6.3: 配置表名字段名支持下拉框,下拉框配置数据来源必填信息校验,时间配置改为支持单选,可编辑配置根据数据来源进行控制,下拉框增加搜索选项",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
...@@ -126,4 +126,4 @@ ...@@ -126,4 +126,4 @@
"publishConfig": { "publishConfig": {
"registry": "https://g.civnet.cn:4873" "registry": "https://g.civnet.cn:4873"
} }
} }
\ No newline at end of file
...@@ -202,7 +202,15 @@ export function GetSelectItemList({ nodeName }) { ...@@ -202,7 +202,15 @@ export function GetSelectItemList({ nodeName }) {
}) })
} }
//获取表 //获取所有表
export function LoadTableV2() {
return request({
url: `PandaOMS/OMS/CaseManage/LoadTableV2`,
method: 'get'
})
}
//获取台账表
export function LoadLedgers() { export function LoadLedgers() {
return request({ return request({
url: `PandaOMS/OMS/WorkOrderCenter/GetCM_Ledger_LoadLedgers`, url: `PandaOMS/OMS/WorkOrderCenter/GetCM_Ledger_LoadLedgers`,
......
...@@ -707,7 +707,7 @@ const textWidgets = [ ...@@ -707,7 +707,7 @@ const textWidgets = [
title: '只读', title: '只读',
type: 'boolean', type: 'boolean',
widget: 'checkbox', widget: 'checkbox',
default: false, default: true,
width: '30%', width: '30%',
}, },
hidden: { hidden: {
...@@ -797,10 +797,11 @@ const selectWidgets = [ ...@@ -797,10 +797,11 @@ const selectWidgets = [
title: '来源方式', title: '来源方式',
name: '来源方式', name: '来源方式',
type: 'string', type: 'string',
widget: 'select', // widget: 'select',
widget: 'SoruceType',
default: '手动输入', default: '手动输入',
enum: ['手动输入', '数据字典', '表数据', '站点'], // enum: ['手动输入', '数据字典', '表数据', '站点'],
enumNames: ['手动输入', '数据字典', '表数据', '站点'], // enumNames: ['手动输入', '数据字典', '表数据', '站点'],
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 80,
}, },
...@@ -808,6 +809,7 @@ const selectWidgets = [ ...@@ -808,6 +809,7 @@ const selectWidgets = [
title: '', title: '',
name: '选项', name: '选项',
type: 'array', type: 'array',
required: '{{formData.soruceType === "手动输入"}}',
hidden: '{{formData.soruceType !== "手动输入"}}', hidden: '{{formData.soruceType !== "手动输入"}}',
default: [], default: [],
widget: 'simpleList', widget: 'simpleList',
...@@ -819,7 +821,7 @@ const selectWidgets = [ ...@@ -819,7 +821,7 @@ const selectWidgets = [
type: 'string', type: 'string',
displayType: 'row', displayType: 'row',
labelWidth: 75, labelWidth: 75,
// required: true, required: true,
default: '', default: '',
props: { props: {
style: { style: {
...@@ -836,37 +838,42 @@ const selectWidgets = [ ...@@ -836,37 +838,42 @@ const selectWidgets = [
}, },
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 80,
dependencies: ['soruceType']
}, },
dictionary: { dictionary: {
title: '{{formData.soruceType}}', title: '{{formData.soruceType}}',
name: '{{formData.soruceType}}', name: '{{formData.soruceType}}',
// required: true, required: '{{formData.soruceType === "数据字典"}}',
hidden: '{{formData.soruceType !== "数据字典"}}', hidden: '{{formData.soruceType !== "数据字典"}}',
type: 'string', type: 'string',
widget: 'Dictionary', widget: 'Dictionary',
value: '{{formData.soruceType !== "数据字典" ? null : ""}}', value: '{{formData.soruceType !== "数据字典" ? null : ""}}',
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 80,
dependencies: ['soruceType']
}, },
tableName: { tableName: {
title: '表名', title: '表名',
name: '表名', name: '表名',
required: true, required: '{{formData.soruceType === "表数据"}}',
hidden: '{{formData.soruceType !== "表数据"}}', hidden: '{{formData.soruceType !== "表数据"}}',
type: 'string', type: 'string',
// widget: 'TableName', widget: 'TableName',
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 80,
dependencies: ['soruceType'],
}, },
fieldName: { fieldName: {
title: '字段名', title: '字段名',
name: '字段名', name: '字段名',
required: true, required: true,
required: '{{formData.soruceType === "表数据"}}',
hidden: '{{formData.soruceType !== "表数据"}}', hidden: '{{formData.soruceType !== "表数据"}}',
type: 'string', type: 'string',
// widget: 'TableName', widget: 'FieldName',
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 80,
dependencies: ['soruceType', 'tableName'],
}, },
isMySite: { isMySite: {
title: '仅显示本人所属的站点', title: '仅显示本人所属的站点',
...@@ -915,13 +922,22 @@ const selectWidgets = [ ...@@ -915,13 +922,22 @@ const selectWidgets = [
default: false, default: false,
width: '25%', width: '25%',
}, },
isSearch: {
title: '搜索',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '25%',
default: true
},
isEdit: { isEdit: {
title: '是否可编辑', title: '是否可编辑',
type: 'boolean', type: 'boolean',
widget: 'BooleanSwitch', widget: 'BooleanSwitch',
displayType: 'row', displayType: 'row',
labelWidth: 120, labelWidth: 120,
description: '勾选后可直接输入选项,可编辑选择仅支持多选' description: '勾选后可直接输入选项,可编辑选择仅支持多选',
hidden: '{{formData.soruceType !== "手动输入"}}'
}, },
description: { description: {
title: '说明', title: '说明',
...@@ -1281,7 +1297,7 @@ const selectWidgets = [ ...@@ -1281,7 +1297,7 @@ const selectWidgets = [
schema: { schema: {
title: '开关', title: '开关',
name: '开关', name: '开关',
type: 'boolean', type: 'number',
widget: 'SwitchSelector', widget: 'SwitchSelector',
}, },
setting: { setting: {
...@@ -1339,11 +1355,23 @@ const selectWidgets = [ ...@@ -1339,11 +1355,23 @@ const selectWidgets = [
default: false, default: false,
width: '25%', width: '25%',
}, },
showText: {
title: '显示文字',
type: 'string',
widget: 'select',
enum: ['开/关', '是/否', '明/暗'],
enumNames: ['开/关', '是/否', '明/暗'],
displayType: 'row',
labelWidth: 80,
props: {
allowClear: true
}
},
description: { description: {
title: '说明', title: '说明',
type: 'string', type: 'string',
displayType: 'row', displayType: 'row',
labelWidth: 55, labelWidth: 80,
}, },
groupStyle: { groupStyle: {
title: '控件样式', title: '控件样式',
...@@ -2023,29 +2051,20 @@ const dateWidgets = [ ...@@ -2023,29 +2051,20 @@ const dateWidgets = [
labelWidth: 80, labelWidth: 80,
default: '请选择日期', default: '请选择日期',
}, },
presetValue: { // presetValue: {
title: '默认值', // title: '默认值',
type: 'string', // type: 'string',
widget: 'DateDefault', // widget: 'DateDefault',
dateFormat: '{{formData.format}}', // dateFormat: '{{formData.format}}',
displayType: 'row', // displayType: 'row',
labelWidth: 80, // labelWidth: 80,
description: '勾选默认当前日期此处配置无效' // description: '勾选默认当前日期此处配置无效'
}, // },
groupSetting: { groupSetting: {
title: '控件设置', title: '控件设置',
type: 'object', type: 'object',
properties: {} properties: {}
}, },
format: {
title: '日期格式',
type: 'string',
enum: ['date', 'dateTime', 'year', 'month', 'week', 'quarter'],
default: 'date',
enumNames: ['日期', '日期时间', '日期年份', '日期月份', '日期周', '日期季度'],
displayType: 'row',
labelWidth: 80,
},
required: { required: {
title: '必填', title: '必填',
type: 'boolean', type: 'boolean',
...@@ -2072,30 +2091,52 @@ const dateWidgets = [ ...@@ -2072,30 +2091,52 @@ const dateWidgets = [
default: false, default: false,
width: '30%', width: '30%',
}, },
defaultCurrent: { format: {
title: '默认当前日期', title: '日期格式',
type: 'boolean', type: 'string',
widget: 'checkbox', enum: ['date', 'dateTime', 'year', 'month', 'week', 'quarter'],
default: false, default: 'date',
width: '50%', enumNames: ['日期', '日期时间', '日期年份', '日期月份', '日期周', '日期季度'],
props: { displayType: 'row',
style: { labelWidth: 80,
marginLeft: '10px',
}
}
}, },
currentDate: { options: {
title: '不超过当前日期', title: '选项',
type: 'boolean', type: 'string',
widget: 'checkbox', widget: 'select',
default: false, enum: ['默认为空', '默认为当前时间', '不超过当前时间'],
width: '50%', default: '默认为空',
props: { enumNames: ['默认为空', '默认为当前时间', '不超过当前时间'],
style: { displayType: 'row',
marginLeft: '10px', labelWidth: 80,
} // props: {
} // allowClear: true
// }
}, },
// defaultCurrent: {
// title: '默认当前日期',
// type: 'boolean',
// widget: 'checkbox',
// default: false,
// width: '50%',
// props: {
// style: {
// marginLeft: '10px',
// }
// }
// },
// currentDate: {
// title: '不超过当前日期',
// type: 'boolean',
// widget: 'checkbox',
// default: false,
// width: '50%',
// props: {
// style: {
// marginLeft: '10px',
// }
// }
// },
groupStyle: { groupStyle: {
title: '控件样式', title: '控件样式',
type: 'object', type: 'object',
...@@ -2181,6 +2222,16 @@ const dateWidgets = [ ...@@ -2181,6 +2222,16 @@ const dateWidgets = [
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 80,
}, },
options: {
title: '选项',
type: 'string',
widget: 'select',
enum: ['默认为空', '默认为当前时间', '不超过当前时间'],
default: '默认为空',
enumNames: ['默认为空', '默认为当前时间', '不超过当前时间'],
displayType: 'row',
labelWidth: 80,
},
description: { description: {
title: '说明', title: '说明',
type: 'string', type: 'string',
...@@ -2214,25 +2265,25 @@ const dateWidgets = [ ...@@ -2214,25 +2265,25 @@ const dateWidgets = [
default: false, default: false,
width: '30%', width: '30%',
}, },
defaultCurrent: { // defaultCurrent: {
title: '默认当前时间', // title: '默认当前时间',
type: 'boolean', // type: 'boolean',
widget: 'checkbox', // widget: 'checkbox',
default: false, // default: false,
width: '50%', // width: '50%',
props: { // props: {
style: { // style: {
marginLeft: '10px', // marginLeft: '10px',
} // }
} // }
}, // },
currentDate: { // currentDate: {
title: '不超过当前时间', // title: '不超过当前时间',
type: 'boolean', // type: 'boolean',
widget: 'checkbox', // widget: 'checkbox',
default: false, // default: false,
width: '50%', // width: '50%',
}, // },
groupStyle: { groupStyle: {
title: '控件样式', title: '控件样式',
type: 'object', type: 'object',
......
import React, { useRef, useEffect, useState, useContext, forwardRef, createContext, useMemo, useLayoutEffect } from 'react' import React, { useRef, useEffect, useState, useContext, forwardRef, createContext, useMemo, useLayoutEffect } from 'react'
import { ConfigProvider, message, Modal, Button } from 'antd' import { ConfigProvider, message, Modal, Button } from 'antd'
import { ExclamationCircleOutlined } from '@ant-design/icons'
import Generator, { defaultSettings } from 'fr-generator' import Generator, { defaultSettings } from 'fr-generator'
import { settings, baseSettings, globalSettings } from './config' import { settings, baseSettings, globalSettings } from './config'
import widgets from '../widgets' import widgets from '../widgets'
...@@ -51,10 +52,35 @@ const FormDesigner = (props, ref) => { ...@@ -51,10 +52,35 @@ const FormDesigner = (props, ref) => {
}, [tableName]) }, [tableName])
const extraButtons = [ const extraButtons = [
false,
false, false,
true, true,
true, true,
true, {
text: '清空',
onClick: (e) => {
Modal.confirm({
title: '确定要清空该表单配置吗?',
icon: <ExclamationCircleOutlined />,
centered: true,
cancelText: '取消',
okText: '确定',
onCancel: () => {
console.log('取消清空')
},
onOk: () => {
const schema = designerRef.current.getValue()
let newschema = {}
for (let key in schema) {
if (key !== 'properties') {
newschema[key] = schema[key]
}
}
designerRef.current.setValue(newschema)
}
})
},
},
{ {
text: '预览', text: '预览',
onClick: (e) => { onClick: (e) => {
......
...@@ -7,17 +7,17 @@ import locale from 'antd/lib/date-picker/locale/zh_CN' ...@@ -7,17 +7,17 @@ import locale from 'antd/lib/date-picker/locale/zh_CN'
const DateTime = (props) => { const DateTime = (props) => {
const { value, onChange, schema } = props const { value, onChange, schema } = props
const { disabled, format, presetValue, placeholder, currentDate, defaultCurrent } = schema const { disabled, format, presetValue, placeholder, options, currentDate, defaultCurrent } = schema
const valueShow = useMemo(() => { const valueShow = useMemo(() => {
if (defaultCurrent) { if (options === '默认为当前时间') {
return (value || new Date()) ? moment(value || new Date()) : null return (value || new Date()) ? moment(value || new Date()) : null
} }
return (value || presetValue) ? moment(value || presetValue) : null return (value || presetValue) ? moment(value || presetValue) : null
}, [presetValue, defaultCurrent, value]) }, [presetValue, defaultCurrent, value])
const disabledDate = (current) => { const disabledDate = (current) => {
if (currentDate) { if (options === '不超过当前时间') {
return current && current > moment() return current && current > moment()
} else { } else {
return false return false
......
...@@ -5,17 +5,17 @@ import moment from 'moment' ...@@ -5,17 +5,17 @@ import moment from 'moment'
const Time = (props) => { const Time = (props) => {
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
const { presetValue, currentDate, defaultCurrent } = schema const { presetValue, currentDate, defaultCurrent, options } = schema
const valueShow = useMemo(() => { const valueShow = useMemo(() => {
if (defaultCurrent) { if (options === '默认为当前时间') {
return (value || new Date()) ? moment(value || new Date(), 'HH:mm:ss') : null return (value || new Date()) ? moment(value || new Date(), 'HH:mm:ss') : null
} }
return (value || presetValue) ? moment(value || presetValue, 'HH:mm:ss') : null return (value || presetValue) ? moment(value || presetValue, 'HH:mm:ss') : null
}, [presetValue, value, defaultCurrent]) }, [presetValue, value, defaultCurrent])
const disabledDate = (current) => { const disabledDate = (current) => {
if (currentDate) { if (options === '不超过当前时间') {
return current && current.format('HH:mm:ss') > moment().format('HH:mm:ss') return current && current.format('HH:mm:ss') > moment().format('HH:mm:ss')
} else { } else {
return false return false
...@@ -35,7 +35,6 @@ const Time = (props) => { ...@@ -35,7 +35,6 @@ const Time = (props) => {
/> />
) )
} }
export default Time export default Time
\ No newline at end of file
...@@ -8,7 +8,7 @@ const ComboBox = (props) => { ...@@ -8,7 +8,7 @@ const ComboBox = (props) => {
const userID = window?.globalConfig?.userInfo?.OID || 1 const userID = window?.globalConfig?.userInfo?.OID || 1
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
const { placeholder, disabled, soruceType, options, dictionary, tableName, fieldName, presetValue, isMultiple, isEdit, isMySite } = schema const { placeholder, disabled, soruceType, options, dictionary, tableName, fieldName, presetValue, isMultiple, isEdit, isMySite, isSearch } = schema
const [dictionaryList, setDictionaryList] = useState([]) const [dictionaryList, setDictionaryList] = useState([])
const [tableData, setTableData] = useState([]) const [tableData, setTableData] = useState([])
const [site, setSite] = useState([]) const [site, setSite] = useState([])
...@@ -113,7 +113,7 @@ const ComboBox = (props) => { ...@@ -113,7 +113,7 @@ const ComboBox = (props) => {
mode={isEdit ? 'tags' : (isMultiple ? 'multiple' : '')} mode={isEdit ? 'tags' : (isMultiple ? 'multiple' : '')}
disabled={disabled} disabled={disabled}
showArrow={!disabled} showArrow={!disabled}
showSearch showSearch={isSearch}
value={valueShow} value={valueShow}
placeholder={placeholder} placeholder={placeholder}
onChange={handleChange} onChange={handleChange}
......
...@@ -4,9 +4,8 @@ import { Switch } from 'antd' ...@@ -4,9 +4,8 @@ import { Switch } from 'antd'
const SwitchSelector = (props) => { const SwitchSelector = (props) => {
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
const { disabled, presetValue } = schema const { disabled, presetValue, showText } = schema
const text = showText ? showText.split('/') : ['', '']
console.log('props', props)
useEffect(() => { useEffect(() => {
if (addons) { if (addons) {
...@@ -18,16 +17,16 @@ const SwitchSelector = (props) => { ...@@ -18,16 +17,16 @@ const SwitchSelector = (props) => {
const switchChange = (checked) => { const switchChange = (checked) => {
if (addons) { if (addons) {
onChange(checked) onChange(checked ? 1 : 0)
} }
} }
return ( return (
<Switch <Switch
checked={value} checked={Boolean(value)}
disabled={disabled} disabled={disabled}
checkedChildren={'开启'} checkedChildren={Array.isArray(text) ? text[0] : ''}
unCheckedChildren="关闭" unCheckedChildren={Array.isArray(text) ? text[1] : ''}
onChange={switchChange} onChange={switchChange}
> >
......
...@@ -61,7 +61,7 @@ const Dictionary = (props) => { ...@@ -61,7 +61,7 @@ const Dictionary = (props) => {
onChange={selectChange} onChange={selectChange}
onFocus={() => getDictionary()} onFocus={() => getDictionary()}
showSearch showSearch
allowClear // allowClear
> >
{ {
options.map(v => { options.map(v => {
......
import React, { useState } from 'react'
import { Select, message } from 'antd'
import { LoadTableV2, LoadTableFields } from '../../../../../apis/process'
const FieldName = (props) => {
const { value, onChange, addons } = props
const { tableName } = addons.formData
const [options, setOptions] = useState([])
const onFocus = async () => {
if (!tableName) {
return message.info('请选择表名!')
}
const { code, data, msg } = await LoadTableFields({ tableName: tableName })
if (code === 0) {
let result = data.root.map(v => { return { label: v.fieldName, value: v.fieldName } })
setOptions(result)
} else {
message.error(msg)
}
}
const selectChange = (value) => {
onChange(value)
}
return (
<Select
options={options}
value={value}
onFocus={onFocus}
onChange={selectChange}
>
</Select>
)
}
export default FieldName
\ No newline at end of file
import React, { useMemo } from 'react'
import { Select } from 'antd'
const options = [
{ label: '手动输入', value: '手动输入' },
{ label: '数据字典', value: '数据字典' },
{ label: '表数据', value: '表数据' },
{ label: '站点', value: '站点' }
]
const SoruceType = (props) => {
const { value, onChange, schema, addons } = props
const selectChange = (e) => {
if (value === '手动输入') {
addons.removeErrorField('options')
} else if (value === '数据字典') {
addons.removeErrorField('dictionary')
} else if (value === '表数据') {
addons.removeErrorField('tableName')
addons.removeErrorField('fieldName')
}
if (e !== '手动输入') {
addons.setValueByPath('isEdit', false)
}
onChange(e)
}
return (
<Select
value={value}
style={{ width: '100%' }}
options={options}
onChange={selectChange}
/>
)
}
export default SoruceType
\ No newline at end of file
import React from 'react'
import { Input, Select } from 'antd'
import Form from 'antd/es/form/Form'
const TableAndField = (props) => {
const { value, onChange } = props
const selectChange = (value) => {
onChange(value)
}
const inputChange = (e) => {
onChange(e.target.value)
}
return (
<Form
labelCol={{
span: 8,
}}
wrapperCol={{
span: 16,
}}
>
<Form.Item
label='表名'
name='tableName'
rules={[
{
required: true,
message: '请输入表名',
}
]}
>
<Input style={{ width: '100%' }} />
</Form.Item>
<Form.Item
label='字段名'
name='fieldName'
rules={[
{
required: true,
message: '请输入字段名',
}
]}
>
<Input />
</Form.Item>
</Form>
)
}
export default TableAndField
\ No newline at end of file
import React, { useMemo, useState } from 'react'
import { Select } from 'antd'
import { LoadTableV2, LoadLedgers } from '../../../../../apis/process'
const TableName = (props) => {
const { value, onChange } = props
const [groupNames, setGroupNames] = useState([])
const [data, setData] = useState([])
const options = useMemo(() => {
let array = []
if (Array.isArray(groupNames)) {
groupNames.forEach(v => {
let options = Array.isArray(data) ? data.filter(s => s.groupNames === v.groupName) : []
array.push({
label: v,
options: options.map(s => { return { label: s.tableName, value: s.tableName } })
})
})
}
return array
}, [groupNames, data])
const onFocus = async () => {
const { code, data } = await LoadTableV2()
if (code === 0) {
setGroupNames(data.groupNames)
setData(data.root)
} else {
message.error('请求错误!')
}
}
const selectChange = (value) => {
onChange(value)
}
return (
<Select
value={value}
options={options}
onFocus={onFocus}
onChange={selectChange}
showSearch
>
</Select>
)
}
export default TableName
\ No newline at end of file
import Dictionary from './Dictionary' import Dictionary from './Dictionary'
import TableAndField from './TableAndField'
import AccountName from './AccountName' import AccountName from './AccountName'
import Fieldshine from './Fieldshine' import Fieldshine from './Fieldshine'
import MappedField from './MappedField' import MappedField from './MappedField'
import ControlShow from './ControlShow' import ControlShow from './ControlShow'
import SoruceType from './SoruceType'
import TableName from './TableName'
import FieldName from './FieldName'
const groupSource = { const groupSource = {
Dictionary, Dictionary,
TableAndField,
AccountName, AccountName,
Fieldshine, Fieldshine,
MappedField, MappedField,
ControlShow, ControlShow,
SoruceType,
TableName,
FieldName,
} }
export default groupSource export default groupSource
\ No newline at end of file
import React from 'react' import React, { useEffect, useContext } from 'react'
import { Input, Popover } from 'antd' import { Input, Popover, ConfigProvider } from 'antd'
import { QrcodeOutlined } from '@ant-design/icons' import { QrcodeOutlined } from '@ant-design/icons'
import QRcode from 'qrcode.react' import QRcode from 'qrcode.react'
import './index.less'
const Coding = (props) => { const Coding = (props) => {
const { value, onChange } = props const { getPrefixCls } = useContext(ConfigProvider.ConfigContext)
const prefixCls = getPrefixCls('pandaXform')
const { value, onChange, schema, addons } = props
const { disabled } = schema
const inputChange = (e) => {
if (addons) {
onChange(e.target.value)
}
}
const content = ( const content = (
<div> <div>
{/* <QRcode value={<div style={{ color: 'red' }}>123</div>} /> */} <QRcode value={value} />
<QRcode src='https://www.runoob.com/w3cnote/javascript-qrcodejs-library.html' />
</div> </div>
) )
return ( return (
<div> <div className={`${prefixCls}-input`} isdisabled={JSON.stringify(disabled)}>
<Input <Input
onChange={inputChange}
disabled={disabled}
addonAfter={ addonAfter={
<Popover content={content}> <Popover content={content}>
<QrcodeOutlined /> <QrcodeOutlined />
</Popover> </Popover>
} }
onChange={e => onChange(e.target.value)}
/> />
</div> </div>
) )
......
@import '~antd/es/style/themes/default.less';
@pandaXform: ~'@{ant-prefix}-pandaXform';
.@{pandaXform} {
.@{pandaXform}-input[isdisabled='true'] {
.@{ant-prefix}-input-group-addon {
border: 1px solid #e9e9e9;
}
}
}
\ No newline at end of file
/**
* @Description: QRCode 使用传入的值生成二维码
* @Params: 参数描述
* @Date: 2021/12/3
* @Author: ChenLong
* */
import React, { useState } from 'react';
import { Input } from 'antd';
import QR from 'qrcode.react';
import './index.less'
const QRCode = ({ schema }) => {
const [show, setShow] = useState(false)
return (
<div className='QRCode'>
<Input
disabled={schema.disabled}
value={schema.default}
onFocus={() => setShow(true)}
onBlur={() => setShow(false)}
/>
<div className='QRCode-img' style={{ display: show ? 'block' : 'none' }}>
{
schema.default ? <QR value={schema.default} /> : null
}
</div>
</div>
);
};
export default QRCode;
.QRCode {
position: relative;
.QRCode-img {
position: absolute;
z-index: 99;
}
}
\ No newline at end of file
import React, { useState, useEffect, useMemo } from 'react' import React, { useState, useEffect, useMemo, useContext } from 'react'
import { Input, message } from 'antd' import { Input, message, ConfigProvider } from 'antd'
import Icon, { EllipsisOutlined } from '@ant-design/icons' import Icon, { EllipsisOutlined } from '@ant-design/icons'
import * as icons from '@ant-design/icons' import * as icons from '@ant-design/icons'
import { GetFieldValueFromTable } from '../../../../apis/process' import { GetFieldValueFromTable } from '../../../../apis/process'
import './index.less'
const iconList = Object.keys(icons).filter((item) => typeof icons[item] === 'object') const iconList = Object.keys(icons).filter((item) => typeof icons[item] === 'object')
...@@ -23,7 +24,8 @@ const debounce = (fn) => { ...@@ -23,7 +24,8 @@ const debounce = (fn) => {
const TextInput = (props) => { const TextInput = (props) => {
const userInfo = window?.globalConfig?.userInfo || { fullName: '【本人姓名】', depart: { name: '【本人部门】' } } const userInfo = window?.globalConfig?.userInfo || { fullName: '【本人姓名】', depart: { name: '【本人部门】' } }
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext)
const prefixCls = getPrefixCls('pandaXform')
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
const { title, disabled, placeholder, presetValue, addonBefore, addonAfter, maxLength, rules, uniqueVerify, tableName, fieldName } = schema const { title, disabled, placeholder, presetValue, addonBefore, addonAfter, maxLength, rules, uniqueVerify, tableName, fieldName } = schema
...@@ -73,15 +75,17 @@ const TextInput = (props) => { ...@@ -73,15 +75,17 @@ const TextInput = (props) => {
}, [uniqueVerify, tableName, fieldName]) }, [uniqueVerify, tableName, fieldName])
return ( return (
<Input <div className={`${prefixCls}-input`} isdisabled={JSON.stringify(disabled)}>
disabled={disabled} <Input
value={value} disabled={disabled}
maxLength={maxLength} value={value}
placeholder={disabled ? null : placeholder} maxLength={maxLength}
onChange={handleChange} placeholder={disabled ? null : placeholder}
addonBefore={iconList.includes(addonBefore) ? <Icon component={icons[addonBefore]} /> : addonBefore} onChange={handleChange}
addonAfter={iconList.includes(addonAfter) ? <Icon component={icons[addonAfter]} /> : addonAfter} addonBefore={iconList.includes(addonBefore) ? <Icon style={{ color: 'pink' }} component={icons[addonBefore]} /> : addonBefore}
/> addonAfter={iconList.includes(addonAfter) ? <Icon component={icons[addonAfter]} /> : addonAfter}
/>
</div>
) )
} }
......
@import '~antd/es/style/themes/default.less';
@pandaXform: ~'@{ant-prefix}-pandaXform';
.@{pandaXform} {
.@{pandaXform}-input[isdisabled='true'] {
.@{ant-prefix}-input-group-addon {
border: 1px solid #e9e9e9;
}
}
}
\ No newline at end of file
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