Skip to content

Commit

Permalink
修复楼盘表单元显示错误的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
qq10137383 committed Jun 21, 2023
1 parent b00197f commit c094d6a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/components/BuildingTable/config/house-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const houseConfig = {
// 房屋单元格默认渲染函数
render: function (h, { definition, houseInfo }) {
const { className, houseStyle, showBlock, includeFields, excludeFields, showSymbol, symbolColumn, simple, showTitle } = definition
const { houseName, blocks, symbols, customClasses = [] } = houseInfo
const { houseNo, houseName, blocks, symbols, customClasses = [] } = houseInfo
const root = getBuildingTable(this)

const renderBlock = () => {
Expand Down Expand Up @@ -71,7 +71,7 @@ const houseConfig = {
return (
<div class={['house-cell-wrap', className, ...customClasses]} style={houseStyle}>
<div class='house-cell__block'>
<h4 class='house-cell__block-title' on-click={clickTitle}>{houseName}</h4>
<h4 class='house-cell__block-title' on-click={clickTitle} title={houseName}>{houseNo}</h4>
{renderBlock()}
</div>
<div class='house-cell__symbol'>
Expand Down
16 changes: 9 additions & 7 deletions src/components/BuildingTable/core/builders/base-builder.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { val } from '../../utils'

/**
* 生成逻辑幢数据
* @param {Object} options
Expand Down Expand Up @@ -25,15 +27,15 @@ export default class BaseBuilder {
// 房屋数据兼容处理
transformHouse(house) {
house.houseName = house.houseName || house.houseNo || '' // 房屋名称
house.unitOrder = Number(house.unitOrder || 1) // 单元序号
house.unitName = house.unitName || `${house.unitOrder}单元` // 单元名称
house.minAtLayer = Number(house.minAtLayer || 1) // 起始楼层
house.layerName = house.layerName || `${house.minAtLayer}` // 楼层名称
house.unitOrder = Number(val(house, 'unitOrder', 1)) // 单元序号
house.unitName = val(house, 'unitName', '') // 单元名称
house.minAtLayer = Number(val(house, 'minAtLayer', 1)) // 起始楼层
house.layerName = house.layerName || `${house.minAtLayer}` // 楼层名称
house.layerCount = Number(house.layerCount || 1) // 占有楼层数(纵向)
house.columnCount = Number(house.columnCount || 1) // 占用房间数(横向)
house.order = Number(house.order || 1) // 排序号
house.isEnabled = Boolean('isEnabled' in house ? house.isEnabled : true) // 是否可操作
house.isSelected = Boolean('isSelected' in house ? house.isSelected : false) // 是否已选中
house.isEnabled = Boolean(val(house, 'isEnabled', true)) // 是否可操作
house.isSelected = Boolean(val(house, 'isSelected', false)) // 是否已选中
house.symbols = house.symbols || [] // 色块符号信息
house.blocks = house.blocks || [] // 字段显示信息
}
Expand Down Expand Up @@ -79,7 +81,7 @@ export default class BaseBuilder {
for (let i = 0; i < layerCount; i++) {
// 处理楼层为负数的(地下室),跳过0层
layer = minAtLayer - i
layer = layer === 0 ? layer - 1: layer
layer = layer === 0 ? layer - 1 : layer
fn(layer, minAtLayer, layerCount)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/BuildingTable/core/builders/flex-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class FlexBuilder extends BaseBuilder {
for (const layer of houseList) {
layer.forEach((unit) => {
unit.sort((m, n) => this.compareHouse(m, n))
unit.forEach((house, index) => (house._columnIndex = index))
unit.forEach((house, index) => (house && (house._columnIndex = index)))
})
}
return houseList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class TableBuilder extends BaseBuilder {
}
// 单元内房屋排序,增加列索引信息
unit.sort((m, n) => this.compareHouse(m, n))
unit.forEach((house, index) => (house._columnIndex = index))
unit.forEach((house, index) => (house && (house._columnIndex = index)))
delete unit._houseCount
})
}
Expand Down
13 changes: 12 additions & 1 deletion src/components/BuildingTable/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function parsePath(path) {
return
}
const segments = path.split('.')
return function(obj) {
return function (obj) {
for (var i = 0; i < segments.length; i++) {
if (!obj) return
obj = obj[segments[i]]
Expand Down Expand Up @@ -107,3 +107,14 @@ export function getBuildingTable(vm) {
return getBuildingTable(vm.$parent)
}
}

/**
* 获取属性值
* @param {Object} obj
* @param {String} key
* @param {any} defaultValue
* @returns
*/
export function val(obj, key, defaultValue) {
return key in obj ? obj[key] : defaultValue
}

0 comments on commit c094d6a

Please sign in to comment.