Showing
7 changed files
with
129 additions
and
63 deletions
1 | # Whether to open mock | 1 | # Whether to open mock |
2 | -VITE_USE_MOCK = true | 2 | +# VITE_USE_MOCK = true |
3 | 3 | ||
4 | # public path | 4 | # public path |
5 | VITE_PUBLIC_PATH = / | 5 | VITE_PUBLIC_PATH = / |
6 | 6 | ||
7 | # Cross-domain proxy, you can configure multiple | 7 | # Cross-domain proxy, you can configure multiple |
8 | # Please note that no line breaks | 8 | # Please note that no line breaks |
9 | -VITE_PROXY = [["/api","http://192.168.10.116:8082/api"],["/upload","http://192.168.10.116:3300/upload"]] | 9 | +VITE_PROXY = [["/api","http://192.168.10.117:8082/api"],["/upload","http://192.168.10.116:3300/upload"]] |
10 | # VITE_PROXY=[["/api","https://vvbin.cn/test"]] | 10 | # VITE_PROXY=[["/api","https://vvbin.cn/test"]] |
11 | 11 | ||
12 | # Delete console | 12 | # Delete console |
@@ -54,7 +54,7 @@ export const columns: BasicColumn[] = [ | @@ -54,7 +54,7 @@ export const columns: BasicColumn[] = [ | ||
54 | 54 | ||
55 | export const searchFormSchema: FormSchema[] = [ | 55 | export const searchFormSchema: FormSchema[] = [ |
56 | { | 56 | { |
57 | - field: 'orderField', | 57 | + field: 'type', |
58 | label: '', | 58 | label: '', |
59 | colProps: { span: 8 }, | 59 | colProps: { span: 8 }, |
60 | component: 'Select', | 60 | component: 'Select', |
@@ -163,7 +163,7 @@ export const formSchema: FormSchema[] = [ | @@ -163,7 +163,7 @@ export const formSchema: FormSchema[] = [ | ||
163 | 163 | ||
164 | export const searchFormSchema: FormSchema[] = [ | 164 | export const searchFormSchema: FormSchema[] = [ |
165 | { | 165 | { |
166 | - field: 'orderField', | 166 | + field: 'type', |
167 | label: '', | 167 | label: '', |
168 | colProps: { span: 8 }, | 168 | colProps: { span: 8 }, |
169 | component: 'Select', | 169 | component: 'Select', |
@@ -16,17 +16,17 @@ | @@ -16,17 +16,17 @@ | ||
16 | label: '查看', | 16 | label: '查看', |
17 | icon: 'clarity:note-edit-line', | 17 | icon: 'clarity:note-edit-line', |
18 | onClick: handleView.bind(null, record), | 18 | onClick: handleView.bind(null, record), |
19 | - // ifShow: (_action) => { | ||
20 | - // return record.status == '已发布'; | ||
21 | - // }, | 19 | + ifShow: (_action) => { |
20 | + return record.status == '已发布'; | ||
21 | + }, | ||
22 | }, | 22 | }, |
23 | { | 23 | { |
24 | label: '编辑', | 24 | label: '编辑', |
25 | icon: 'clarity:note-edit-line', | 25 | icon: 'clarity:note-edit-line', |
26 | onClick: handleEdit.bind(null, record), | 26 | onClick: handleEdit.bind(null, record), |
27 | - // ifShow: (_action) => { | ||
28 | - // return record.status == '草稿'; | ||
29 | - // }, | 27 | + ifShow: (_action) => { |
28 | + return record.status == '草稿'; | ||
29 | + }, | ||
30 | }, | 30 | }, |
31 | { | 31 | { |
32 | label: '删除', | 32 | label: '删除', |
@@ -86,20 +86,27 @@ | @@ -86,20 +86,27 @@ | ||
86 | Object.assign(getAllData, values); | 86 | Object.assign(getAllData, values); |
87 | isJudgeWherePoint.value.forEach((f) => { | 87 | isJudgeWherePoint.value.forEach((f) => { |
88 | if (f == 0) { | 88 | if (f == 0) { |
89 | - pointArray.value = []; | 89 | + if (pointArray.value.length == 0) { |
90 | + pointArray.value = []; | ||
91 | + } | ||
90 | } else if (f == 1) { | 92 | } else if (f == 1) { |
91 | //组织 | 93 | //组织 |
92 | - pointArray.value.push(getAllData.organizationId); | 94 | + if (pointArray.value.length == 0) { |
95 | + pointArray.value.push(getAllData.organizationId); | ||
96 | + } | ||
93 | } else if (f == 2) { | 97 | } else if (f == 2) { |
94 | //部门 | 98 | //部门 |
95 | let findDeptId = newArray.value.find((f) => { | 99 | let findDeptId = newArray.value.find((f) => { |
96 | return f == isJudgeWherePoint.value[4]; | 100 | return f == isJudgeWherePoint.value[4]; |
97 | }); | 101 | }); |
98 | - console.log(findDeptId); | ||
99 | - pointArray.value.push(findDeptId); | 102 | + if (pointArray.value.length == 0) { |
103 | + pointArray.value.push(findDeptId); | ||
104 | + } | ||
100 | } else if (f == 3) { | 105 | } else if (f == 3) { |
101 | //个人 | 106 | //个人 |
102 | - pointArray.value = [3]; | 107 | + if (pointArray.value.length == 0) { |
108 | + pointArray.value = [3]; | ||
109 | + } | ||
103 | } | 110 | } |
104 | }); | 111 | }); |
105 | getAllData.pointId = pointArray.value; | 112 | getAllData.pointId = pointArray.value; |
@@ -109,8 +116,8 @@ | @@ -109,8 +116,8 @@ | ||
109 | emit('success'); | 116 | emit('success'); |
110 | resetFields(); | 117 | resetFields(); |
111 | setTimeout(() => { | 118 | setTimeout(() => { |
112 | - pointArray.value = []; | ||
113 | - isJudgeWherePoint.value = []; | 119 | + pointArray.value.length = 0; |
120 | + isJudgeWherePoint.value.length = 0; | ||
114 | }, 1000); | 121 | }, 1000); |
115 | } | 122 | } |
116 | if (unref(isUpdate)) { | 123 | if (unref(isUpdate)) { |
@@ -128,19 +135,27 @@ | @@ -128,19 +135,27 @@ | ||
128 | Object.assign(getAllData, values); | 135 | Object.assign(getAllData, values); |
129 | isJudgeWherePoint.value.forEach((f) => { | 136 | isJudgeWherePoint.value.forEach((f) => { |
130 | if (f == 0) { | 137 | if (f == 0) { |
131 | - pointArray.value = []; | 138 | + if (pointArray.value.length == 0) { |
139 | + pointArray.value = []; | ||
140 | + } | ||
132 | } else if (f == 1) { | 141 | } else if (f == 1) { |
133 | //组织 | 142 | //组织 |
134 | - pointArray.value.push(getAllData.organizationId); | 143 | + if (pointArray.value.length == 0) { |
144 | + pointArray.value.push(getAllData.organizationId); | ||
145 | + } | ||
135 | } else if (f == 2) { | 146 | } else if (f == 2) { |
136 | //部门 | 147 | //部门 |
137 | let findDeptId = newArray.value.find((f) => { | 148 | let findDeptId = newArray.value.find((f) => { |
138 | return f == isJudgeWherePoint.value[4]; | 149 | return f == isJudgeWherePoint.value[4]; |
139 | }); | 150 | }); |
140 | - pointArray.value.push(findDeptId); | 151 | + if (pointArray.value.length == 0) { |
152 | + pointArray.value.push(findDeptId); | ||
153 | + } | ||
141 | } else if (f == 3) { | 154 | } else if (f == 3) { |
142 | //个人 | 155 | //个人 |
143 | - pointArray.value = [3]; | 156 | + if (pointArray.value.length == 0) { |
157 | + pointArray.value = [3]; | ||
158 | + } | ||
144 | } | 159 | } |
145 | }); | 160 | }); |
146 | getAllData.pointId = pointArray.value; | 161 | getAllData.pointId = pointArray.value; |
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | :title="getTitle" | 6 | :title="getTitle" |
7 | width="800px" | 7 | width="800px" |
8 | > | 8 | > |
9 | - <PageWrapper title="我的通知详情"> | 9 | + <PageWrapper title="站内通知详情"> |
10 | <Description @register="register1" class="mt-4" /> | 10 | <Description @register="register1" class="mt-4" /> |
11 | </PageWrapper> | 11 | </PageWrapper> |
12 | <BasicTable :columns="columns" :dataSource="tableData"> | 12 | <BasicTable :columns="columns" :dataSource="tableData"> |
@@ -21,44 +21,44 @@ | @@ -21,44 +21,44 @@ | ||
21 | import { Description, DescItem, useDescription } from '/@/components/Description/index'; | 21 | import { Description, DescItem, useDescription } from '/@/components/Description/index'; |
22 | import { PageWrapper } from '/@/components/Page'; | 22 | import { PageWrapper } from '/@/components/Page'; |
23 | 23 | ||
24 | - const schema: DescItem[] = [ | ||
25 | - { | ||
26 | - field: 'title', | ||
27 | - label: '标题', | ||
28 | - }, | ||
29 | - { | ||
30 | - field: 'content', | ||
31 | - label: '内容', | ||
32 | - }, | ||
33 | - { | ||
34 | - field: 'senderName', | ||
35 | - label: '发送者', | ||
36 | - }, | ||
37 | - { | ||
38 | - field: 'senderDate', | ||
39 | - label: '发送时间', | ||
40 | - }, | ||
41 | - { | ||
42 | - field: 'type', | ||
43 | - label: '类型', | ||
44 | - render: (_, data) => { | ||
45 | - return data.type === 'MEETING' | ||
46 | - ? '公告' | ||
47 | - : data.type === 'MEETING1' | ||
48 | - ? '会议' | ||
49 | - : data.type === 'MEETING2' | ||
50 | - ? '其他' | ||
51 | - : ''; | ||
52 | - }, | ||
53 | - }, | ||
54 | - ]; | ||
55 | - | ||
56 | export default defineComponent({ | 24 | export default defineComponent({ |
57 | name: 'ConfigDrawer', | 25 | name: 'ConfigDrawer', |
58 | components: { BasicDrawer, BasicTable, Description, PageWrapper }, | 26 | components: { BasicDrawer, BasicTable, Description, PageWrapper }, |
59 | emits: ['success', 'register'], | 27 | emits: ['success', 'register'], |
60 | setup() { | 28 | setup() { |
61 | - let tableData: [] = ref([]); | 29 | + let tableData = ref([]); |
30 | + const schema: DescItem[] = [ | ||
31 | + { | ||
32 | + field: 'title', | ||
33 | + label: '标题', | ||
34 | + }, | ||
35 | + { | ||
36 | + field: 'content', | ||
37 | + label: '内容', | ||
38 | + }, | ||
39 | + { | ||
40 | + field: 'senderName', | ||
41 | + label: '发送者', | ||
42 | + }, | ||
43 | + { | ||
44 | + field: 'senderDate', | ||
45 | + label: '发送时间', | ||
46 | + }, | ||
47 | + { | ||
48 | + field: 'type', | ||
49 | + label: '类型', | ||
50 | + render: (_, data) => { | ||
51 | + return data.type === 'MEETING' | ||
52 | + ? '公告' | ||
53 | + : data.type === 'MEETING1' | ||
54 | + ? '会议' | ||
55 | + : data.type === 'MEETING2' | ||
56 | + ? '其他' | ||
57 | + : ''; | ||
58 | + }, | ||
59 | + }, | ||
60 | + ]; | ||
61 | + | ||
62 | const columns: BasicColumn[] = [ | 62 | const columns: BasicColumn[] = [ |
63 | { | 63 | { |
64 | title: '接收者', | 64 | title: '接收者', |
@@ -13,17 +13,19 @@ | @@ -13,17 +13,19 @@ | ||
13 | v-model:value="model[field]" | 13 | v-model:value="model[field]" |
14 | :treeData="treeData" | 14 | :treeData="treeData" |
15 | :replaceFields="{ title: 'menuName' }" | 15 | :replaceFields="{ title: 'menuName' }" |
16 | - :checked-keys="roleMenus" | 16 | + :checkedkeys="roleMenus" |
17 | checkable | 17 | checkable |
18 | toolbar | 18 | toolbar |
19 | + ref="tree" | ||
19 | title="菜单分配" | 20 | title="菜单分配" |
21 | + @check="handleCheckClick" | ||
20 | /> | 22 | /> |
21 | </template> | 23 | </template> |
22 | </BasicForm> | 24 | </BasicForm> |
23 | </BasicDrawer> | 25 | </BasicDrawer> |
24 | </template> | 26 | </template> |
25 | <script lang="ts"> | 27 | <script lang="ts"> |
26 | - import { defineComponent, ref, computed, unref } from 'vue'; | 28 | + import { defineComponent, ref, computed, unref, getCurrentInstance } from 'vue'; |
27 | import { BasicForm, useForm } from '/@/components/Form/index'; | 29 | import { BasicForm, useForm } from '/@/components/Form/index'; |
28 | import { formSchema } from './role.data'; | 30 | import { formSchema } from './role.data'; |
29 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | 31 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
@@ -44,10 +46,13 @@ | @@ -44,10 +46,13 @@ | ||
44 | components: { BasicDrawer, BasicForm, BasicTree }, | 46 | components: { BasicDrawer, BasicForm, BasicTree }, |
45 | emits: ['success', 'register'], | 47 | emits: ['success', 'register'], |
46 | setup(_, { emit }) { | 48 | setup(_, { emit }) { |
49 | + const { proxy } = getCurrentInstance(); | ||
50 | + | ||
47 | const isUpdate = ref(true); | 51 | const isUpdate = ref(true); |
48 | const treeData = ref<TreeItem[]>([]); | 52 | const treeData = ref<TreeItem[]>([]); |
49 | const roleMenus = ref<string[]>([]); | 53 | const roleMenus = ref<string[]>([]); |
50 | const roleId = ref(''); | 54 | const roleId = ref(''); |
55 | + const allCheckedKeys = ref<string[]>([]); | ||
51 | 56 | ||
52 | const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({ | 57 | const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({ |
53 | labelWidth: 90, | 58 | labelWidth: 90, |
@@ -66,6 +71,16 @@ | @@ -66,6 +71,16 @@ | ||
66 | }); | 71 | }); |
67 | } | 72 | } |
68 | 73 | ||
74 | + /** | ||
75 | + * 根据角色id获取所有的菜单ids----里面包含父级id---会造成回显数据时 | ||
76 | + * 存在父级id则默认勾选所有子级id | ||
77 | + */ | ||
78 | + function useChildrenIdsRemoveParentId(str, arr) { | ||
79 | + let index = arr.indexOf(str); | ||
80 | + arr.splice(index, 1); | ||
81 | + return arr; | ||
82 | + } | ||
83 | + | ||
69 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | 84 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
70 | resetFields(); | 85 | resetFields(); |
71 | roleId.value = ''; | 86 | roleId.value = ''; |
@@ -86,16 +101,35 @@ | @@ -86,16 +101,35 @@ | ||
86 | }); | 101 | }); |
87 | treeData.value = treeValues; | 102 | treeData.value = treeValues; |
88 | } | 103 | } |
89 | - if (data.record) { | ||
90 | - roleMenus.value = await getMenusIdsByRoleId(data.record.id); | ||
91 | - roleId.value = data.record.id; | ||
92 | - } | ||
93 | - isUpdate.value = !!data?.isUpdate; | ||
94 | if (unref(isUpdate)) { | 104 | if (unref(isUpdate)) { |
105 | + if (data.record) { | ||
106 | + //通过角色id去获取角色对应的菜单的ids | ||
107 | + roleMenus.value = await getMenusIdsByRoleId(data.record.id); | ||
108 | + treeData.value.map((m) => { | ||
109 | + roleMenus.value.map((m1) => { | ||
110 | + if (m.key === m1) { | ||
111 | + proxy.useChildrenIdsRemoveParentId(m1, roleMenus.value); | ||
112 | + } | ||
113 | + }); | ||
114 | + }); | ||
115 | + proxy.$refs.tree.setCheckedKeys(roleMenus.value); | ||
116 | + roleId.value = data.record.id; | ||
117 | + } | ||
95 | setFieldsValue({ | 118 | setFieldsValue({ |
96 | ...data.record, | 119 | ...data.record, |
97 | }); | 120 | }); |
98 | } | 121 | } |
122 | + | ||
123 | + // if (data.record) { | ||
124 | + // roleMenus.value = await getMenusIdsByRoleId(data.record.id); | ||
125 | + // roleId.value = data.record.id; | ||
126 | + // } | ||
127 | + // isUpdate.value = !!data?.isUpdate; | ||
128 | + // if (unref(isUpdate)) { | ||
129 | + // setFieldsValue({ | ||
130 | + // ...data.record, | ||
131 | + // }); | ||
132 | + // } | ||
99 | }); | 133 | }); |
100 | 134 | ||
101 | const getTitle = computed(() => (!unref(isUpdate) ? '新增角色' : '编辑角色')); | 135 | const getTitle = computed(() => (!unref(isUpdate) ? '新增角色' : '编辑角色')); |
@@ -110,7 +144,7 @@ | @@ -110,7 +144,7 @@ | ||
110 | remark: values.remark, | 144 | remark: values.remark, |
111 | status: values.status, | 145 | status: values.status, |
112 | roleType: RoleEnum.ROLE_TENANT_ADMIN, | 146 | roleType: RoleEnum.ROLE_TENANT_ADMIN, |
113 | - menu: [...values.menu], | 147 | + menu: allCheckedKeys.value as string[], |
114 | }; | 148 | }; |
115 | console.log(req, '请求参数'); | 149 | console.log(req, '请求参数'); |
116 | saveOrUpdateRoleInfoWithMenu(req).then(() => { | 150 | saveOrUpdateRoleInfoWithMenu(req).then(() => { |
@@ -121,8 +155,25 @@ | @@ -121,8 +155,25 @@ | ||
121 | setDrawerProps({ confirmLoading: false }); | 155 | setDrawerProps({ confirmLoading: false }); |
122 | } | 156 | } |
123 | } | 157 | } |
158 | + // Tree check事件 | ||
159 | + const handleCheckClick = (_, e) => { | ||
160 | + allCheckedKeys.value = []; | ||
161 | + let nodes = e.checkedNodes; | ||
162 | + let halfKeys = e.halfCheckedKeys; | ||
163 | + nodes.map((node) => { | ||
164 | + if (node.key != halfKeys[0] && halfKeys.length == []) { | ||
165 | + allCheckedKeys.value.push(node.key); | ||
166 | + } else { | ||
167 | + allCheckedKeys.value.push(node.key); | ||
168 | + } | ||
169 | + }); | ||
170 | + allCheckedKeys.value.push(...halfKeys); | ||
171 | + }; | ||
124 | 172 | ||
125 | return { | 173 | return { |
174 | + allCheckedKeys, | ||
175 | + useChildrenIdsRemoveParentId, | ||
176 | + handleCheckClick, | ||
126 | registerDrawer, | 177 | registerDrawer, |
127 | registerForm, | 178 | registerForm, |
128 | getTitle, | 179 | getTitle, |