|
|
@ -111,13 +111,12 @@ |
|
|
|
@click="saveCategory" |
|
|
|
>保存</el-button> |
|
|
|
</div> |
|
|
|
<!-- :data="menus" @check="menuChange" :default-checked-keys="categoryIds"--> |
|
|
|
<!-- :load="getCategoryDataList" @check="menuChange" :default-checked-keys="categoryIds"--> |
|
|
|
<el-tree |
|
|
|
ref="category" |
|
|
|
lazy |
|
|
|
:data="categoryDatas" |
|
|
|
:load="getCategoryDataList" |
|
|
|
:default-checked-keys="categoryIds" |
|
|
|
default-expand-all |
|
|
|
show-checkbox |
|
|
|
node-key="id" |
|
|
|
highlight-current |
|
|
@ -132,7 +131,8 @@ |
|
|
|
|
|
|
|
<script> |
|
|
|
import crudfonds from '@/api/system/fonds' |
|
|
|
import { FetchCategoryMenuChildren } from '@/api/system/category/category' |
|
|
|
// FetchCategoryMenuChildren |
|
|
|
import { FetchCategoryMenu } from '@/api/system/category/category' |
|
|
|
import CRUD, { presenter, header, form, crud } from '@crud/crud' |
|
|
|
import rrOperation from '@crud/RR.operation' |
|
|
|
import crudOperation from '@crud/CRUD.operation' |
|
|
@ -159,7 +159,7 @@ export default { |
|
|
|
mixins: [presenter(), header(), form(defaultForm), crud()], |
|
|
|
data() { |
|
|
|
return { |
|
|
|
defaultProps: { children: 'children', label: 'cnName', isLeaf: 'leaf' }, |
|
|
|
defaultProps: { children: 'children', label: 'cnName' }, |
|
|
|
currentId: 0, categoryLoading: false, showButton: false, |
|
|
|
categoryDatas: [], categoryIds: [], depts: [], deptDatas: [], // 多选时使用 |
|
|
|
categoryAllData: [], |
|
|
@ -191,7 +191,8 @@ export default { |
|
|
|
], |
|
|
|
blurryTime: null, |
|
|
|
deleteData: [], // 删除选中的data |
|
|
|
chooseNode: null |
|
|
|
chooseNode: null, |
|
|
|
categoryTreeData: [] |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
@ -201,15 +202,32 @@ export default { |
|
|
|
}, |
|
|
|
created() { |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
FetchCategoryMenu().then(res => { |
|
|
|
this.categoryDatas = this.filterData(res) |
|
|
|
}) |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
getCategoryDataList(node, resolve) { |
|
|
|
setTimeout(() => { |
|
|
|
if (node.level > 2) return resolve([]) |
|
|
|
FetchCategoryMenuChildren(node.data.id ? node.data.id : 0).then(res => { |
|
|
|
resolve(res) |
|
|
|
}) |
|
|
|
}, 100) |
|
|
|
// getCategoryDataList(node, resolve) { |
|
|
|
// setTimeout(() => { |
|
|
|
// if (node.level > 2) return resolve([]) |
|
|
|
// FetchCategoryMenuChildren(node.data.id ? node.data.id : 0).then(res => { |
|
|
|
// resolve(res) |
|
|
|
// }) |
|
|
|
// }, 100) |
|
|
|
// }, |
|
|
|
filterData(data) { |
|
|
|
return data.filter(node => { |
|
|
|
this.$set(node, 'isChecked', false) |
|
|
|
if (node.children && node.children.length > 0) { |
|
|
|
node.children = this.filterData(node.children) // 递归处理子节点 |
|
|
|
} |
|
|
|
return node.isType !== 3 // 过滤掉isType为3的节点 |
|
|
|
}) |
|
|
|
}, |
|
|
|
// getCategoryDataList(node, resolve) { |
|
|
|
// resolve(this.categoryTreeData) |
|
|
|
// }, |
|
|
|
[CRUD.HOOK.beforeRefresh]() { |
|
|
|
if (this.blurryTime) { |
|
|
|
this.crud.query.startTime = this.blurryTime[0] |
|
|
@ -240,9 +258,13 @@ export default { |
|
|
|
this.$refs.category.setCheckedKeys([]) |
|
|
|
// 保存当前的角色id |
|
|
|
this.currentId = val.fondsId |
|
|
|
console.log('val', val) |
|
|
|
console.log('this.currentId', this.currentId) |
|
|
|
crudfonds.FetchFondsDetail({ id: this.currentId }).then((res) => { |
|
|
|
console.log(res) |
|
|
|
// 初始化默认选中的key |
|
|
|
this.categoryIds = [] |
|
|
|
console.log(res.categorys) |
|
|
|
if (res.categorys) { |
|
|
|
res.categorys.forEach(function(data) { |
|
|
|
_this.categoryIds.push(data.id) |
|
|
@ -315,36 +337,38 @@ export default { |
|
|
|
}).catch(() => { |
|
|
|
}) |
|
|
|
}, |
|
|
|
categoryChange(categorys) { |
|
|
|
console.log(categorys) |
|
|
|
if (categorys.pid === 0) { |
|
|
|
categorys.isChecked = !categorys.isChecked |
|
|
|
this.categoryIds.push(categorys.id) |
|
|
|
this.categoryAllData.forEach(childIds => { |
|
|
|
if (categorys.isChecked) { |
|
|
|
const index = this.categoryIds.indexOf(childIds.id) |
|
|
|
if (index !== -1) { |
|
|
|
this.categoryIds.splice(index, 1) |
|
|
|
} |
|
|
|
this.categoryIds.push(childIds.id) |
|
|
|
} else { |
|
|
|
this.categoryIds = [] |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
if (this.categoryIds.indexOf(categorys.id) !== -1) { |
|
|
|
const index = this.categoryIds.indexOf(categorys.id) |
|
|
|
if (index !== -1) { |
|
|
|
this.categoryIds.splice(index, 1) |
|
|
|
} |
|
|
|
} else { |
|
|
|
const index = this.categoryIds.indexOf(categorys.id) |
|
|
|
if (index === -1) { |
|
|
|
this.categoryIds.push(categorys.id) |
|
|
|
findNodeById(id, nodes) { |
|
|
|
for (const node of nodes) { |
|
|
|
if (node.id === id) { |
|
|
|
return node |
|
|
|
} else if (node.children.length > 0) { |
|
|
|
const foundNode = this.findNodeById(id, node.children) |
|
|
|
if (foundNode) { |
|
|
|
return foundNode |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.$refs.category.setCheckedKeys(this.categoryIds) |
|
|
|
return null |
|
|
|
}, |
|
|
|
getAllChildIds(id, nodes) { |
|
|
|
const node = this.findNodeById(id, nodes) |
|
|
|
if (node) { |
|
|
|
let childIds = [node.id] |
|
|
|
for (const child of node.children) { |
|
|
|
childIds = childIds.concat(this.getAllChildIds(child.id, nodes)) |
|
|
|
} |
|
|
|
return childIds |
|
|
|
} else { |
|
|
|
return [] |
|
|
|
} |
|
|
|
}, |
|
|
|
categoryChange(categorys) { |
|
|
|
console.log(categorys) |
|
|
|
console.log(this.categoryDatas) |
|
|
|
const childrenIds = this.getAllChildIds(categorys.id, this.categoryDatas) |
|
|
|
console.log('childrenIds', childrenIds) |
|
|
|
console.log(this.$refs.category.getCheckedKeys()) |
|
|
|
this.categoryIds = this.$refs.category.getCheckedKeys() |
|
|
|
}, |
|
|
|
// 保存菜单 |
|
|
|
saveCategory() { |
|
|
@ -369,6 +393,7 @@ export default { |
|
|
|
update() { |
|
|
|
// 无刷新更新 表格数据 |
|
|
|
crudfonds.FetchInitFondsList().then(res => { |
|
|
|
console.log(res) |
|
|
|
for (let i = 0; i < this.crud.data.length; i++) { |
|
|
|
if (res.fondsId === this.crud.data[i].fondsId) { |
|
|
|
this.crud.data[i] = res |
|
|
|