Commit dbd05bb4 authored by 田翔's avatar 田翔

fix: 增加地址以及设备二维码配置,台账选择器隐射字段默认设置

parent 431ecb15
{
"name": "panda-xform",
"version": "1.5.5",
"description": "1.5.5: 字段名称处理",
"version": "1.5.6",
"description": "1.5.6: 增加地址以及设备二维码配置,台账选择器隐射字段默认设置",
"keywords": [
"panda-xform"
],
......
......@@ -214,6 +214,17 @@ const textWidgets = [
type: 'object',
properties: {}
},
required: {
title: '必填',
type: 'boolean',
default: false,
width: '33%',
props: {
style: {
marginLeft: '10px',
}
}
},
disabled: {
title: '只读',
type: 'boolean',
......@@ -228,25 +239,22 @@ const textWidgets = [
default: false,
width: '33%',
},
required: {
title: '必填',
type: 'boolean',
default: false,
width: '33%',
props: {
style: {
marginLeft: '10px',
}
}
},
isStoreID: {
title: '是否存储ID',
type: 'boolean',
default: false,
// width: '33%',
hidden: "{{!['【本人姓名】','【本人部门】'].includes(rootValue.presetValue) }}",
dependencies: ['presetValue'],
},
isQRCode: {
title: '设备二维码',
type: 'boolean',
widget: 'BooleanSwitch',
default: false,
displayType: 'row',
labelWidth: 120,
description: '是否解析为二维码格式(手持端专用)',
},
description: {
title: '说明',
type: 'string',
......@@ -390,6 +398,15 @@ const textWidgets = [
default: false,
width: '30%',
},
currentAddress: {
title: '获取当前地址',
type: 'boolean',
widget: 'BooleanSwitch',
default: false,
displayType: 'row',
labelWidth: 120,
description: '是否自动获取当前地址(手持端专用)',
},
description: {
title: '说明',
type: 'string',
......@@ -1321,10 +1338,10 @@ const selectWidgets = [
presetValue: {
title: '默认值',
type: 'string',
displayType: 'row',
widget: 'CascadeDefault',
displayType: 'row',
labelWidth: 80,
dependencies: ['soruceType']
// dependencies: ['soruceType']
},
gorupSoruce: {
title: '数据来源',
......@@ -1708,7 +1725,7 @@ const selectWidgets = [
displayType: 'row',
labelWidth: 100,
required: true,
dependencies: ['accountName'],
dependencies: ['accountName', '$id'],
default: [],
description: '单字段映射支持多选,多字段映射仅支持单选',
},
......@@ -2498,19 +2515,19 @@ const advancedWidgets = [
}
}
},
hidden: {
title: '隐藏',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
},
emphasis: {
title: '强调',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
// hidden: {
// title: '隐藏',
// type: 'boolean',
// widget: 'checkbox',
// default: false,
// width: '33%',
// },
description: {
title: '说明',
type: 'string',
widget: 'htmlInput',
displayType: 'row',
labelWidth: 60,
},
gorupSoruce: {
title: '数据来源',
......@@ -2525,15 +2542,39 @@ const advancedWidgets = [
labelWidth: 80,
required: true
},
mappedField: {
title: '映射字段',
type: 'array',
widget: 'MappedField',
displayType: 'row',
labelWidth: 80,
required: true,
default: [],
},
defaultShow: {
title: '默认显示',
type: 'boolean',
widget: 'BooleanSwitch',
default: false,
displayType: 'row',
labelWidth: 80,
},
controlShow: {
title: '控制规则',
type: 'string',
displayType: 'row',
labelWidth: 80,
widget: 'ControlShow',
},
...groupStyle,
},
},
{
text: '个性签名',
name: '个性签名',
text: '手写签名',
name: '手写签名',
schema: {
title: '个性签名',
name: '个性签名',
title: '手写签名',
name: '手写签名',
type: 'string',
widget: 'Signature',
width: '100%',
......@@ -2569,7 +2610,7 @@ const settings = [
widgets: fileWidgets,
},
{
title: '地图控件',
title: 'GIS控件',
show: true,
widgets: mapWidgets,
},
......
......@@ -91,7 +91,6 @@ const FormDesigner = (props, ref) => {
if (errors.length) {
return message.error('表单校验未通过!')
}
console.log('formValue', formValue)
}
return (
......
......@@ -11,7 +11,7 @@ import {
} from '../../../../apis/process'
import { Table, Button, Modal, message, Popconfirm } from 'antd'
import { SnippetsOutlined, PlusOutlined, FormOutlined, DeleteOutlined, } from '@ant-design/icons'
// import FormDesigner from '../../../FormDesigner'
import FormRender, { useForm } from 'form-render'
const icons = {
'详情': <SnippetsOutlined />,
......@@ -22,15 +22,12 @@ let formStateStr = '添加'
const RelationForm = (props) => {
console.log('props', props)
const fieldNames = ['事件编号', '工单编号']
const { value, onChange, schema, addons } = props
const { disabled, source, accountName } = schema
// const configInfo = source ? { ...JSON.parse(source) } : {}
const [listData, setListData] = useState([])
const { codes } = parent
const form = useForm()
const [config, setConfig] = useState({ webShowFieldGroup: '', fieldGroup: '' })
const [dataSource, setDataSource] = useState([])
const [groupMeta, setGroupMeta] = useState([])
......@@ -370,6 +367,8 @@ const RelationForm = (props) => {
}
}, [accountName])
console.log('tablesSchema', tablesSchema)
return (
<div className={styles.relationForm}>
<div className={styles.header}>
......@@ -392,15 +391,10 @@ const RelationForm = (props) => {
bodyStyle={{ height: 700 }}
destroyOnClose
>
{/* <FormDesigner
tablesSchema={tablesSchema}
/> */}
{/* <JsonToHtml
isReadOnly={isReadOnly}
tablesSchema={tablesSchema}
ref={parseFormRef}
noButtons
/> */}
<FormRender
form={form}
schema={tablesSchema}
/>
</Modal>
</div>
)
......
......@@ -48,7 +48,11 @@ const CascadeSelector = (props) => {
return result;
}
const cascaderChange = selectedValues => {
const cascaderChange = (selectedValues) => {
if (addons) {
if (!selectedValues) {
return onChange('')
}
const result = []
// 递归查询城市所有数据
function findCityData(city) {
......@@ -65,7 +69,6 @@ const CascadeSelector = (props) => {
findCityData(city)
// 分发监听
const cityValue = result.map(v => v.label)
if (addons) {
onChange(cityValue.join('/'))
}
}
......
......@@ -22,6 +22,8 @@ const CheckBox = (props) => {
useEffect(() => {
if (addons) {
addons.setValue(addons.dataPath, presetValue)
} else {
onChange(presetValue)
}
}, [presetValue])
......
......@@ -4,9 +4,10 @@ import { GetSelectItemList, GetFieldValueFromTable, getStationListByUserID } fro
const { Option } = Select
const ComboBox = ({ value, onChange, schema }) => {
const ComboBox = (props) => {
const userID = window?.globalConfig?.userInfo?.OID || 1
const { value, onChange, schema, addons } = props
const { placeholder, disabled, soruceType, options, dictionary, tableName, fieldName, presetValue, isMultiple, isEdit, isMySite } = schema
const [dictionaryList, setDictionaryList] = useState([])
const [tableData, setTableData] = useState([])
......@@ -54,6 +55,7 @@ const ComboBox = ({ value, onChange, schema }) => {
}
const onFocus = async () => {
if (addons) {
if (soruceType === '数据字典') {
if (!dictionary) {
return message.error('请选择数据字典!')
......@@ -94,6 +96,7 @@ const ComboBox = ({ value, onChange, schema }) => {
}
}
}
}
return (
<Select
......
......@@ -23,6 +23,7 @@ const DeptSelector = (props) => {
}
const iconClick = async () => {
if (addons) {
const { code, data, msg } = await getDeptList()
if (code === 0) {
setTreeData(data)
......@@ -30,6 +31,7 @@ const DeptSelector = (props) => {
message.error(msg)
}
}
}
useEffect(() => {
if (addons) {
......
......@@ -6,7 +6,6 @@ const CascadeDefault = (props) => {
const { value, onChange, schema, addons } = props
const { soruceType } = addons.formData
const { disabled } = schema
const enums = useMemo(() => {
if (soruceType === '城市数据') {
......@@ -75,10 +74,9 @@ const CascadeDefault = (props) => {
return (
<Cascader
value={value ? getDefaultValue(value) : []}
value={value}
showSearch
onChange={cascaderChange}
disabled={disabled}
style={{ width: '100%' }}
options={enums}
/>
......
......@@ -10,7 +10,6 @@ const FieldNames = (props) => {
const [fieldName, setFieldName] = useState([])
const selectChange = (value) => {
console.log('value', value)
onChange(value)
}
......@@ -30,6 +29,8 @@ const FieldNames = (props) => {
let array = value.split('/')
if (array.length === 3) {
onChange(array[2])
} else if (array.length === 2) {
onChange(array[1])
}
}
}, [value])
......
import React, { useEffect, useState, useRef } from 'react';
// import { RuleValidation } from '@/services/workflow/workflow';
import { Modal, Input, Form, message, Dropdown, Menu, Tree } from 'antd';
import styles from './index.less';
// import Tree from '@/components/ExpendableTree';
const { TextArea } = Input;
const fnList = [
{ label: '是否为工作日', value: '$fn.isWorkDay()' },
{ label: '是否为工作时间', value: '$fn.isWorkTime()' },
];
const RuleConfig = props => {
const { visible, handleCancel, fieldList, onSubumit, RuleContent, flag } = props;
const [rule, setRule] = useState([]);
const [expandedKey, setExpandedKey] = useState(''); // 默认展开项
const [currentSelectId, setCurrentSelectId] = useState(''); // 选中得节点
const ruleText = useRef();
const chooseIndex = useRef(0);
const [form] = Form.useForm();
useEffect(() => {
if (visible) {
setExpandedKey(fieldList[0].TableName);
setRule(RuleContent);
setTimeout(() => {
console.log(document.getElementById('ruleText'));
console.log(ruleText.current);
document
.getElementById('ruleText')
.setSelectionRange(RuleContent.length, RuleContent.length); // 重新定位光标
}, 0);
} else {
chooseIndex.current = 0;
setExpandedKey('');
setCurrentSelectId('');
setRule('');
}
}, [visible]);
// 保存线配置
const onSave = () => {
console.log('rule', rule)
// RuleValidation({ ruleContent: rule }).then(res => {
// if (res.data) {
// onSubumit(rule);
// } else {
// message.error('请检查规则是否正确');
// }
// });
};
// 处理树数据
const mapTree = (val, index) => ({
title: val.TableName,
key: val.TableName,
children: val.TableFieldNames.map(item => ({
title: item,
key: `${val.TableName}.${item}`,
})),
});
const onSelect = (prop, treeNode) => {
console.log(prop, treeNode);
if (!treeNode.node.children) {
insert(`{${treeNode.node.key}}`);
}
setCurrentSelectId(prop[0]);
};
const insert = text => {
let ednIndex = document.getElementById('ruleText').selectionEnd;
let rangeIndex = document.getElementById('ruleText').selectionStart;
console.log(ednIndex, rangeIndex, 'endene');
setRule(`${rule.slice(0, rangeIndex)}${text}${rule.slice(rangeIndex)}`);
rangeIndex += text.toString().length;
ruleText.current.focus();
};
const insertFn = value => {
insert(value);
};
const fnListRender = (
<Menu>
{fnList.map(item => (
<Menu.Item key={item.value} onClick={() => insertFn(item.value)}>
{item.label}
</Menu.Item>
))}
</Menu>
);
return (
<Modal
title="规则配置"
visible={visible}
onOk={onSave}
width="740px"
onCancel={handleCancel}
maskClosable={false}
destroyOnClose
getContainer={false}
>
<div className={styles.configContent}>
<div className={styles.leftTree}>
<Tree
blockNode
autoExpandParent
onSelect={onSelect}
selectedKeys={[currentSelectId]}
expandedKeys={expandedKey}
treeData={fieldList.map((item, index) => mapTree(item, index))}
/>
</div>
<div className={styles.rightContent}>
{flag == 1 && <div className={styles.title}>符合以下条件时工单扭转到对应的节点</div>}
<div className={styles.textAreaBox}>
<Dropdown overlay={fnListRender} placement="bottom" arrow>
<div className={styles.insertFn}>插入函数</div>
</Dropdown>
<TextArea
id="ruleText"
autoSize={{ minRows: 19, maxRows: 19 }}
value={rule}
rows={4}
ref={ruleText}
onChange={e => setRule(e.target.value)}
/>
</div>
<ul className={styles.tipBox}>
<li>
<p>请从左侧面板选择字段或选项</p>
<p>
{'支持'} <i>英文</i> {'模式下运算符(+、-、*、/><==!=<=>='}
</p>
</li>
{flag === 1 ? (
<>
<li>
<p>参考场景:</p>
<p>当报销金额大于1000时,才能进入所选节点,则可将流转条件设置为:</p>
<p>
<em>{'报销金额 > 1000'}</em>
</p>
</li>
</>
) : (
<li>{`示例:{表名.是否缴费} = ‘是’ and {表名.缴费金额} > 1000`}</li>
)}
</ul>
</div>
</div>
</Modal>
)
}
export default RuleConfig;
import React, { useEffect, useState, useRef } from 'react';
// import { RuleValidation } from '@/services/workflow/workflow';
import { Modal, Input, Form, message, Dropdown, Menu, Tree } from 'antd';
import styles from './index.less';
// import Tree from '@/components/ExpendableTree';
const { TextArea } = Input;
// import RuleConfig from './RuleConfig';
const ControlShow = (props) => {
const { value, onChange } = props
const inputChange = (e) => {
onChange(e.target.value)
}
return (
<div>
<Input
// onClick={inputClick}
onChange={inputChange}
/>
{/* <RuleConfig
fieldList={fieldList}
RuleContent={123}
visible={visible}
handleCancel={() => { }}
onSubumit={() => { }}
flag={2}
/> */}
</div>
)
}
export default ControlShow
......@@ -9,7 +9,7 @@ const { TreeNode } = TreeSelect
const Fieldshine = (props) => {
const { addons, onChange, value } = props
const { accountName, tableNameParent } = addons.formData
const { $id, accountName, tableNameParent } = addons.formData
const [form] = Form.useForm()
const [visible, setVisible] = useState(false)
......@@ -31,6 +31,9 @@ const Fieldshine = (props) => {
}
const inputClick = async () => {
if ($id.includes('台账选择器')) {
return message.info('请选择字段名称')
}
if (!accountName) {
return message.info('请选择台账名称')
}
......@@ -51,7 +54,10 @@ const Fieldshine = (props) => {
} else {
message.error(res2.msg)
}
form.setFieldsValue({ field: value })
let field = value.length ? value : [{ fromField: '', toField: $id }]
console.log('field', field)
form.setFieldsValue({ field })
setVisible(true)
}
......@@ -73,13 +79,15 @@ const Fieldshine = (props) => {
<Form.List name="field">
{(value, { add, remove }) => (
<>
{value.map(({ key, name, ...restField }) => (
{value.map(({ key, name, ...restField }, index) => (
<Space
key={key}
style={{
display: 'flex',
marginBottom: '5px ',
justifyContent: 'center',
position: 'relative',
left: index === 0 ? '-11px' : '',
}}
align="baseline"
>
......@@ -138,11 +146,13 @@ const Fieldshine = (props) => {
showCheckedStrategy
>
<TreeNode value='事件_测试02' title='事件_测试02' disabled>
{toField.map(s => <TreeNode value={s.alias} title={s.name} key={s.name} />)}
{
index === 0 ? <TreeNode value={$id} title={$id} /> : toField.map(s => <TreeNode value={s.name} title={s.name} key={s.name} />)
}
</TreeNode>
</TreeSelect>
</Form.Item>
<MinusCircleOutlined onClick={() => remove(name)} />
{index !== 0 ? <MinusCircleOutlined onClick={() => remove(name)} /> : null}
</Space>
))}
<Form.Item style={{ padding: '0 10px' }}>
......
import React, { useState } from 'react'
import { Form, Space, TreeSelect, Button, Input, Modal, message } from 'antd'
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'
import styles from './index.less'
import { ReloadTableFields, QueryFields } from '../../../../../apis/process'
const { TreeNode } = TreeSelect
const MappedField = (props) => {
const { value, onChange, schema, addons } = props
const { accountName, tableNameParent } = addons.formData
const [form] = Form.useForm()
const [visible, setVisible] = useState(false)
const [fromField, setFromField] = useState([])
const [toField, setToField] = useState([])
const inputClick = async () => {
if (!accountName) {
message.info('请选择台账名称')
}
const req1 = QueryFields(accountName)
const req2 = ReloadTableFields({ tableName: tableNameParent })
const [res1, res2] = await Promise.all([req1, req2])
console.log(res1, res2)
if (res1.code === 0) {
setToField(res1.data)
} else {
message.error(res1.msg)
}
if (res2.code === 0) {
setFromField(res2.data.root)
} else {
message.error(res2.msg)
}
setVisible(true)
}
const onOk = () => {
form
.validateFields()
.then((values) => {
const { field } = form.getFieldsValue()
onChange(field)
setVisible(false)
})
.catch((info) => {
console.log('Validate Failed:', info)
})
}
return (
<div className={styles.mappedField}>
<Input
value={value && value.length ? JSON.stringify(value) : null}
onClick={inputClick}
/>
<Modal
title={accountName}
visible={visible}
onCancel={() => setVisible(false)}
onOk={onOk}
>
<Form name="dynamic_form_nest_item" form={form} autoComplete="off">
<Form.List name="field">
{(value, { add, remove }) => (
<>
{value.map(({ key, name, ...restField }, index) => (
<Space
key={key}
style={{
display: 'flex',
marginBottom: '5px ',
justifyContent: 'center'
}}
align="baseline"
>
<Form.Item
{...restField}
name={[name, 'fromField']}
rules={[
{
required: true,
message: '来源字段必填',
}
]}
>
<TreeSelect
showSearch
style={{ width: '180px' }}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
placeholder="请选择字段名 "
allowClear
treeDefaultExpandAll
showCheckedStrategy
>
<TreeNode value='内置字段' title='内置字段' disabled>
{['工单编号', '事件编号'].map(s => <TreeNode value={s} title={s} key={s} />)}
</TreeNode>
<TreeNode value='附加字段' title='附加字段' disabled>
{fromField.map(s => {
if (['工单编号', '事件编号'].includes(s.name)) {
return null
}
return <TreeNode value={s.name} title={s.name} key={s.name} />
})}
</TreeNode>
</TreeSelect>
</Form.Item>
<div className={styles.centerImg}></div>
<Form.Item
{...restField}
name={[name, 'toField']}
rules={[
{
required: true,
message: '目标字段必填',
},
{
validator: (rules, value, callback) => {
const { field } = form.getFieldsValue()
let toFields = Array.from(new Set([...field.map(v => v.toField)]))
if (toFields.length !== field.length) {
return Promise.reject('目标字段不能重复!')
}
return Promise.resolve()
}
}
]}
>
<TreeSelect
showSearch
style={{ width: '180px' }}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
placeholder="请选择字段名 "
allowClear
treeDefaultExpandAll
showCheckedStrategy
>
<TreeNode value={accountName} title={accountName} disabled>
{toField.map(s => <TreeNode value={s} title={s} key={s} />)}
</TreeNode>
</TreeSelect>
</Form.Item>
<MinusCircleOutlined onClick={() => remove(name)} />
</Space>
))}
<Form.Item style={{ padding: '0 10px' }}>
<Button type="dashed" onClick={() => add()} block icon={<PlusOutlined />}>
添加映射
</Button>
</Form.Item>
</>
)}
</Form.List>
</Form>
</Modal>
</div>
)
}
export default MappedField
\ No newline at end of file
@imgSrc: '../../../../../assets/images/settting';
.mappedField {
.centerImg {
width: 24px;
height: 24px;
background: url('@{imgSrc}/值映射.png');
background-size: 100% 100%;
position: relative;
top: 7px;
}
}
\ No newline at end of file
......@@ -2,12 +2,16 @@ import Dictionary from './Dictionary'
import TableAndField from './TableAndField'
import AccountName from './AccountName'
import Fieldshine from './Fieldshine'
import MappedField from './MappedField'
import ControlShow from './ControlShow'
const groupSource = {
Dictionary,
TableAndField,
AccountName,
Fieldshine,
MappedField,
ControlShow,
}
export default groupSource
\ No newline at end of file
......@@ -3,23 +3,27 @@ import { InputNumber } from 'antd'
const NumberInput = (props) => {
const { value, onChange, schema } = props
const { value, onChange, schema, addons } = props
const { disabled, presetValue, placeholder, prefix, formatter } = schema
useEffect(() => {
onChange(presetValue)
}, [presetValue, formatter])
const inputChange = (value) => {
if (addons) {
onChange(value)
}
}
return (
<InputNumber
defaultValue={null}
prefix={prefix}
placeholder={placeholder}
disabled={disabled}
value={value}
formatter={(value) => value && formatter ? `${value}${formatter}` : value}
parser={(value) => value && formatter && value.replace(formatter, '')}
onChange={value => onChange(value)}
onChange={inputChange}
style={{ width: '100%' }}
/>
)
......
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