Commit 3f0216b6c2343ed94f05741708c64871bf859a62
Merge branch 'local_dev_ft' into 'main'
feat:菜单管理新增权限标识 See merge request huang/yun-teng-iot-front!453
Showing
5 changed files
with
66 additions
and
49 deletions
... | ... | @@ -18,9 +18,7 @@ |
18 | 18 | <!-- <Divider orientation="left">触发器</Divider> --> |
19 | 19 | <Divider orientation="left"> |
20 | 20 | <a-tooltip> |
21 | - <template #title | |
22 | - >场景联动触发的首要条件,"触发器"之间的关系为或,“执行条件”与“触发器”之间的关系为且。</template | |
23 | - > | |
21 | + <template #title>触发器不可为空,消息只要满足触发条件中任意一个即可触发。</template> | |
24 | 22 | 触发器 |
25 | 23 | <QuestionCircleOutlined :style="{ fontSize: '14px', marginLeft: '5px' }" /> |
26 | 24 | </a-tooltip> |
... | ... | @@ -39,7 +37,7 @@ |
39 | 37 | <!-- 按钮 --> |
40 | 38 | <a-button type="primary" class="mt-4" @click="addTrigger" v-if="isView"> |
41 | 39 | <PlusOutlined /> |
42 | - 新增触发器<span style="visibility: hidden">发</span> | |
40 | + 触发器(OR)<span style="visibility: hidden">发</span> | |
43 | 41 | </a-button> |
44 | 42 | <!-- 按钮 --> |
45 | 43 | </div> |
... | ... | @@ -48,10 +46,7 @@ |
48 | 46 | <!-- 执行条件-begin --> |
49 | 47 | <Divider orientation="left"> |
50 | 48 | <a-tooltip> |
51 | - <template #title | |
52 | - >场景联动触发的次要条件,"执行条件"之间的关系为或, | |
53 | - “执行条件”与“触发器”之间的关系为且。</template | |
54 | - > | |
49 | + <template #title>执行条件可为空,消息需要满足所有执行条件才会被处理。</template> | |
55 | 50 | 执行条件 |
56 | 51 | <QuestionCircleOutlined :style="{ fontSize: '14px', marginLeft: '5px' }" /> |
57 | 52 | </a-tooltip> |
... | ... | @@ -70,7 +65,7 @@ |
70 | 65 | <!-- 按钮 --> |
71 | 66 | <a-button type="primary" class="mt-4" @click="addCondition" v-if="isView"> |
72 | 67 | <PlusOutlined /> |
73 | - 新增执行条件 | |
68 | + 执行条件(AND) | |
74 | 69 | </a-button> |
75 | 70 | <!-- 按钮 --> |
76 | 71 | </div> | ... | ... |
... | ... | @@ -31,6 +31,16 @@ |
31 | 31 | ]" |
32 | 32 | /> |
33 | 33 | </template> |
34 | + <template #status="{ record }"> | |
35 | + <Switch | |
36 | + :disabled="disabled" | |
37 | + :checked="record.status === 1" | |
38 | + :loading="record.pendingStatus" | |
39 | + checkedChildren="启用" | |
40 | + unCheckedChildren="禁用" | |
41 | + @change="(checked:boolean)=>statusChange(checked,record)" | |
42 | + /> | |
43 | + </template> | |
34 | 44 | </BasicTable> |
35 | 45 | <ItemDrawer @register="registerDrawer" @success="handleSuccess" /> |
36 | 46 | </div> |
... | ... | @@ -38,30 +48,40 @@ |
38 | 48 | </div> |
39 | 49 | </template> |
40 | 50 | <script lang="ts"> |
41 | - import { defineComponent } from 'vue'; | |
42 | - | |
51 | + import { defineComponent, ref } from 'vue'; | |
43 | 52 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
44 | 53 | import { sysDictItemPage, deleteDictItem } from '/@/api/system/dict'; |
45 | - | |
54 | + import { Switch } from 'ant-design-vue'; | |
46 | 55 | import { BasicDrawer, useDrawer, useDrawerInner } from '/@/components/Drawer'; |
47 | 56 | import ItemDrawer from '/@/views/system/dict/item/ItemDrawer.vue'; |
48 | - | |
49 | 57 | import { columns, searchFormSchema } from './dict.item.data'; |
50 | 58 | import { useMessage } from '/@/hooks/web/useMessage'; |
51 | 59 | import Authority from '/@/components/Authority/src/Authority.vue'; |
60 | + import { setDictItemStatus } from '/@/api/system/dict'; | |
52 | 61 | |
53 | 62 | export default defineComponent({ |
54 | 63 | name: 'ItemIndex', |
55 | - components: { BasicDrawer, BasicTable, ItemDrawer, TableAction, Authority }, | |
64 | + components: { BasicDrawer, BasicTable, ItemDrawer, TableAction, Authority, Switch }, | |
56 | 65 | setup() { |
57 | 66 | let dictId; |
67 | + const disabled = ref(false); | |
58 | 68 | const { createMessage } = useMessage(); |
59 | 69 | const [registerDrawer, { openDrawer }] = useDrawer(); |
60 | 70 | const [register] = useDrawerInner((data) => { |
61 | - dictId = data.id; | |
71 | + dictId = data.data.id; | |
72 | + if ( | |
73 | + data.data.dictCode === 'enabled_platform_admin_auth' || | |
74 | + data.data.dictCode === 'disabled_tenant_auth' || | |
75 | + data.data.dictCode === 'enabled_sysadmin_auth' | |
76 | + ) { | |
77 | + disabled.value = true; | |
78 | + } else { | |
79 | + disabled.value = false; | |
80 | + } | |
81 | + | |
62 | 82 | reload(); |
63 | 83 | }); |
64 | - const [registerTable, { reload }] = useTable({ | |
84 | + const [registerTable, { reload, setSelectedRowKeys, setProps }] = useTable({ | |
65 | 85 | title: '字典值列表', |
66 | 86 | api: sysDictItemPage, |
67 | 87 | columns, |
... | ... | @@ -117,7 +137,27 @@ |
117 | 137 | function handleSuccess() { |
118 | 138 | reload(); |
119 | 139 | } |
120 | - | |
140 | + const statusChange = async (checked, record) => { | |
141 | + setProps({ | |
142 | + loading: true, | |
143 | + }); | |
144 | + setSelectedRowKeys([]); | |
145 | + const newStatus = checked ? 1 : 0; | |
146 | + const { createMessage } = useMessage(); | |
147 | + try { | |
148 | + await setDictItemStatus(record.id, newStatus); | |
149 | + if (newStatus) { | |
150 | + createMessage.success(`启用成功`); | |
151 | + } else { | |
152 | + createMessage.success('禁用成功'); | |
153 | + } | |
154 | + } finally { | |
155 | + setProps({ | |
156 | + loading: false, | |
157 | + }); | |
158 | + reload(); | |
159 | + } | |
160 | + }; | |
121 | 161 | return { |
122 | 162 | register, |
123 | 163 | registerTable, |
... | ... | @@ -126,6 +166,8 @@ |
126 | 166 | handleEdit, |
127 | 167 | handleDelete, |
128 | 168 | handleSuccess, |
169 | + statusChange, | |
170 | + disabled, | |
129 | 171 | }; |
130 | 172 | }, |
131 | 173 | }); | ... | ... |
1 | 1 | import { BasicColumn } from '/@/components/Table'; |
2 | 2 | import { FormSchema } from '/@/components/Table'; |
3 | -import { h } from 'vue'; | |
4 | -import { Switch } from 'ant-design-vue'; | |
5 | -import { setDictItemStatus } from '/@/api/system/dict'; | |
6 | -import { useMessage } from '/@/hooks/web/useMessage'; | |
3 | + | |
7 | 4 | export const columns: BasicColumn[] = [ |
8 | 5 | { |
9 | 6 | title: '文本值', |
... | ... | @@ -24,30 +21,7 @@ export const columns: BasicColumn[] = [ |
24 | 21 | title: '状态', |
25 | 22 | dataIndex: 'status', |
26 | 23 | width: 100, |
27 | - customRender: ({ record }) => { | |
28 | - if (!Reflect.has(record, 'pendingStatus')) { | |
29 | - record.pendingStatus = false; | |
30 | - } | |
31 | - return h(Switch, { | |
32 | - checked: record.status === 1, | |
33 | - checkedChildren: '已启用', | |
34 | - unCheckedChildren: '已禁用', | |
35 | - loading: record.pendingStatus, | |
36 | - onChange(checked: boolean) { | |
37 | - record.pendingStatus = true; | |
38 | - const newStatus = checked ? 1 : 0; | |
39 | - const { createMessage } = useMessage(); | |
40 | - setDictItemStatus(record.id, newStatus) | |
41 | - .then(() => { | |
42 | - record.status = newStatus; | |
43 | - createMessage.success(`修改成功`); | |
44 | - }) | |
45 | - .finally(() => { | |
46 | - record.pendingStatus = false; | |
47 | - }); | |
48 | - }, | |
49 | - }); | |
50 | - }, | |
24 | + slots: { customRender: 'status' }, | |
51 | 25 | }, |
52 | 26 | { |
53 | 27 | title: '排序', | ... | ... |
... | ... | @@ -129,9 +129,6 @@ export const formSchema: FormSchema[] = [ |
129 | 129 | { label: t('routes.common.system.menuEditPagesMenu'), value: '1' }, //菜单 |
130 | 130 | { label: t('routes.common.system.menuEditPagesButton'), value: '2' }, //按钮 |
131 | 131 | ], |
132 | - onChange: (e) => { | |
133 | - console.log('--------11111---------------', e); | |
134 | - }, | |
135 | 132 | }, |
136 | 133 | colProps: { lg: 24, md: 24 }, |
137 | 134 | }, |
... | ... | @@ -187,6 +184,15 @@ export const formSchema: FormSchema[] = [ |
187 | 184 | }, |
188 | 185 | }, |
189 | 186 | { |
187 | + field: 'permission', | |
188 | + label: '权限标识', //路由地址 | |
189 | + component: 'Input', | |
190 | + required: true, | |
191 | + componentProps: { | |
192 | + maxLength: 255, | |
193 | + }, | |
194 | + }, | |
195 | + { | |
190 | 196 | field: 'component', |
191 | 197 | label: t('routes.common.system.menuEditPagesComponentsPath'), //组件路径 |
192 | 198 | component: 'Input', | ... | ... |