|
|
|
|
@ -31,7 +31,8 @@ |
|
|
|
|
|
|
|
|
|
<div class="form-box"> |
|
|
|
|
<div v-if="isComponentOpen"> |
|
|
|
|
<div class="form-bom" ref="lineChart"></div> |
|
|
|
|
<div v-if="dataTree.length > 0" class="form-bom" ref="lineChart"></div> |
|
|
|
|
<el-empty v-else description="数据为空"></el-empty> |
|
|
|
|
</div> |
|
|
|
|
<div v-if="isSubOpen"> |
|
|
|
|
<avue-crud |
|
|
|
|
@ -163,6 +164,7 @@ export default { |
|
|
|
|
isSubOpen: false, |
|
|
|
|
isComponentOpen: false, |
|
|
|
|
data: [], |
|
|
|
|
dataTree: [], |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
@ -190,6 +192,7 @@ export default { |
|
|
|
|
this.isSubOpen = false; |
|
|
|
|
getDsPartTree({ partCode: this.form.bujian, zPartCode: this.form.zijian }).then(res => { |
|
|
|
|
let resData = res.data.data; |
|
|
|
|
this.dataTree = res.data.data; |
|
|
|
|
let arr = JSON.parse(JSON.stringify(resData).replace(/partName/g, 'name')); |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
this.createBarChart(arr); |
|
|
|
|
@ -201,8 +204,6 @@ export default { |
|
|
|
|
this.isComponentOpen = false; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 获取组织树 |
|
|
|
|
|
|
|
|
|
// 获取子件列表 |
|
|
|
|
|
|
|
|
|
resetFn() { |
|
|
|
|
@ -240,6 +241,7 @@ export default { |
|
|
|
|
borderWidth: 2, |
|
|
|
|
borderColor: '#fff', |
|
|
|
|
borderRadius: 4, // 圆角半径,值越大圆角越明显 |
|
|
|
|
paddingLeft: 10, |
|
|
|
|
}, |
|
|
|
|
// 动态计算节点大小:宽度=最长文本宽度,高度=行数*行高+内边距 |
|
|
|
|
symbolSize: (val, params) => { |
|
|
|
|
@ -247,9 +249,18 @@ export default { |
|
|
|
|
const nodeName = params?.name || '未知节点'; |
|
|
|
|
const childCount = params?.children?.length || 0; |
|
|
|
|
const childText = `${childCount}个子件`; |
|
|
|
|
const nodeQuota = nodeData?.quota !== undefined ? nodeData.quota : ''; |
|
|
|
|
|
|
|
|
|
// 计算文本宽度 |
|
|
|
|
const textWidth = Math.max(nodeName.length * 12, childText.length * 12) + 30; |
|
|
|
|
return [Math.max(textWidth, 100), 60]; // 高度设为60px(适配两行文本) |
|
|
|
|
// 动态计算行数 |
|
|
|
|
let lineCount = 2; // 默认 2 行(partCode + name) |
|
|
|
|
if (nodeQuota !== '' && nodeQuota !== null) { |
|
|
|
|
lineCount = 3; // 有 quota 时 3 行 |
|
|
|
|
} |
|
|
|
|
// 计算高度:每行 20px + 上下内边距 20px |
|
|
|
|
const height = lineCount * 20 + 10; |
|
|
|
|
return [Math.max(textWidth, 100), height]; // 高度设为60px(适配两行文本) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
label: { |
|
|
|
|
|