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

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

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