Commit 4489aaf3 authored by 田翔's avatar 田翔

fix: 增加唯一值校验,增加位置坐标,增加业务选择

parent a007dc7c
{
"name": "panda-xform",
"version": "1.5.0",
"description": "1.5.0: 选择器支持搜索,可编辑功能,日期,时间选择器支持配置",
"version": "1.5.1",
"description": "1.5.1: 增加唯一值校验,增加位置坐标,增加业务选择",
"keywords": [
"panda-xform"
],
......@@ -38,6 +38,7 @@
"qrcode.react": "^1.0.1",
"react": "17.0.2",
"react-file-viewer": "^1.2.1",
"react-sign2": "^0.0.3",
"react-svg": "15.1.9",
"yarn": "^1.22.17"
},
......@@ -125,4 +126,4 @@
"publishConfig": {
"registry": "https://g.civnet.cn:4873"
}
}
\ No newline at end of file
}
......@@ -210,6 +210,14 @@ export function LoadLedgers() {
})
}
//通过台账名称获取字段
export function QueryFields(accountName) {
return request({
url: `PandaOMS/OMS/WorkOrderCenter/GetCMLedger_QueryFields${accountName ? `?accountName=${accountName}` : ''}`,
method: 'get'
})
}
//获取表字段
export function LoadTableFields(paramas) {
return request({
......
......@@ -108,7 +108,7 @@ const globalSettings = {
title: '表名',
type: 'string',
widget: 'TableNames',
default: '事件_测试02',
// default: '事件_测试02',
required: true,
displayType: 'row',
labelWidth: 70,
......
......@@ -147,9 +147,9 @@ const textWidgets = [
placeholder: {
title: '提示语',
type: 'string',
// widget: 'Placeholder',
displayType: 'row',
labelWidth: 80,
default: '请输入内容'
},
presetValue: {
title: '默认值',
......@@ -166,10 +166,21 @@ const textWidgets = [
required: {
title: '必填',
type: 'boolean',
widget: 'BooleanSwitch',
default: false,
displayType: 'row',
labelWidth: 100,
width: '33%',
props: {
style: {
marginLeft: '10px',
}
}
},
isStoreID: {
title: '是否存储ID',
type: 'boolean',
default: false,
width: '66%',
hidden: "{{!['【本人姓名】','【本人部门】'].includes(rootValue.presetValue) }}",
dependencies: ['presetValue'],
},
maxLength: {
title: '字节最大长度',
......@@ -204,7 +215,6 @@ const textWidgets = [
title: '表名',
type: 'string',
hidden: "{{formData.uniqueVerify !== '表名/字段名'}}",
// required: "{{formData.uniqueVerify === '表名/字段名'}}",
displayType: 'row',
labelWidth: 100,
dependencies: ['uniqueVerify'],
......@@ -652,9 +662,6 @@ const selectWidgets = [
required: true,
displayType: 'row',
labelWidth: 80,
// props: {
// disabled: true
// }
},
title: {
title: '标题',
......@@ -824,7 +831,7 @@ const selectWidgets = [
widget: 'BooleanSwitch',
displayType: 'row',
labelWidth: 120,
description: '勾选后可直接输入选项'
description: '勾选后可直接输入选项,可编辑选择仅支持多选'
},
groupStyle: {
title: '控件样式',
......@@ -1636,27 +1643,7 @@ const selectWidgets = [
placeholder: '示例:部门="XX部门"'
}
},
groupStyle: {
title: '控件样式',
type: 'object',
properties: {}
},
width: {
title: '元素宽度',
type: 'string',
widget: 'percentSlider',
},
labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
},
...groupStyle,
}
}
]
......@@ -2265,7 +2252,7 @@ const mapWidgets = [
schema: {
title: '位置坐标',
type: 'string',
// widget: 'SearchLocation',
widget: 'SearchLocation',
},
setting: {
groupBase: {
......@@ -2295,7 +2282,7 @@ const mapWidgets = [
type: 'string',
displayType: 'row',
labelWidth: 80,
default: '请选择设备'
default: '请输入位置'
},
groupSetting: {
title: '控件设置',
......@@ -2360,6 +2347,11 @@ const advancedWidgets = [
width: '100%',
},
setting: {
groupBase: {
title: '基础信息',
type: 'object',
properties: {}
},
$id: {
title: '字段名称',
type: 'string',
......@@ -2375,41 +2367,67 @@ const advancedWidgets = [
displayType: 'row',
labelWidth: 80,
},
source: {
title: '数据来源',
type: 'string',
displayType: 'row',
default: '{}',
widget: 'DataSource',
labelWidth: 80,
groupSetting: {
title: '控件设置',
type: 'object',
properties: {}
},
disabled: {
title: '只读',
type: 'boolean',
widget: 'BooleanSwitch',
displayType: 'row',
labelWidth: 80,
default: false
widget: 'checkbox',
default: false,
width: '33%',
props: {
style: {
marginLeft: '10px'
}
}
},
width: {
title: '元素宽度',
type: 'string',
widget: 'percentSlider',
// default: '100%',
hidden: {
title: '隐藏',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
},
labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
emphasis: {
title: '强调',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
},
gorupSoruce: {
title: '数据来源',
type: 'object',
properties: {}
},
accountName: {
title: '台账名称',
type: 'string',
widget: 'AccountName',
displayType: 'row',
labelWidth: 80,
required: true
},
...groupStyle,
},
},
{
text: '个性签名',
name: '个性签名',
schema: {
title: '个性签名',
name: '个性签名',
type: 'string',
widget: 'Signature',
width: '100%',
},
setting: {
},
}
]
const settings = [
......
......@@ -76,34 +76,37 @@ const FormDesigner = (props) => {
}
return (
<div className={prefixCls} style={{ height: '750px' }}>
<Generator
configProvider={{ prefixCls: prefixCls }}
mapping={{
object: 'Header',
}}
validation={true}
ref={ref}
extraButtons={extraButtons}
onChange={onChange}
widgets={widgets}
onCanvasSelect={onCanvasSelect}
settings={settings}
commonSettings={baseSettings}
globalSettings={globalSettings}
/>
<Modal
title={tableName}
width='80%'
bodyStyle={{ height: '700px', overflow: 'auto' }}
onOk={() => setVisible(false)}
onCancel={() => setVisible(false)}
visible={visible}
>
<FormRender schema={schema} />
</Modal>
<div className={prefixCls} style={{ width: '100%', height: '100%', background: 'white' }}>
<div style={{ height: '750px' }}>
<Generator
configProvider={{ prefixCls: prefixCls }}
mapping={{
object: 'Header',
}}
validation={true}
ref={ref}
extraButtons={extraButtons}
onChange={onChange}
widgets={widgets}
onCanvasSelect={onCanvasSelect}
settings={settings}
commonSettings={baseSettings}
globalSettings={globalSettings}
/>
<Modal
title={tableName}
width='80%'
bodyStyle={{ height: '700px', overflow: 'auto' }}
onOk={() => setVisible(false)}
onCancel={() => setVisible(false)}
visible={visible}
// getContainer={false}
destroyOnClose
>
<FormRender schema={schema} />
</Modal>
</div>
</div>
)
}
......
......@@ -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 { GlobalStore } from '../../../FormRender'
// import FormDesigner from '../../../FormDesigner'
const icons = {
'详情': <SnippetsOutlined />,
......@@ -20,18 +20,15 @@ const icons = {
}
let formStateStr = '添加'
const RelationForm = ({ value, onChange, schema }) => {
const RelationForm = (props) => {
const fieldNames = ['事件编号', '工单编号']
const { disabled, source } = schema
const configInfo = source ? { ...JSON.parse(source) } : {}
// const { listData, setListData, parent } = useContext(GlobalStore)
// console.log(parseFormData, setParseFormData)
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 [config, setConfig] = useState({ webShowFieldGroup: '', fieldGroup: '' })
......@@ -45,7 +42,7 @@ const RelationForm = ({ value, onChange, schema }) => {
// const getMsg = () => {
// let fields = configInfo['映射字段'].map(v => v.toField)
// return `台账【${configInfo['台账名称']}】缺少${fields.join('、')}字段`
// return `台账【${accountName}】缺少${fields.join('、')}字段`
// }
// const show = useMemo(() => {
......@@ -205,18 +202,20 @@ const RelationForm = ({ value, onChange, schema }) => {
}, [formState])
const rowClick = async (v, r) => {
setRow(r)
if (v === '详情') {
setFormData(getItem(r))
setVisible(true)
} else if (v === '编辑') {
setFormData(getItem(r))
setVisible(true)
} else if (v === '删除') {
deleteTableInfo(r)
if (addons) {
setRow(r)
if (v === '详情') {
setFormData(getItem(r))
setVisible(true)
} else if (v === '编辑') {
setFormData(getItem(r))
setVisible(true)
} else if (v === '删除') {
deleteTableInfo(r)
}
formStateStr = v
setFormState(v)
}
formStateStr = v
setFormState(v)
}
const getItem = (data, max) => {
......@@ -240,7 +239,7 @@ const RelationForm = ({ value, onChange, schema }) => {
}
const deleteTableInfo = (r) => {
let listItem = { type: 'delete', accountTable: configInfo['台账名称'], id: r.ID, values: getItem('delete', r) }
let listItem = { type: 'delete', accountTable: accountName, id: r.ID, values: getItem('delete', r) }
if (r.ID.includes('前端ID')) {
let list = listData.filter(v => v.id !== r.ID)
setListData(list)
......@@ -253,7 +252,7 @@ const RelationForm = ({ value, onChange, schema }) => {
}
const getTableInfo = async (r) => {
const { code, data } = await GetTableDataInfo({ accountName: configInfo['台账名称'], id: Number(r.ID) })
const { code, data } = await GetTableDataInfo({ accountName: accountName, id: Number(r.ID) })
if (code === 0) {
setFormData(data)
setVisible(true)
......@@ -263,7 +262,7 @@ const RelationForm = ({ value, onChange, schema }) => {
}
const getConfig = async () => {
let { code, data, msg } = await GetAccountConfigInfo(configInfo['台账名称'])
let { code, data, msg } = await GetAccountConfigInfo(accountName)
if (code === 0) {
setConfig(data)
getTableData(data.addFieldGroup ? data.addFieldGroup.split(',') : [])
......@@ -273,7 +272,7 @@ const RelationForm = ({ value, onChange, schema }) => {
}
const getGroupMeta = async () => {
const { code, data, msg } = await GetTableGroupMeta(configInfo['台账名称'])
const { code, data, msg } = await GetTableGroupMeta(accountName)
if (code === 0) {
setGroupMeta(data)
} else {
......@@ -299,7 +298,7 @@ const RelationForm = ({ value, onChange, schema }) => {
// onChange(`出错了,${getMsg()}`)
// }
let params = {
accountName: configInfo['台账名称'],
accountName: accountName,
direction: 'desc',
timeField: '录入时间',
pageIndex: 0,
......@@ -330,7 +329,7 @@ const RelationForm = ({ value, onChange, schema }) => {
const onOk = async () => {
let formData = parseFormRef.current.getFormValues()
let type = row.ID.includes('前端ID') ? 'add' : 'edit'
let itemData = { type, accountTable: configInfo['台账名称'], id: row.ID, values: formData }
let itemData = { type, accountTable: accountName, id: row.ID, values: formData }
if (formStateStr !== '添加') {
let array = []
dataSource.forEach(v => {
......@@ -357,19 +356,19 @@ const RelationForm = ({ value, onChange, schema }) => {
// if (!localForm.length) {
// return message.error(getMsg())
// }
setRow({ ID: `前端ID${new Date().getTime()}` })
setFormState('添加')
formStateStr = '添加'
setVisible(true)
if (addons) {
setRow({ ID: `前端ID${new Date().getTime()}` })
setFormState('添加')
formStateStr = '添加'
setVisible(true)
}
}
useEffect(() => {
console.log('configInfo', configInfo)
if (configInfo['台账名称']) {
if (accountName) {
getData()
}
}, [configInfo['台账名称']])
}, [accountName])
return (
<div className={styles.relationForm}>
......@@ -385,7 +384,7 @@ const RelationForm = ({ value, onChange, schema }) => {
pagination={{ total: dataSource.length, showTotal: (value) => `总计 ${value} 条` }}
/>
<Modal
title={schema.name}
title={accountName}
width='90%'
visible={visible}
onOk={onOk}
......@@ -393,6 +392,9 @@ const RelationForm = ({ value, onChange, schema }) => {
bodyStyle={{ height: 700 }}
destroyOnClose
>
{/* <FormDesigner
tablesSchema={tablesSchema}
/> */}
{/* <JsonToHtml
isReadOnly={isReadOnly}
tablesSchema={tablesSchema}
......
import React from 'react'
import Sign from 'react-sign2'
const Signature = (props) => {
const { value } = props
return (
<div>
<Sign />
</div>
)
}
export default Signature
\ No newline at end of file
import RelationForm from './RelationForm'
import Signature from './Signature'
const advanced = {
RelationForm
RelationForm,
Signature,
}
export default advanced
\ No newline at end of file
......@@ -8,7 +8,6 @@ import {
GraphicsLayer,
Graphic
} from '@wisdom-map/arcgismap'
// import { GlobalStore } from "../../../../index";
import point from './img/point.png'
let geometrystr = ''
......@@ -195,7 +194,6 @@ const Device = ({ addons, value, onChange, schema }) => {
const { placeholder, disabled } = schema
const [visible, setVisible] = useState(false)
// const { paths } = useContext(GlobalStore)
const layersConifg = { layers: mapConfig }
let clickref = useRef(null)
let view = useRef(null)
......@@ -255,7 +253,7 @@ const Device = ({ addons, value, onChange, schema }) => {
}
const iconClick = () => {
if (!schema.disabled) {
if (addons) {
setVisible(true)
}
}
......@@ -298,7 +296,7 @@ const Device = ({ addons, value, onChange, schema }) => {
cancelText={'取消'}
okText={'确定'}
bodyStyle={{ height: 600, overflowY: 'auto', position: 'relative' }}
destroyOnClose={true}
getContainer={true}
>
<ArcGISSceneMap
getMapInfo={getMapInfo}
......
......@@ -9,6 +9,7 @@ let AMapFunction = null; // 存储地图的构造函数
let coverLayer = {}; // 存储分区的地图对象
const DrawPartition = ({ value, onChange, name, schema }) => {
console.log('DrawPartition')
const mapSettings = window.globalConfig.mapsettings;
const [loading, setLoading] = useState(false);
const [visible, setVisible] = useState(false);
......
import React, { useState, useEffect, useContext } from 'react'
import { Input, message } from 'antd';
// import { GlobalStore } from '../../../FormDesigner'
import { Input, message } from 'antd'
import { AMap } from '@wisdom-map/amap'
const SearchLocation = ({ value, onChange, name, schema }) => {
const SearchLocation = (props) => {
const { value, onChange, name, schema, addons } = props
const { disabled, placeholder } = schema
const [extraData, setExtraData] = useState(null);
const [address, setAddress] = useState('');
const [pos, setPos] = useState('');
const renderSearch = async () => {
// 封装之后的AMap,如果需要使用高德地图上的方法,则需要按照如下方法去使用
AMap.prototype.key = 'e83f64300a2a55a33fa8e4ab9a46bca6';
let map = await AMap.prototype.loadLocaScript();
map.plugin(['AMap.PlaceSearch', 'AMap.AutoComplete'], function (e) {
map?.plugin(['AMap.PlaceSearch', 'AMap.AutoComplete'], function (e) {
let auto = new map.AutoComplete({
input: 'searchInput'
});
......@@ -33,26 +35,32 @@ const SearchLocation = ({ value, onChange, name, schema }) => {
}
});
})
};
}
const inputChange = (e) => {
if (addons) {
setAddress(e.target.value)
onChange(e.target.value)
}
}
useEffect(() => {
renderSearch();
if (value) setAddress(value);
}, [])
if (addons) {
renderSearch()
}
// if (value) setAddress(value)
}, [value])
return (
<>
<Input
placeholder={placeholder}
disabled={disabled}
onChange={(e) => {
setAddress(e.target.value)
onChange(e.target.value)
}}
id={'searchInput'}
value={value}
style={{ width: '100%' }}
/>
</>
<Input
placeholder={placeholder}
disabled={disabled}
onChange={inputChange}
id={addons ? 'searchInput' : null}
value={value}
style={{ width: '100%' }}
/>
)
}
export default SearchLocation;
export default SearchLocation
......@@ -44,17 +44,19 @@ const AccountSelector = (props) => {
}
const iconClick = () => {
if (!accountName) {
return message.info('请配置台账名称!')
}
if (!fieldshine.length) {
return message.info('请配置映射字段!')
}
setVisible(true)
if (!pageConfig.webShowFieldGroup) {
getPageConfig()
if (addons) {
if (!accountName) {
return message.info('请配置台账名称!')
}
if (!fieldshine.length) {
return message.info('请配置映射字段!')
}
setVisible(true)
if (!pageConfig.webShowFieldGroup) {
getPageConfig()
}
getPageList()
}
getPageList()
}
const getPageConfig = async () => {
......@@ -97,8 +99,6 @@ const AccountSelector = (props) => {
setKeys(rows.map(v => v.ID))
setParams({ ...params, ...outParams, total: data.totalCount })
}
} else {
onChange(`出错了!${msg}`)
}
setLoading(false)
}
......@@ -118,7 +118,6 @@ const AccountSelector = (props) => {
Object.keys(addons.formData[child]).forEach(sun => {
fieldshine.forEach(v => {
if (sun === v.toField) {
console.log()
const schema = form.getSchemaByPath(`${child}.${sun}`)
if (schema.widget === 'fileUpload') {
form.setSchemaByPath(`${child}.${sun}`, { ...schema, otherFile: row[v.fromField] })
......
......@@ -4,6 +4,8 @@ import { LoadUnattachedTables } from '../../../../../apis/process'
const TableNames = (props) => {
console.log('props11', props)
const { value, schema, onChange } = props
const [options, setOptions] = useState([])
......
......@@ -30,7 +30,6 @@ const InputDefault = (props) => {
const content = (
<Select
allowClear
placeholder='请选择环境变量'
style={{ width: '100%' }}
options={options}
......@@ -42,6 +41,7 @@ const InputDefault = (props) => {
return (
<div className='InputDefault'>
<Input
allowClear
value={value}
onChange={inputChange}
style={style}
......
......@@ -2,7 +2,7 @@ import React, { useEffect, 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 } from '../../../../../apis/process'
import { ReloadTableFields, QueryFields } from '../../../../../apis/process'
const { TreeNode } = TreeSelect
......@@ -28,12 +28,14 @@ const Fieldshine = (props) => {
if (!accountName) {
return message.info('请选择台账名称')
}
const req1 = ReloadTableFields({ tableName: '设备_台账_户表' })
const req1 = QueryFields(accountName)
console.log(addons, addons.getValue('root'))
const req2 = ReloadTableFields({ tableName: '事件_测试02' })
// const req3 = QueryFields(accountName)
const [res1, res2] = await Promise.all([req1, req2])
if (res1.code === 0) {
if (Array.isArray(res1.data.root)) {
setFromField(res1.data.root)
if (Array.isArray(res1.data)) {
setFromField(res1.data)
}
} else {
message.error(res1.msg)
......@@ -99,8 +101,8 @@ const Fieldshine = (props) => {
treeDefaultExpandAll
showCheckedStrategy
>
<TreeNode value='设备_台账_户表' title='设备_台账_户表' disabled>
{fromField.map(s => <TreeNode value={s.alias} title={s.name} key={s.name} />)}
<TreeNode value={accountName} title={accountName} disabled>
{fromField.map(s => <TreeNode value={s} title={s} key={s} />)}
</TreeNode>
</TreeSelect>
</Form.Item>
......
......@@ -6,42 +6,26 @@ import { GetFieldValueFromTable } from '../../../../apis/process'
const iconList = Object.keys(icons).filter((item) => typeof icons[item] === 'object')
const debounce = (fn) => {
let t = null
return function (e) {
const context = this
const args = arguments
if (t) {
clearTimeout(t)
}
t = setTimeout(function () {
fn.call(context, args)
}, 200)
}
}
const TextInput = (props) => {
const userInfo = window?.globalConfig?.userInfo || { fullName: '【本人姓名】', depart: { name: '【本人部门】' } }
const { value, onChange, schema, addons } = props
const { disabled, placeholder, presetValue, addonBefore, addonAfter, maxLength, rules, uniqueVerify, tableName, fieldName } = schema
// const [fields, setFields] = useState([])
// const [uniqueRules, setUniqueRules] = useState([])
// const uniqueRules = useMemo(() => {
// if (uniqueVerify === '表名/字段名') {
// if (tableName && fieldName) {
// return [
// {
// validator: async (rule, value, callback) => {
// console.log('validator', value)
// const { code, data, msg } = await GetFieldValueFromTable(tableName, fieldName)
// if (code === 0) {
// if (!disabled && res.data.includes(value)) {
// callback(new Error(`${12}已重复,请重新输入`));
// }
// }
// callback()
// }
// }
// ]
// }
// }
// return []
// }, [uniqueVerify, tableName, fieldName])
// const inputRules = useMemo(() => {
// let array = Array.isArray(rules) ? rules : []
// return array.concat(uniqueRules)
// }, [rules, uniqueRules])
const { title, disabled, placeholder, presetValue, addonBefore, addonAfter, maxLength, rules, uniqueVerify, tableName, fieldName } = schema
useEffect(() => {
if (addons) {
......@@ -67,45 +51,44 @@ const TextInput = (props) => {
const handleChange = (e) => {
if (addons) {
onChange(e.target.value)
// addons.setValue(addons.dataPath, e.target.value)
}
}
// useEffect(async () => {
// if (uniqueVerify === '表名/字段名') {
// if (tableName && fieldName) {
// setUniqueRules([
// {
// validator: async (rule, value, callback) => {
// const { code, data, msg } = await GetFieldValueFromTable(tableName, fieldName)
// if (code === 0) {
// if (!disabled && res.data.includes(value)) {
// callback(new Error(`${dataObj.alias}已重复,请重新输入`));
// }
// }
// callback()
// }
// }
// ])
// // const { code, data, msg } = await GetFieldValueFromTable(tableName, fieldName)
// // if (code === 0) {
// // if (Array.isArray(data)) {
useEffect(() => {
if (addons) {
addons.setValue(addons.dataPath, presetValue)
} else {
onChange(presetValue)
}
}, [presetValue])
// // setFields(data)
// // } else {
// // setFields([])
// // }
// // } else {
// // message.error(msg)
// // }
// }
// }
// }, [uniqueVerify, disabled])
useEffect(() => {
if (uniqueVerify === '表名/字段名' && tableName && fieldName) {
if (addons) {
let getValue = async (params) => {
const [rule, value, callback] = params
const { code, data, msg } = await GetFieldValueFromTable(tableName, fieldName, `${fieldName}=${value}`)
if (code === 0) {
if (Array.isArray(data) && data.length) {
callback(new Error(`${title}已重复,请重新输入`));
}
} else {
callback()
}
}
let uniqueRules = [
{
validator: debounce(getValue)
}
]
addons.setSchemaByPath(addons.dataPath, { ...schema, rules: uniqueRules })
}
}
}, [uniqueVerify, tableName, fieldName])
return (
<Input
style={style}
// rules={inputRules}
disabled={disabled}
value={value}
maxLength={maxLength}
......
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