| | |
| | | <script setup lang="ts"> |
| | | import type { Recordable } from '@vben/types'; |
| | | |
| | | import { onMounted, ref } from 'vue'; |
| | | import { useRouter } from 'vue-router'; |
| | | import { computed, onMounted, ref } from 'vue'; |
| | | |
| | | import { useAccess } from '@vben/access'; |
| | | import { Page, useVbenDrawer, useVbenModal, type VbenFormProps } from '@vben/common-ui'; |
| | | import { $t } from '@vben/locales'; |
| | | import { useUserStore } from '@vben/stores'; |
| | | import { addFullName, getPopupContainer, getVxePopupContainer } from '@vben/utils'; |
| | | |
| | | import { Modal, Popconfirm, Space } from 'ant-design-vue'; |
| | |
| | | import { delFixture, fixtureExport, listFixture } from '#/api/eims/fixture'; |
| | | import { getDeptTree, userList } from '#/api/system/user'; |
| | | import { commonDownloadExcel } from '#/utils/file/download'; |
| | | import fixtureBorrowDrawer from '#/views/eims/fixture-borrow/fixture-borrow-drawer.vue'; |
| | | |
| | | import { columns, querySchema } from './data'; |
| | | import fixtureDrawer from './fixture-drawer.vue'; |
| | | import fixtureImportModal from './fixture-import-modal.vue'; |
| | | import FixtureTypeTree from './fixture-type-tree.vue'; |
| | | |
| | | const userStore = useUserStore(); |
| | | const userId = userStore.userInfo?.userId; |
| | | |
| | | // 左边工具类型 |
| | | const selectTypeId = ref<string[]>([]); |
| | | defineExpose({ |
| | | tableSelect |
| | | }); |
| | | |
| | | const formOptions: VbenFormProps = { |
| | | commonConfig: { |
| | |
| | | connectedComponent: fixtureDrawer |
| | | }); |
| | | |
| | | const [FixtureBorrowDrawer, fixtureBorrowDrawerApi] = useVbenDrawer({ |
| | | connectedComponent: fixtureBorrowDrawer |
| | | }); |
| | | |
| | | /** |
| | | * 导入 |
| | | */ |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | function handleBorrow(row: Recordable<any>, status: string) { |
| | | if (userId === null || userId === undefined || userId === '') { |
| | | Modal.error({ |
| | | content: '获取用户信息失败,请重新登录后重试!', |
| | | title: '提示' |
| | | }); |
| | | return false; |
| | | } |
| | | // 工具台账借用状态TODO fixture_borrow_status 0-空闲 1-借出 |
| | | if (status === '0') { |
| | | // 空闲时借出,新增一条借出数据 |
| | | fixtureBorrowDrawerApi.setData({ status, borrowUser: userId, fixtureId: row.id, fixtureName: row.fixtureName, fixturePage: true }); |
| | | fixtureBorrowDrawerApi.open(); |
| | | } else if (status === '1') { |
| | | // 借出时归还,更新借出数据 |
| | | fixtureBorrowDrawerApi.setData({ id: row.curBorrowId }); |
| | | fixtureBorrowDrawerApi.open(); |
| | | } |
| | | } |
| | | function handleDownloadExcel() { |
| | | commonDownloadExcel(fixtureExport, '工具台账', tableApi.formApi.form.values, { |
| | | fieldMappingTime: formOptions.fieldMappingTime |
| | | }); |
| | | } |
| | | |
| | | const router = useRouter(); |
| | | |
| | | function handleDetail(record: Recordable<any>) { |
| | | router.push(`/fixture/detail/${record.id}`); |
| | | } |
| | | |
| | | /** |
| | |
| | | onMounted(async () => { |
| | | await setupDeptSelect(); |
| | | }); |
| | | |
| | | const { hasAccessByRoles } = useAccess(); |
| | | const isSuperAdmin = computed(() => hasAccessByRoles(['superadmin'])); |
| | | /** |
| | | * 只有借用用户和管理员可以点击归还 |
| | | */ |
| | | function isBorrowUser(row: any) { |
| | | return isSuperAdmin.value || row?.borrowUser === userId; |
| | | } |
| | | |
| | | function isBorrow(row: any) { |
| | | // TODO 对应字典状态fixture_borrow_status 0-空闲 1-借出 |
| | | return row.borrowStatus === '0' || row.borrowStatus === null; |
| | | } |
| | | |
| | | function isReturn(row: any) { |
| | | // TODO 对应字典状态fixture_borrow_status 0-空闲 1-借出 |
| | | return row.borrowStatus === '1'; |
| | | } |
| | | |
| | | // 选中数据 |
| | | function tableSelect() { |
| | | return tableApi.grid.getCheckboxRecords(); |
| | | } |
| | | </script> |
| | | |
| | | <template> |
| | |
| | | </Space> |
| | | </template> |
| | | |
| | | <template #equName="{ row }"> |
| | | <Space> |
| | | <a-button type="link" @click="handleDetail(row)"> {{ row.equName }}</a-button> |
| | | </Space> |
| | | </template> |
| | | |
| | | <template #action="{ row }"> |
| | | <Space> |
| | | <ghost-button v-access:code="['eims:fixture:edit']" @click.stop="handleEdit(row)"> |
| | | {{ $t('pages.common.edit') }} |
| | | </ghost-button> |
| | | <ghost-button v-if="row.menuType !== 'F'" class="btn-success" v-access:code="['eims:fixture:list']" @click="handleDetail(row)"> |
| | | {{ $t('pages.common.info') }} |
| | | <ghost-button v-if="isBorrow(row)" class="btn-success" v-access:code="['eims:fixture:borrow']" @click="handleBorrow(row, '0')"> |
| | | 借用 |
| | | </ghost-button> |
| | | <ghost-button |
| | | v-else-if="isReturn(row) && isBorrowUser(row)" |
| | | v-access:code="['eims:fixture:borrow']" |
| | | @click="handleBorrow(row, '1')" |
| | | > |
| | | 归还 |
| | | </ghost-button> |
| | | <Popconfirm :get-popup-container="getVxePopupContainer" placement="left" title="确认删除?" @confirm="handleDelete(row)"> |
| | | <ghost-button danger v-access:code="['eims:fixture:remove']" @click.stop=""> |
| | |
| | | </BasicTable> |
| | | </div> |
| | | <FixtureDrawer @reload="tableApi.query()" /> |
| | | <FixtureBorrowDrawer @reload="tableApi.query()" /> |
| | | <FixtureImportModal @reload="tableApi.query()" /> |
| | | </Page> |
| | | </template> |