|
|
@@ -1,9 +1,9 @@
|
|
|
<template>
|
|
|
- <div class="organization-container">
|
|
|
+ <div class="resourceanization-container">
|
|
|
<div class="left">
|
|
|
<TreeParts
|
|
|
:treeData="resourcetree_data"
|
|
|
- :title="$t('permission.resource.organization')"
|
|
|
+ :title="$t('permission.resource.tree_title')"
|
|
|
:fieldNames="{
|
|
|
key: 'menuId',
|
|
|
title: 'menuName',
|
|
|
@@ -20,27 +20,27 @@
|
|
|
<a-card :title="$t('permission.resource.details')" style="height: 100%">
|
|
|
<ResourceForm
|
|
|
:resource_form="resource_form"
|
|
|
- @statusChange="orgFromStatusChange"
|
|
|
- @save="orgFromSave"
|
|
|
- @reset="orgFromReset"
|
|
|
+ @statusChange="resourceFromStatusChange"
|
|
|
+ @save="resourceFromSave"
|
|
|
+ @reset="resourceFromReset"
|
|
|
>
|
|
|
<template #actions>
|
|
|
- <a-button v-hasPerm="'system:resource:edit'" @click="orgFromSave">{{
|
|
|
+ <a-button v-hasPerm="'system:resource:edit'" @click="resourceFromSave">{{
|
|
|
$t('permission.resource.save')
|
|
|
}}</a-button>
|
|
|
- <a-button @click="orgFromReset">{{ $t('permission.resource.reset') }}</a-button>
|
|
|
+ <a-button @click="resourceFromReset">{{ $t('permission.resource.reset') }}</a-button>
|
|
|
</template>
|
|
|
</ResourceForm>
|
|
|
</a-card>
|
|
|
</div>
|
|
|
|
|
|
<Modal
|
|
|
- :visible.sync="resourcevisible"
|
|
|
- @ok="orgFromSave"
|
|
|
- @cancel="orgFromCancel"
|
|
|
+ :visible.sync="resource_visible"
|
|
|
+ @ok="resourceFromSave"
|
|
|
+ @cancel="resourceFromCancel"
|
|
|
:title="$t('permission.resource.add')"
|
|
|
>
|
|
|
- <ResourceForm :resource_form="resource_form"></ResourceForm>
|
|
|
+ <ResourceForm ref="resourceForm" :resource_form="resource_form"></ResourceForm>
|
|
|
</Modal>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -61,7 +61,8 @@ import {
|
|
|
DeleteResource
|
|
|
} from '../../../apis/permission/resource';
|
|
|
|
|
|
-const resourcevisible = ref(false);
|
|
|
+const resourceForm = ref(null);
|
|
|
+const resource_visible = ref(false);
|
|
|
const is_edit_mode = ref(true);
|
|
|
const resourcetree_data = ref([]);
|
|
|
const tree_permission_list = {
|
|
|
@@ -130,7 +131,7 @@ const onAddBtnClick = (nodeData) => {
|
|
|
// 多余的参数
|
|
|
resource_form.orderNum = 0;
|
|
|
|
|
|
- resourcevisible.value = true;
|
|
|
+ resource_visible.value = true;
|
|
|
is_edit_mode.value = false;
|
|
|
};
|
|
|
|
|
|
@@ -144,7 +145,7 @@ const onDeleteBtnClick = async ({ menuId }) => {
|
|
|
}
|
|
|
getResourceTree();
|
|
|
};
|
|
|
-const orgFromStatusChange = async (status) => {
|
|
|
+const resourceFromStatusChange = async (status) => {
|
|
|
const data = {
|
|
|
menuId: resource_form.resourceId[0],
|
|
|
status
|
|
|
@@ -159,28 +160,34 @@ const orgFromStatusChange = async (status) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-const orgFromSave = async () => {
|
|
|
- const data = {
|
|
|
- ...resource_form,
|
|
|
- menuId: is_edit_mode.value && resource_form.resourceId ? resource_form.resourceId[0] : null
|
|
|
- };
|
|
|
-
|
|
|
- const apiCall = is_edit_mode.value ? UpdateResource : CreateResource;
|
|
|
- const { code } = await apiCall(data);
|
|
|
-
|
|
|
- if (code === 200) {
|
|
|
- const action = is_edit_mode.value ? '编辑' : '新增';
|
|
|
- Message.success({
|
|
|
- title: `${action}用户`,
|
|
|
- content: `${action}成功`
|
|
|
+const resourceFromSave = async () => {
|
|
|
+ if (resourceForm.value.$refs.resourceFormRef.validate) {
|
|
|
+ resourceForm.value.$refs.resourceFormRef.validate(async (valid) => {
|
|
|
+ if (!valid) {
|
|
|
+ const data = {
|
|
|
+ ...resource_form,
|
|
|
+ menuId: is_edit_mode.value && resource_form.resourceId ? resource_form.resourceId[0] : null
|
|
|
+ };
|
|
|
+
|
|
|
+ const apiCall = is_edit_mode.value ? UpdateResource : CreateResource;
|
|
|
+ const { code } = await apiCall(data);
|
|
|
+
|
|
|
+ if (code === 200) {
|
|
|
+ const action = is_edit_mode.value ? '编辑' : '新增';
|
|
|
+ Message.success({
|
|
|
+ title: `${action}用户`,
|
|
|
+ content: `${action}成功`
|
|
|
+ });
|
|
|
+
|
|
|
+ getResourceTree();
|
|
|
+ resource_visible.value = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
-
|
|
|
- getResourceTree();
|
|
|
- resourcevisible.value = false;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-const orgFromReset = () => {
|
|
|
+const resourceFromReset = () => {
|
|
|
resource_form.resourceId = null;
|
|
|
resource_form.parentName = '';
|
|
|
resource_form.status = 0;
|
|
|
@@ -190,9 +197,9 @@ const orgFromReset = () => {
|
|
|
resource_form.address = '';
|
|
|
};
|
|
|
|
|
|
-const orgFromCancel = () => {
|
|
|
+const resourceFromCancel = () => {
|
|
|
is_edit_mode.value = true;
|
|
|
- resourcevisible.value = false;
|
|
|
+ resource_visible.value = false;
|
|
|
};
|
|
|
onMounted(() => {
|
|
|
if (hasPermission('system:resource:list')) {
|
|
|
@@ -200,14 +207,14 @@ onMounted(() => {
|
|
|
} else {
|
|
|
Message.error({
|
|
|
title: '权限不足',
|
|
|
- content: '您没有权限查看资源列表'
|
|
|
+ content: '抱歉,您没有权限查看资源列表'
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
</script>
|
|
|
|
|
|
<style lang="css" scoped>
|
|
|
-.organization-container {
|
|
|
+.resourceanization-container {
|
|
|
display: flex;
|
|
|
justify-content: space-between;
|
|
|
height: calc(100% - 56px);
|