¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div> |
| | | <!--å¼ç¨è¡¨æ ¼--> |
| | | <BasicTable @register="registerTable" :rowSelection="rowSelection"> |
| | | <!--ææ§½:tableæ é¢--> |
| | | <template #tableTitle> |
| | | <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> æ°å¢</a-button> |
| | | <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导åº</a-button> |
| | | <j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导å
¥</j-upload-button> |
| | | <a-dropdown v-if="selectedRowKeys.length > 0"> |
| | | <template #overlay> |
| | | <a-menu> |
| | | <a-menu-item key="1" @click="batchHandleDelete"> |
| | | <Icon icon="ant-design:delete-outlined" /> |
| | | å é¤ |
| | | </a-menu-item> |
| | | </a-menu> |
| | | </template> |
| | | <a-button |
| | | >æ¹éæä½ |
| | | <Icon icon="mdi:chevron-down" /> |
| | | </a-button> |
| | | </a-dropdown> |
| | | </template> |
| | | <!--æä½æ --> |
| | | <template #action="{ record }"> |
| | | <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" /> |
| | | </template> |
| | | <!--åæ®µåæ¾ææ§½--> |
| | | <template #htmlSlot="{ text }"> |
| | | <div v-html="text"></div> |
| | | </template> |
| | | <!--çå¸åºåæ®µåæ¾ææ§½--> |
| | | <template #pcaSlot="{ text }"> |
| | | {{ getAreaTextByCode(text) }} |
| | | </template> |
| | | <template #fileSlot="{ text }"> |
| | | <span v-if="!text" style="font-size: 12px; font-style: italic">æ æä»¶</span> |
| | | <a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small" @click="downloadFile(text)">ä¸è½½</a-button> |
| | | </template> |
| | | </BasicTable> |
| | | <!-- 表ååºå --> |
| | | <DryHerbModal @register="registerModal" @success="handleSuccess" /> |
| | | </div> |
| | | </template> |
| | | |
| | | <script lang="ts" name="dry-dryHerb" setup> |
| | | import { ref } from 'vue' |
| | | import DryHerbModal from './components/DryHerbModal.vue' |
| | | import { batchDelete, deleteOne, getExportUrl, getImportUrl, list } from './api/DryHerb.api' |
| | | import { columns, searchFormSchema } from './dataDefine/DryHerb.data' |
| | | import { useModal } from '/@/components/Modal' |
| | | import { BasicTable, TableAction } from '/@/components/Table' |
| | | import { useListPage } from '/@/hooks/system/useListPage' |
| | | import { downloadFile } from '/@/utils/common/renderUtils' |
| | | const checkedKeys = ref<Array<string | number>>([]) |
| | | //注åmodel |
| | | const [registerModal, { openModal }] = useModal() |
| | | //注åtableæ°æ® |
| | | const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({ |
| | | tableProps: { |
| | | title: 'è¯æ', |
| | | api: list, |
| | | columns, |
| | | canResize: false, |
| | | formConfig: { |
| | | //labelWidth: 120, |
| | | schemas: searchFormSchema, |
| | | autoSubmitOnEnter: true, |
| | | showAdvancedButton: true, |
| | | fieldMapToNumber: [], |
| | | fieldMapToTime: [], |
| | | }, |
| | | actionColumn: { |
| | | width: 120, |
| | | fixed: 'right', |
| | | }, |
| | | }, |
| | | exportConfig: { |
| | | name: 'è¯æ', |
| | | url: getExportUrl, |
| | | }, |
| | | importConfig: { |
| | | url: getImportUrl, |
| | | success: handleSuccess, |
| | | }, |
| | | }) |
| | | |
| | | const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext |
| | | |
| | | /** |
| | | * æ°å¢äºä»¶ |
| | | */ |
| | | function handleAdd() { |
| | | openModal(true, { |
| | | isUpdate: false, |
| | | showFooter: true, |
| | | }) |
| | | } |
| | | /** |
| | | * ç¼è¾äºä»¶ |
| | | */ |
| | | function handleEdit(record: Recordable) { |
| | | openModal(true, { |
| | | record, |
| | | isUpdate: true, |
| | | showFooter: true, |
| | | }) |
| | | } |
| | | /** |
| | | * 详æ
|
| | | */ |
| | | function handleDetail(record: Recordable) { |
| | | openModal(true, { |
| | | record, |
| | | isUpdate: true, |
| | | showFooter: false, |
| | | }) |
| | | } |
| | | /** |
| | | * å é¤äºä»¶ |
| | | */ |
| | | async function handleDelete(record) { |
| | | await deleteOne({ id: record.id }, handleSuccess) |
| | | } |
| | | /** |
| | | * æ¹éå é¤äºä»¶ |
| | | */ |
| | | async function batchHandleDelete() { |
| | | await batchDelete({ ids: selectedRowKeys.value }, handleSuccess) |
| | | } |
| | | /** |
| | | * æååè° |
| | | */ |
| | | function handleSuccess() { |
| | | ;(selectedRowKeys.value = []) && reload() |
| | | } |
| | | /** |
| | | * æä½æ |
| | | */ |
| | | function getTableAction(record) { |
| | | return [ |
| | | { |
| | | label: 'ç¼è¾', |
| | | onClick: handleEdit.bind(null, record), |
| | | }, |
| | | ] |
| | | } |
| | | /** |
| | | * 䏿æä½æ |
| | | */ |
| | | function getDropDownAction(record) { |
| | | return [ |
| | | { |
| | | label: '详æ
', |
| | | onClick: handleDetail.bind(null, record), |
| | | }, |
| | | { |
| | | label: 'å é¤', |
| | | popConfirm: { |
| | | title: 'æ¯å¦ç¡®è®¤å é¤', |
| | | confirm: handleDelete.bind(null, record), |
| | | }, |
| | | }, |
| | | ] |
| | | } |
| | | </script> |
| | | |
| | | <style scoped></style> |