| | |
| | | <script setup lang="ts"> |
| | | import type { Recordable } from '@vben/types'; |
| | | |
| | | import { ref } from 'vue'; |
| | | import { useRoute, useRouter } from 'vue-router'; |
| | | import { computed, nextTick, ref } from 'vue'; |
| | | import { useRoute } from 'vue-router'; |
| | | |
| | | import { useAccess } from '@vben/access'; |
| | | import { Page, useVbenDrawer, type VbenFormProps } from '@vben/common-ui'; |
| | | import { $t } from '@vben/locales'; |
| | | import { getVxePopupContainer } from '@vben/utils'; |
| | |
| | | import { commonDownloadExcel } from '#/utils/file/download'; |
| | | |
| | | import { columns, querySchema } from './data'; |
| | | import equDrawer from './equ-drawer.vue'; |
| | | import detailDrawer from './detail-drawer.vue'; |
| | | import EquTypeTree from './equ-type-tree.vue'; |
| | | |
| | | const route = useRoute(); |
| | |
| | | |
| | | // 左边部门用 |
| | | const selectTypeId = ref<string[]>([]); |
| | | // 已盘点 |
| | | const check = ref<string>('已盘'); |
| | | // 未盘点 |
| | | const noCheck = ref<string>('未盘'); |
| | | // 查询添加盘点标记过滤 |
| | | const checkFilter = ref<string>(); |
| | | |
| | | const formOptions: VbenFormProps = { |
| | | commonConfig: { |
| | |
| | | wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4', |
| | | handleReset: async () => { |
| | | selectTypeId.value = []; |
| | | checkFilter.value = undefined; |
| | | // eslint-disable-next-line no-use-before-define |
| | | const { formApi, reload } = tableApi; |
| | | await formApi.resetForm(); |
| | |
| | | columns, |
| | | height: 'auto', |
| | | keepSource: true, |
| | | pagerConfig: {}, |
| | | pagerConfig: { |
| | | // 默认条数 |
| | | pageSize: 1000, |
| | | // 分页可选条数 |
| | | pageSizes: [1000, 2000, 3000, 4000, 5000] |
| | | }, |
| | | proxyConfig: { |
| | | ajax: { |
| | | query: async ({ page }, formValues = {}) => { |
| | |
| | | } else { |
| | | Reflect.deleteProperty(formValues, 'equTypeId'); |
| | | } |
| | | // 是否盘点 |
| | | if (checkFilter.value === '0' || checkFilter.value === '1') { |
| | | formValues.status = checkFilter.value; |
| | | } else { |
| | | Reflect.deleteProperty(formValues, 'status'); |
| | | } |
| | | return await listInventoryDetail({ |
| | | pageNum: page.currentPage, |
| | | pageSize: page.pageSize, |
| | | inventoryId, |
| | | ...formValues |
| | | }); |
| | | }, |
| | | querySuccess: () => { |
| | | nextTick(() => { |
| | | // 过滤已盘和未盘的数据 |
| | | // eslint-disable-next-line no-use-before-define |
| | | const data = tableApi.grid.getData(); |
| | | const data0 = data.filter((item) => { |
| | | return item.status === '' || item.status === null || item.status === '0'; |
| | | }); |
| | | if (data0 !== null && data0.length > 0) { |
| | | noCheck.value = `未盘(${data0.length})`; |
| | | } |
| | | const data1 = data.filter((item) => { |
| | | return item.status !== '' && item.status !== null && item.status === '1'; |
| | | }); |
| | | if (data1 !== null && data1.length > 0) { |
| | | check.value = `已盘(${data1.length})`; |
| | | } |
| | | }); |
| | | } |
| | | } |
| | |
| | | } |
| | | }); |
| | | |
| | | const [EquDrawer, equDrawerApi] = useVbenDrawer({ |
| | | connectedComponent: equDrawer |
| | | const [DetailDrawer, detailDrawerApi] = useVbenDrawer({ |
| | | connectedComponent: detailDrawer |
| | | }); |
| | | |
| | | function handleAdd() { |
| | | equDrawerApi.setData({}); |
| | | equDrawerApi.open(); |
| | | } |
| | | |
| | | async function handleEdit(record: Recordable<any>) { |
| | | equDrawerApi.setData({ id: record.equId }); |
| | | equDrawerApi.open(); |
| | | detailDrawerApi.setData({ id: record.id }); |
| | | detailDrawerApi.open(); |
| | | } |
| | | |
| | | async function handleDelete(row: Recordable<any>) { |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | function handleDownloadExcel() { |
| | | commonDownloadExcel(inventoryDetailExport, '盘点明细', tableApi.formApi.form.values, { |
| | | fieldMappingTime: formOptions.fieldMappingTime |
| | |
| | | const inventoryFlag = row.inventoryFlag === null || row.inventoryFlag; |
| | | return inventoryFlag ? '未盘点' : '已盘点'; |
| | | } |
| | | |
| | | const router = useRouter(); |
| | | function handleDetail(record: Recordable<any>) { |
| | | router.push(`/equ/detail/${record.id}`); |
| | | function handleQuery(isChecked: string) { |
| | | checkFilter.value = isChecked; |
| | | tableApi.query(); |
| | | } |
| | | const { hasAccessByRoles } = useAccess(); |
| | | const isSuperAdmin = computed(() => hasAccessByRoles(['superadmin'])); |
| | | </script> |
| | | |
| | | <template> |
| | |
| | | <BasicTable class="flex-1 overflow-hidden" table-title="盘点明细列表"> |
| | | <template #toolbar-tools> |
| | | <Space> |
| | | <a-button @click="handleQuery('0')">{{ noCheck }}</a-button> |
| | | <a-button type="primary" @click="handleQuery('1')"> {{ check }}</a-button> |
| | | <a-button v-access:code="['eims:inventory:export']" @click="handleDownloadExcel"> |
| | | {{ $t('pages.common.export') }} |
| | | </a-button> |
| | | <a-button :disabled="!vxeCheckboxChecked(tableApi)" danger type="primary" v-access:code="['eims:inventory:remove']" @click="handleMultiDelete"> |
| | | <a-button |
| | | :disabled="!vxeCheckboxChecked(tableApi) || !isSuperAdmin" |
| | | danger |
| | | type="primary" |
| | | v-access:code="['eims:inventory:remove']" |
| | | @click="handleMultiDelete" |
| | | > |
| | | {{ $t('pages.common.delete') }} |
| | | </a-button> |
| | | <a-button type="primary" v-access:code="['eims:inventory:add']" @click="handleAdd"> |
| | | {{ $t('pages.common.add') }} |
| | | </a-button> |
| | | </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:inventory:edit']" @click.stop="handleEdit(row)"> |
| | | <ghost-button :disabled="!isSuperAdmin" v-access:code="['eims:inventory: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:inventory:list']" @click="handleDetail(row)"> |
| | | {{ $t('pages.common.info') }} |
| | | </ghost-button> |
| | | <Popconfirm :get-popup-container="getVxePopupContainer" placement="left" title="确认删除?" @confirm="handleDelete(row)"> |
| | | <ghost-button danger v-access:code="['eims:inventory:remove']" @click.stop=""> |
| | | <ghost-button :disabled="!isSuperAdmin" danger v-access:code="['eims:inventory:remove']" @click.stop=""> |
| | | {{ $t('pages.common.delete') }} |
| | | </ghost-button> |
| | | </Popconfirm> |
| | |
| | | </template> |
| | | </BasicTable> |
| | | </div> |
| | | <EquDrawer @reload="tableApi.query()" /> |
| | | <DetailDrawer @reload="tableApi.query()" /> |
| | | </Page> |
| | | </template> |