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

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

parent 4d75c339
{
"name": "panda-xform",
"version": "2.7.8",
"description": "2.7.8: 改变地图引用模式",
"version": "2.7.9",
"description": "2.7.9: 城市选择器bug,数据源弹出层修改展示名称",
"keywords": [
"panda-xform"
],
......
......@@ -14,62 +14,9 @@ const CascadeSelector = (props) => {
return []
}, [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) => {
if (addons) {
if (!selectedValues) {
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('/'))
onChange(selectedValues.join('/'))
}
}
......@@ -81,7 +28,8 @@ const CascadeSelector = (props) => {
<Cascader
allowClear
placeholder={placeholder}
value={value ? getDefaultValue(value) : []}
fieldNames={{ label: 'label', value: 'label', children: 'children' }}
value={value ? value.split('/') : []}
onChange={cascaderChange}
disabled={disabled}
style={{ width: '100%' }}
......
......@@ -68,6 +68,11 @@ const FieldNames = (props) => {
const onOk = () => {
onChange(radioValue)
if (widget !== 'RelationForm') {
addons.setValueByPath('title', radioValue)
} else {
addons.setValueByPath('titleShow', radioValue)
}
setVisible(false)
}
......@@ -126,7 +131,7 @@ const FieldNames = (props) => {
options.map(v => {
if (!v.widget) {
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>
</Col>
)
......@@ -143,7 +148,7 @@ const FieldNames = (props) => {
options.map(v => {
if (v.widget) {
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}>
{v.name}
</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