Commit bf3c4533 authored by 皮倩雯's avatar 皮倩雯

fix: '修改新增节点辅助视图交互'

parent 722a0c30
Pipeline #65596 passed with stages
import React, { useEffect } from 'react'; import React, { useEffect, useState } from 'react';
import { Modal, Form, Button, Input, Space } from 'antd'; import { Modal, Form, Button, Input, Space, Select, Switch, Radio } from 'antd';
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
import { LoadLedgers } from '@/services/tablemanager/tablemanager';
const ParmarModal = props => { const ParmarModal = props => {
const { pageUrl, visible, handleCancel, parmarCallBack } = props; const { pageUrl, visible, handleCancel, parmarCallBack } = props;
const [form] = Form.useForm(); const [form] = Form.useForm();
const [keepStandingBook, setKeepStandingBook] = useState([]);
const [visibleChecked, setVisibleChecked] = useState(true);
const [shineFieldsData, setShineFieldsData] = useState(['事件编号', '工单编号', 'GIS编号']);
const { Option } = Select;
useEffect(() => { useEffect(() => {
if (visible) { if (visible) {
LoadLedgers().then(res => {
if (res.code === 0) {
let data = [];
res.data.root.map(i => {
data.push(i.name);
});
setKeepStandingBook(res.data.root);
}
});
// 给url通过字符串分割成表单需要的数据形式 // 给url通过字符串分割成表单需要的数据形式
console.log(pageUrl); console.log(pageUrl);
if (pageUrl) { if (pageUrl) {
if (pageUrl.indexOf('[') !== -1) { if (pageUrl.indexOf('[') !== -1) {
form.setFieldsValue({ parmars: JSON.parse(pageUrl) }); let data = JSON.parse(pageUrl);
console.log(data.shineFields);
console.log(data.shineFields.formField);
form.setFieldsValue({
accountName: data.accountName,
editable: data.editable,
shineFields: data.shineFields[0].formField,
});
} }
} }
} else { } else {
...@@ -23,21 +45,28 @@ const ParmarModal = props => { ...@@ -23,21 +45,28 @@ const ParmarModal = props => {
const onFinish = () => { const onFinish = () => {
form.validateFields().then(validate => { form.validateFields().then(validate => {
if (validate) { if (validate) {
let parma = form.getFieldsValue().parmars; let obj = form.getFieldsValue();
console.log(parma, 'parma'); // let parma = obj.parmars;
if (parma) { let data = {};
parmarCallBack(JSON.stringify(parma)); data.accountName = obj.accountName;
} else { data.editable = visibleChecked;
parmarCallBack(); data.shineFields = [{ formField: obj.shineFields, toField: obj.shineFields }];
} // data.shineFields = parma;
parmarCallBack(JSON.stringify(data));
} }
}); });
}; };
const change = e => {
setVisibleChecked(e);
};
return ( return (
<div> <div>
<Modal <Modal
title="参数配置" title="参数配置"
visible={visible} visible={visible}
width="500px"
onOk={onFinish} onOk={onFinish}
onCancel={handleCancel} onCancel={handleCancel}
maskClosable={false} maskClosable={false}
...@@ -45,8 +74,39 @@ const ParmarModal = props => { ...@@ -45,8 +74,39 @@ const ParmarModal = props => {
centered centered
> >
<div style={{ maxHeight: '400px', overflowY: 'scroll', marginBottom: '10px' }}> <div style={{ maxHeight: '400px', overflowY: 'scroll', marginBottom: '10px' }}>
<Form name="form" form={form} labelCol={{ span: 7 }}> <Form name="form" form={form} labelCol={{ span: 4 }}>
<Form.List name="parmars"> <Form.Item
label="台账名"
name="accountName"
rules={[{ required: true, message: '请选择台账名' }]}
>
<Select placeholder="请选择台账名" showSearch>
{keepStandingBook
? keepStandingBook.map((item, index) => (
<Option key={index} value={item.name}>
{item.name}
</Option>
))
: ''}
</Select>
</Form.Item>
<Form.Item label="可编辑" name="editable">
<Switch
checkedChildren="是"
unCheckedChildren="否"
checked={visibleChecked}
onChange={change}
/>
</Form.Item>
<Form.Item label="映射字段" name="shineFields">
<Select placeholder="请选择映射字段" showSearch>
{shineFieldsData.map((item, index) => (
<Option key={index} value={item}>
{item}
</Option>
))}
</Select>
{/* <Form.List name="parmars">
{(fields, { add, remove }) => ( {(fields, { add, remove }) => (
<> <>
{fields.map(({ key, name, fieldKey, ...restField }) => ( {fields.map(({ key, name, fieldKey, ...restField }) => (
...@@ -58,17 +118,17 @@ const ParmarModal = props => { ...@@ -58,17 +118,17 @@ const ParmarModal = props => {
<Form.Item <Form.Item
{...restField} {...restField}
style={{ marginBottom: '5px' }} style={{ marginBottom: '5px' }}
name={[name, 'webParamKey']} name={[name, 'formField']}
fieldKey={[fieldKey, 'key']} fieldKey={[fieldKey, 'key']}
validateTrigger={['onChange', 'onBlur']} validateTrigger={['onChange', 'onBlur']}
rules={[ rules={[
{ required: true, message: '请填写参数名' }, { required: true, message: '请选择字段名' },
{ {
validator: () => { validator: () => {
// 验证参数名不能重复 // 验证参数名不能重复
const allKey = form const allKey = form
.getFieldsValue() .getFieldsValue()
.parmars.map(item => (item ? item.webParamKey : '')); .parmars.map(item => (item ? item.formField : ''));
const repeatKey = new Set(allKey); const repeatKey = new Set(allKey);
if (repeatKey.size !== allKey.length) { if (repeatKey.size !== allKey.length) {
return Promise.reject(new Error('参数名重复')); return Promise.reject(new Error('参数名重复'));
...@@ -78,26 +138,28 @@ const ParmarModal = props => { ...@@ -78,26 +138,28 @@ const ParmarModal = props => {
}, },
]} ]}
> >
<Input placeholder="请填写参数名" /> <Input placeholder="请选择字段名" />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
{...restField} {...restField}
style={{ marginBottom: '5px' }} style={{ marginBottom: '5px' }}
name={[name, 'webParamValue']} name={[name, 'toField']}
fieldKey={[fieldKey, 'value']} fieldKey={[fieldKey, 'value']}
rules={[{ required: true, message: '请填写参数' }]} rules={[{ required: true, message: '请选择映射字段名' }]}
> >
<Input placeholder="请填写参数" /> <Input placeholder="请选择映射字段名" />
</Form.Item> </Form.Item>
<MinusCircleOutlined <MinusCircleOutlined
onClick={() => remove(name)} onClick={() => remove(name)}
style={{ marginLeft: '10px', fontSize: '20px' }} style={{ marginLeft: '10px', fontSize: '20px' }}
/> />
</Space> </Space>
))} ))}
<Form.Item> <Form.Item>
<Button <Button
style={{ width: '375px', marginLeft: '30px' }} style={{ width: '372px' }}
type="dashed" type="dashed"
onClick={() => add()} onClick={() => add()}
block block
...@@ -108,7 +170,8 @@ const ParmarModal = props => { ...@@ -108,7 +170,8 @@ const ParmarModal = props => {
</Form.Item> </Form.Item>
</> </>
)} )}
</Form.List> </Form.List> */}
</Form.Item>
</Form> </Form>
</div> </div>
</Modal> </Modal>
......
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