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

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

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