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 class GetHouseCodeOutput
{ {
public string Id { get; set; } public string Id { get; set; }
public string HouseCode { get; set; }
public int Type { get; set; } public int Type { get; set; }
public int Industry { get; set; } public int Industry { get; set; }
public string AreaCode { get; set; } public string AreaCode { get; set; }

View File

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

View File

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

View File

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