refactor: 代码规范、Bug修复

This commit is contained in:
2025-09-26 09:10:37 +08:00
parent 3610f8f7db
commit dcc288acc4
572 changed files with 41415 additions and 44746 deletions
@@ -1,76 +1,83 @@
<template>
<el-cascader
v-model="value"
:disabled="disabled"
:options="deptOptions"
style="width: 100%"
@change="handleChange"
/>
</template>
<script>
import { queryDeptSelectProDataSource } from '@/api/system/component'
import CsMessage from '@/utils/elementui/CsMessage'
export default {
name: 'CuteProductLineSelectPro',
props: {
value: {
type: Array,
default: null
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
deptOptions: [],
selectedValue: this.value
}
},
watch: {
value(newVal) {
this.selectedValue = newVal
}
},
created() {
this.fetchDeptData()
},
methods: {
// 递归清理空的children属性
cleanEmptyChildren(data) {
return data.map(item => {
const newItem = { ...item }
if (newItem.children && newItem.children.length > 0) {
// 递归处理子节点
newItem.children = this.cleanEmptyChildren(newItem.children)
} else {
// 删除空的children属性
delete newItem.children
}
return newItem
})
},
fetchDeptData() {
queryDeptSelectProDataSource().then(data => {
this.deptOptions = this.cleanEmptyChildren(data)
console.error('deptOptions', this.deptOptions)
}).catch(error => {
console.error('获取部门数据失败:', error)
CsMessage.Error('获取部门数据失败')
})
},
handleChange(value) {
this.selectedValue = value
// 绑定change事件
this.$emit('change', value)
// 绑定form value
this.$emit('input', value)
}
}
}
</script>
<!--
* 产品线级联选择组件
* @author odboy
* @email tianjun@odboy.cn
* @created 2025-08-01
-->
<template>
<el-cascader
v-model="productLine"
:disabled="disabled"
:options="deptOptions"
style="width: 100%"
@change="handleChange"
/>
</template>
<script>
import { queryDeptSelectProDataSource } from '@/api/system/component'
import CsMessage from '@/utils/elementui/CsMessage'
export default {
name: 'CuteProductLineSelectPro',
props: {
value: {
type: Array,
default: null
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
deptOptions: [],
productLine: this.value
}
},
watch: {
value(newVal) {
this.productLine = newVal
}
},
created() {
this.fetchDeptData()
},
methods: {
// 递归清理空的children属性
cleanEmptyChildren(data) {
return data.map(item => {
const newItem = { ...item }
if (newItem.children && newItem.children.length > 0) {
// 递归处理子节点
newItem.children = this.cleanEmptyChildren(newItem.children)
} else {
// 删除空的children属性
delete newItem.children
}
return newItem
})
},
fetchDeptData() {
queryDeptSelectProDataSource().then(data => {
this.deptOptions = this.cleanEmptyChildren(data)
// console.error('deptOptions', this.deptOptions)
}).catch(error => {
console.error('获取部门数据失败:', error)
CsMessage.Error('获取部门数据失败')
})
},
handleChange(value) {
this.productLine = value
// console.error('value', value)
// 绑定change事件
this.$emit('change', value)
// 绑定form value
this.$emit('input', value)
}
}
}
</script>