|
@@ -80,22 +80,24 @@ export default {
|
|
|
this.$emit('close');
|
|
|
},
|
|
|
handleSubmit() {
|
|
|
- if (this.selectedValue.length == 0) {
|
|
|
+ const approveContent = this.nodeTransferLabel();
|
|
|
+ // 获取目标树所有的key
|
|
|
+ const allKeys = this.$refs.transferTree.allKeyValue(false, this.$refs.transferTree.targetData);
|
|
|
+ const resourceInfos = allKeys
|
|
|
+ .map((item) => this.$refs.transferTree.$refs['to-tree'].getNode(item).data)
|
|
|
+ .map((item) => {
|
|
|
+ return {
|
|
|
+ appId: item.appId,
|
|
|
+ funId: item.id
|
|
|
+ };
|
|
|
+ })
|
|
|
+ .filter((item) => item.appId);
|
|
|
+
|
|
|
+ // 已选资源有变更,则可以直接保存,无变更,则需要至少选中一条
|
|
|
+ // 判断有无变更的标准:resourceInfos的funId 与getSetFunIdsByUser方法返回的已选资源id作匹配
|
|
|
+ if (this.havefunIds.length == 0 && this.selectedValue.length == 0) {
|
|
|
this.$message.warning('请至少选择一条功能资源!');
|
|
|
} else {
|
|
|
- const approveContent = this.nodeTransferLabel();
|
|
|
- // 获取目标树所有的key
|
|
|
- const allKeys = this.$refs.transferTree.allKeyValue(false, this.$refs.transferTree.targetData);
|
|
|
- const resourceInfos = allKeys
|
|
|
- .map((item) => this.$refs.transferTree.$refs['to-tree'].getNode(item).data)
|
|
|
- .map((item) => {
|
|
|
- return {
|
|
|
- appId: item.appId,
|
|
|
- funId: item.id
|
|
|
- };
|
|
|
- })
|
|
|
- .filter((item) => item.appId);
|
|
|
-
|
|
|
this.$emit('success', approveContent, this.selectedValue, resourceInfos);
|
|
|
}
|
|
|
},
|
|
@@ -110,9 +112,11 @@ export default {
|
|
|
const params = {
|
|
|
userId: this.$store.getters.user.id
|
|
|
};
|
|
|
- userHasAuthFunIds(params).then((res) => {
|
|
|
- resolve(res.data.content);
|
|
|
- });
|
|
|
+ userHasAuthFunIds(params)
|
|
|
+ .then((res) => {
|
|
|
+ resolve(res.data.content);
|
|
|
+ })
|
|
|
+ .catch(() => resolve([]));
|
|
|
});
|
|
|
},
|
|
|
// 获取全量的菜单树
|
|
@@ -153,10 +157,10 @@ export default {
|
|
|
|
|
|
async created() {
|
|
|
this.data = await this.getAllTree();
|
|
|
- const funIds = await this.getSetFunIdsByUser();
|
|
|
- this.selectedValue = [...this.selectKeys, ...funIds];
|
|
|
+ this.havefunIds = await this.getSetFunIdsByUser();
|
|
|
+ this.selectedValue = [...this.selectKeys, ...this.havefunIds];
|
|
|
if (this.needFilter) {
|
|
|
- this.selectedValue = this.getChildKeys(this.data, [...this.selectKeys, ...funIds]);
|
|
|
+ this.selectedValue = this.getChildKeys(this.data, [...this.selectKeys, ...this.havefunIds]);
|
|
|
}
|
|
|
},
|
|
|
mounted() {}
|