diff --git a/src/components/BuildingTable/config/house-config.js b/src/components/BuildingTable/config/house-config.js
index 09f9575..186c260 100644
--- a/src/components/BuildingTable/config/house-config.js
+++ b/src/components/BuildingTable/config/house-config.js
@@ -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 = () => {
@@ -71,7 +71,7 @@ const houseConfig = {
return (
-
{houseName}
+ {houseNo}
{renderBlock()}
diff --git a/src/components/BuildingTable/core/builders/base-builder.js b/src/components/BuildingTable/core/builders/base-builder.js
index 88170e7..f2c8ad1 100644
--- a/src/components/BuildingTable/core/builders/base-builder.js
+++ b/src/components/BuildingTable/core/builders/base-builder.js
@@ -1,3 +1,5 @@
+import { val } from '../../utils'
+
/**
* 生成逻辑幢数据
* @param {Object} options
@@ -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 || [] // 字段显示信息
}
@@ -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)
}
}
diff --git a/src/components/BuildingTable/core/builders/flex-builder.js b/src/components/BuildingTable/core/builders/flex-builder.js
index 64ecba1..f306af7 100644
--- a/src/components/BuildingTable/core/builders/flex-builder.js
+++ b/src/components/BuildingTable/core/builders/flex-builder.js
@@ -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
diff --git a/src/components/BuildingTable/core/builders/table-builder.js b/src/components/BuildingTable/core/builders/table-builder.js
index d582c00..98ab1b3 100644
--- a/src/components/BuildingTable/core/builders/table-builder.js
+++ b/src/components/BuildingTable/core/builders/table-builder.js
@@ -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
})
}
diff --git a/src/components/BuildingTable/utils/index.js b/src/components/BuildingTable/utils/index.js
index 5dd5b8c..d40deb3 100644
--- a/src/components/BuildingTable/utils/index.js
+++ b/src/components/BuildingTable/utils/index.js
@@ -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]]
@@ -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
+}
\ No newline at end of file