Commit 2832b019 authored by 田翔's avatar 田翔

fix: 城市选择器bug,数据源弹出层修改展示名称

parent 4d75c339
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "2.7.8", "version": "2.7.9",
"description": "2.7.8: 改变地图引用模式", "description": "2.7.9: 城市选择器bug,数据源弹出层修改展示名称",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -14,62 +14,9 @@ const CascadeSelector = (props) => { ...@@ -14,62 +14,9 @@ const CascadeSelector = (props) => {
return [] return []
}, [sourceType]) }, [sourceType])
const getDefaultValue = selectedValues => {
if (!selectedValues || !selectedValues.length) {
return []
}
const result = [];
// 递归查询城市名称数据
function findLabel(children) {
children.forEach(item => {
const { label, value, children } = item;
if (selectedValues.includes(label)) {
result.push(value);
}
if (children && children.length) {
findLabel(children);
}
});
}
// 卡省份解决县或市名称一样的问题
city.forEach(item => {
const { label, value, children } = item;
if (selectedValues.includes(label)) {
result.push(value);
if (children && children.length) {
findLabel(children);
}
}
});
// 设置默认值
return result;
}
const cascaderChange = (selectedValues) => { const cascaderChange = (selectedValues) => {
if (addons) { if (addons) {
if (!selectedValues) { onChange(selectedValues.join('/'))
return onChange('')
}
const result = []
// 递归查询城市所有数据
function findCityData(city) {
city.forEach(item => {
const { id, label, value, children } = item;
if (selectedValues.includes(value)) {
result.push({ id, label, value })
if (children && children.length) {
findCityData(children)
}
}
})
}
findCityData(city)
// 分发监听
const cityValue = result.map(v => v.label)
onChange(cityValue.join('/'))
} }
} }
...@@ -81,7 +28,8 @@ const CascadeSelector = (props) => { ...@@ -81,7 +28,8 @@ const CascadeSelector = (props) => {
<Cascader <Cascader
allowClear allowClear
placeholder={placeholder} placeholder={placeholder}
value={value ? getDefaultValue(value) : []} fieldNames={{ label: 'label', value: 'label', children: 'children' }}
value={value ? value.split('/') : []}
onChange={cascaderChange} onChange={cascaderChange}
disabled={disabled} disabled={disabled}
style={{ width: '100%' }} style={{ width: '100%' }}
......
...@@ -68,6 +68,11 @@ const FieldNames = (props) => { ...@@ -68,6 +68,11 @@ const FieldNames = (props) => {
const onOk = () => { const onOk = () => {
onChange(radioValue) onChange(radioValue)
if (widget !== 'RelationForm') {
addons.setValueByPath('title', radioValue)
} else {
addons.setValueByPath('titleShow', radioValue)
}
setVisible(false) setVisible(false)
} }
...@@ -126,7 +131,7 @@ const FieldNames = (props) => { ...@@ -126,7 +131,7 @@ const FieldNames = (props) => {
options.map(v => { options.map(v => {
if (!v.widget) { if (!v.widget) {
return ( return (
<Col span={8} style={{ marginTop: '10px' }}> <Col key={v.name} span={8} style={{ marginTop: '10px' }}>
<Radio key={v.name} value={v.name}>{v.name}</Radio> <Radio key={v.name} value={v.name}>{v.name}</Radio>
</Col> </Col>
) )
...@@ -143,7 +148,7 @@ const FieldNames = (props) => { ...@@ -143,7 +148,7 @@ const FieldNames = (props) => {
options.map(v => { options.map(v => {
if (v.widget) { if (v.widget) {
return ( return (
<Col span={8} style={{ marginTop: '15px', display: 'flex', justifyContent: 'space-between' }}> <Col span={8} key={v.name} style={{ marginTop: '15px', display: 'flex', justifyContent: 'space-between' }}>
<Radio disabled key={v.name} value={v.name}> <Radio disabled key={v.name} value={v.name}>
{v.name} {v.name}
</Radio> </Radio>
......
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