Showing
7 changed files
with
129 additions
and
63 deletions
| 1 | 1 | # Whether to open mock |
| 2 | -VITE_USE_MOCK = true | |
| 2 | +# VITE_USE_MOCK = true | |
| 3 | 3 | |
| 4 | 4 | # public path |
| 5 | 5 | VITE_PUBLIC_PATH = / |
| 6 | 6 | |
| 7 | 7 | # Cross-domain proxy, you can configure multiple |
| 8 | 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 | 10 | # VITE_PROXY=[["/api","https://vvbin.cn/test"]] |
| 11 | 11 | |
| 12 | 12 | # Delete console | ... | ... |
| ... | ... | @@ -16,17 +16,17 @@ |
| 16 | 16 | label: '查看', |
| 17 | 17 | icon: 'clarity:note-edit-line', |
| 18 | 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 | 24 | label: '编辑', |
| 25 | 25 | icon: 'clarity:note-edit-line', |
| 26 | 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 | 32 | label: '删除', | ... | ... |
| ... | ... | @@ -86,20 +86,27 @@ |
| 86 | 86 | Object.assign(getAllData, values); |
| 87 | 87 | isJudgeWherePoint.value.forEach((f) => { |
| 88 | 88 | if (f == 0) { |
| 89 | - pointArray.value = []; | |
| 89 | + if (pointArray.value.length == 0) { | |
| 90 | + pointArray.value = []; | |
| 91 | + } | |
| 90 | 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 | 97 | } else if (f == 2) { |
| 94 | 98 | //部门 |
| 95 | 99 | let findDeptId = newArray.value.find((f) => { |
| 96 | 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 | 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 | 112 | getAllData.pointId = pointArray.value; |
| ... | ... | @@ -109,8 +116,8 @@ |
| 109 | 116 | emit('success'); |
| 110 | 117 | resetFields(); |
| 111 | 118 | setTimeout(() => { |
| 112 | - pointArray.value = []; | |
| 113 | - isJudgeWherePoint.value = []; | |
| 119 | + pointArray.value.length = 0; | |
| 120 | + isJudgeWherePoint.value.length = 0; | |
| 114 | 121 | }, 1000); |
| 115 | 122 | } |
| 116 | 123 | if (unref(isUpdate)) { |
| ... | ... | @@ -128,19 +135,27 @@ |
| 128 | 135 | Object.assign(getAllData, values); |
| 129 | 136 | isJudgeWherePoint.value.forEach((f) => { |
| 130 | 137 | if (f == 0) { |
| 131 | - pointArray.value = []; | |
| 138 | + if (pointArray.value.length == 0) { | |
| 139 | + pointArray.value = []; | |
| 140 | + } | |
| 132 | 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 | 146 | } else if (f == 2) { |
| 136 | 147 | //部门 |
| 137 | 148 | let findDeptId = newArray.value.find((f) => { |
| 138 | 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 | 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 | 161 | getAllData.pointId = pointArray.value; | ... | ... |
| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | :title="getTitle" |
| 7 | 7 | width="800px" |
| 8 | 8 | > |
| 9 | - <PageWrapper title="我的通知详情"> | |
| 9 | + <PageWrapper title="站内通知详情"> | |
| 10 | 10 | <Description @register="register1" class="mt-4" /> |
| 11 | 11 | </PageWrapper> |
| 12 | 12 | <BasicTable :columns="columns" :dataSource="tableData"> |
| ... | ... | @@ -21,44 +21,44 @@ |
| 21 | 21 | import { Description, DescItem, useDescription } from '/@/components/Description/index'; |
| 22 | 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 | 24 | export default defineComponent({ |
| 57 | 25 | name: 'ConfigDrawer', |
| 58 | 26 | components: { BasicDrawer, BasicTable, Description, PageWrapper }, |
| 59 | 27 | emits: ['success', 'register'], |
| 60 | 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 | 62 | const columns: BasicColumn[] = [ |
| 63 | 63 | { |
| 64 | 64 | title: '接收者', | ... | ... |
| ... | ... | @@ -13,17 +13,19 @@ |
| 13 | 13 | v-model:value="model[field]" |
| 14 | 14 | :treeData="treeData" |
| 15 | 15 | :replaceFields="{ title: 'menuName' }" |
| 16 | - :checked-keys="roleMenus" | |
| 16 | + :checkedkeys="roleMenus" | |
| 17 | 17 | checkable |
| 18 | 18 | toolbar |
| 19 | + ref="tree" | |
| 19 | 20 | title="菜单分配" |
| 21 | + @check="handleCheckClick" | |
| 20 | 22 | /> |
| 21 | 23 | </template> |
| 22 | 24 | </BasicForm> |
| 23 | 25 | </BasicDrawer> |
| 24 | 26 | </template> |
| 25 | 27 | <script lang="ts"> |
| 26 | - import { defineComponent, ref, computed, unref } from 'vue'; | |
| 28 | + import { defineComponent, ref, computed, unref, getCurrentInstance } from 'vue'; | |
| 27 | 29 | import { BasicForm, useForm } from '/@/components/Form/index'; |
| 28 | 30 | import { formSchema } from './role.data'; |
| 29 | 31 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
| ... | ... | @@ -44,10 +46,13 @@ |
| 44 | 46 | components: { BasicDrawer, BasicForm, BasicTree }, |
| 45 | 47 | emits: ['success', 'register'], |
| 46 | 48 | setup(_, { emit }) { |
| 49 | + const { proxy } = getCurrentInstance(); | |
| 50 | + | |
| 47 | 51 | const isUpdate = ref(true); |
| 48 | 52 | const treeData = ref<TreeItem[]>([]); |
| 49 | 53 | const roleMenus = ref<string[]>([]); |
| 50 | 54 | const roleId = ref(''); |
| 55 | + const allCheckedKeys = ref<string[]>([]); | |
| 51 | 56 | |
| 52 | 57 | const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({ |
| 53 | 58 | labelWidth: 90, |
| ... | ... | @@ -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 | 84 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
| 70 | 85 | resetFields(); |
| 71 | 86 | roleId.value = ''; |
| ... | ... | @@ -86,16 +101,35 @@ |
| 86 | 101 | }); |
| 87 | 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 | 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 | 118 | setFieldsValue({ |
| 96 | 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 | 135 | const getTitle = computed(() => (!unref(isUpdate) ? '新增角色' : '编辑角色')); |
| ... | ... | @@ -110,7 +144,7 @@ |
| 110 | 144 | remark: values.remark, |
| 111 | 145 | status: values.status, |
| 112 | 146 | roleType: RoleEnum.ROLE_TENANT_ADMIN, |
| 113 | - menu: [...values.menu], | |
| 147 | + menu: allCheckedKeys.value as string[], | |
| 114 | 148 | }; |
| 115 | 149 | console.log(req, '请求参数'); |
| 116 | 150 | saveOrUpdateRoleInfoWithMenu(req).then(() => { |
| ... | ... | @@ -121,8 +155,25 @@ |
| 121 | 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 | 173 | return { |
| 174 | + allCheckedKeys, | |
| 175 | + useChildrenIdsRemoveParentId, | |
| 176 | + handleCheckClick, | |
| 126 | 177 | registerDrawer, |
| 127 | 178 | registerForm, |
| 128 | 179 | getTitle, | ... | ... |