Commit 6e98aa64 authored by 田翔's avatar 田翔

fix: 编码形态优化

parent 787da4bc
{
"name": "panda-xform",
"version": "4.8.9",
"description": "4.8.9 手写签名标签长度优化",
"version": "4.9.0",
"description": "4.9.0 编码形态优化",
"keywords": [
"panda-xform"
],
......
......@@ -375,6 +375,31 @@ export function LoadTableFields(paramas) {
})
}
//获取地图方案
export function getMaplayerByTerminalType() {
return request({
url: `PandaGIS/MapServer/Maplayer/GetMaplayerByTerminalType?terminalType=scheme&isBaseMap=false&v=1691659617`,
method: 'get'
})
}
//通过方案获取获图层
export function GetLayerList(serviceName) {
return request({
url: `PandaGIS/MapServer/MetaData/D_GetLayerList?serviceName=${serviceName}`,
method: 'get'
})
}
//通过图层获取字段
export function GetLayerFields({ mapServer, layerName }) {
return request({
url: `PandaGIS/MapServer/MetaData/GetLayerFields?mapServer=${mapServer}&layerName=${layerName}`,
method: 'get'
})
}
//获取表字段(无附加表)
export function ReloadTableFields(paramas) {
return request({
......
......@@ -2287,13 +2287,13 @@ const mapWidgets = [
default: false,
description: '只读情况下会显示缩略图'
},
// fieldshine: {
// title: '映射字段',
// name: '映射字段',
// type: 'array',
// widget: 'DeviceFieldshine',
// default: [],
// },
fieldshine: {
title: '映射字段',
name: '映射字段',
type: 'array',
widget: 'DeviceFieldshine',
default: [],
},
required: {
title: '必填',
type: 'boolean',
......
import React, { useEffect, useState } from 'react'
import { Form, Space, TreeSelect, Button, Input, Modal, message } from 'antd'
import { Form, Space, TreeSelect, Button, Input, Modal, message, Select } from 'antd'
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'
import styles from './index.less'
import { ReloadTableFields, QueryFields } from '../../../../../apis/process'
import { ReloadTableFields, QueryFields, getMaplayerByTerminalType, GetLayerList, GetLayerFields } from '../../../../../apis/process'
import Drag from '../../../../components/Drag'
const { TreeNode } = TreeSelect
......@@ -10,10 +10,14 @@ const { TreeNode } = TreeSelect
const DeviceFieldshine = (props) => {
const { addons, onChange, value } = props
const { $id, accountName, tableNameParent } = addons.formData
const formData = addons.formData
const [form] = Form.useForm()
const [visible, setVisible] = useState(false)
const [mapServers, setMapServers] = useState([])
const [service, setService] = useState(formData?.service)
const [layers, setLayers] = useState([])
const [layerName, setlayerName] = useState(formData?.layerName)
const [fromField, setFromField] = useState([])
const [toField, setToField] = useState([])
......@@ -21,10 +25,9 @@ const DeviceFieldshine = (props) => {
form
.validateFields()
.then((values) => {
const { field } = form.getFieldsValue()
if (field.length !== 1) {
addons.setValue('isMultiple', false)
}
const { field, service, layerName } = form.getFieldsValue()
addons.setValue('service', service)
addons.setValue('layerName', layerName)
onChange(field)
setVisible(false)
})
......@@ -34,15 +37,43 @@ const DeviceFieldshine = (props) => {
}
const inputClick = async () => {
const { code, data } = await ReloadTableFields({ tableName: tableNameParent })
const { code, data } = await ReloadTableFields({ tableName: formData?.tableNameParent })
if (code === 0) {
setToField(data.root)
}
let field = value.length ? value : [{ fromField: 'GIS编码', toField: 'GIS编码' }, { fromField: 'GIS图层', toField: 'GIS图层' }]
form.setFieldsValue({ field })
let field = value.length ? value : []
form.setFieldsValue({ field, service: formData?.service, layerName: formData?.layerName })
setVisible(true)
}
const serviceFocus = async () => {
const { code, data } = await getMaplayerByTerminalType()
if (code === '0') {
setMapServers(data)
}
}
const layerNameFocus = async () => {
let { success, root } = await GetLayerList(service)
if (success === true) {
let array = []
root.forEach(v => {
let values = v.layerName.split(':')
if (values.length === 2) {
array.push({ layerID: v.layerID, layerName: values[1] })
}
})
setLayers(array)
}
}
const fromFieldFocus = async (value) => {
const { code, data } = await GetLayerFields({ mapServer: service, layerName: layerName })
if (code === '0') {
setFromField(data)
}
}
return (
<div className={styles.fieldshine}>
<Input
......@@ -58,19 +89,57 @@ const DeviceFieldshine = (props) => {
onOk={onOk}
>
<Form name="dynamic_form_nest_item" form={form} autoComplete="off">
<Form.List name="field">
<Form.Item
label='方案名称'
name='service'
rules={[
{
required: true,
message: '方案名称必填',
},
]}
>
<Select
onFocus={serviceFocus}
onChange={(value) => setService(value)}
>
{
mapServers.map(v => <Select.Option value={v.servicename}>{v.schemename}</Select.Option>)
}
</Select>
</Form.Item>
<Form.Item
label='图层名称'
name='layerName'
rules={[
{
required: true,
message: '图层名称必填',
},
]}
>
<Select
onFocus={layerNameFocus}
onChange={(value) => setlayerName(value)}
>
{
layers.map(v => <Select.Option value={v.layerName}>{v.layerName}</Select.Option>)
}
</Select>
</Form.Item>
<Form.List name="field" label='字段映射'>
{(value, { add, remove }) => (
<>
{value.map(({ key, name, ...restField }, index) => (
<Space
key={key}
// style={{
// display: 'flex',
// marginBottom: '5px ',
// justifyContent: 'center',
// position: 'relative',
// left: index === 0 ? '-11px' : '',
// }}
style={{
display: 'flex',
marginBottom: '5px',
justifyContent: 'center',
position: 'relative',
left: index === 0 ? '-11px' : '',
}}
align="baseline"
>
<Form.Item
......@@ -91,10 +160,9 @@ const DeviceFieldshine = (props) => {
allowClear
treeDefaultExpandAll
showCheckedStrategy
onFocus={fromFieldFocus}
>
<TreeNode value={accountName} title={accountName} disabled>
{fromField.map(s => <TreeNode value={s} title={s} key={s} />)}
</TreeNode>
{fromField.map(s => <TreeNode value={s.field} title={s.fieldAlias} key={s.field} />)}
</TreeSelect>
</Form.Item>
<div className={styles.centerImg}></div>
......@@ -127,19 +195,19 @@ const DeviceFieldshine = (props) => {
treeDefaultExpandAll
showCheckedStrategy
>
<TreeNode value={tableNameParent} title={tableNameParent} disabled>
<TreeNode value={formData?.tableNameParent} title={formData?.tableNameParent} disabled>
{toField.map(s => <TreeNode value={s.name} title={s.name} key={s.name} />)}
</TreeNode>
</TreeSelect>
</Form.Item>
{/* {index !== 0 ? <MinusCircleOutlined onClick={() => remove(name)} /> : null} */}
{index !== 0 ? <MinusCircleOutlined onClick={() => remove(name)} /> : null}
</Space>
))}
{/* <Form.Item style={{ padding: '0 10px' }}>
<Form.Item style={{ padding: '0 10px' }}>
<Button type="dashed" onClick={() => add()} block icon={<PlusOutlined />}>
添加映射
</Button>
</Form.Item> */}
</Form.Item>
</>
)}
</Form.List>
......
......@@ -17,9 +17,9 @@ const Coding = (props) => {
useEffect(() => {
if (addons) {
addons.setValue(addons.dataPath, presetValue)
addons.setValue(addons.dataPath, presetValue || '')
} else {
onChange(presetValue)
onChange(presetValue || '')
}
}, [])
......
......@@ -64,9 +64,9 @@ const TextInput = (props) => {
}
}
if (addons) {
addons.setValue(addons.dataPath, value)
addons.setValue(addons.dataPath, value || '')
} else {
onChange(value)
onChange(value || '')
}
}, [presetValue])
......
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