Commit 0e96e576 authored by 前端-黄佳鑫's avatar 前端-黄佳鑫

fix: 采购能力-待新增招标/待新增商城招标下适用地市应该为非必填

parent 56d32757
......@@ -34,14 +34,14 @@ width: 100%;
}
`
const { Option } = Select
const { Option } = Select
const MultAddress = (props) => {
const { value: _v, mutators } = props
const {
placeholder = [],
warningText = intl.formatMessage({id: 'components.qingwanshanxiangguanxinxi'}),
warningText = intl.formatMessage({ id: 'components.qingwanshanxiangguanxinxi' }),
onlyShowText = false,
...rest
} = props.props["x-component-props"] || {}
......@@ -51,9 +51,9 @@ const MultAddress = (props) => {
// 处理表单提交置空触发错误角标提示
let value = null
if(!_v || !_v.length) {
if (!_v || !_v.length) {
value = [{ provinceCode: null, province: null, cityCode: null, city: null }]
} else if(value?.length && !value[0]['provinceCode'] && !value[0]['province'] && !value[0]['cityCode'] && !value[0]['city']) {
} else if (value?.length && !value[0]['provinceCode'] && !value[0]['province'] && !value[0]['cityCode'] && !value[0]['city']) {
mutators.change([])
} else {
value = _v
......@@ -67,14 +67,23 @@ const MultAddress = (props) => {
useEffect(() => {
getManageAreaAll().then(res => {
if (res.code === 1000) {
setprovince(res.data)
const tempProvinceData = []
tempProvinceData.push({
code: '0',
name: intl.formatMessage({ id: 'components.suoyou' }),
pcode: '0',
})
for (const item of res.data) {
tempProvinceData.push({ ...item })
}
setprovince(tempProvinceData)
}
})
}, [])
useEffect(() => {
value.forEach((item , index) => {
if(item.provinceCode) {
value.forEach((item, index) => {
if (item.provinceCode) {
renderProvice([...value], item['provinceCode'], index).then(() => {
renderCity([...value], item['cityCode'], index)
})
......@@ -83,8 +92,8 @@ const MultAddress = (props) => {
}, [province])
useEffect(() => {
if(flag.current && value[0]['provinceCode']) {
value.forEach((item , index) => {
if (flag.current && value[0]['provinceCode']) {
value.forEach((item, index) => {
renderProvice([...value], item['provinceCode'], index).then(() => {
renderCity([...value], item['cityCode'], index)
})
......@@ -108,11 +117,11 @@ const MultAddress = (props) => {
setcode([...cityCode]);
if (num === 1) {
// @ 省份切换 清空之前选的市
result[idx]['city'] = null
result[idx]['cityCode'] = null
result[idx]['cityName'] = null
result[idx]['city'] = intl.formatMessage({ id: 'components.suoyou' })
result[idx]['cityCode'] = '0'
result[idx]['cityName'] = intl.formatMessage({ id: 'components.suoyou' })
renderProvice(result, val, idx)
} else if(num === 2) {
} else if (num === 2) {
renderCity(result, val, idx)
}
mutators.change(result)
......@@ -127,7 +136,28 @@ const MultAddress = (props) => {
if (res.code === 1000) {
result[idx].provinceCode = val;
result[idx].province = item.name;
city[idx] = { citydata: res.data }
if (val === '0') {
city[idx] = {
citydata: [{
code: '0',
name: intl.formatMessage({ id: 'components.suoyou' }),
pcode: '0',
}]
}
} else {
const tempCityList = []
tempCityList.push({
code: '0',
name: intl.formatMessage({ id: 'components.suoyou' }),
pcode: '0',
})
for (const cityItem of res.data) {
tempCityList.push({ ...cityItem })
}
city[idx] = {
citydata: tempCityList
}
}
setcity([...city])
}
})
......@@ -186,30 +216,30 @@ const MultAddress = (props) => {
// 删除一条地址
const removeAddress = (idx: any) => {
const requisitionFormAddressFilter = value.filter((item: any, index: number) => index !== idx)
const cityFilter = city.filter((item: any, index: number) => index !== idx)
requisitionFormAddressFilter.forEach((item: any, index: number) => {
const cityCode = code.find(it => item.cityCode);
if (cityCode !== item.cityCode) {
item.disabled = false
}
})
setcity(cityFilter)
mutators.change(requisitionFormAddressFilter)
const requisitionFormAddressFilter = value.filter((item: any, index: number) => index !== idx)
const cityFilter = city.filter((item: any, index: number) => index !== idx)
requisitionFormAddressFilter.forEach((item: any, index: number) => {
const cityCode = code.find(it => item.cityCode);
if (cityCode !== item.cityCode) {
item.disabled = false
}
})
setcity(cityFilter)
mutators.change(requisitionFormAddressFilter)
}
const _renderAreas = (item: any, idx: number) => {
if(onlyShowText){
if (onlyShowText) {
return (
<div key={`paramAddress${idx}_`}>{item.province}/{item.city}</div>
)
}else{
} else {
return (
<Row gutter={10} key={`paramAddress${idx}_`} className="formwrap">
<Col span={12}>
<Form.Item>
<Select
placeholder={intl.formatMessage({id: 'components.qingxuanze'})}
placeholder={intl.formatMessage({ id: 'components.qingxuanze' })}
onDropdownVisibleChange={onDropdownVisibleChange}
onChange={(value) => {
changeAddress(value, idx, 1)
......@@ -228,7 +258,7 @@ const MultAddress = (props) => {
<Col span={12}>
<Form.Item>
<Select
placeholder={intl.formatMessage({id: 'components.qingxuanze'})}
placeholder={intl.formatMessage({ id: 'components.qingxuanze' })}
onDropdownVisibleChange={onDropdownVisibleChange}
onChange={(value) => {
changeAddress(value, idx, 2)
......@@ -244,11 +274,11 @@ const MultAddress = (props) => {
</Select>
</Form.Item>
</Col>
{ !readOnly ? <div className="formbutton">
{!readOnly ? <div className="formbutton">
{
(idx === value.length - 1) &&
<Form.Item>
<Button style={{marginRight: 16}} type='primary' onClick={() => addAddress(idx)}><PlusOutlined /></Button>
<Button style={{ marginRight: 16 }} type='primary' onClick={() => addAddress(idx)}><PlusOutlined /></Button>
</Form.Item>
}
{
......@@ -257,7 +287,7 @@ const MultAddress = (props) => {
<Button onClick={() => removeAddress(idx)}><MinusOutlined /></Button>
</Form.Item>
}
</div> : null }
</div> : null}
</Row>
)
}
......
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