fix(components): 修复组件中的空值处理和命名规范问题

This commit is contained in:
2026-02-05 15:13:36 +08:00
parent b727302781
commit 34ea875550
6 changed files with 15 additions and 13 deletions
@@ -74,8 +74,8 @@ export default {
// 绑定node-click事件
this.$emit('node-click', value)
// 绑定form value
this.$emit('change', value.id)
this.$emit('input', value.id)
this.$emit('change', value ? value.id : null)
this.$emit('input', value ? value.id : null)
},
resetField() {
this.$refs.deptTree.setCurrentNode(null)
@@ -61,7 +61,7 @@ export default {
let isLt2M = true
isLt2M = file.size / 1024 ** 2 < 100
if (!isLt2M) {
this.$message.error('上传文件大小不能超过 100MB')
KitMessage.Error('上传文件大小不能超过 100MB')
return false
}
return isLt2M
@@ -59,7 +59,7 @@ export default {
let isLt2M = true
isLt2M = file.size / 1024 ** 2 < 100
if (!isLt2M) {
this.$message.error('上传文件大小不能超过 100MB')
KitMessage.Error('上传文件大小不能超过 100MB')
return false
}
return isLt2M
@@ -15,7 +15,7 @@
@change="handleChange"
>
<el-option
v-for="item in deptOptions"
v-for="item in productLineOptions"
:key="item.value"
:label="item.label"
:value="item.value"
@@ -44,7 +44,7 @@ export default {
},
data() {
return {
deptOptions: [],
productLineOptions: [],
innerValue: this.value
}
},
@@ -59,7 +59,7 @@ export default {
methods: {
fetchDeptData() {
listMetadata().then(data => {
this.deptOptions = data
this.productLineOptions = data
}).catch(error => {
console.error('获取部门数据失败:', error)
KitMessage.Error('获取部门数据失败')
@@ -67,7 +67,7 @@ export default {
},
handleChange(value) {
this.innerValue = value
for (const item of this.deptOptions) {
for (const item of this.productLineOptions) {
if (item.value === value) {
this.$emit('detail', item)
break
@@ -8,7 +8,7 @@
<el-cascader
v-model="innerValue"
:disabled="disabled"
:options="deptOptions"
:options="productLineOptions"
style="width: 100%"
placeholder="请选择产品线"
@change="handleChange"
@@ -36,7 +36,7 @@ export default {
},
data() {
return {
deptOptions: [],
productLineOptions: [],
innerValue: this.value
}
},
@@ -51,6 +51,9 @@ export default {
methods: {
// 递归清理空的children属性
cleanEmptyChildren(data) {
if (!data || !Array.isArray(data)) {
return []
}
return data.map(item => {
const newItem = { ...item }
if (newItem.children && newItem.children.length > 0) {
@@ -65,8 +68,7 @@ export default {
},
fetchDeptData() {
listMetadata().then(data => {
this.deptOptions = this.cleanEmptyChildren(data)
// console.error('deptOptions', this.deptOptions)
this.productLineOptions = this.cleanEmptyChildren(data)
}).catch(error => {
console.error('获取部门数据失败:', error)
KitMessage.Error('获取部门数据失败')
@@ -41,7 +41,7 @@ export default {
},
data() {
return {
innerValue: [],
innerValue: null,
loading: false,
options: []
}