Showing
17 changed files
with
209 additions
and
206 deletions
| 1 | 1 | import { ref, computed } from 'vue'; |
| 2 | +import { BasicTableProps } from '/@/components/Table'; | |
| 2 | 3 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 4 | + | |
| 3 | 5 | /** |
| 4 | 6 | * |
| 5 | 7 | * @param deleteFn 要删除的API接口方法 |
| 6 | 8 | * @param handleSuccess 刷新表格的方法 |
| 9 | + * @param setProps 用于设置表格的loading状态函数 - 防止页面重复提交 | |
| 10 | + * | |
| 7 | 11 | * @returns { |
| 8 | 12 | * hasBatchDelete: 是否可以删除 |
| 9 | 13 | * selectionOptions 表格复选框配置项 |
| ... | ... | @@ -21,10 +25,11 @@ interface selectionOptions { |
| 21 | 25 | type: 'radio' | 'checkbox'; |
| 22 | 26 | }; |
| 23 | 27 | } |
| 24 | -export const useBatchDelete = ( | |
| 28 | +export function useBatchDelete( | |
| 25 | 29 | deleteFn: (deleteIds: string[]) => Promise<void>, |
| 26 | - handleSuccess: () => void | |
| 27 | -) => { | |
| 30 | + handleSuccess: () => void, | |
| 31 | + setProps: (props: Partial<BasicTableProps>) => void | |
| 32 | +) { | |
| 28 | 33 | const { createMessage } = useMessage(); |
| 29 | 34 | const selectedRowIds = ref<string[]>([]); |
| 30 | 35 | const hasBatchDelete = computed(() => selectedRowIds.value.length <= 0); |
| ... | ... | @@ -41,20 +46,23 @@ export const useBatchDelete = ( |
| 41 | 46 | selectedRowIds.value = selectedRowKeys; |
| 42 | 47 | }; |
| 43 | 48 | const handleDeleteOrBatchDelete = async (record: Recordable | null) => { |
| 44 | - if (record) { | |
| 45 | - try { | |
| 49 | + setProps({ | |
| 50 | + loading: true, | |
| 51 | + }); | |
| 52 | + try { | |
| 53 | + if (record) { | |
| 46 | 54 | await deleteFn([record.id]); |
| 47 | 55 | createMessage.success('删除成功'); |
| 48 | - handleSuccess(); | |
| 49 | - } catch (e) {} | |
| 50 | - } else { | |
| 51 | - try { | |
| 56 | + } else { | |
| 52 | 57 | await deleteFn(selectedRowIds.value); |
| 53 | 58 | createMessage.success('批量删除成功'); |
| 54 | - console.log(selectedRowIds.value); | |
| 55 | - handleSuccess(); | |
| 56 | - } catch (e) {} | |
| 57 | - selectedRowIds.value = []; | |
| 59 | + selectedRowIds.value = []; | |
| 60 | + } | |
| 61 | + } finally { | |
| 62 | + setProps({ | |
| 63 | + loading: false, | |
| 64 | + }); | |
| 65 | + handleSuccess(); | |
| 58 | 66 | } |
| 59 | 67 | }; |
| 60 | 68 | |
| ... | ... | @@ -72,4 +80,4 @@ export const useBatchDelete = ( |
| 72 | 80 | }, |
| 73 | 81 | }; |
| 74 | 82 | return { hasBatchDelete, selectionOptions, handleDeleteOrBatchDelete, resetSelectedRowKeys }; |
| 75 | -}; | |
| 83 | +} | ... | ... |
| ... | ... | @@ -81,7 +81,7 @@ |
| 81 | 81 | </template> |
| 82 | 82 | |
| 83 | 83 | <script lang="ts"> |
| 84 | - import { defineComponent, reactive, h } from 'vue'; | |
| 84 | + import { defineComponent, reactive, h, nextTick } from 'vue'; | |
| 85 | 85 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| 86 | 86 | import { PageWrapper } from '/@/components/Page'; |
| 87 | 87 | import { useDrawer } from '/@/components/Drawer'; |
| ... | ... | @@ -116,16 +116,7 @@ |
| 116 | 116 | const handleSuccess = () => { |
| 117 | 117 | reload(); |
| 118 | 118 | }; |
| 119 | - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | |
| 120 | - useBatchDelete(deleteAlarmConfig, handleSuccess); | |
| 121 | - selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { | |
| 122 | - // Demo:status为1的选择框禁用 | |
| 123 | - if (record.status === 1) { | |
| 124 | - return { disabled: true }; | |
| 125 | - } else { | |
| 126 | - return { disabled: false }; | |
| 127 | - } | |
| 128 | - }; | |
| 119 | + | |
| 129 | 120 | // 表格hooks |
| 130 | 121 | const [registerTable, { reload, setProps, setSelectedRowKeys }] = useTable({ |
| 131 | 122 | title: '告警配置列表', |
| ... | ... | @@ -147,7 +138,19 @@ |
| 147 | 138 | slots: { customRender: 'action' }, |
| 148 | 139 | fixed: 'right', |
| 149 | 140 | }, |
| 150 | - ...selectionOptions, | |
| 141 | + }); | |
| 142 | + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | |
| 143 | + useBatchDelete(deleteAlarmConfig, handleSuccess, setProps); | |
| 144 | + selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { | |
| 145 | + // Demo:status为1的选择框禁用 | |
| 146 | + if (record.status === 1) { | |
| 147 | + return { disabled: true }; | |
| 148 | + } else { | |
| 149 | + return { disabled: false }; | |
| 150 | + } | |
| 151 | + }; | |
| 152 | + nextTick(() => { | |
| 153 | + setProps(selectionOptions); | |
| 151 | 154 | }); |
| 152 | 155 | // 弹框 |
| 153 | 156 | const [registerDrawer, { openDrawer }] = useDrawer(); | ... | ... |
| ... | ... | @@ -6,12 +6,7 @@ |
| 6 | 6 | @select="handleSelect" |
| 7 | 7 | ref="organizationIdTreeRef" |
| 8 | 8 | /> |
| 9 | - <BasicTable | |
| 10 | - :clickToRowSelect="false" | |
| 11 | - @register="registerTable" | |
| 12 | - :searchInfo="searchInfo" | |
| 13 | - class="w-3/4 xl:w-4/5" | |
| 14 | - > | |
| 9 | + <BasicTable @register="registerTable" :searchInfo="searchInfo" class="w-3/4 xl:w-4/5"> | |
| 15 | 10 | <template #toolbar> |
| 16 | 11 | <Authority value="api:yt:admin:addAlarmContact"> |
| 17 | 12 | <a-button type="primary" @click="handleCreateOrEdit(null)"> 新增告警联系人 </a-button> |
| ... | ... | @@ -56,13 +51,14 @@ |
| 56 | 51 | </template> |
| 57 | 52 | |
| 58 | 53 | <script lang="ts"> |
| 59 | - import { defineComponent, reactive, ref, computed } from 'vue'; | |
| 54 | + import { defineComponent, reactive, nextTick } from 'vue'; | |
| 60 | 55 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| 61 | 56 | import { PageWrapper } from '/@/components/Page'; |
| 62 | - import { useMessage } from '/@/hooks/web/useMessage'; | |
| 63 | 57 | import { useDrawer } from '/@/components/Drawer'; |
| 64 | 58 | import ContactDrawer from './ContactDrawer.vue'; |
| 65 | 59 | import { useResetOrganizationTree, OrganizationIdTree } from '/@/views/common/organizationIdTree'; |
| 60 | + import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; | |
| 61 | + | |
| 66 | 62 | import { getAlarmContact, deleteAlarmContact } from '/@/api/alarm/contact/alarmContact'; |
| 67 | 63 | import { searchFormSchema, columns } from './config.data'; |
| 68 | 64 | import { Authority } from '/@/components/Authority'; |
| ... | ... | @@ -77,18 +73,13 @@ |
| 77 | 73 | Authority, |
| 78 | 74 | }, |
| 79 | 75 | setup() { |
| 80 | - let selectedRowIds = ref<string[]>([]); | |
| 81 | - const hasBatchDelete = computed(() => selectedRowIds.value.length <= 0); | |
| 82 | - // 复选框事件 | |
| 83 | - const onSelectRowChange = (selectedRowKeys: string[]) => { | |
| 84 | - selectedRowIds.value = selectedRowKeys; | |
| 85 | - }; | |
| 86 | 76 | const searchInfo = reactive<Recordable>({}); |
| 87 | 77 | const { organizationIdTreeRef, resetFn } = useResetOrganizationTree(searchInfo); |
| 88 | 78 | // 表格hooks |
| 89 | - const [registerTable, { reload }] = useTable({ | |
| 79 | + const [registerTable, { reload, setProps }] = useTable({ | |
| 90 | 80 | title: '告警联系人列表', |
| 91 | 81 | api: getAlarmContact, |
| 82 | + clickToRowSelect: false, | |
| 92 | 83 | columns, |
| 93 | 84 | clickToRowSelect: false, |
| 94 | 85 | formConfig: { |
| ... | ... | @@ -99,10 +90,6 @@ |
| 99 | 90 | useSearchForm: true, |
| 100 | 91 | showTableSetting: true, |
| 101 | 92 | bordered: true, |
| 102 | - rowSelection: { | |
| 103 | - onChange: onSelectRowChange, | |
| 104 | - type: 'checkbox', | |
| 105 | - }, | |
| 106 | 93 | rowKey: 'id', |
| 107 | 94 | actionColumn: { |
| 108 | 95 | width: 200, |
| ... | ... | @@ -112,14 +99,20 @@ |
| 112 | 99 | fixed: 'right', |
| 113 | 100 | }, |
| 114 | 101 | }); |
| 102 | + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete( | |
| 103 | + deleteAlarmContact, | |
| 104 | + handleSuccess, | |
| 105 | + setProps | |
| 106 | + ); | |
| 107 | + nextTick(() => { | |
| 108 | + setProps(selectionOptions); | |
| 109 | + }); | |
| 115 | 110 | // 弹框 |
| 116 | 111 | const [registerDrawer, { openDrawer }] = useDrawer(); |
| 117 | - const { createMessage } = useMessage(); | |
| 118 | - | |
| 119 | 112 | // 刷新 |
| 120 | - const handleSuccess = () => { | |
| 113 | + function handleSuccess() { | |
| 121 | 114 | reload(); |
| 122 | - }; | |
| 115 | + } | |
| 123 | 116 | // 新增或编辑 |
| 124 | 117 | const handleCreateOrEdit = (record: Recordable | null) => { |
| 125 | 118 | if (record) { |
| ... | ... | @@ -133,24 +126,6 @@ |
| 133 | 126 | }); |
| 134 | 127 | } |
| 135 | 128 | }; |
| 136 | - // 删除或批量删除 | |
| 137 | - const handleDeleteOrBatchDelete = async (record: Recordable | null) => { | |
| 138 | - if (record) { | |
| 139 | - try { | |
| 140 | - await deleteAlarmContact([record.id]); | |
| 141 | - createMessage.success('删除联系人成功'); | |
| 142 | - handleSuccess(); | |
| 143 | - } catch (e) {} | |
| 144 | - } else { | |
| 145 | - try { | |
| 146 | - await deleteAlarmContact(selectedRowIds.value); | |
| 147 | - createMessage.success('批量删除联系人成功'); | |
| 148 | - selectedRowIds.value = []; | |
| 149 | - handleSuccess(); | |
| 150 | - } catch (e) {} | |
| 151 | - } | |
| 152 | - }; | |
| 153 | - | |
| 154 | 129 | // 树形选择器 |
| 155 | 130 | const handleSelect = (organizationId: string) => { |
| 156 | 131 | searchInfo.organizationId = organizationId; | ... | ... |
| ... | ... | @@ -68,10 +68,9 @@ |
| 68 | 68 | </template> |
| 69 | 69 | |
| 70 | 70 | <script lang="ts"> |
| 71 | - import { defineComponent, reactive, ref, computed } from 'vue'; | |
| 71 | + import { defineComponent, reactive, ref, nextTick } from 'vue'; | |
| 72 | 72 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| 73 | 73 | import { PageWrapper } from '/@/components/Page'; |
| 74 | - import { useMessage } from '/@/hooks/web/useMessage'; | |
| 75 | 74 | import { useDrawer } from '/@/components/Drawer'; |
| 76 | 75 | import ContactDrawer from './ConfigurationCenterDrawer.vue'; |
| 77 | 76 | import { useResetOrganizationTree, OrganizationIdTree } from '/@/views/common/organizationIdTree'; |
| ... | ... | @@ -80,6 +79,8 @@ |
| 80 | 79 | getPage, |
| 81 | 80 | deleteConfigurationCenter, |
| 82 | 81 | } from '/@/api/configuration/center/configurationCenter'; |
| 82 | + import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; | |
| 83 | + | |
| 83 | 84 | import { getAppEnvConfig } from '/@/utils/env'; |
| 84 | 85 | import { Authority } from '/@/components/Authority'; |
| 85 | 86 | |
| ... | ... | @@ -95,7 +96,6 @@ |
| 95 | 96 | setup() { |
| 96 | 97 | const { VITE_GLOB_CONFIGURATION } = getAppEnvConfig(); |
| 97 | 98 | let selectedRowIds = ref<string[]>([]); |
| 98 | - const hasBatchDelete = computed(() => selectedRowIds.value.length <= 0); | |
| 99 | 99 | // 复选框事件 |
| 100 | 100 | const onSelectRowChange = (selectedRowKeys: string[]) => { |
| 101 | 101 | selectedRowIds.value = selectedRowKeys; |
| ... | ... | @@ -103,7 +103,7 @@ |
| 103 | 103 | const searchInfo = reactive<Recordable>({}); |
| 104 | 104 | const { organizationIdTreeRef, resetFn } = useResetOrganizationTree(searchInfo); |
| 105 | 105 | // 表格hooks |
| 106 | - const [registerTable, { reload }] = useTable({ | |
| 106 | + const [registerTable, { reload, setProps }] = useTable({ | |
| 107 | 107 | title: '组态中心列表', |
| 108 | 108 | api: getPage, |
| 109 | 109 | columns, |
| ... | ... | @@ -117,10 +117,6 @@ |
| 117 | 117 | useSearchForm: true, |
| 118 | 118 | showTableSetting: true, |
| 119 | 119 | bordered: true, |
| 120 | - rowSelection: { | |
| 121 | - onChange: onSelectRowChange, | |
| 122 | - type: 'checkbox', | |
| 123 | - }, | |
| 124 | 120 | rowKey: 'id', |
| 125 | 121 | actionColumn: { |
| 126 | 122 | width: 200, |
| ... | ... | @@ -130,14 +126,22 @@ |
| 130 | 126 | fixed: 'right', |
| 131 | 127 | }, |
| 132 | 128 | }); |
| 129 | + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete( | |
| 130 | + deleteConfigurationCenter, | |
| 131 | + handleSuccess, | |
| 132 | + setProps | |
| 133 | + ); | |
| 134 | + nextTick(() => { | |
| 135 | + setProps(selectionOptions); | |
| 136 | + }); | |
| 137 | + | |
| 133 | 138 | // 弹框 |
| 134 | 139 | const [registerDrawer, { openDrawer }] = useDrawer(); |
| 135 | - const { createMessage } = useMessage(); | |
| 136 | 140 | |
| 137 | 141 | // 刷新 |
| 138 | - const handleSuccess = () => { | |
| 142 | + function handleSuccess() { | |
| 139 | 143 | reload(); |
| 140 | - }; | |
| 144 | + } | |
| 141 | 145 | // 新增或编辑 |
| 142 | 146 | const handleCreateOrEdit = (record: Recordable | null) => { |
| 143 | 147 | if (record) { |
| ... | ... | @@ -151,24 +155,6 @@ |
| 151 | 155 | }); |
| 152 | 156 | } |
| 153 | 157 | }; |
| 154 | - // 删除或批量删除 | |
| 155 | - const handleDeleteOrBatchDelete = async (record: Recordable | null) => { | |
| 156 | - if (record) { | |
| 157 | - try { | |
| 158 | - await deleteConfigurationCenter([record.id]); | |
| 159 | - createMessage.success('删除组态成功'); | |
| 160 | - handleSuccess(); | |
| 161 | - } catch (e) {} | |
| 162 | - } else { | |
| 163 | - try { | |
| 164 | - await deleteConfigurationCenter(selectedRowIds.value); | |
| 165 | - createMessage.success('批量删除组态成功'); | |
| 166 | - selectedRowIds.value = []; | |
| 167 | - handleSuccess(); | |
| 168 | - } catch (e) {} | |
| 169 | - } | |
| 170 | - }; | |
| 171 | - | |
| 172 | 158 | // 树形选择器 |
| 173 | 159 | const handleSelect = (organizationId: string) => { |
| 174 | 160 | searchInfo.organizationId = organizationId; | ... | ... |
| ... | ... | @@ -114,13 +114,12 @@ |
| 114 | 114 | {{ item.name }} |
| 115 | 115 | </Tooltip> |
| 116 | 116 | </div> |
| 117 | - | |
| 118 | 117 | <div class="flex w-7/10"> |
| 119 | 118 | <Progress |
| 120 | 119 | :showInfo="false" |
| 121 | 120 | size="small" |
| 122 | 121 | style="width: 70%" |
| 123 | - :percent="item.count / 10000" | |
| 122 | + :percent="(item.count / tenantTop10[0].count) * 100" | |
| 124 | 123 | :strokeWidth="12" |
| 125 | 124 | :strokeColor=" |
| 126 | 125 | index === 0 | ... | ... |
| ... | ... | @@ -155,7 +155,7 @@ |
| 155 | 155 | </div> |
| 156 | 156 | </template> |
| 157 | 157 | <script lang="ts"> |
| 158 | - import { defineComponent, reactive, unref } from 'vue'; | |
| 158 | + import { defineComponent, reactive, unref, nextTick } from 'vue'; | |
| 159 | 159 | import { DeviceState, DeviceTypeEnum } from '/@/api/device/model/deviceModel'; |
| 160 | 160 | import { BasicTable, useTable, TableAction, TableImg } from '/@/components/Table'; |
| 161 | 161 | import { columns, searchFormSchema } from './config/device.data'; |
| ... | ... | @@ -202,17 +202,6 @@ |
| 202 | 202 | Authority, |
| 203 | 203 | }, |
| 204 | 204 | setup(_) { |
| 205 | - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | |
| 206 | - useBatchDelete(deleteDevice, handleSuccess); | |
| 207 | - selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { | |
| 208 | - // Demo:status为1的选择框禁用 | |
| 209 | - if (record.customerId) { | |
| 210 | - return { disabled: true }; | |
| 211 | - } else { | |
| 212 | - return { disabled: false }; | |
| 213 | - } | |
| 214 | - }; | |
| 215 | - | |
| 216 | 205 | const { createMessage } = useMessage(); |
| 217 | 206 | const go = useGo(); |
| 218 | 207 | const searchInfo = reactive<Recordable>({}); |
| ... | ... | @@ -220,7 +209,7 @@ |
| 220 | 209 | const [registerModal, { openModal }] = useModal(); |
| 221 | 210 | const [registerCustomerModal, { openModal: openCustomerModal }] = useModal(); |
| 222 | 211 | const [registerDetailDrawer, { openDrawer }] = useDrawer(); |
| 223 | - const [registerTable, { reload, setSelectedRowKeys }] = useTable({ | |
| 212 | + const [registerTable, { reload, setSelectedRowKeys, setProps }] = useTable({ | |
| 224 | 213 | title: '设备列表', |
| 225 | 214 | api: devicePage, |
| 226 | 215 | columns, |
| ... | ... | @@ -242,7 +231,19 @@ |
| 242 | 231 | slots: { customRender: 'action' }, |
| 243 | 232 | fixed: 'right', |
| 244 | 233 | }, |
| 245 | - ...selectionOptions, | |
| 234 | + }); | |
| 235 | + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | |
| 236 | + useBatchDelete(deleteDevice, handleSuccess, setProps); | |
| 237 | + selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { | |
| 238 | + // Demo:status为1的选择框禁用 | |
| 239 | + if (record.customerId) { | |
| 240 | + return { disabled: true }; | |
| 241 | + } else { | |
| 242 | + return { disabled: false }; | |
| 243 | + } | |
| 244 | + }; | |
| 245 | + nextTick(() => { | |
| 246 | + setProps(selectionOptions); | |
| 246 | 247 | }); |
| 247 | 248 | |
| 248 | 249 | const userInfo: any = getAuthCache(USER_INFO_KEY); | ... | ... |
| ... | ... | @@ -55,7 +55,7 @@ |
| 55 | 55 | </div> |
| 56 | 56 | </template> |
| 57 | 57 | <script lang="ts"> |
| 58 | - import { defineComponent, h } from 'vue'; | |
| 58 | + import { defineComponent, h, nextTick } from 'vue'; | |
| 59 | 59 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| 60 | 60 | import { messageConfigPage, deleteMessageConfig } from '/@/api/message/config'; |
| 61 | 61 | import { useDrawer } from '/@/components/Drawer'; |
| ... | ... | @@ -77,16 +77,7 @@ |
| 77 | 77 | function handleSuccess() { |
| 78 | 78 | reload(); |
| 79 | 79 | } |
| 80 | - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | |
| 81 | - useBatchDelete(deleteMessageConfig, handleSuccess); | |
| 82 | - selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { | |
| 83 | - // Demo:status为1的选择框禁用 | |
| 84 | - if (record.status === 1) { | |
| 85 | - return { disabled: true }; | |
| 86 | - } else { | |
| 87 | - return { disabled: false }; | |
| 88 | - } | |
| 89 | - }; | |
| 80 | + | |
| 90 | 81 | const [registerTable, { reload, setProps, setSelectedRowKeys }] = useTable({ |
| 91 | 82 | title: '消息配置列表', |
| 92 | 83 | api: messageConfigPage, |
| ... | ... | @@ -106,7 +97,19 @@ |
| 106 | 97 | slots: { customRender: 'action' }, |
| 107 | 98 | fixed: 'right', |
| 108 | 99 | }, |
| 109 | - ...selectionOptions, | |
| 100 | + }); | |
| 101 | + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | |
| 102 | + useBatchDelete(deleteMessageConfig, handleSuccess, setProps); | |
| 103 | + selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { | |
| 104 | + // Demo:status为1的选择框禁用 | |
| 105 | + if (record.status === 1) { | |
| 106 | + return { disabled: true }; | |
| 107 | + } else { | |
| 108 | + return { disabled: false }; | |
| 109 | + } | |
| 110 | + }; | |
| 111 | + nextTick(() => { | |
| 112 | + setProps(selectionOptions); | |
| 110 | 113 | }); |
| 111 | 114 | |
| 112 | 115 | function handleCreate() { | ... | ... |
| ... | ... | @@ -41,9 +41,8 @@ |
| 41 | 41 | </div> |
| 42 | 42 | </template> |
| 43 | 43 | <script lang="ts"> |
| 44 | - import { defineComponent } from 'vue'; | |
| 44 | + import { defineComponent, nextTick } from 'vue'; | |
| 45 | 45 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| 46 | - import { useDrawerInner } from '/@/components/Drawer'; | |
| 47 | 46 | import { columns, searchFormSchema } from './email.data'; |
| 48 | 47 | import { mailLogPage, deleteMailLog } from '/@/api/message/records'; |
| 49 | 48 | import { useModal } from '/@/components/Modal'; |
| ... | ... | @@ -56,12 +55,7 @@ |
| 56 | 55 | components: { EmailDetail, BasicTable, TableAction, Authority }, |
| 57 | 56 | setup() { |
| 58 | 57 | const [registerModal, { openModal }] = useModal(); |
| 59 | - const { hasBatchDelete, selectionOptions, handleDeleteOrBatchDelete } = useBatchDelete( | |
| 60 | - deleteMailLog, | |
| 61 | - handleSuccess | |
| 62 | - ); | |
| 63 | - const [register] = useDrawerInner(() => {}); | |
| 64 | - const [registerTable, { reload }] = useTable({ | |
| 58 | + const [registerTable, { reload, setProps }] = useTable({ | |
| 65 | 59 | title: '邮件发送列表', |
| 66 | 60 | api: mailLogPage, |
| 67 | 61 | columns, |
| ... | ... | @@ -81,7 +75,14 @@ |
| 81 | 75 | slots: { customRender: 'action' }, |
| 82 | 76 | fixed: 'right', |
| 83 | 77 | }, |
| 84 | - ...selectionOptions, | |
| 78 | + }); | |
| 79 | + const { hasBatchDelete, selectionOptions, handleDeleteOrBatchDelete } = useBatchDelete( | |
| 80 | + deleteMailLog, | |
| 81 | + handleSuccess, | |
| 82 | + setProps | |
| 83 | + ); | |
| 84 | + nextTick(() => { | |
| 85 | + setProps(selectionOptions); | |
| 85 | 86 | }); |
| 86 | 87 | |
| 87 | 88 | function handleCreate() {} |
| ... | ... | @@ -97,7 +98,6 @@ |
| 97 | 98 | } |
| 98 | 99 | |
| 99 | 100 | return { |
| 100 | - register, | |
| 101 | 101 | registerTable, |
| 102 | 102 | registerModal, |
| 103 | 103 | handleCreate, | ... | ... |
| ... | ... | @@ -40,7 +40,7 @@ |
| 40 | 40 | </div> |
| 41 | 41 | </template> |
| 42 | 42 | <script lang="ts"> |
| 43 | - import { defineComponent, h } from 'vue'; | |
| 43 | + import { defineComponent, h, nextTick } from 'vue'; | |
| 44 | 44 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| 45 | 45 | import { columns, searchFormSchema } from './sms.data'; |
| 46 | 46 | import { Modal } from 'ant-design-vue'; |
| ... | ... | @@ -53,12 +53,7 @@ |
| 53 | 53 | name: 'SmsLog', |
| 54 | 54 | components: { BasicTable, TableAction, Authority }, |
| 55 | 55 | setup() { |
| 56 | - // 批量删除的hooks | |
| 57 | - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete( | |
| 58 | - deleteSmsLog, | |
| 59 | - handleSuccess | |
| 60 | - ); | |
| 61 | - const [registerTable, { reload }] = useTable({ | |
| 56 | + const [registerTable, { reload, setProps }] = useTable({ | |
| 62 | 57 | title: '短信发送列表', |
| 63 | 58 | api: smsLogPage, |
| 64 | 59 | columns, |
| ... | ... | @@ -78,7 +73,14 @@ |
| 78 | 73 | slots: { customRender: 'action' }, |
| 79 | 74 | fixed: 'right', |
| 80 | 75 | }, |
| 81 | - ...selectionOptions, | |
| 76 | + }); | |
| 77 | + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete( | |
| 78 | + deleteSmsLog, | |
| 79 | + handleSuccess, | |
| 80 | + setProps | |
| 81 | + ); | |
| 82 | + nextTick(() => { | |
| 83 | + setProps(selectionOptions); | |
| 82 | 84 | }); |
| 83 | 85 | function handleQuery(record: Recordable) { |
| 84 | 86 | Modal.info({ | ... | ... |
| ... | ... | @@ -52,6 +52,7 @@ |
| 52 | 52 | title: '是否确认删除', |
| 53 | 53 | confirm: handleDeleteOrBatchDelete.bind(null, record), |
| 54 | 54 | }, |
| 55 | + ifShow: record.status == 0, | |
| 55 | 56 | }, |
| 56 | 57 | ]" |
| 57 | 58 | /> |
| ... | ... | @@ -63,7 +64,7 @@ |
| 63 | 64 | </div> |
| 64 | 65 | </template> |
| 65 | 66 | <script lang="ts"> |
| 66 | - import { defineComponent } from 'vue'; | |
| 67 | + import { defineComponent, nextTick } from 'vue'; | |
| 67 | 68 | import { BasicTable, TableAction, useTable } from '/@/components/Table'; |
| 68 | 69 | import { useDrawer } from '/@/components/Drawer'; |
| 69 | 70 | import TemplateDrawer from './TemplateDrawer.vue'; |
| ... | ... | @@ -92,16 +93,7 @@ |
| 92 | 93 | reload(); |
| 93 | 94 | } |
| 94 | 95 | const [registerDrawer, { openDrawer }] = useDrawer(); |
| 95 | - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | |
| 96 | - useBatchDelete(deleteMessageTemplate, handleSuccess); | |
| 97 | - selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { | |
| 98 | - // Demo:status为1的选择框禁用 | |
| 99 | - if (record.status === 1) { | |
| 100 | - return { disabled: true }; | |
| 101 | - } else { | |
| 102 | - return { disabled: false }; | |
| 103 | - } | |
| 104 | - }; | |
| 96 | + | |
| 105 | 97 | const [registerTable, { reload, setProps, setSelectedRowKeys }] = useTable({ |
| 106 | 98 | title: '消息模板列表', |
| 107 | 99 | api: messageTemplatePage, |
| ... | ... | @@ -121,7 +113,19 @@ |
| 121 | 113 | slots: { customRender: 'action' }, |
| 122 | 114 | fixed: 'right', |
| 123 | 115 | }, |
| 124 | - ...selectionOptions, | |
| 116 | + }); | |
| 117 | + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | |
| 118 | + useBatchDelete(deleteMessageTemplate, handleSuccess, setProps); | |
| 119 | + selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { | |
| 120 | + // Demo:status为1的选择框禁用 | |
| 121 | + if (record.status === 1) { | |
| 122 | + return { disabled: true }; | |
| 123 | + } else { | |
| 124 | + return { disabled: false }; | |
| 125 | + } | |
| 126 | + }; | |
| 127 | + nextTick(() => { | |
| 128 | + setProps(selectionOptions); | |
| 125 | 129 | }); |
| 126 | 130 | |
| 127 | 131 | function handleCreate() { | ... | ... |
| ... | ... | @@ -62,7 +62,7 @@ |
| 62 | 62 | </div> |
| 63 | 63 | </template> |
| 64 | 64 | <script lang="ts"> |
| 65 | - import { defineComponent, ref } from 'vue'; | |
| 65 | + import { defineComponent, ref, nextTick } from 'vue'; | |
| 66 | 66 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| 67 | 67 | import { useDrawer } from '/@/components/Drawer'; |
| 68 | 68 | import NotifyManagerDrawer from './useDrawer.vue'; |
| ... | ... | @@ -84,12 +84,9 @@ |
| 84 | 84 | const [registerDrawer, { openDrawer }] = useDrawer(); |
| 85 | 85 | const [registerAdd, { openDrawer: openDrawerAdd }] = useDrawer(); |
| 86 | 86 | // 批量删除 |
| 87 | - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete( | |
| 88 | - notifyDeleteApi, | |
| 89 | - handleSuccess | |
| 90 | - ); | |
| 87 | + | |
| 91 | 88 | const NotifyManagerDrawerRef = ref(); |
| 92 | - const [registerTable, { reload }] = useTable({ | |
| 89 | + const [registerTable, { reload, setProps }] = useTable({ | |
| 93 | 90 | title: '通知列表', |
| 94 | 91 | api: notifyGetTableApi, |
| 95 | 92 | columns, |
| ... | ... | @@ -108,7 +105,14 @@ |
| 108 | 105 | slots: { customRender: 'action' }, |
| 109 | 106 | fixed: 'right', |
| 110 | 107 | }, |
| 111 | - ...selectionOptions, | |
| 108 | + }); | |
| 109 | + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete( | |
| 110 | + notifyDeleteApi, | |
| 111 | + handleSuccess, | |
| 112 | + setProps | |
| 113 | + ); | |
| 114 | + nextTick(() => { | |
| 115 | + setProps(selectionOptions); | |
| 112 | 116 | }); |
| 113 | 117 | |
| 114 | 118 | function handleAdd() { | ... | ... |
| ... | ... | @@ -60,6 +60,7 @@ |
| 60 | 60 | </div> |
| 61 | 61 | </template> |
| 62 | 62 | <script lang="ts" setup> |
| 63 | + import { nextTick } from 'vue'; | |
| 63 | 64 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| 64 | 65 | import { useDrawer } from '/@/components/Drawer'; |
| 65 | 66 | import { |
| ... | ... | @@ -76,17 +77,6 @@ |
| 76 | 77 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 77 | 78 | import { Authority } from '/@/components/Authority'; |
| 78 | 79 | |
| 79 | - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | |
| 80 | - useBatchDelete(screenLinkPageDeleteApi, handleSuccess); | |
| 81 | - selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { | |
| 82 | - // Demo:status为1的选择框禁用 | |
| 83 | - if (record.status === 1) { | |
| 84 | - return { disabled: true }; | |
| 85 | - } else { | |
| 86 | - return { disabled: false }; | |
| 87 | - } | |
| 88 | - }; | |
| 89 | - | |
| 90 | 80 | const userInfo: any = getAuthCache(USER_INFO_KEY); |
| 91 | 81 | const userId = userInfo.userId; |
| 92 | 82 | |
| ... | ... | @@ -110,7 +100,19 @@ |
| 110 | 100 | slots: { customRender: 'action' }, |
| 111 | 101 | fixed: 'right', |
| 112 | 102 | }, |
| 113 | - ...selectionOptions, | |
| 103 | + }); | |
| 104 | + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | |
| 105 | + useBatchDelete(screenLinkPageDeleteApi, handleSuccess, setProps); | |
| 106 | + selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { | |
| 107 | + // Demo:status为1的选择框禁用 | |
| 108 | + if (record.status === 1) { | |
| 109 | + return { disabled: true }; | |
| 110 | + } else { | |
| 111 | + return { disabled: false }; | |
| 112 | + } | |
| 113 | + }; | |
| 114 | + nextTick(() => { | |
| 115 | + setProps(selectionOptions); | |
| 114 | 116 | }); |
| 115 | 117 | |
| 116 | 118 | function handleAdd() { | ... | ... |
| ... | ... | @@ -59,7 +59,7 @@ |
| 59 | 59 | </template> |
| 60 | 60 | |
| 61 | 61 | <script lang="ts" setup> |
| 62 | - import { ref } from 'vue'; | |
| 62 | + import { ref,nextTick } from 'vue'; | |
| 63 | 63 | import { Switch } from 'ant-design-vue'; |
| 64 | 64 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| 65 | 65 | import { columns, searchFormSchema } from './config/config.data'; |
| ... | ... | @@ -76,16 +76,6 @@ |
| 76 | 76 | reload(); |
| 77 | 77 | }; |
| 78 | 78 | |
| 79 | - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | |
| 80 | - useBatchDelete(deleteTransformApi, handleSuccess); | |
| 81 | - selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { | |
| 82 | - // Demo:status为1的选择框禁用 | |
| 83 | - if (record.status === 1) { | |
| 84 | - return { disabled: true }; | |
| 85 | - } else { | |
| 86 | - return { disabled: false }; | |
| 87 | - } | |
| 88 | - }; | |
| 89 | 79 | const [registerTable, { reload, setProps, setSelectedRowKeys }] = useTable({ |
| 90 | 80 | api: getConvertApi, |
| 91 | 81 | title: '转换脚本列表', |
| ... | ... | @@ -107,7 +97,20 @@ |
| 107 | 97 | slots: { customRender: 'action' }, |
| 108 | 98 | fixed: 'right', |
| 109 | 99 | }, |
| 110 | - ...selectionOptions, | |
| 100 | + }); | |
| 101 | + | |
| 102 | + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } = | |
| 103 | + useBatchDelete(deleteTransformApi, handleSuccess, setProps); | |
| 104 | + selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => { | |
| 105 | + // Demo:status为1的选择框禁用 | |
| 106 | + if (record.status === 1) { | |
| 107 | + return { disabled: true }; | |
| 108 | + } else { | |
| 109 | + return { disabled: false }; | |
| 110 | + } | |
| 111 | + }; | |
| 112 | + nextTick(() => { | |
| 113 | + setProps(selectionOptions); | |
| 111 | 114 | }); |
| 112 | 115 | const [registerDrawer, { openDrawer }] = useDrawer(); |
| 113 | 116 | ... | ... |
| ... | ... | @@ -80,7 +80,7 @@ |
| 80 | 80 | </div> |
| 81 | 81 | </template> |
| 82 | 82 | <script lang="ts"> |
| 83 | - import { defineComponent, reactive } from 'vue'; | |
| 83 | + import { defineComponent, reactive, nextTick } from 'vue'; | |
| 84 | 84 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| 85 | 85 | import { deleteUser, getAccountList } from '/@/api/system/system'; |
| 86 | 86 | import { PageWrapper } from '/@/components/Page'; |
| ... | ... | @@ -106,14 +106,10 @@ |
| 106 | 106 | }, |
| 107 | 107 | setup() { |
| 108 | 108 | const go = useGo(); |
| 109 | - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete( | |
| 110 | - deleteUser, | |
| 111 | - handleSuccess | |
| 112 | - ); | |
| 113 | 109 | const [registerModal, { openModal }] = useModal(); |
| 114 | 110 | let searchInfo = reactive<Recordable>({}); |
| 115 | 111 | const { organizationIdTreeRef, resetFn } = useResetOrganizationTree(searchInfo); |
| 116 | - const [registerTable, { reload }] = useTable({ | |
| 112 | + const [registerTable, { reload, setProps }] = useTable({ | |
| 117 | 113 | title: '账号列表', |
| 118 | 114 | api: getAccountList, |
| 119 | 115 | rowKey: 'id', |
| ... | ... | @@ -134,7 +130,14 @@ |
| 134 | 130 | dataIndex: 'action', |
| 135 | 131 | slots: { customRender: 'action' }, |
| 136 | 132 | }, |
| 137 | - ...selectionOptions, | |
| 133 | + }); | |
| 134 | + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete( | |
| 135 | + deleteUser, | |
| 136 | + handleSuccess, | |
| 137 | + setProps | |
| 138 | + ); | |
| 139 | + nextTick(() => { | |
| 140 | + setProps(selectionOptions); | |
| 138 | 141 | }); |
| 139 | 142 | |
| 140 | 143 | function handleCreate() { | ... | ... |
| ... | ... | @@ -53,7 +53,8 @@ |
| 53 | 53 | </div> |
| 54 | 54 | </template> |
| 55 | 55 | <script lang="ts"> |
| 56 | - import { defineComponent } from 'vue'; | |
| 56 | + import { defineComponent, nextTick } from 'vue'; | |
| 57 | + | |
| 57 | 58 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| 58 | 59 | import { sysDictPage, deleteDict } from '/@/api/system/dict'; |
| 59 | 60 | import { useDrawer } from '/@/components/Drawer'; |
| ... | ... | @@ -70,11 +71,8 @@ |
| 70 | 71 | setup() { |
| 71 | 72 | const [registerDrawer, { openDrawer: openDrawer }] = useDrawer(); |
| 72 | 73 | const [registerItemDrawer, { openDrawer: openItemDrawer }] = useDrawer(); |
| 73 | - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete( | |
| 74 | - deleteDict, | |
| 75 | - handleSuccess | |
| 76 | - ); | |
| 77 | - const [registerTable, { reload }] = useTable({ | |
| 74 | + | |
| 75 | + const [registerTable, { reload, setProps }] = useTable({ | |
| 78 | 76 | title: '字典配置列表', |
| 79 | 77 | api: sysDictPage, |
| 80 | 78 | columns, |
| ... | ... | @@ -93,7 +91,14 @@ |
| 93 | 91 | slots: { customRender: 'action' }, |
| 94 | 92 | fixed: 'right', |
| 95 | 93 | }, |
| 96 | - ...selectionOptions, | |
| 94 | + }); | |
| 95 | + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete( | |
| 96 | + deleteDict, | |
| 97 | + handleSuccess, | |
| 98 | + setProps | |
| 99 | + ); | |
| 100 | + nextTick(() => { | |
| 101 | + setProps(selectionOptions); | |
| 97 | 102 | }); |
| 98 | 103 | |
| 99 | 104 | function handleCreate() { | ... | ... |
| ... | ... | @@ -62,11 +62,8 @@ |
| 62 | 62 | const [registerModal, { openDrawer }] = useDrawer(); |
| 63 | 63 | const { t } = useI18n(); //加载国际化 |
| 64 | 64 | const getI18n = computed(() => t('routes.common.organization.toolCreateOrganization')); |
| 65 | - const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete( | |
| 66 | - delOrganization, | |
| 67 | - handleSuccess | |
| 68 | - ); | |
| 69 | - const [registerTable, { reload, expandAll }] = useTable({ | |
| 65 | + | |
| 66 | + const [registerTable, { reload, expandAll, setProps }] = useTable({ | |
| 70 | 67 | title: t('routes.common.organization.toolOrganizationList'), |
| 71 | 68 | api: getOrganizationList, |
| 72 | 69 | columns, |
| ... | ... | @@ -85,7 +82,15 @@ |
| 85 | 82 | slots: { customRender: 'action' }, |
| 86 | 83 | fixed: 'right', |
| 87 | 84 | }, |
| 88 | - ...selectionOptions, | |
| 85 | + }); | |
| 86 | + | |
| 87 | + const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete( | |
| 88 | + delOrganization, | |
| 89 | + handleSuccess, | |
| 90 | + setProps | |
| 91 | + ); | |
| 92 | + nextTick(() => { | |
| 93 | + setProps(selectionOptions); | |
| 89 | 94 | }); |
| 90 | 95 | /** |
| 91 | 96 | * 获得删除提示框的文字 | ... | ... |