|
@ -23,7 +23,7 @@ |
|
|
</el-button> |
|
|
</el-button> |
|
|
</template> |
|
|
</template> |
|
|
<template v-slot:right> |
|
|
<template v-slot:right> |
|
|
<el-button :loading="crud.downloadLoading" :disabled="!crud.data.length" size="mini" @click="doExport"> |
|
|
|
|
|
|
|
|
<el-button :loading="crud.downloadLoading" size="mini" :disabled="crud.selections.length === 0" @click="doExport(crud.selections)"> |
|
|
<i class="iconfont icon-daochu" /> |
|
|
<i class="iconfont icon-daochu" /> |
|
|
导出 |
|
|
导出 |
|
|
</el-button> |
|
|
</el-button> |
|
@ -104,25 +104,24 @@ |
|
|
<span class="role-span role-tab-active">门类关联</span> |
|
|
<span class="role-span role-tab-active">门类关联</span> |
|
|
</el-tooltip> |
|
|
</el-tooltip> |
|
|
<el-button |
|
|
<el-button |
|
|
v-permission="['admin','roles:edit']" |
|
|
|
|
|
|
|
|
v-permission="['admin','fonds:edit']" |
|
|
:disabled="!showButton" |
|
|
:disabled="!showButton" |
|
|
:loading="menuLoading" |
|
|
|
|
|
|
|
|
:loading="categoryLoading" |
|
|
size="mini" |
|
|
size="mini" |
|
|
@click="saveMenu" |
|
|
|
|
|
|
|
|
@click="saveCategory" |
|
|
>保存</el-button> |
|
|
>保存</el-button> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<!-- :data="menus" @check="menuChange" :default-checked-keys="categoryIds"--> |
|
|
<el-tree |
|
|
<el-tree |
|
|
ref="menu" |
|
|
|
|
|
|
|
|
ref="category" |
|
|
lazy |
|
|
lazy |
|
|
:data="menus" |
|
|
|
|
|
:default-checked-keys="menuIds" |
|
|
|
|
|
:load="getMenuDatas" |
|
|
|
|
|
:props="defaultProps" |
|
|
|
|
|
check-strictly |
|
|
|
|
|
accordion |
|
|
|
|
|
|
|
|
:data="categoryDatas" |
|
|
|
|
|
:load="getCategoryDataList" |
|
|
|
|
|
:default-checked-keys="categoryIds" |
|
|
show-checkbox |
|
|
show-checkbox |
|
|
node-key="id" |
|
|
node-key="id" |
|
|
@check="menuChange" |
|
|
|
|
|
|
|
|
highlight-current |
|
|
|
|
|
:props="defaultProps" |
|
|
/> |
|
|
/> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
@ -132,14 +131,17 @@ |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import crudfonds from '@/api/system/fonds' |
|
|
import crudfonds from '@/api/system/fonds' |
|
|
import { getDepts, getDeptSuperior } from '@/api/system/dept' |
|
|
|
|
|
import { getMenusTree, getChild } from '@/api/system/menu' |
|
|
|
|
|
|
|
|
// getMenusTree |
|
|
|
|
|
// import { getChild } from '@/api/system/menu' FetchCategoryMenu |
|
|
|
|
|
import { FetchCategoryMenuChildren } from '@/api/system/category' |
|
|
import CRUD, { presenter, header, form, crud } from '@crud/crud' |
|
|
import CRUD, { presenter, header, form, crud } from '@crud/crud' |
|
|
import rrOperation from '@crud/RR.operation' |
|
|
import rrOperation from '@crud/RR.operation' |
|
|
import crudOperation from '@crud/CRUD.operation' |
|
|
import crudOperation from '@crud/CRUD.operation' |
|
|
import pagination from '@crud/Pagination' |
|
|
import pagination from '@crud/Pagination' |
|
|
import DateRangePicker from '@/components/DateRangePicker' |
|
|
import DateRangePicker from '@/components/DateRangePicker' |
|
|
import { downloadFile } from '@/utils/index' |
|
|
|
|
|
|
|
|
import { exportFile } from '@/utils/index' |
|
|
|
|
|
import qs from 'qs' |
|
|
|
|
|
import { mapGetters } from 'vuex' |
|
|
|
|
|
|
|
|
const defaultForm = { id: null, fondsName: null, fondsNameAbbr: null, fondsNo: null, fondsOrders: 999, fondsStatus: null, fondsRemarks: null } |
|
|
const defaultForm = { id: null, fondsName: null, fondsNameAbbr: null, fondsNo: null, fondsOrders: 999, fondsStatus: null, fondsRemarks: null } |
|
|
export default { |
|
|
export default { |
|
@ -158,9 +160,9 @@ export default { |
|
|
mixins: [presenter(), header(), form(defaultForm), crud()], |
|
|
mixins: [presenter(), header(), form(defaultForm), crud()], |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
defaultProps: { children: 'children', label: 'label', isLeaf: 'leaf' }, |
|
|
|
|
|
currentId: 0, menuLoading: false, showButton: false, |
|
|
|
|
|
menus: [], menuIds: [], depts: [], deptDatas: [], // 多选时使用 |
|
|
|
|
|
|
|
|
defaultProps: { children: 'children', label: 'cnName', isLeaf: 'leaf' }, |
|
|
|
|
|
currentId: 0, categoryLoading: false, showButton: false, |
|
|
|
|
|
categoryDatas: [], categoryIds: [], depts: [], deptDatas: [], // 多选时使用 |
|
|
permission: { |
|
|
permission: { |
|
|
add: ['admin', 'fonds:add'], |
|
|
add: ['admin', 'fonds:add'], |
|
|
edit: ['admin', 'fonds:edit'], |
|
|
edit: ['admin', 'fonds:edit'], |
|
@ -188,15 +190,22 @@ export default { |
|
|
{ key: '0', display_name: '停用' } |
|
|
{ key: '0', display_name: '停用' } |
|
|
], |
|
|
], |
|
|
blurryTime: null, |
|
|
blurryTime: null, |
|
|
deleteData: [] // 删除选中的data |
|
|
|
|
|
|
|
|
deleteData: [], // 删除选中的data |
|
|
|
|
|
chooseNode: null |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
computed: { |
|
|
|
|
|
...mapGetters([ |
|
|
|
|
|
'baseApi' |
|
|
|
|
|
]) |
|
|
|
|
|
}, |
|
|
created() { |
|
|
created() { |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
getMenuDatas(node, resolve) { |
|
|
|
|
|
|
|
|
getCategoryDataList(node, resolve) { |
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
getMenusTree(node.data.id ? node.data.id : 0).then(res => { |
|
|
|
|
|
|
|
|
if (node.level > 2) return resolve([]) |
|
|
|
|
|
FetchCategoryMenuChildren(node.data.id ? node.data.id : 0).then(res => { |
|
|
resolve(res) |
|
|
resolve(res) |
|
|
}) |
|
|
}) |
|
|
}, 100) |
|
|
}, 100) |
|
@ -208,16 +217,17 @@ export default { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
[CRUD.HOOK.afterRefresh]() { |
|
|
[CRUD.HOOK.afterRefresh]() { |
|
|
this.$refs.menu.setCheckedKeys([]) |
|
|
|
|
|
|
|
|
this.$refs.category.setCheckedKeys([]) |
|
|
}, |
|
|
}, |
|
|
// 新增前初始化部门信息 |
|
|
|
|
|
|
|
|
// 新增前 |
|
|
[CRUD.HOOK.beforeToAdd](crud, form) { |
|
|
[CRUD.HOOK.beforeToAdd](crud, form) { |
|
|
form.menus = null |
|
|
form.menus = null |
|
|
}, |
|
|
}, |
|
|
// 编辑前初始化自定义数据权限的部门信息 |
|
|
|
|
|
|
|
|
// 编辑前 |
|
|
[CRUD.HOOK.beforeToEdit](crud, form) { |
|
|
[CRUD.HOOK.beforeToEdit](crud, form) { |
|
|
// 将角色的菜单清空,避免日志入库数据过长 |
|
|
// 将角色的菜单清空,避免日志入库数据过长 |
|
|
// form.menus = null |
|
|
// form.menus = null |
|
|
|
|
|
form.id = form.fondsId |
|
|
}, |
|
|
}, |
|
|
// 提交前做的操作 |
|
|
// 提交前做的操作 |
|
|
[CRUD.HOOK.afterValidateCU](crud) { |
|
|
[CRUD.HOOK.afterValidateCU](crud) { |
|
@ -227,13 +237,13 @@ export default { |
|
|
if (val) { |
|
|
if (val) { |
|
|
// const _this = this |
|
|
// const _this = this |
|
|
// 清空菜单的选中 |
|
|
// 清空菜单的选中 |
|
|
this.$refs.menu.setCheckedKeys([]) |
|
|
|
|
|
|
|
|
this.$refs.category.setCheckedKeys([]) |
|
|
// 保存当前的角色id |
|
|
// 保存当前的角色id |
|
|
this.currentId = val.id |
|
|
this.currentId = val.id |
|
|
// 初始化默认选中的key |
|
|
// 初始化默认选中的key |
|
|
this.menuIds = [] |
|
|
|
|
|
|
|
|
this.categoryIds = [] |
|
|
// val.menus.forEach(function(data) { |
|
|
// val.menus.forEach(function(data) { |
|
|
// _this.menuIds.push(data.id) |
|
|
|
|
|
|
|
|
// _this.categoryIds.push(data.id) |
|
|
// }) |
|
|
// }) |
|
|
this.showButton = true |
|
|
this.showButton = true |
|
|
} |
|
|
} |
|
@ -263,6 +273,7 @@ export default { |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
changeStatus(data, val) { |
|
|
changeStatus(data, val) { |
|
|
|
|
|
data.id = data.fondsId |
|
|
this.$confirm('此操作将禁用 / 启用全宗 “' + data.fondsName + '”' + '<span>你是否还要继续?</span>', '提示', { |
|
|
this.$confirm('此操作将禁用 / 启用全宗 “' + data.fondsName + '”' + '<span>你是否还要继续?</span>', '提示', { |
|
|
confirmButtonText: '继续', |
|
|
confirmButtonText: '继续', |
|
|
cancelButtonText: '取消', |
|
|
cancelButtonText: '取消', |
|
@ -279,7 +290,7 @@ export default { |
|
|
data.fondsStatus = !data.fondsStatus |
|
|
data.fondsStatus = !data.fondsStatus |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
doExport() { |
|
|
|
|
|
|
|
|
doExport(data) { |
|
|
crud.downloadLoading = true |
|
|
crud.downloadLoading = true |
|
|
this.$confirm('此操作将导出所选数据' + '<span>你是否还要继续?</span>', '提示', { |
|
|
this.$confirm('此操作将导出所选数据' + '<span>你是否还要继续?</span>', '提示', { |
|
|
confirmButtonText: '继续', |
|
|
confirmButtonText: '继续', |
|
@ -287,53 +298,55 @@ export default { |
|
|
type: 'warning', |
|
|
type: 'warning', |
|
|
dangerouslyUseHTMLString: true |
|
|
dangerouslyUseHTMLString: true |
|
|
}).then(() => { |
|
|
}).then(() => { |
|
|
console.log(this.crud.data) |
|
|
|
|
|
crudfonds.FetchDownload().then(result => { |
|
|
|
|
|
downloadFile(result, crud.title + '数据', 'xlsx') |
|
|
|
|
|
crud.downloadLoading = false |
|
|
|
|
|
}).catch(() => { |
|
|
|
|
|
crud.downloadLoading = false |
|
|
|
|
|
}) |
|
|
|
|
|
}).catch(() => { |
|
|
|
|
|
|
|
|
const ids = [] |
|
|
|
|
|
data.forEach(val => { |
|
|
|
|
|
ids.push(val.fondsId) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
|
|
|
menuChange(menu) { |
|
|
|
|
|
// 获取该节点的所有子节点,id 包含自身 |
|
|
|
|
|
getChild(menu.id).then(childIds => { |
|
|
|
|
|
// 判断是否在 menuIds 中,如果存在则删除,否则添加 |
|
|
|
|
|
if (this.menuIds.indexOf(menu.id) !== -1) { |
|
|
|
|
|
for (let i = 0; i < childIds.length; i++) { |
|
|
|
|
|
const index = this.menuIds.indexOf(childIds[i]) |
|
|
|
|
|
if (index !== -1) { |
|
|
|
|
|
this.menuIds.splice(index, 1) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
for (let i = 0; i < childIds.length; i++) { |
|
|
|
|
|
const index = this.menuIds.indexOf(childIds[i]) |
|
|
|
|
|
if (index === -1) { |
|
|
|
|
|
this.menuIds.push(childIds[i]) |
|
|
|
|
|
|
|
|
const params = { |
|
|
|
|
|
'fondsIds': ids |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
this.$refs.menu.setCheckedKeys(this.menuIds) |
|
|
|
|
|
|
|
|
exportFile(this.baseApi + '/api/fonds/download?' + qs.stringify(params, { indices: false })) |
|
|
|
|
|
}).catch(() => { |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
// menuChange(menu) { |
|
|
|
|
|
// console.log(menu) |
|
|
|
|
|
// // 获取该节点的所有子节点,id 包含自身 |
|
|
|
|
|
// getChild(menu.id).then(childIds => { |
|
|
|
|
|
// // 判断是否在 categoryIds 中,如果存在则删除,否则添加 |
|
|
|
|
|
// if (this.categoryIds.indexOf(menu.id) !== -1) { |
|
|
|
|
|
// for (let i = 0; i < childIds.length; i++) { |
|
|
|
|
|
// const index = this.categoryIds.indexOf(childIds[i]) |
|
|
|
|
|
// if (index !== -1) { |
|
|
|
|
|
// this.categoryIds.splice(index, 1) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// } else { |
|
|
|
|
|
// for (let i = 0; i < childIds.length; i++) { |
|
|
|
|
|
// const index = this.categoryIds.indexOf(childIds[i]) |
|
|
|
|
|
// if (index === -1) { |
|
|
|
|
|
// this.categoryIds.push(childIds[i]) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// this.$refs.category.setCheckedKeys(this.categoryIds) |
|
|
|
|
|
// }) |
|
|
|
|
|
// }, |
|
|
// 保存菜单 |
|
|
// 保存菜单 |
|
|
saveMenu() { |
|
|
|
|
|
this.menuLoading = true |
|
|
|
|
|
const role = { id: this.currentId, menus: [] } |
|
|
|
|
|
|
|
|
saveCategory() { |
|
|
|
|
|
this.categoryLoading = true |
|
|
|
|
|
const fonds = { id: this.currentId, menus: [] } |
|
|
// 得到已选中的 key 值 |
|
|
// 得到已选中的 key 值 |
|
|
this.menuIds.forEach(function(id) { |
|
|
|
|
|
|
|
|
this.categoryIds.forEach(function(id) { |
|
|
const menu = { id: id } |
|
|
const menu = { id: id } |
|
|
role.menus.push(menu) |
|
|
|
|
|
|
|
|
fonds.menus.push(menu) |
|
|
}) |
|
|
}) |
|
|
crudfonds.editMenu(role).then(() => { |
|
|
|
|
|
|
|
|
crudfonds.editMenu(fonds).then(() => { |
|
|
this.crud.notify('保存成功', CRUD.NOTIFICATION_TYPE.SUCCESS) |
|
|
this.crud.notify('保存成功', CRUD.NOTIFICATION_TYPE.SUCCESS) |
|
|
this.menuLoading = false |
|
|
|
|
|
|
|
|
this.categoryLoading = false |
|
|
this.update() |
|
|
this.update() |
|
|
}).catch(err => { |
|
|
}).catch(err => { |
|
|
this.menuLoading = false |
|
|
|
|
|
|
|
|
this.categoryLoading = false |
|
|
console.log(err.response.data.message) |
|
|
console.log(err.response.data.message) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
@ -348,38 +361,6 @@ export default { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
|
|
|
// 获取部门数据 |
|
|
|
|
|
getDepts() { |
|
|
|
|
|
getDepts({ enabled: true }).then(res => { |
|
|
|
|
|
this.depts = res.content.map(function(obj) { |
|
|
|
|
|
if (obj.hasChildren) { |
|
|
|
|
|
obj.children = null |
|
|
|
|
|
} |
|
|
|
|
|
return obj |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
getSupDepts(depts) { |
|
|
|
|
|
const ids = [] |
|
|
|
|
|
depts.forEach(dept => { |
|
|
|
|
|
ids.push(dept.id) |
|
|
|
|
|
}) |
|
|
|
|
|
getDeptSuperior(ids).then(res => { |
|
|
|
|
|
const date = res.content |
|
|
|
|
|
this.buildDepts(date) |
|
|
|
|
|
this.depts = date |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
buildDepts(depts) { |
|
|
|
|
|
depts.forEach(data => { |
|
|
|
|
|
if (data.children) { |
|
|
|
|
|
this.buildDepts(data.children) |
|
|
|
|
|
} |
|
|
|
|
|
if (data.hasChildren && !data.children) { |
|
|
|
|
|
data.children = null |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|