Commit 2f6f368f authored by 彭俊龙's avatar 彭俊龙

feat:代码提交

parent e51a9e27
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "6.11.14", "version": "6.11.48",
"description": "6.11.14 区域到位组件新增默认范围", "description": "6.11.48 设备选择组件支持有默认值时自动映射属性字段值",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -610,6 +610,15 @@ export function placeAroundRelay(url) { ...@@ -610,6 +610,15 @@ export function placeAroundRelay(url) {
}) })
} }
export function identify(url) {
return request({
url: `/PandaGIS/MapServer/Query/Data/Identify`,
method: 'get',
params: url
})
}
//获取表字段 //获取表字段
export function LoadTableFields(paramas) { export function LoadTableFields(paramas) {
return request({ return request({
...@@ -682,6 +691,20 @@ export function GetAreaLayerTaskData(data) { ...@@ -682,6 +691,20 @@ export function GetAreaLayerTaskData(data) {
}) })
} }
//获取图层区域数据(多图层查询)
export function GetLayerDataAndMedia(data) {
return request({
headers: {
'Content-Type': 'application/json',
accept: 'text/plain',
'Server-Name': data?.mapServerName || localStorage.getItem('PipenetLayer') || '',
},
url: `/PandaGIS/MapServer/GIS/Query/GetLayerDataAndMedia`,
method: 'get',
params: data.params,
})
}
//获取多图层区域数据 //获取多图层区域数据
export function GetManyLayerAreaData(data) { export function GetManyLayerAreaData(data) {
return request({ return request({
......
...@@ -17,13 +17,13 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -17,13 +17,13 @@ const SearchGroup = forwardRef((props, ref) => {
getQueryInfo, getQueryInfo,
})) }))
const { accountName, config, notUse, checkName, btnsClick, keys, fieldSearch } = props const { accountName, config, notUse, checkName, btnsClick, keys, fieldSearch, defaultSearchInfo } = props
const { enableBatchOperation, enableImportExport, exportTemplateName, enablePrint, enableQuickSearch, enableTimeFilter, parent, accountFieids } = config const { enableBatchOperation, enableImportExport, exportTemplateName, enablePrint, enableQuickSearch, enableTimeFilter, parent, accountFieids } = config
const [form] = Form.useForm() const [form] = Form.useForm()
const [searchLabel, setSearchLabel] = useState('快捷搜索') const [searchLabel, setSearchLabel] = useState('快捷搜索')
const [dateArray, setDateArray] = useState([]) const [dateArray, setDateArray] = useState([])
const [formatterStr, setFormatterStr] = useState('YYYY-MM-DD HH:mm:ss') const [formatterStr, setFormatterStr] = useState('YYYY-MM-DD HH:mm:ss')
const [queryInfo, setQueryInfo] = useState({ info: '', timeFrom: '', timeTo: '' }) const [queryInfo, setQueryInfo] = useState({ info: defaultSearchInfo || '', timeFrom: '', timeTo: '' })
const searchShow = useMemo(() => { const searchShow = useMemo(() => {
return accountFieids.some(v => v.likeSearch) return accountFieids.some(v => v.likeSearch)
}, [accountFieids]) }, [accountFieids])
...@@ -354,7 +354,10 @@ const SearchGroup = forwardRef((props, ref) => { ...@@ -354,7 +354,10 @@ const SearchGroup = forwardRef((props, ref) => {
useEffect(() => { useEffect(() => {
setSearchLabel('快捷搜索') setSearchLabel('快捷搜索')
}, [accountName]) if(defaultSearchInfo){
form.setFieldsValue({ info: defaultSearchInfo })
}
}, [accountName, defaultSearchInfo])
return ( return (
<Row className={styles.controlRow}> <Row className={styles.controlRow}>
......
...@@ -63,10 +63,12 @@ const Account = (props, ref) => { ...@@ -63,10 +63,12 @@ const Account = (props, ref) => {
timeLimit, timeLimit,
getDeleted, getDeleted,
accountId, accountId,
defaultSearchInfo,
defaultType, defaultType,
pageSizes, pageSizes,
isExportRelationForm, isExportRelationForm,
isExportImage isExportImage,
showDetailCallBack
} = props; } = props;
const userID = window?.globalConfig?.userInfo?.OID || 1; const userID = window?.globalConfig?.userInfo?.OID || 1;
let initParams = { let initParams = {
...@@ -78,7 +80,7 @@ const Account = (props, ref) => { ...@@ -78,7 +80,7 @@ const Account = (props, ref) => {
pageSize: 100, pageSize: 100,
timeFrom: '', timeFrom: '',
timeTo: '', timeTo: '',
info: '', info: defaultSearchInfo || '',
queryForm: [], queryForm: [],
queryTable: [], queryTable: [],
queryWheres: [], queryWheres: [],
...@@ -414,10 +416,18 @@ const Account = (props, ref) => { ...@@ -414,10 +416,18 @@ const Account = (props, ref) => {
}; };
const tableChange = (page, filters, sorter) => { const tableChange = (page, filters, sorter) => {
console.log(page, filters, sorter, 'tableChange');
let queryWheres = []; let queryWheres = [];
let json = getFieldInfo(config.formJson)
let getType = (value, schema)=>{
if(schema && schema.sourceType === '表数据'){
return value.length > 1 ? '包括' : '等于'
}
return '模糊查询'
}
Object.keys(filters).forEach(k => { Object.keys(filters).forEach(k => {
if (filters[k]?.[0]) { if (filters[k]?.[0]) {
queryWheres.push({ field: k, type: '模糊查询', value: filters[k].join(',') }); queryWheres.push({ field: k, type: getType(filters[k], json[k]), value: filters[k].join(',') });
} }
}); });
let param = { let param = {
...@@ -467,6 +477,10 @@ const Account = (props, ref) => { ...@@ -467,6 +477,10 @@ const Account = (props, ref) => {
} }
}, []); }, []);
useEffect(() => {
showDetailCallBack && showDetailCallBack(detailShow)
},[detailShow])
const items = ( const items = (
<Menu> <Menu>
<Menu.Item onClick={() => toExcel('content', '单据')} icon={<FileExcelOutlined />}> <Menu.Item onClick={() => toExcel('content', '单据')} icon={<FileExcelOutlined />}>
...@@ -641,6 +655,7 @@ const Account = (props, ref) => { ...@@ -641,6 +655,7 @@ const Account = (props, ref) => {
onChange={search} onChange={search}
btnsClick={btnsClick} btnsClick={btnsClick}
keys={keys} keys={keys}
defaultSearchInfo={defaultSearchInfo}
accountName={params.accountName} accountName={params.accountName}
config={config} config={config}
notUse={notUse} notUse={notUse}
......
...@@ -1948,6 +1948,15 @@ const baseWidgets = [ ...@@ -1948,6 +1948,15 @@ const baseWidgets = [
title: '字段说明', title: '字段说明',
type: 'string', type: 'string',
}, },
mobileShowType: {
title: '展示形式',
type: 'string',
description: '移动端展示专用',
widget: 'select',
enum: ['卡片', '列表'],
default: '',
enumNames: ['卡片', '列表'],
},
isHidden: { isHidden: {
title: '是否隐藏', title: '是否隐藏',
type: 'boolean', type: 'boolean',
...@@ -2008,14 +2017,14 @@ const baseWidgets = [ ...@@ -2008,14 +2017,14 @@ const baseWidgets = [
description: '开启后只显示自己所属站点数据', description: '开启后只显示自己所属站点数据',
}, },
autofill: { autofill: {
title: '自动映射值', title: '默认值自动映射',
name: '站点过滤', name: '站点过滤',
type: 'boolean', type: 'boolean',
default: false, default: false,
displayType: 'row', displayType: 'row',
labelWidth: 110, labelWidth: 160,
widget: 'BooleanSwitch', widget: 'BooleanSwitch',
description: '开启后会将台账中的值自动映射在表单中', description: '开启后会将默认值作为台账查询条件将第一行数据映射到表单中',
}, },
isMultiple: { isMultiple: {
title: '多选', title: '多选',
...@@ -3075,14 +3084,14 @@ const businessWidgets = [ ...@@ -3075,14 +3084,14 @@ const businessWidgets = [
description: '开启后只显示自己所属站点数据', description: '开启后只显示自己所属站点数据',
}, },
autofill: { autofill: {
title: '自动映射值', title: '默认值自动映射',
name: '站点过滤', name: '站点过滤',
type: 'boolean', type: 'boolean',
default: false, default: false,
displayType: 'row', displayType: 'row',
labelWidth: 110, labelWidth: 160,
widget: 'BooleanSwitch', widget: 'BooleanSwitch',
description: '开启后会将台账中的值自动映射在表单中', description: '开启后会将默认值作为台账查询条件将第一行数据映射到表单中',
}, },
isMultiple: { isMultiple: {
title: '多选', title: '多选',
...@@ -4071,7 +4080,7 @@ const mapWidgets = [ ...@@ -4071,7 +4080,7 @@ const mapWidgets = [
title: '到位区域', title: '到位区域',
type: 'string', type: 'string',
description: '默认边界范围或手绘到位范围', description: '默认边界范围或手绘到位范围',
widget: 'DrawArea' widget: 'DrawMap'
}, },
allowedLimit: { allowedLimit: {
title: '允许偏差范围(米)', title: '允许偏差范围(米)',
...@@ -4085,6 +4094,28 @@ const mapWidgets = [ ...@@ -4085,6 +4094,28 @@ const mapWidgets = [
type: 'boolean', type: 'boolean',
widget: 'SwitchDefault' widget: 'SwitchDefault'
}, },
required: {
title: '必填',
type: 'boolean',
default: false,
width: '50%',
},
isHidden: {
title: '是否隐藏',
type: 'boolean',
widget: 'IsHidden',
default: false,
displayType: 'row',
labelWidth: 80,
},
hiddenCondition: {
title: '隐藏条件',
type: 'string',
description: '所有形态默认显示',
widget: 'HiddenCondition',
hidden: "{{formData.isHidden}}",
dependencies: ['isHidden'],
},
groupStyle: { groupStyle: {
title: '控件样式', title: '控件样式',
type: 'object', type: 'object',
...@@ -4341,7 +4372,8 @@ const advancedWidgets = [ ...@@ -4341,7 +4372,8 @@ const advancedWidgets = [
props: { props: {
options: [ options: [
{ label: '数据字典', value: '数据字典' }, { label: '数据字典', value: '数据字典' },
{ label: '表数据', value: '表数据' } { label: '表数据', value: '表数据' },
{ label: '手动输入', value: '手动输入' },
] ]
} }
}, },
...@@ -4350,7 +4382,7 @@ const advancedWidgets = [ ...@@ -4350,7 +4382,7 @@ const advancedWidgets = [
type: 'string', type: 'string',
// required: true, // required: true,
widget: 'FieldNames', widget: 'FieldNames',
hidden: "{{formData.sourceType != '数据字典'}}", hidden: "{{formData.sourceType != '数据字典' && formData.sourceType != '手动输入'}}",
dependencies: ['$id'], dependencies: ['$id'],
}, },
dictionary: { dictionary: {
...@@ -4412,6 +4444,13 @@ const advancedWidgets = [ ...@@ -4412,6 +4444,13 @@ const advancedWidgets = [
widget: 'FieldName', widget: 'FieldName',
dependencies: ['tableName'], dependencies: ['tableName'],
}, },
selectSource:{
title: '选择项',
hidden: '{{formData.sourceType !== "手动输入"}}',
type: 'string',
widget: 'DataSelect',
dependencies: ['fieldParent']
},
required: { required: {
title: '必填', title: '必填',
type: 'boolean', type: 'boolean',
...@@ -4597,6 +4636,15 @@ const advancedWidgets = [ ...@@ -4597,6 +4636,15 @@ const advancedWidgets = [
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 80,
}, },
mobileShowType: {
title: '展示形式',
type: 'string',
description: '移动端展示专用',
widget: 'select',
enum: ['卡片', '列表'],
default: '',
enumNames: ['卡片', '列表'],
},
hiddenCondition: { hiddenCondition: {
title: '隐藏条件', title: '隐藏条件',
type: 'string', type: 'string',
......
...@@ -132,6 +132,8 @@ const FormDesigner = (props, ref) => { ...@@ -132,6 +132,8 @@ const FormDesigner = (props, ref) => {
if (data && typeof data === 'string' && Array.isArray(res.data.root)) { if (data && typeof data === 'string' && Array.isArray(res.data.root)) {
setFieldName(res.data.root) setFieldName(res.data.root)
let json = getJSON(JSON.parse(data), res.data.root) let json = getJSON(JSON.parse(data), res.data.root)
let { inError, outError, fields, newSchema } = getFields(json)
window.designer = fields
designerRef?.current?.setValue(json) designerRef?.current?.setValue(json)
setSchema(json) setSchema(json)
} }
...@@ -335,8 +337,10 @@ const FormDesigner = (props, ref) => { ...@@ -335,8 +337,10 @@ const FormDesigner = (props, ref) => {
} }
const onSchemaChange = (schema) => { const onSchemaChange = (schema) => {
let { inError, outError, fields, newSchema } = getFields(schema) let { inError, outError, fields, newSchema } = getFields(schema)
window.designer = fields window.designer = fields
console.log(schema, fields, 'schemaschema')
if (inError || outError) { if (inError || outError) {
designerRef.current.setValue(newSchema) designerRef.current.setValue(newSchema)
} }
......
...@@ -25,6 +25,7 @@ const getFormDataObj = (formData) => { ...@@ -25,6 +25,7 @@ const getFormDataObj = (formData) => {
const RelationForm = (props) => { const RelationForm = (props) => {
console.log(props, '关联表单')
const userID = window?.globalConfig?.userInfo?.OID || 1 const userID = window?.globalConfig?.userInfo?.OID || 1
const fullName = window?.globalConfig?.userInfo?.fullName || '' const fullName = window?.globalConfig?.userInfo?.fullName || ''
const codes = window?.pandaXform?.codes || { 工单编号: '', 事件编号: '', } const codes = window?.pandaXform?.codes || { 工单编号: '', 事件编号: '', }
......
...@@ -229,6 +229,7 @@ const AccountSelector = (props) => { ...@@ -229,6 +229,7 @@ const AccountSelector = (props) => {
} }
const onOk = () => { const onOk = () => {
console.log(fieldshine, 'fieldshine');
if (fieldshine.length > 1) { if (fieldshine.length > 1) {
let row = dataSource.find(v => v.ID === keys[0]) || {}; let row = dataSource.find(v => v.ID === keys[0]) || {};
Object.keys(addons.formData).forEach(child => { Object.keys(addons.formData).forEach(child => {
...@@ -393,7 +394,10 @@ const AccountSelector = (props) => { ...@@ -393,7 +394,10 @@ const AccountSelector = (props) => {
type: isMultiple && fieldshine.length === 1 ? 'checkbox' : 'radio', type: isMultiple && fieldshine.length === 1 ? 'checkbox' : 'radio',
selectedRowKeys: keys, selectedRowKeys: keys,
fixed: 'left', fixed: 'left',
onChange: (keys) => setKeys(keys) onChange: (keys) => {
console.log(keys, 'keys');
setKeys(keys)
}
}} }}
onRow={record => ({ onRow={record => ({
onClick: event => { onClick: event => {
......
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react';
import { Input, Button } from 'antd' import { Input, Button } from 'antd';
import { CompassOutlined, DownOutlined, UpOutlined } from '@ant-design/icons' import { CompassOutlined, DownOutlined, UpOutlined } from '@ant-design/icons';
import { import {
ArcGISSceneMap, ArcGISSceneMap,
AutoCompleteSearch, AutoCompleteSearch,
...@@ -9,39 +9,30 @@ import { ...@@ -9,39 +9,30 @@ import {
GraphicsLayer, GraphicsLayer,
Point, Point,
geomUtils, geomUtils,
} from '@wisdom-map/arcgismap' } from '@wisdom-map/arcgismap';
import Drag from '../../../components/Drag' import Drag from '../../../components/Drag';
import { isJson, isObject, mercatorToLngLat, lngmkt } from '../../../../utils' import { isJson, isObject, mercatorToLngLat, lngmkt } from '../../../../utils';
import { getLocation, getLocationV5, GetAreaNameByCoordinate, placeAroundRelay } from '../../../../apis/process' import { getLocation, getLocationV5, GetAreaNameByCoordinate, placeAroundRelay } from '../../../../apis/process';
import styles from './index.less' import styles from './index.less';
const Coordinate = (props) => { const Coordinate = props => {
const { token, client, uiwidgets } = window.globalConfig;
const { token, client, uiwidgets } = window.globalConfig const { value, onChange, schema, addons } = props;
const { value, onChange, schema, addons } = props const { disabled, presetValue, placeholder, addressSync, screenShot, areaSync, areaSyncField } = schema;
const {
disabled,
presetValue,
placeholder,
addressSync,
screenShot,
areaSync,
areaSyncField,
} = schema
const [layersConifg, setLayersConifg] = useState(() => { const [layersConifg, setLayersConifg] = useState(() => {
const mapConfig = window.globalConfig.mapsettings?.layers || null const mapConfig = window.globalConfig.mapsettings?.layers || null;
return { layers: mapConfig }; return { layers: mapConfig };
}); });
const [screenShotShow, setScreenShotShow] = useState(false) const [screenShotShow, setScreenShotShow] = useState(false);
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false);
const [initCoordinate, setInitCoordinate] = useState([]) const [initCoordinate, setInitCoordinate] = useState([]);
const [currentPointerCoordinate, setCurrentPointerCoordinate] = useState([]) const [currentPointerCoordinate, setCurrentPointerCoordinate] = useState([]);
const [targetPathText, setTargetPathText] = useState('') const [targetPathText, setTargetPathText] = useState('');
const [text, setText] = useState(presetValue ? '加载中...' : '(空)') const [text, setText] = useState(presetValue ? '加载中...' : '(空)');
const [put, setPut] = useState(true) const [put, setPut] = useState(true);
const [view, setView] = useState(null) const [view, setView] = useState(null);
const getView = (viewObject) => { const getView = viewObject => {
if (viewObject) { if (viewObject) {
setView(viewObject); setView(viewObject);
let coordGetLayer = viewObject.map.layers.find(layer => layer.id == 'coordGet'); let coordGetLayer = viewObject.map.layers.find(layer => layer.id == 'coordGet');
...@@ -56,146 +47,143 @@ const Coordinate = (props) => { ...@@ -56,146 +47,143 @@ const Coordinate = (props) => {
if (value) { if (value) {
coordGetLayer.removeAll(); coordGetLayer.removeAll();
const newVal = value.split(','); const newVal = value.split(',');
const defalutGraphic = createGraphic(new Point({ const defalutGraphic = createGraphic(
new Point({
x: newVal[0], x: newVal[0],
y: newVal[1], y: newVal[1],
spatialReference: { spatialReference: {
wkid: 3857 wkid: 3857,
} },
})); }),
);
coordGetLayer.add(defalutGraphic); coordGetLayer.add(defalutGraphic);
setTimeout(() => { setTimeout(() => {
viewObject.goTo({ viewObject.goTo({
center: geomUtils.toGeometry({ x: Number(newVal[0]), y: Number(newVal[1]) }), center: geomUtils.toGeometry({ x: Number(newVal[0]), y: Number(newVal[1]) }),
scale: viewObject.scale - 1, scale: viewObject.scale - 1,
}) });
}, 2000) }, 2000);
} }
if (!disabled) { if (!disabled) {
getPoints(viewObject, coordGetLayer); getPoints(viewObject, coordGetLayer);
} }
} }
} };
const getMapInfo = (viewObject) => { const getMapInfo = viewObject => {
if (viewObject) { if (viewObject) {
setView(viewObject); setView(viewObject);
let coordGetLayer = viewObject.map.layers.find(layer => layer.id == 'coordGet'); let coordGetLayer = viewObject.map.layers.find(layer => layer.id == 'coordGet');
if (coordGetLayer) { if (coordGetLayer) {
viewObject.map.remove(coordGetLayer); viewObject.map.remove(coordGetLayer);
} else { } else {
coordGetLayer = new GraphicsLayer({ id: 'coordGet' }) coordGetLayer = new GraphicsLayer({ id: 'coordGet' });
} }
viewObject.map.add(coordGetLayer); viewObject.map.add(coordGetLayer);
if (value) { if (value) {
coordGetLayer.removeAll(); coordGetLayer.removeAll();
const newVal = value.split(','); const newVal = value.split(',');
const defalutGraphic = createGraphic(new Point({ const defalutGraphic = createGraphic(
new Point({
x: newVal[0], x: newVal[0],
y: newVal[1], y: newVal[1],
spatialReference: { spatialReference: {
wkid: 3857 wkid: 3857,
} },
})); }),
);
coordGetLayer.add(defalutGraphic); coordGetLayer.add(defalutGraphic);
setTimeout(() => { setTimeout(() => {
viewObject.goTo({ viewObject.goTo({
center: geomUtils.toGeometry({ x: Number(newVal[0]), y: Number(newVal[1]) }), center: geomUtils.toGeometry({ x: Number(newVal[0]), y: Number(newVal[1]) }),
scale: viewObject.scale - 1, scale: viewObject.scale - 1,
}) });
}, 2000) }, 2000);
}
} }
} }
};
const createGraphic = (geometry) => { const createGraphic = geometry => {
return new Graphic({ return new Graphic({
geometry: geometry, geometry: geometry,
symbol: { symbol: {
type: "picture-marker", // autocasts as new PictureMarkerSymbol() type: 'picture-marker', // autocasts as new PictureMarkerSymbol()
url: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAhCAYAAAA2/OAtAAAACXBIWXMAAArrAAAK6wGCiw1aAAAGlmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg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QAyIB1hEPLS9bbAZr/SNAa5sqLQWeZI5RY2pn7vEMRsqAFekkPEM8Osh0WOpgzzYHaoqlFRuAcdNEFkHnCup4OC+zAKlOMpzQWSdAQgiew24XFbB1gcdxMox8O06p6X1pYCvHhB9JnWAtDdVqMIccLKedVuTHgVudAsD3j6ANWBTuQ1MBZFdafhb+m8Q2SJwtqJ7p1wHVoGXmoFtkTZF/I4Hr3sdqqGmUDXm/JvZk5eb3A5widO+PJxJDVQ2vvbQIGkrcUDVmGsXnn72lYrf9i26xEf3V+5E38Dmxo0j5ehVAV+JP6qGWWR1ZnT8zG/9A1tA1w7zE/c0VTWfjU8ur/T0XUyqyzvpzIWFo2MVVU3vsG5VXUuE5vP5Nedc5aPJqatbxhSbgVvGFD+cnFpwzqWbrNc5V3LOLebz+cqulROG4T9Hxx/rGVsvyeHKRs4hCPD7gw998N3g8B9N6d4Fbs3MzJTCMFSAjuUYhuFq7ang7+nlO6dQekRk7f3jU+9WxXiqWlbVn2dnZ5fCMGzp8Xtu65Hn/7jc3fv5kXL5zFJv38K65xtUi/Pz8zf3mttRFx8dmf4+4+kbk8dey+VyI/8J1lA2m03NDfR8m81mH/lfgA29N/pwbr9j77ctd/pn419SR9UArKBoRwAAAABJRU5ErkJggg==',
height: "30px" width: '20px',
} height: '30px',
, },
}); });
} };
const getPoints = (view, coordGetLayer) => { const getPoints = (view, coordGetLayer) => {
drawTool.activate({ drawTool.activate({
view, view,
action: 'point', action: 'point',
target: 'erroSendUpWidget',// 随便写 target: 'erroSendUpWidget', // 随便写
toolTip: '左键选择位置', toolTip: '左键选择位置',
drawEnd: geometry => { drawEnd: geometry => {
setTargetPathText('') setTargetPathText('');
setCurrentPointerCoordinate([geometry.x, geometry.y]) setCurrentPointerCoordinate([geometry.x, geometry.y]);
coordGetLayer && coordGetLayer.removeAll() coordGetLayer && coordGetLayer.removeAll();
const coordGraphic = createGraphic(geometry) const coordGraphic = createGraphic(geometry);
coordGetLayer.add(coordGraphic) coordGetLayer.add(coordGraphic);
getPoints(view, coordGetLayer) getPoints(view, coordGetLayer);
}, },
rightClick: () => { getPoints(view, coordGetLayer) } rightClick: () => {
}) getPoints(view, coordGetLayer);
} },
});
};
const showMap = () => { const showMap = () => {
setVisible(true) setVisible(true);
} };
const onCancel = () => { const onCancel = () => {
setCurrentPointerCoordinate(initCoordinate) setCurrentPointerCoordinate(initCoordinate);
setVisible(false) setVisible(false);
} };
const getTargetPath = (value) => { const getTargetPath = value => {
let paths = Object.keys(addons.formData) let paths = Object.keys(addons.formData);
let targetPath = null let targetPath = null;
if (Array.isArray(paths)) { if (Array.isArray(paths)) {
paths.forEach(v => { paths.forEach(v => {
let values = addons.getValue(v) let values = addons.getValue(v);
if (isObject(values)) { if (isObject(values)) {
for (let key in values) { for (let key in values) {
if (key === value) { if (key === value) {
targetPath = `${v}.${key}` targetPath = `${v}.${key}`;
} }
} }
} }
}) });
}
return targetPath
} }
return targetPath;
};
const onOk = async () => { const onOk = async () => {
if (addressSync) { if (addressSync) {
let targetPath = getTargetPath(addressSync) let targetPath = getTargetPath(addressSync);
if (targetPath) { if (targetPath) {
const { widget } = addons?.getSchemaByPath(targetPath)
if(widget === 'CustomMap' && view){
const mapExentJson = {
mapExtent: `${view.extent.xmin},${view.extent.ymin},${
view.extent.xmax
},${view.extent.ymax}`,
imageDisplay: `${view.width},${view.height},96`,
zoom: view.zoom,
}
addons.setValue(targetPath, JSON.stringify(mapExentJson))
}else {
if (targetPathText) { if (targetPathText) {
addons.setValue(targetPath, targetPathText) addons.setValue(targetPath, targetPathText);
} else { } else {
let LngLat = mercatorToLngLat(currentPointerCoordinate[0], currentPointerCoordinate[1]) let LngLat = mercatorToLngLat(currentPointerCoordinate[0], currentPointerCoordinate[1]);
let newCoord = gcj02_To_gps84(LngLat[0], LngLat[1]) let newCoord = gcj02_To_gps84(LngLat[0], LngLat[1]);
let postStr = { let postStr = {
lon: newCoord.lng, lon: newCoord.lng,
lat: newCoord.lat, lat: newCoord.lat,
ver: 1, ver: 1,
} };
let url = `http://api.tianditu.gov.cn/geocoder?postStr=${JSON.stringify(postStr)}&type=geocode&tk=a1d480f55b805db96e1ed295e62c72b1` let url = `http://api.tianditu.gov.cn/geocoder?postStr=${JSON.stringify(
const { code, data } = await placeAroundRelay(url) postStr,
)}&type=geocode&tk=a1d480f55b805db96e1ed295e62c72b1`;
const { code, data } = await placeAroundRelay(url);
if (code === '0' && isJson(data)) { if (code === '0' && isJson(data)) {
let res = JSON.parse(data) || {} let res = JSON.parse(data) || {};
let text = res?.result?.addressComponent?.poi || res?.result?.formatted_address || '' let text = res?.result?.addressComponent?.poi || res?.result?.formatted_address || '';
const schema = addons.getSchemaByPath(targetPath); const schema = addons.getSchemaByPath(targetPath);
if (['TextInput', 'fileUpload'].includes(schema.widget)) { if (['TextInput', 'fileUpload'].includes(schema.widget)) {
addons.setSchemaByPath(targetPath, { ...schema, otherValue: text }); addons.setSchemaByPath(targetPath, { ...schema, otherValue: text });
...@@ -207,19 +195,22 @@ const Coordinate = (props) => { ...@@ -207,19 +195,22 @@ const Coordinate = (props) => {
} }
} }
} }
}
if (areaSync && areaSyncField) { if (areaSync && areaSyncField) {
let targetPath = getTargetPath(areaSyncField) let targetPath = getTargetPath(areaSyncField);
if (targetPath) { if (targetPath) {
const { code, data } = await GetAreaNameByCoordinate({ sourceType: areaSync, x: Number(currentPointerCoordinate[0]), y: Number(currentPointerCoordinate[1]) }) const { code, data } = await GetAreaNameByCoordinate({
sourceType: areaSync,
x: Number(currentPointerCoordinate[0]),
y: Number(currentPointerCoordinate[1]),
});
if (code === 0 && data) { if (code === 0 && data) {
addons.setValue(targetPath, data) addons.setValue(targetPath, data);
}
} }
} }
setVisible(false)
onChange(currentPointerCoordinate.join(','))
} }
setVisible(false);
onChange(currentPointerCoordinate.join(','));
};
/**火星转84*/ /**火星转84*/
const gcj02_To_gps84 = (lng, lat) => { const gcj02_To_gps84 = (lng, lat) => {
...@@ -269,67 +260,69 @@ const Coordinate = (props) => { ...@@ -269,67 +260,69 @@ const Coordinate = (props) => {
return newCoord; return newCoord;
}; };
const getAddress = async (presetValue) => { const getAddress = async presetValue => {
if (presetValue) { if (presetValue) {
let coordinate = presetValue.split(',') let coordinate = presetValue.split(',');
let LngLat = mercatorToLngLat(coordinate[0], coordinate[1]) let LngLat = mercatorToLngLat(coordinate[0], coordinate[1]);
let newCoord = gcj02_To_gps84(LngLat[0], LngLat[1]) let newCoord = gcj02_To_gps84(LngLat[0], LngLat[1]);
let postStr = { let postStr = {
lon: newCoord.lng, lon: newCoord.lng,
lat: newCoord.lat, lat: newCoord.lat,
ver: 1, ver: 1,
} };
let url = `http://api.tianditu.gov.cn/geocoder?postStr=${JSON.stringify(postStr)}&type=geocode&tk=a1d480f55b805db96e1ed295e62c72b1` let url = `http://api.tianditu.gov.cn/geocoder?postStr=${JSON.stringify(
const { code, data } = await placeAroundRelay(url) postStr,
)}&type=geocode&tk=a1d480f55b805db96e1ed295e62c72b1`;
const { code, data } = await placeAroundRelay(url);
if (code === '0' && isJson(data)) { if (code === '0' && isJson(data)) {
let res = JSON.parse(data) || {} let res = JSON.parse(data) || {};
let text = res?.result?.addressComponent?.poi || res?.result?.formatted_address || '' let text = res?.result?.addressComponent?.poi || res?.result?.formatted_address || '';
setText(text) setText(text);
}
} }
} }
};
const callback = (value) => { const callback = value => {
if (value?.location && view) { if (value?.location && view) {
let array = value?.location.split(',') let array = value?.location.split(',');
let point = lngmkt({ lng: Number(array[0]), lat: Number(array[1]) }) let point = lngmkt({ lng: Number(array[0]), lat: Number(array[1]) });
onChange(`${point.x},${point.y}`) onChange(`${point.x},${point.y}`);
if (value?.name) { if (value?.name) {
setTargetPathText(`${value?.name}`) setTargetPathText(`${value?.name}`);
} else { } else {
setTargetPathText('') setTargetPathText('');
}
} }
} }
};
useEffect(() => { useEffect(() => {
if (value) { if (value) {
let _temp = value && value.split(',') || [] let _temp = (value && value.split(',')) || [];
setCurrentPointerCoordinate(_temp) setCurrentPointerCoordinate(_temp);
setInitCoordinate(_temp) setInitCoordinate(_temp);
} }
}, [value]) }, [value]);
useEffect(() => { useEffect(() => {
if (addons) { if (addons) {
addons.setValueByPath(addons.dataPath, presetValue) addons.setValueByPath(addons.dataPath, presetValue);
} else { } else {
onChange(presetValue) onChange(presetValue);
} }
getAddress(presetValue) getAddress(presetValue);
}, [presetValue]) }, [presetValue]);
useEffect(() => { useEffect(() => {
if (disabled && screenShot) { if (disabled && screenShot) {
addons?.setSchemaByPath(addons.dataPath, { ...schema, width: '67%' }) addons?.setSchemaByPath(addons.dataPath, { ...schema, width: '67%' });
} }
if (screenShot && disabled) { if (screenShot && disabled) {
let time = Math.round(Math.random() * 2000) let time = Math.round(Math.random() * 2000);
setTimeout(() => { setTimeout(() => {
setScreenShotShow(true) setScreenShotShow(true);
}, time) }, time);
} }
}, [disabled, screenShot]) }, [disabled, screenShot]);
const getCityName = () => { const getCityName = () => {
let cityName = '中华人民共和国'; let cityName = '中华人民共和国';
...@@ -343,7 +336,7 @@ const Coordinate = (props) => { ...@@ -343,7 +336,7 @@ const Coordinate = (props) => {
cityName = pipeNetLayer.areaName; cityName = pipeNetLayer.areaName;
} }
return cityName; return cityName;
} };
if (screenShotShow && addons) { if (screenShotShow && addons) {
return ( return (
...@@ -364,24 +357,24 @@ const Coordinate = (props) => { ...@@ -364,24 +357,24 @@ const Coordinate = (props) => {
getMapInfo={getMapInfo} getMapInfo={getMapInfo}
widgets={[ widgets={[
{ {
"label": "缩放", label: '缩放',
"url": "mapgis/widgets/Zoom", url: 'mapgis/widgets/Zoom',
"top": "20", top: '20',
// "bottom": "333", // "bottom": "333",
"right": "20", right: '20',
"config": "", config: '',
"widgetId": "widget_bpm_缩放", widgetId: 'widget_bpm_缩放',
"breadcrumbMap": "缩放" breadcrumbMap: '缩放',
}, },
{ {
"label": "比例尺", label: '比例尺',
"url": "mapgis/widgets/ScaleBar", url: 'mapgis/widgets/ScaleBar',
"left": "20", left: '20',
"top": "180", top: '180',
// "bottom": "20", // "bottom": "20",
"config": "", config: '',
"widgetId": "widget_bpm_比例尺", widgetId: 'widget_bpm_比例尺',
"breadcrumbMap": "比例尺" breadcrumbMap: '比例尺',
}, },
]} ]}
token={token} token={token}
...@@ -390,33 +383,32 @@ const Coordinate = (props) => { ...@@ -390,33 +383,32 @@ const Coordinate = (props) => {
</div> </div>
</div> </div>
</div> </div>
) );
} }
return ( return (
<div className={styles.coordinate}> <div className={styles.coordinate}>
{ {!disabled ? (
!disabled ?
<Input <Input
disabled={disabled} disabled={disabled}
placeholder={disabled ? (placeholder || '') : (placeholder || '点击选择坐标')} placeholder={disabled ? placeholder || '' : placeholder || '点击选择坐标'}
value={value} value={value}
addonAfter={disabled ? null : <CompassOutlined style={{ color: 'rgba(0, 0, 0, 0.25)' }} onClick={showMap} />} addonAfter={disabled ? null : <CompassOutlined style={{ color: 'rgba(0, 0, 0, 0.25)' }} onClick={showMap} />}
style={{ width: '100%' }} style={{ width: '100%' }}
onClick={showMap} onClick={showMap}
/> />
: ) : (
<Button <Button
icon={<CompassOutlined style={{ color: value ? '#0092fe' : 'rgba(0, 0, 0, 0.25)' }} />} icon={<CompassOutlined style={{ color: value ? '#0092fe' : 'rgba(0, 0, 0, 0.25)' }} />}
onClick={() => { onClick={() => {
if (value) { if (value) {
showMap() showMap();
} }
}} }}
> >
{value ? '查看位置' : '无位置信息'} {value ? '查看位置' : '无位置信息'}
</Button> </Button>
} )}
<Drag <Drag
width={'80%'} width={'80%'}
title="选取坐标" title="选取坐标"
...@@ -425,32 +417,35 @@ const Coordinate = (props) => { ...@@ -425,32 +417,35 @@ const Coordinate = (props) => {
onCancel={onCancel} onCancel={onCancel}
cancelText={'取消'} cancelText={'取消'}
okText={'确定'} okText={'确定'}
bodyStyle={{ height: 600, overflowY: "auto", position: 'relative' }} bodyStyle={{ height: 600, overflowY: 'auto', position: 'relative' }}
destroyOnClose={true} destroyOnClose={true}
{...disabled ? { footer: null } : {}} {...(disabled ? { footer: null } : {})}
> >
<div style={{ height: '90%' }}> <div style={{ height: '90%' }}>
<ArcGISSceneMap <ArcGISSceneMap
getMapInfo={getView} getMapInfo={getView}
widgets={[{ widgets={[
{
label: '底图切换', label: '底图切换',
right: 60, right: 60,
bottom: 45, bottom: 45,
config: {}, config: {},
}]} },
]}
token={token} token={token}
client={token ? client : 'sandbox'} client={token ? client : 'sandbox'}
/> />
{ {view ? (
view ? <div style={{ width: '400px', position: 'absolute', right: '0', top: '25px' }}> <div style={{ width: '400px', position: 'absolute', right: '0', top: '25px' }}>
<AutoCompleteSearch areaName={getCityName()} view={view} callback={callback} /> <AutoCompleteSearch areaName={getCityName()} view={view} callback={callback} />
</div> : '' </div>
} ) : (
''
)}
</div> </div>
</Drag> </Drag>
</div > </div>
) );
};
}
export default Coordinate export default Coordinate;
...@@ -8,19 +8,20 @@ import { ...@@ -8,19 +8,20 @@ import {
GraphicsLayer, GraphicsLayer,
Graphic Graphic
} from '@wisdom-map/arcgismap' } from '@wisdom-map/arcgismap'
import { getPipenetLayerAsync } from '@wisdom-map/basemap'
import point from './img/point.png' import point from './img/point.png'
import { isJson, isObject, mercatorToLngLat, lngmkt } from '../../../../utils' import { isJson, isObject, mercatorToLngLat, lngmkt, debounce } from '../../../../utils'
import { getLocation, getLocationV5, GetAreaNameByCoordinate, placeAroundRelay } from '../../../../apis/process' import { getLocation, getLocationV5, GetAreaNameByCoordinate, placeAroundRelay, identify, GetLayerList, GetLayerDataAndMedia } from '../../../../apis/process'
import Drag from '../../../components/Drag' import Drag from '../../../components/Drag'
import styles from './index.less' import styles from './index.less'
let geometrystr = '' let geometrystr
let gisInfo = {} let gisInfo = {}
let layer = 0 let layer = 0
const Device = (props) => { const Device = (props) => {
const { token, client } = window.globalConfig const { token, client, mapsettings } = window.globalConfig
const { addons, value, onChange, schema } = props const { addons, value, onChange, schema } = props
const { const {
placeholder, placeholder,
...@@ -41,8 +42,9 @@ const Device = (props) => { ...@@ -41,8 +42,9 @@ const Device = (props) => {
const isSendQueryRef = useRef(false) const isSendQueryRef = useRef(false)
const getView = (mapObj, Map, extentInfos, layersInfo) => { const getView = (mapObj, Map, extentInfos, layersInfo) => {
if (mapObj && layersInfo && !isSendQueryRef.current) { if (mapObj && !isSendQueryRef.current) {
setTimeout(() => { console.log(mapObj, Map, extentInfos, layersInfo, layerName, '地图方案信息');
setTimeout(async () => {
let gisCode = '' let gisCode = ''
let gisLayerName = '' let gisLayerName = ''
let values = addons?.getValues() let values = addons?.getValues()
...@@ -60,7 +62,10 @@ const Device = (props) => { ...@@ -60,7 +62,10 @@ const Device = (props) => {
} }
}) })
} }
if (mapObj) { if (mapObj) {
const mapInfo = await getPipenetLayerAsync({map: mapObj.map});
if(!mapInfo) return
view.current = mapObj view.current = mapObj
let arr = (value && value.split(',')) || [] let arr = (value && value.split(',')) || []
let obj = (arr.length === 2) ? { point: { x: Number(arr[0]), y: Number(arr[1]) } } : {} let obj = (arr.length === 2) ? { point: { x: Number(arr[0]), y: Number(arr[1]) } } : {}
...@@ -74,6 +79,7 @@ const Device = (props) => { ...@@ -74,6 +79,7 @@ const Device = (props) => {
clickref.current?.closetip() clickref.current?.closetip()
clickref.current = null clickref.current = null
} }
clickref.current = new WorkFlowEquipmentQuery({ clickref.current = new WorkFlowEquipmentQuery({
layerInfos: layersInfo, layerInfos: layersInfo,
view: view.current, view: view.current,
...@@ -121,11 +127,36 @@ const Device = (props) => { ...@@ -121,11 +127,36 @@ const Device = (props) => {
} }
}) })
} }
}, 500) }, 1000)
isSendQueryRef.current = true isSendQueryRef.current = true
} }
} }
const getGisData = ()=>{
let gisCode = ''
let gisLayerName = ''
let values = addons?.formData
console.log(values, 'sssss')
if (isObject(values)) {
Object.keys(values).forEach(key => {
if (isObject(values[key])) {
Object.keys(values[key]).forEach(k => {
if (k === 'GIS编码') {
gisCode = values[key][k] || ''
}
if (k === 'GIS图层') {
gisLayerName = values[key][k] || ''
}
})
}
})
}
return {
gisCode,
gisLayerName
}
}
const getMapInfo = (mapObj, Map) => { const getMapInfo = (mapObj, Map) => {
let gisCode = '' let gisCode = ''
let gisLayerName = '' let gisLayerName = ''
...@@ -144,8 +175,10 @@ const Device = (props) => { ...@@ -144,8 +175,10 @@ const Device = (props) => {
} }
}) })
} }
setTimeout(() => { setTimeout(async () => {
if (mapObj) { if (mapObj) {
const mapInfo = await getPipenetLayerAsync({map: mapObj.map});
if(!mapInfo) return
view.current = mapObj view.current = mapObj
let arr = (value && value.split(',')) || [] let arr = (value && value.split(',')) || []
let obj = (arr.length === 2) ? { point: { x: Number(arr[0]), y: Number(arr[1]) } } : {} let obj = (arr.length === 2) ? { point: { x: Number(arr[0]), y: Number(arr[1]) } } : {}
...@@ -204,7 +237,7 @@ const Device = (props) => { ...@@ -204,7 +237,7 @@ const Device = (props) => {
} }
}) })
} }
}, 500) }, 1000)
} }
const iconClick = () => { const iconClick = () => {
...@@ -311,41 +344,43 @@ const Device = (props) => { ...@@ -311,41 +344,43 @@ const Device = (props) => {
} }
const onOk = () => { const onOk = () => {
onChange(geometrystr) onChange(geometrystr)
let { paths } = addons.getSchemaByPath('#') let { paths } = addons.getSchemaByPath('#')
if (Array.isArray(paths)) { if (Array.isArray(paths)) {
paths.forEach(v => { paths.forEach(v => {
let values = addons.getValue(v) let values = addons.getValue(v)
if (isObject(values)) { if (isObject(values)) {
console.log(values, props, '设备选择')
for (let key in values) { for (let key in values) {
if (Array.isArray(fieldshine) && fieldshine.length) { if (Array.isArray(fieldshine) && fieldshine.length) {
fieldshine.forEach(item => { fieldshine.forEach(item => {
if (item.toField === key && gisInfo?.[item.fromField]) { if (item.toField === key) {
const schema = addons.getSchemaByPath(`${v}.${key}`); const schema = addons.getSchemaByPath(`${v}.${key}`);
if (['FileUpload', 'TextInput'].includes(schema.widget)) { if (['FileUpload', 'TextInput'].includes(schema.widget)) {
addons.setSchemaByPath(`${v}.${key}`, { ...schema, otherValue: gisInfo?.[item?.fromField] }); addons.setSchemaByPath(`${v}.${key}`, { ...schema, otherValue: gisInfo?.[item?.fromField] || '' });
} else if (['NumberInput'].includes(schema.widget)) { } else if (['NumberInput'].includes(schema.widget)) {
addons.setValueByPath(`${v}.${key}`, gisInfo?.[item?.fromField] + '') addons.setValueByPath(`${v}.${key}`, gisInfo?.[item?.fromField] || 0 + '')
} else { } else {
addons.setValueByPath(`${v}.${key}`, gisInfo?.[item?.fromField]) addons.setValueByPath(`${v}.${key}`, gisInfo?.[item?.fromField] || '')
} }
} }
}) })
} }
if (key === 'GIS编码' && gisInfo.gisCode) { if (key === 'GIS编码') {
const schema = addons.getSchemaByPath(`${v}.${key}`); const schema = addons.getSchemaByPath(`${v}.${key}`);
if (['FileUpload', 'TextInput'].includes(schema.widget)) { if (['FileUpload', 'TextInput'].includes(schema.widget)) {
addons.setSchemaByPath(`${v}.${key}`, { ...schema, otherValue: gisInfo.gisCode }); addons.setSchemaByPath(`${v}.${key}`, { ...schema, otherValue: gisInfo.gisCode || '' });
} else { } else {
addons.setValueByPath(`${v}.${key}`, gisInfo.gisCode) addons.setValueByPath(`${v}.${key}`, gisInfo.gisCode || '')
} }
} }
if (key === 'GIS图层' && gisInfo.layerName) { if (key === 'GIS图层') {
const schema = addons.getSchemaByPath(`${v}.${key}`); const schema = addons.getSchemaByPath(`${v}.${key}`);
if (['FileUpload', 'TextInput'].includes(schema.widget)) { if (['FileUpload', 'TextInput'].includes(schema.widget)) {
addons.setSchemaByPath(`${v}.${key}`, { ...schema, otherValue: gisInfo.layerName }); addons.setSchemaByPath(`${v}.${key}`, { ...schema, otherValue: gisInfo.layerName || '' });
} else { } else {
addons.setValueByPath(`${v}.${key}`, gisInfo.layerName) addons.setValueByPath(`${v}.${key}`, gisInfo.layerName || '')
} }
} }
} }
...@@ -366,6 +401,9 @@ const Device = (props) => { ...@@ -366,6 +401,9 @@ const Device = (props) => {
if (addons) { if (addons) {
if (presetValue) { if (presetValue) {
geometrystr = presetValue geometrystr = presetValue
setTimeout(() => {
renderData(presetValue)
}, 500);
} }
addons.setValueByPath(addons.dataPath, presetValue) addons.setValueByPath(addons.dataPath, presetValue)
} else { } else {
...@@ -379,6 +417,28 @@ const Device = (props) => { ...@@ -379,6 +417,28 @@ const Device = (props) => {
} }
}, [disabled, screenShot]) }, [disabled, screenShot])
const renderData = (val)=>{
const layer = mapsettings.layers.find(v=> v.layerType == 'PipenetLayer')
if(!layer) return;
const { id } = layer;
const { gisCode, gisLayerName } = getGisData();
console.log({ gisCode, gisLayerName }, props, '默认值映射阀门数据')
if(!gisCode || !gisLayerName) return;
GetLayerDataAndMedia({
mapServerName: id,
params: {
layerName:gisLayerName,
gisCode
}
}).then(res=> {
if(res.code == 0){
const { layerName, code, attrbutdata } = res.data.coordinate
gisInfo = { layerName: layerName, gisCode: code, ...attrbutdata }
onOk();
}
})
}
if (screenShot && disabled && addons) { if (screenShot && disabled && addons) {
return ( return (
<div className={styles.deviceShot}> <div className={styles.deviceShot}>
...@@ -395,7 +455,7 @@ const Device = (props) => { ...@@ -395,7 +455,7 @@ const Device = (props) => {
</div> </div>
<div className={styles.mapBox} style={{ height: put ? '208px' : '0px' }}> <div className={styles.mapBox} style={{ height: put ? '208px' : '0px' }}>
<ArcGISSceneMap <ArcGISSceneMap
getMapInfo={getMapInfo} getMapInfo={debounce(getMapInfo)}
widgets={[]} widgets={[]}
token={token} token={token}
client={token ? client : 'sandbox'} client={token ? client : 'sandbox'}
...@@ -442,7 +502,7 @@ const Device = (props) => { ...@@ -442,7 +502,7 @@ const Device = (props) => {
{...disabled ? { footer: null } : {}} {...disabled ? { footer: null } : {}}
> >
<ArcGISSceneMap <ArcGISSceneMap
getMapInfo={getView} getMapInfo={debounce(getView)}
widgets={[]} widgets={[]}
token={token} token={token}
client={token ? client : 'sandbox'} client={token ? client : 'sandbox'}
......
...@@ -30,7 +30,6 @@ const PunchInMap = props => { ...@@ -30,7 +30,6 @@ const PunchInMap = props => {
const getView = viewObj => { const getView = viewObj => {
setView(viewObj); setView(viewObj);
}; };
console.log(customFlagRef, rings, 'customFlagRefcustomFlagRef')
useEffect(() => { useEffect(() => {
if (view) { if (view) {
if (value) { if (value) {
......
...@@ -35,7 +35,9 @@ const ComboBox = (props) => { ...@@ -35,7 +35,9 @@ const ComboBox = (props) => {
console.log(props, 'propssssss') console.log(props, 'propssssss')
if (addons) { if (addons) {
if (sourceType === '站点') { if (sourceType === '站点') {
setTimeout(() => {
getStation(presetValue) getStation(presetValue)
}, 10);
} }
if(sourceType === '数据字典' && dictionary && saveVal){ if(sourceType === '数据字典' && dictionary && saveVal){
getDictionaryItemList(dictionary) getDictionaryItemList(dictionary)
......
import React, { useEffect, useState, useMemo } from 'react' import React, { useEffect, useState, useMemo, useRef } from 'react';
import { Select, message } from 'antd' import { Select, message } from 'antd';
import { GetSelectItemList, GetFieldValueFromTable, GetFieldValueByTableName } from '../../../../apis/process' import { GetSelectItemList, GetFieldValueFromTable, GetFieldValueByTableName } from '../../../../apis/process';
import eventEmitter from '../../../../utils/eventEmitter'; import eventEmitter from '../../../../utils/eventEmitter';
const { Option } = Select const { Option } = Select;
const RelevanceSelect = (props) => {
const { value, onChange, schema, addons, title } = props
const { $id, disabled, placeholder, fieldParent, dictionary, presetValue, whereField, whereType, sourceType, fieldTableKey, tableName, fieldName, displayName } = schema
const [options, setOptions] = useState([])
const [tableData, setTableData] = useState([])
const RelevanceSelect = props => {
const { value, onChange, schema, addons, title } = props;
const {
$id,
disabled,
placeholder,
fieldParent,
selectSource,
dictionary,
presetValue,
whereField,
whereType,
sourceType,
fieldTableKey,
tableName,
fieldName,
displayName,
} = schema;
const [options, setOptions] = useState([]);
const [tableData, setTableData] = useState([]);
const [selectWidth, setSelectWidth] = useState(0);
const divRef = useRef(null)
//用于表数据的父子级控件之间联动 //用于表数据的父子级控件之间联动
useEffect(() => { useEffect(() => {
if(addons){ if(divRef.current){
if(getTargetPath()){ const width = divRef.current.offsetWidth;
const path = getTargetPath() setSelectWidth(width)
eventEmitter.on(`${path}_event`, (val)=> dealParentData(val)) console.log('实际宽度:', width, divRef.current);
} }
if(!fieldTableKey && getChildrenSchemaByKey(title) && presetValue){//表数据类型的父级控件联动子级加载数据 if (addons) {
setTimeout(() => { eventEmitter.emit(`${addons?.dataPath}_event`, presetValue )}, 100) if (getTargetPath()) {
const path = getTargetPath();
eventEmitter.on(`${path}_event`, val => dealParentData(val));
}
if (((sourceType === '表数据' && !fieldTableKey) || (sourceType === '手动输入' && !fieldParent)) && getChildrenSchemaByKey(title) && presetValue) {
//表数据类型的父级控件联动子级加载数据
setTimeout(() => {
eventEmitter.emit(`${addons?.dataPath}_event`, presetValue);
}, 100);
} }
} }
return () => { return () => {
if(getTargetPath()){ if (getTargetPath()) {
const path = getTargetPath(fieldTableKey) const path = getTargetPath(fieldTableKey);
eventEmitter.removeAllListeners(`${path}_event`); eventEmitter.removeAllListeners(`${path}_event`);
} }
} };
}, [addons]) }, []);
useEffect(() => { useEffect(() => {
if(sourceType === '表数据' && presetValue){ if (sourceType === '表数据' && presetValue) {
setTimeout(() => { setTimeout(() => {
getTableData() getTableData();
}, 100); }, 100);
} }
if (sourceType === '手动输入') {
customData();
}
if (addons) { if (addons) {
addons.setValue(addons.dataPath, presetValue || '') addons.setValue(addons.dataPath, presetValue || '');
} else { } else {
onChange(presetValue) onChange(presetValue);
} }
}, [presetValue, sourceType]);
}, [presetValue, sourceType]) const selectChange = value => {
console.log(value, tableData, 'value');
const selectChange = (value) => {
if (addons) { if (addons) {
onChange(value || '') onChange(value || '');
if(getChildrenSchemaByKey(title)){ if (getChildrenSchemaByKey(title)) {
eventEmitter.emit(`${addons?.dataPath}_event`, value) eventEmitter.emit(`${addons?.dataPath}_event`, value);
}
} }
} }
};
///处理父级传入的数据-表数据 ///处理父级传入的数据-表数据
const dealParentData = async (val) => { const dealParentData = async val => {
console.log(val, '父级数据');
if (sourceType === '表数据') {
const { code, data, msg } = await GetFieldValueByTableName({ const { code, data, msg } = await GetFieldValueByTableName({
params: { params: {
tableName: tableName, tableName: tableName,
fieldName: `${displayName},${fieldName}`, fieldName: `${displayName},${fieldName}`,
}, },
data: [{ data: [
{
field: whereField, field: whereField,
type: whereType, type: whereType,
value: val value: val,
}] },
}) ],
});
if (code === 0) { if (code === 0) {
if (Array.isArray(data)) { if (Array.isArray(data)) {
setTableData(data.filter(v => v)) setTableData(data.filter(v => v));
if(data.length > 0){
let fieldNameData = data[0].find(v => v.fieldName === fieldName);
onChange(fieldNameData?.fieldValue || '');
}
} else { } else {
setTableData([]) setTableData([]);
} }
} else { } else {
message.error(msg) message.error(msg);
}
}
if (sourceType === '手动输入') {
console.log(selectSource, addons.dataPath, val, 'selectSource');
if (selectSource) {
const jsonObj = JSON.parse(selectSource);
const arr = jsonObj.filter(v => v.parent.includes(val || '')).map(v => v.value);
setOptions(arr);
let v = '';
if(arr.length > 0){
if(presetValue && arr.includes(presetValue)){
v = presetValue;
}else {
v = arr[0]
}
}else{
v = ''
} }
if(!val){
v = ''
}
onChange(v);
if (getChildrenSchemaByKey(title)) {
eventEmitter.emit(`${addons?.dataPath}_event`, v);
}
// if(!val || (presetValue && !arr.includes(presetValue))){
// onChange('');
// }
} }
}
};
const getTargetPath = () => { const getTargetPath = () => {
if(sourceType != '表数据' || !fieldTableKey || !addons) return null; if (((sourceType === '表数据' && !fieldTableKey) || (sourceType === '手动输入' && !fieldParent)) || !addons) return null;
let targetPath = null let targetPath = null;
for(const k of Object.keys(addons.formData)){ for (const k of Object.keys(addons.formData)) {
for(const s of Object.keys(addons.formData[k])){ for (const s of Object.keys(addons.formData[k])) {
if(fieldTableKey === s){ if(sourceType === '表数据' && fieldTableKey === s){
targetPath = `${k}.${s}` targetPath = `${k}.${s}`;
break; break;
} }
if(sourceType === '手动输入' && fieldParent === s){
targetPath = `${k}.${s}`;
break;
} }
} }
return targetPath
} }
return targetPath;
};
const getChildrenSchemaByKey = (key) => { const getChildrenSchemaByKey = key => {
let schema = null; let schema = null;
if(sourceType != '表数据') return null; if (sourceType != '表数据' && sourceType != '手动输入') return null;
const formData = addons.formData const formData = addons.formData;
for(const k of Object.keys(formData).filter(f=> f != 'relationForm')){ for (const k of Object.keys(formData).filter(f => f != 'relationForm')) {
for(const s of Object.keys(formData[k])){ for (const s of Object.keys(formData[k])) {
const path = `${k}.${s}` const path = `${k}.${s}`;
let _schema = addons?.getSchemaByPath(path) let _schema = addons?.getSchemaByPath(path);
if(_schema?.fieldTableKey === key){ if(sourceType === '表数据'){
schema = _schema if (_schema?.fieldTableKey === fieldTableKey) {
schema = _schema;
break;
}
}else{
if (_schema?.fieldParent === fieldParent) {
schema = _schema;
break; break;
} }
} }
} }
return schema
} }
return schema;
};
const enums = useMemo(() => { const enums = useMemo(() => {
switch (sourceType) { switch (sourceType) {
case '数据字典': case '数据字典':
return Array.isArray(options) ? options : [] return Array.isArray(options) ? options : [];
case '手动输入':
return Array.isArray(options) ? options : [];
case '表数据': case '表数据':
return Array.isArray(tableData) ? tableData : [] return Array.isArray(tableData) ? tableData : [];
default: default:
return [] return [];
} }
}, [sourceType, options, tableData]) }, [sourceType, options, tableData]);
const children = useMemo(() => { const children = useMemo(() => {
let children = [] let children = [];
if (Array.isArray(enums)) { if (Array.isArray(enums)) {
enums.forEach(v => { enums.forEach((v, i) => {
if (sourceType === '数据字典') { if (sourceType === '数据字典') {
children.push(<Option value={v.nodeValue} key={v}>{v.nodeValue}</Option>) children.push(
<Option value={v.nodeValue} key={v}>
{v.nodeValue}
</Option>,
);
} else if (sourceType === '手动输入') {
children.push(
<Option value={v} key={i}>
{v}
</Option>,
);
} else { } else {
let displayData = v?.find(v=> v.fieldName === displayName) let displayData = v?.find(v => v.fieldName === displayName);
let fieldNameData = v?.find(v=> v.fieldName === fieldName) let fieldNameData = v?.find(v => v.fieldName === fieldName);
children.push(<Option key={v} value={fieldNameData?.fieldValue}>{displayData?.fieldValue}</Option>) children.push(
} <Option key={v} value={fieldNameData?.fieldValue}>
}) {displayData?.fieldValue}
} </Option>,
return children );
}, [sourceType, enums]) }
});
}
return children;
}, [sourceType, enums]);
const onfocus = async () => { const onfocus = async () => {
if (!addons) return if (!addons) return;
if(sourceType === '数据字典') { if (sourceType === '数据字典') {
getDictionary() getDictionary();
}else if(!fieldTableKey){ } else if (sourceType === '表数据' && !fieldTableKey) {
getTableData() getTableData();
} }
};
const customData = () => {
if (selectSource) {
const jsonObj = JSON.parse(selectSource);
setOptions(jsonObj.map(v => v.value));
} }
};
const getTableData = async () => { const getTableData = async () => {
if (!tableName) { if (!tableName) {
return message.info('请选择表名!') return message.info('请选择表名!');
} }
if (!fieldName) { if (!fieldName) {
return message.info('请选择存储字段名!') return message.info('请选择存储字段名!');
} }
if (!displayName) { if (!displayName) {
return message.info('请选择展示字段名!') return message.info('请选择展示字段名!');
} }
const { code, data, msg } = await GetFieldValueByTableName({ const { code, data, msg } = await GetFieldValueByTableName({
params: { params: {
tableName: tableName, tableName: tableName,
fieldName: `${displayName},${fieldName}`, fieldName: `${displayName},${fieldName}`,
}, },
data: [] data: [],
}) });
if (code === 0) { if (code === 0) {
if (Array.isArray(data)) { if (Array.isArray(data)) {
setTableData(data.filter(v => v)) setTableData(data.filter(v => v));
} else { } else {
setTableData([]) setTableData([]);
} }
} else { } else {
message.error(msg) message.error(msg);
}
} }
};
const getDictionary = async () => { const getDictionary = async () => {
if (!dictionary) { if (!dictionary) {
return message.error('缺少数据字典!') return message.error('缺少数据字典!');
} }
const { code, data, msg } = await GetSelectItemList({ nodeName: dictionary }) const { code, data, msg } = await GetSelectItemList({ nodeName: dictionary });
if (code === 0) { if (code === 0) {
if (Array.isArray(data)) { if (Array.isArray(data)) {
let filterKey = null let filterKey = null;
Object.keys(addons.formData).forEach(v => { Object.keys(addons.formData).forEach(v => {
if (addons.formData[v]) { if (addons.formData[v]) {
Object.keys(addons.formData[v]).forEach(s => { Object.keys(addons.formData[v]).forEach(s => {
if (fieldParent === s) { if (fieldParent === s) {
filterKey = addons.formData[v][s] filterKey = addons.formData[v][s];
} }
}) });
} }
}) });
if (filterKey) { if (filterKey) {
setOptions(data.filter(v => v.nodeName === filterKey)) setOptions(data.filter(v => v.nodeName === filterKey));
} else { } else {
setOptions(data) setOptions(data);
} }
} }
} else { } else {
message.error(msg) message.error(msg);
}
} }
};
return ( return (
<div style={{ width: '100%' }} ref={divRef}>
<Select <Select
value={value} value={value}
onFocus={onfocus} onFocus={onfocus}
style={{ width: '100%' }} style={{ width: selectWidth > 0 ? `${selectWidth}px` : '100%' }}
onChange={selectChange} onChange={selectChange}
disabled={disabled} disabled={disabled}
placeholder={disabled ? (placeholder || '') : (placeholder || '请选择内容')} placeholder={disabled ? placeholder || '' : placeholder || '请选择内容'}
allowClear allowClear
> >
{ {children}
children
}
</Select> </Select>
) </div>
} );
};
export default RelevanceSelect export default RelevanceSelect;
\ No newline at end of file
import React, { useEffect, useRef, useState } from 'react';
import { Button, Select, message, Modal, Input, Space } from 'antd';
import { LoadTableV2, LoadTableFields, ReloadTableFields } from '../../../../../apis/process';
import { isArray, isObject } from '../../../../../utils';
const { TextArea } = Input;
const DataSelect = props => {
console.log(props, '关联选择数据导入');
const { value, onChange, addons } = props;
const { tableName, tableNameParent, fieldParent } = addons.formData;
const [options, setOptions] = useState([]);
const [parentOptions, setParentOptions] = useState([]);
const [showType, setShowType] = useState('');
const [visible, setVisible] = useState(false);
const [text, setText] = useState('');
const [pSelectVal, setPSelectVal] = useState('')
const [selectVal, setSelectVal] = useState([])
let currentVals = useRef([])
let parentVals = useRef([])
useEffect(()=>{
if(value){
const objList = JSON.parse(value)
currentVals.current = objList
setOptions(objList.map(v=> {
return {
label: v.value,
value: v.value
}
}))
setText(objList.map(v=> v.value).join('\n'))
}
}, [value])
useEffect(()=>{
if(fieldParent){
console.log(getParentSchema(fieldParent), 'getParentSchema(fieldParent)')
getParentSource(fieldParent)
}
}, [fieldParent])
const getParentSource = (fieldName)=>{
const schema = getParentSchema(fieldName)
if(schema){
const { selectSource } = schema;
const arr= JSON.parse(selectSource)
parentVals.current = arr
if(isArray(arr)){
setParentOptions(arr.map(v=> {
return {
label: v.value,
value: v.value
}
}))
}
}
}
const getParentSchema = (fieldName) => {
if(!window.designer) return null;
return window.designer.find(v=> v.fieldName === fieldName)
}
const handleClick = (type)=>{
if(type === 'config' && !fieldParent){
message.warn('请先选择父字段名!')
return;
}
setShowType(type)
setVisible(true)
}
const textInput = (e)=>{
setText(e.target.value)
}
const onOk = ()=>{
if(showType === 'import'){
const currentArr = text.split('\n')
const arr = currentArr.filter((item, index) => currentArr.indexOf(item) === index && item);
if(currentVals.current.length > 0){//如果已有值则追加
let objList= currentVals.current
objList = objList.filter(v=> arr.includes(v.value))
objList = [
...objList,
...(arr.filter(v=> !objList.map(x=> x.value).includes(v)).map(v=> {
return {
value: v,
parent: []
}
}))
]
currentVals.current = objList
onChange(JSON.stringify(objList))
}else{
const arr1 = arr.map(v=> {
return {
value: v,
parent: []
}
})
currentVals.current = arr1
onChange(JSON.stringify(arr1))
}
}else{
console.log(currentVals, 'currentVals')
onChange(JSON.stringify(currentVals.current))
}
setVisible(false)
setPSelectVal('')
setSelectVal([])
}
const handleSelect = (e)=>{
if(Array.isArray(e)){//子级
setSelectVal(e)
if(e.length > 0){
currentVals.current.forEach(v=> {
if(v.parent.includes(pSelectVal)){//找到关联了父级的子选项
if(!e.includes(v.value)){//如果子选项不存在则剔除父级
v.parent = v.parent.filter(x=> x !== pSelectVal)
}
}
if(e.includes(v.value)){
if(!v.parent.includes(pSelectVal)){
v.parent.push(pSelectVal)
}
}
})
}else{
currentVals.current.forEach(v=> {
if(v.parent.includes(pSelectVal)){
v.parent = v.parent.filter(x=> x !== pSelectVal)
}
})
}
}else{
setPSelectVal(e)
const vals = currentVals.current.filter(v=> v.parent.includes(e)).map(v=> v.value)
setSelectVal(vals)
}
}
const handleClose = ()=>{
setVisible(false)
setPSelectVal('')
setSelectVal([])
}
return (
<>
<Select options={options} placeholder={options.length ? '已配置' : ''}></Select>
<Button type={'link'} onClick={() => handleClick('import')}>
数据导入
</Button>
<Button type={'link'} onClick={() => handleClick('config')}>联动配置</Button>
<Modal title={showType === 'import' ? '数据导入' : '父子级联动'} visible={visible} onCancel={handleClose} onOk={onOk} destroyOnClose>
{showType === 'import' && (
<div>
<p>数据源批量导入,一条数据独占一行</p>
<TextArea value={text} rows={6} onChange={textInput}></TextArea>
</div>
)}
{showType === 'config' && (
<Space>
<span>父级选项:</span>
<Select value={pSelectVal} onChange={handleSelect} options={parentOptions} style={{ width: '120px' }}></Select>
<span>子级选项:</span>
<Select value={selectVal} mode={'multiple'} maxTagCount={2} onChange={handleSelect} style={{ width: '160px' }} options={pSelectVal.length && options}></Select>
</Space>
)}
</Modal>
</>
);
};
export default DataSelect;
import React, { useState, useEffect, useRef } from 'react'
import { Input, Button } from 'antd'
import { CompassOutlined, DownOutlined } from '@ant-design/icons'
import styles from './index.less'
import {
ArcGISSceneMap,
AutoCompleteSearch,
Drawtool as drawTool,
Graphic,
GraphicsLayer,
Point,
geomUtils,
SimpleLineSymbol,
SimpleFillSymbol,
} from '@wisdom-map/arcgismap'
import Drag from '../../../../components/Drag'
import { isJson, isObject, mercatorToLngLat } from '../../../../../utils'
const DrawMap = (props) => {
const { token, client } = window.globalConfig
const { value, onChange, schema, addons } = props
const { disabled, placeholder, presetValue, addressSync, screenShot } = schema
const [visible, setVisible] = useState(false)
const [rings, setRings] = useState({})
const [text, setText] = useState(presetValue ? '已绘制' : '(空)')
const [put, setPut] = useState(true)
const viewRef = useRef(null)
const layers = useRef(null)
console.log('props区域绘制111111', props)
const createPaths = (view) => {
setTimeout(() => {
if (isJson(value)) {
layers.current && view.map.remove(layers.current)
let layer = new Graphic({
geometry: geomUtils.toGeometry(JSON.parse(value)),
symbol: new SimpleFillSymbol({
}),
})
layers.current = new GraphicsLayer()
layers.current.add(layer)
view.map.add(layers.current)
}
}, 2000)
}
const getView = (viewObject) => {
setRings(isJson(value) ? JSON.parse(value) : '')
viewRef.current = viewObject
createPaths(viewObject)
}
const getMapInfo = (viewObject) => {
setRings(isJson(value) ? JSON.parse(value) : '')
viewRef.current = viewObject
createPaths(viewObject)
}
const getPoints = (view) => {
if (view) {
view.map.remove(layers.current)
drawTool.activate({
view,
action: 'polygon',
target: 'erroSendUpWidget',// 随便写
toolTip: '左键选择位置',
drawEnd: geometry => {
setRings({ rings: geometry.rings })
let layer = new Graphic({
geometry: geometry,
symbol: new SimpleFillSymbol({
}),
})
layers.current = new GraphicsLayer()
layers.current.add(layer)
view.map.add(layers.current)
},
// rightClick: () => { getPoints(view, coordGetLayer) }
})
}
}
const start = () => {
getPoints(viewRef.current)
}
const clear = ()=>{
if(viewRef.current){
viewRef.current.map.remove(layers.current)
setRings('')
}
}
const showMap = () => {
setVisible(true)
}
const onCancel = () => {
setVisible(false)
}
const onOk = () => {
onChange(isObject(rings) ? JSON.stringify(rings) : '')
setVisible(false)
}
useEffect(() => {
if (addons) {
addons.setValueByPath(addons.dataPath, presetValue)
} else {
onChange(presetValue)
}
}, [presetValue])
useEffect(()=>{
if(isObject){
if (addons) {
addons.setValueByPath(addons.dataPath, value)
} else {
onChange && onChange(value)
}
}
}, [value])
useEffect(() => {
if (disabled && screenShot) {
addons?.setSchemaByPath(addons.dataPath, { ...schema, width: '67%' })
}
}, [disabled, screenShot])
if (screenShot && disabled && addons) {
return (
<div className={styles.drawAreaShot}>
<div className={styles.content}>
<div className={styles.top}>
<div className={styles.text}>{text}</div>
<div
className={styles.icon}
onClick={() => setPut(!put)}
style={{ transform: `rotate(${put ? 0 : 180}deg)` }}
>
<DownOutlined />
</div>
</div>
<div className={styles.mapBox} style={{ height: put ? '208px' : '0px' }}>
<ArcGISSceneMap
getMapInfo={getMapInfo}
widgets={[]}
token={token}
client={token ? client : 'sandbox'}
/>
</div>
</div>
</div>
)
}
return (
<div>
{
!disabled ?
<Input
disabled={disabled}
placeholder={disabled ? (placeholder || '') : (placeholder || '点击绘制区域')}
value={isJson(value) ? '已绘制' : ''}
addonAfter={disabled ? null : <CompassOutlined style={{ color: 'rgba(0, 0, 0, 0.25)' }} onClick={showMap} />}
style={{ width: '100%' }}
onClick={showMap}
/>
:
<Button
icon={<CompassOutlined style={{ color: value ? '#0092fe' : 'rgba(0, 0, 0, 0.25)' }} />}
onClick={() => {
if (value) {
showMap()
}
}}
>
{value ? '查看区域' : '无区域信息'}
</Button>
}
<Drag
width={'80%'}
title="选取坐标"
visible={visible}
onOk={onOk}
onCancel={onCancel}
cancelText={'取消'}
okText={'确定'}
bodyStyle={{ height: 600, overflowY: "auto", position: 'relative' }}
destroyOnClose={true}
{...disabled ? { footer: null } : {}}
>
<div style={{ height: '90%' }}>
<Button
style={{ position: 'absolute', zIndex: '99', right: '120px', top: '10px' }}
type='primary'
onClick={start}
>
开始绘制
</Button>
<Button
style={{ position: 'absolute', zIndex: '99', right: '10px', top: '10px' }}
type='primary'
danger
onClick={clear}
>
清除绘制
</Button>
<ArcGISSceneMap
getMapInfo={getView}
widgets={[]}
token={token}
client={token ? client : 'sandbox'}
/>
</div>
</Drag>
</div >
)
}
export default DrawMap
\ No newline at end of file
.drawAreaShot {
width: 100%;
border: 1px solid #ccc;
.content {
width: 100%;
.top {
padding: 0 10px;
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
height: 40px;
color: #727272;
.icon {
transition: all 0.5s ease-in-out;
&:hover {
cursor: pointer;
}
}
}
.mapBox {
position: relative;
width: 100%;
height: 208px;
overflow: hidden;
transition: all 0.5s ease-in-out;
}
}
}
\ No newline at end of file
...@@ -25,7 +25,8 @@ import TimeInterval from "./TimeInterval"; ...@@ -25,7 +25,8 @@ import TimeInterval from "./TimeInterval";
import DeviceType from "./DeviceType"; import DeviceType from "./DeviceType";
import OptionRender from "./OptionRender"; import OptionRender from "./OptionRender";
import StatusOption from "./StatusOption"; import StatusOption from "./StatusOption";
import DrawMap from './DrawMap'
import DataSelect from './DataSelect'
const groupSource = { const groupSource = {
Dictionary, Dictionary,
AccountName, AccountName,
...@@ -53,7 +54,9 @@ const groupSource = { ...@@ -53,7 +54,9 @@ const groupSource = {
TimeInterval, TimeInterval,
DeviceType, DeviceType,
OptionRender, OptionRender,
StatusOption StatusOption,
DrawMap,
DataSelect
} }
export default groupSource export default groupSource
...@@ -7,7 +7,6 @@ const TextArea = (props) => { ...@@ -7,7 +7,6 @@ const TextArea = (props) => {
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
const { disabled, placeholder, presetValue, maxLength, rows, otherValue } = schema const { disabled, placeholder, presetValue, maxLength, rows, otherValue } = schema
console.log(props, 'asdasdasdasd')
useEffect(() => { useEffect(() => {
if (addons) { if (addons) {
......
...@@ -29,7 +29,6 @@ const debounce = (fn) => { ...@@ -29,7 +29,6 @@ const debounce = (fn) => {
} }
const TextInput = (props) => { const TextInput = (props) => {
const preview = sessionStorage.getItem('FormRender') const preview = sessionStorage.getItem('FormRender')
const userInfo = preview === 'preview' ? initUserInfo : window?.globalConfig?.userInfo || initUserInfo const userInfo = preview === 'preview' ? initUserInfo : window?.globalConfig?.userInfo || initUserInfo
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
...@@ -108,7 +107,7 @@ const TextInput = (props) => { ...@@ -108,7 +107,7 @@ const TextInput = (props) => {
} }
} }
//编辑状态下需要被覆盖 //编辑状态下需要被覆盖
if (loaclPaths.includes(textDefalut) && !disabled) { if (loaclPaths.includes(textDefalut) && !disabled && !presetValue) {
valueNext = getValueNext() valueNext = getValueNext()
} }
addons.setValue(addons.dataPath, valueNext || '') addons.setValue(addons.dataPath, valueNext || '')
...@@ -150,7 +149,7 @@ const TextInput = (props) => { ...@@ -150,7 +149,7 @@ const TextInput = (props) => {
}, [uniqueVerify, tableName, fieldName]) }, [uniqueVerify, tableName, fieldName])
useEffect(() => { useEffect(() => {
if (otherValue) { if (otherValue || (!otherValue && otherValue !== showValue)) {
setShowValue(otherValue) setShowValue(otherValue)
onChange(otherValue) onChange(otherValue)
} }
......
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