Commit fa183584223f9593cc683b4541fe7567d180c89a
Merge branch 'ft-dev' into 'main'
feat:通知增加查看功能 See merge request huang/yun-teng-iot-front!20
Showing
10 changed files
with
197 additions
and
75 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 |
@@ -26,10 +26,9 @@ enum NotifyManagerApi { | @@ -26,10 +26,9 @@ enum NotifyManagerApi { | ||
26 | // * 获取详情 | 26 | // * 获取详情 |
27 | // * @param | 27 | // * @param |
28 | // */ | 28 | // */ |
29 | -export const screenLinkPageByDeptIdGetDevice = (params: NoticeByIdParams) => { | 29 | +export const noticeByIdGetInfo = (id: string) => { |
30 | return defHttp.get({ | 30 | return defHttp.get({ |
31 | - url: NotifyManagerApi.NOTICE_GET_DETAIL_URL, | ||
32 | - params, | 31 | + url: `${NotifyManagerApi.NOTICE_GET_DETAIL_URL}/${id}`, |
33 | }); | 32 | }); |
34 | }; | 33 | }; |
35 | 34 |
@@ -10,34 +10,49 @@ | @@ -10,34 +10,49 @@ | ||
10 | 10 | ||
11 | const schema: DescItem[] = [ | 11 | const schema: DescItem[] = [ |
12 | { | 12 | { |
13 | + field: 'creator', | ||
14 | + label: '创建者', | ||
15 | + }, | ||
16 | + { | ||
13 | field: 'title', | 17 | field: 'title', |
14 | label: '标题', | 18 | label: '标题', |
15 | }, | 19 | }, |
16 | { | 20 | { |
17 | - field: 'content', | ||
18 | - label: '内容', | 21 | + field: 'updateTime', |
22 | + label: '更新时间', | ||
19 | }, | 23 | }, |
20 | { | 24 | { |
21 | field: 'senderName', | 25 | field: 'senderName', |
22 | label: '发送者', | 26 | label: '发送者', |
23 | }, | 27 | }, |
24 | { | 28 | { |
25 | - field: 'createTime', | ||
26 | - label: '发送时间', | 29 | + field: 'readDate', |
30 | + label: '阅读时间', | ||
31 | + }, | ||
32 | + { | ||
33 | + field: 'readStatus', | ||
34 | + label: '阅读状态', | ||
35 | + render: (_, data) => { | ||
36 | + return data.readStatus === 0 ? '草稿' : data.readStatus === 1 ? '已读' : '其他'; | ||
37 | + }, | ||
27 | }, | 38 | }, |
28 | { | 39 | { |
29 | field: 'type', | 40 | field: 'type', |
30 | label: '类型', | 41 | label: '类型', |
31 | render: (_, data) => { | 42 | render: (_, data) => { |
32 | - return data.type === 'MEETING' | 43 | + return data.type === 'NOTICE' |
33 | ? '公告' | 44 | ? '公告' |
34 | - : data.type === 'MEETING1' | 45 | + : data.type === 'MEETING' |
35 | ? '会议' | 46 | ? '会议' |
36 | - : data.type === 'MEETING2' | 47 | + : data.type === 'OTHER' |
37 | ? '其他' | 48 | ? '其他' |
38 | : ''; | 49 | : ''; |
39 | }, | 50 | }, |
40 | }, | 51 | }, |
52 | + { | ||
53 | + field: 'updater', | ||
54 | + label: '更新者', | ||
55 | + }, | ||
41 | ]; | 56 | ]; |
42 | export default defineComponent({ | 57 | export default defineComponent({ |
43 | components: { Description, PageWrapper }, | 58 | components: { Description, PageWrapper }, |
@@ -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', |
@@ -4,36 +4,78 @@ | @@ -4,36 +4,78 @@ | ||
4 | @register="registerDrawer" | 4 | @register="registerDrawer" |
5 | :showFooter="false" | 5 | :showFooter="false" |
6 | :title="getTitle" | 6 | :title="getTitle" |
7 | - width="800px" | 7 | + width="1000px" |
8 | > | 8 | > |
9 | <DetailChild :emitChildData="childData" /> | 9 | <DetailChild :emitChildData="childData" /> |
10 | + <BasicTable :columns="columns" :dataSource="tableData"> | ||
11 | + <span></span> | ||
12 | + </BasicTable> | ||
10 | </BasicDrawer> | 13 | </BasicDrawer> |
11 | </template> | 14 | </template> |
12 | <script lang="ts"> | 15 | <script lang="ts"> |
13 | import { defineComponent, ref, computed, unref } from 'vue'; | 16 | import { defineComponent, ref, computed, unref } from 'vue'; |
14 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | 17 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
15 | import DetailChild from './child/index.vue'; | 18 | import DetailChild from './child/index.vue'; |
16 | - import { notifyMyGetDetailApi } from '/@/api/stationnotification/stationnotifyApi'; | ||
17 | - | ||
18 | - // import { useMessage } from '/@/hooks/web/useMessage'; | 19 | + import { |
20 | + notifyMyGetrReadApi, | ||
21 | + notifyMyGetDetailApi, | ||
22 | + } from '/@/api/stationnotification/stationnotifyApi'; | ||
23 | + import { BasicTable } from '/@/components/Table'; | ||
19 | 24 | ||
20 | export default defineComponent({ | 25 | export default defineComponent({ |
21 | name: 'ConfigDrawer', | 26 | name: 'ConfigDrawer', |
22 | - components: { BasicDrawer, DetailChild }, | 27 | + components: { BasicDrawer, DetailChild, BasicTable }, |
23 | emits: ['success', 'register'], | 28 | emits: ['success', 'register'], |
24 | setup() { | 29 | setup() { |
25 | - // const { createMessage } = useMessage(); | ||
26 | const isUpdate = ref(true); | 30 | const isUpdate = ref(true); |
27 | - let childData: any = ref(null); | 31 | + const childData: any = ref(null); |
32 | + const tableData = ref([]); | ||
33 | + const columns: BasicColumn[] = [ | ||
34 | + { | ||
35 | + title: '创建时间', | ||
36 | + dataIndex: 'createTime', | ||
37 | + }, | ||
38 | + { | ||
39 | + title: '阅读状态', | ||
40 | + dataIndex: 'readStatus', | ||
41 | + format: (_text: string, record: Recordable) => { | ||
42 | + return record.readStatus === 0 ? '草稿' : record.readStatus === 1 ? '已读' : '其他'; | ||
43 | + }, | ||
44 | + }, | ||
45 | + { | ||
46 | + title: '阅读时间', | ||
47 | + dataIndex: 'readDate', | ||
48 | + }, | ||
49 | + { | ||
50 | + title: '发送者', | ||
51 | + dataIndex: 'senderName', | ||
52 | + }, | ||
53 | + { | ||
54 | + title: '类型', | ||
55 | + dataIndex: 'type', | ||
56 | + render: (_, data) => { | ||
57 | + return data.type === 'NOTICE' | ||
58 | + ? '公告' | ||
59 | + : data.type === 'MEETING' | ||
60 | + ? '会议' | ||
61 | + : data.type === 'OTHER' | ||
62 | + ? '其他' | ||
63 | + : ''; | ||
64 | + }, | ||
65 | + }, | ||
66 | + ]; | ||
67 | + // const { createMessage } = useMessage(); | ||
28 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | 68 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
29 | setDrawerProps({ confirmLoading: false }); | 69 | setDrawerProps({ confirmLoading: false }); |
30 | isUpdate.value = !!data?.isUpdate; | 70 | isUpdate.value = !!data?.isUpdate; |
31 | - console.log(data.record); | ||
32 | if (data.record) { | 71 | if (data.record) { |
33 | - // console.log(data.record.id); | ||
34 | let getData = await notifyMyGetDetailApi(data.record.id); | 72 | let getData = await notifyMyGetDetailApi(data.record.id); |
35 | childData.value = getData; | 73 | childData.value = getData; |
36 | - // createMessage.success() | 74 | + let tableGet = await notifyMyGetrReadApi({ |
75 | + page: 1, | ||
76 | + pageSize: 10, | ||
77 | + }); | ||
78 | + tableData.value = tableGet.items; | ||
37 | } | 79 | } |
38 | //编辑 | 80 | //编辑 |
39 | if (unref(isUpdate)) { | 81 | if (unref(isUpdate)) { |
@@ -47,6 +89,8 @@ | @@ -47,6 +89,8 @@ | ||
47 | }; | 89 | }; |
48 | 90 | ||
49 | return { | 91 | return { |
92 | + tableData, | ||
93 | + columns, | ||
50 | childData, | 94 | childData, |
51 | handleCancel, | 95 | handleCancel, |
52 | getTitle, | 96 | getTitle, |
@@ -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,20 +6,17 @@ | @@ -6,20 +6,17 @@ | ||
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"> | ||
13 | - <span></span> | ||
14 | - </BasicTable> | ||
15 | </BasicDrawer> | 12 | </BasicDrawer> |
16 | </template> | 13 | </template> |
17 | <script lang="ts"> | 14 | <script lang="ts"> |
18 | import { defineComponent, ref, computed, unref } from 'vue'; | 15 | import { defineComponent, ref, computed, unref } from 'vue'; |
19 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | 16 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
20 | - import { BasicTable } from '/@/components/Table'; | ||
21 | import { Description, DescItem, useDescription } from '/@/components/Description/index'; | 17 | import { Description, DescItem, useDescription } from '/@/components/Description/index'; |
22 | import { PageWrapper } from '/@/components/Page'; | 18 | import { PageWrapper } from '/@/components/Page'; |
19 | + import { noticeByIdGetInfo } from '/@/api/stationnotification/stationnotifyApi'; | ||
23 | 20 | ||
24 | const schema: DescItem[] = [ | 21 | const schema: DescItem[] = [ |
25 | { | 22 | { |
@@ -51,46 +48,47 @@ | @@ -51,46 +48,47 @@ | ||
51 | : ''; | 48 | : ''; |
52 | }, | 49 | }, |
53 | }, | 50 | }, |
51 | + { | ||
52 | + field: 'status', | ||
53 | + label: '状态', | ||
54 | + }, | ||
55 | + { | ||
56 | + field: 'updateTime', | ||
57 | + label: '更新时间', | ||
58 | + }, | ||
59 | + { | ||
60 | + field: 'receiverType', | ||
61 | + label: '接收类型', | ||
62 | + }, | ||
63 | + { | ||
64 | + field: 'createTime', | ||
65 | + label: '创建时间', | ||
66 | + }, | ||
54 | ]; | 67 | ]; |
55 | - | ||
56 | export default defineComponent({ | 68 | export default defineComponent({ |
57 | name: 'ConfigDrawer', | 69 | name: 'ConfigDrawer', |
58 | - components: { BasicDrawer, BasicTable, Description, PageWrapper }, | 70 | + components: { BasicDrawer, Description, PageWrapper }, |
59 | emits: ['success', 'register'], | 71 | emits: ['success', 'register'], |
60 | setup() { | 72 | setup() { |
61 | - let tableData: [] = ref([]); | ||
62 | - const columns: BasicColumn[] = [ | ||
63 | - { | ||
64 | - title: '接收者', | ||
65 | - dataIndex: 'senderName', | ||
66 | - }, | ||
67 | - { | ||
68 | - title: '阅读状态', | ||
69 | - dataIndex: 'status', | ||
70 | - }, | ||
71 | - { | ||
72 | - title: '阅读时间', | ||
73 | - dataIndex: 'createTime', | ||
74 | - }, | ||
75 | - ]; | 73 | + let descInfo = ref(null); |
76 | const isUpdate = ref(true); | 74 | const isUpdate = ref(true); |
75 | + | ||
77 | const [registerDrawer, { setDrawerProps }] = useDrawerInner(async (data) => { | 76 | const [registerDrawer, { setDrawerProps }] = useDrawerInner(async (data) => { |
78 | setDrawerProps({ confirmLoading: false }); | 77 | setDrawerProps({ confirmLoading: false }); |
79 | isUpdate.value = !!data?.isUpdate; | 78 | isUpdate.value = !!data?.isUpdate; |
80 | - tableData.value.push(data.record); | 79 | + let getDescInfo = await noticeByIdGetInfo(data.record.id); |
80 | + descInfo.value = getDescInfo; | ||
81 | }); | 81 | }); |
82 | const getTitle = computed(() => (!unref(isUpdate) ? '查看通知' : '查看通知')); | 82 | const getTitle = computed(() => (!unref(isUpdate) ? '查看通知' : '查看通知')); |
83 | const [register1] = useDescription({ | 83 | const [register1] = useDescription({ |
84 | title: '详情', | 84 | title: '详情', |
85 | bordered: false, | 85 | bordered: false, |
86 | - data: tableData, | 86 | + data: descInfo, |
87 | schema: schema, | 87 | schema: schema, |
88 | }); | 88 | }); |
89 | return { | 89 | return { |
90 | register1, | 90 | register1, |
91 | - tableData, | ||
92 | getTitle, | 91 | getTitle, |
93 | - columns, | ||
94 | registerDrawer, | 92 | registerDrawer, |
95 | }; | 93 | }; |
96 | }, | 94 | }, |
@@ -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, |