update housecode

This commit is contained in:
2021-06-24 18:15:58 +08:00
parent 64bb1c3352
commit 5bf0cb5a12
4 changed files with 50 additions and 21 deletions

View File

@@ -29,6 +29,7 @@ namespace Ewide.Application
public class GetHouseCodeOutput
{
public string Id { get; set; }
public string HouseCode { get; set; }
public int Type { get; set; }
public int Industry { get; set; }
public string AreaCode { get; set; }

View File

@@ -36,6 +36,8 @@ export default class index extends Component {
loading: false,
})
})
} else {
this.setState({ loading: false })
}
}

View File

@@ -19,6 +19,7 @@ import { cloneDeep, isEqual } from 'lodash'
import getDictData from 'util/dic'
import { api } from 'common/api'
import { CITY } from 'util/global'
import auth from 'components/authorized/handler'
const initialValues = {
type: 1,
@@ -85,6 +86,8 @@ export default class form extends Component {
//#region 从后端转换成前段所需格式
await this.initMap()
const options = { ...this.state.options }
const { data: areaTree } = await api.getAreaTree()
options.areaTree = areaTree
// 有数据
if (this.record) {
const { type, areaCode } = this.record
@@ -95,6 +98,16 @@ export default class form extends Component {
areaCode.substr(0, 9),
areaCode,
]
switch (areaTree[0].adCode.length) {
case 6:
this.record.areaCode = this.record.areaCode.slice(1)
break
case 9:
this.record.areaCode = this.record.areaCode.slice(2)
break
default:
break
}
// 获取项目和片区列表
const data = await this.getProjectsAndZones({
areaCode: this.record.areaCode,
@@ -107,12 +120,12 @@ export default class form extends Component {
this.map.setCenter(position)
}
const codes = await getDictData('house_type', 'house_industry')
const { data: areaTree } = await api.getAreaTree()
options.areaTree = areaTree
this.setState({
codes,
options,
})
this.showHouseCode()
//#endregion
this.form.current.setFieldsValue(this.record)
@@ -136,7 +149,7 @@ export default class form extends Component {
const postData = form.getFieldsValue()
//#region 从前段转换后端所需格式
if (postData.areaCode) {
postData.areaCode = postData.areaCode[3]
postData.areaCode = postData.areaCode[postData.areaCode.length - 1]
}
//#endregion
return postData
@@ -282,21 +295,22 @@ export default class form extends Component {
type = value.type
}
if (!(areaCode && areaCode.length === 4)) return null
if (!(areaCode && areaCode.length > 0 && areaCode[areaCode.length - 1].length === 12))
return null
try {
const result = {}
if (mode.includes('projects')) {
const { data: projects } = await api.houseProjectList({
areaCode: areaCode[3],
areaCode: areaCode[areaCode.length - 1],
type,
})
result.projects = projects
}
if (mode.includes('zones')) {
const { data: zones } = await api.houseZoneList({
areaCode: areaCode[3],
areaCode: areaCode[areaCode.length - 1],
})
result.zones = zones
}
@@ -323,8 +337,14 @@ export default class form extends Component {
})
} else if (values) {
const { type, industry, areaCode, projectId, no } = values
if (areaCode && areaCode.length === 4 && projectId && no) {
let houseCode = areaCode[3]
if (
areaCode &&
areaCode.length > 0 &&
areaCode[areaCode.length - 1].length === 12 &&
projectId &&
no
) {
let houseCode = areaCode[areaCode.length - 1]
const projectSort = this.state.options.projects.find(p => p.id === projectId).sort
houseCode += projectSort.toString().padStart(3, '0')
houseCode += no.toString().padStart(3, '0')
@@ -368,17 +388,20 @@ export default class form extends Component {
// 所属区域
else if (changedValues.hasOwnProperty('areaCode')) {
this.setState({ loading: true })
const data = await this.getProjectsAndZones()
form.setFieldsValue({ projectId: undefined, zoneId: undefined })
this.setState({
options: {
...this.state.options,
...data,
},
loading: false,
})
this.showHouseCode(form.getFieldsValue())
const flag = auth({ houseCode: 'getNextNoByCode' })
if (flag) {
this.setState({ loading: true })
const data = await this.getProjectsAndZones()
form.setFieldsValue({ projectId: undefined, zoneId: undefined })
this.setState({
options: {
...this.state.options,
...data,
},
loading: false,
})
this.showHouseCode(form.getFieldsValue())
}
}
// 所属项目
@@ -474,7 +497,10 @@ export default class form extends Component {
<Form.Item
name="areaCode"
rules={[
{ required: true, message: '请选择房屋所在区域' },
{
required: true,
message: '请选择房屋所在区域',
},
]}
>
<Cascader

View File

@@ -211,7 +211,7 @@ export default class index extends Component {
.padStart(3, '0')}`,
path,
param: {
id: record.id,
id: record && record.id,
},
})
// modal.current.open({