| | |
| | | <script lang="ts" setup> |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { MesPdTemplateApi } from '#/api/mes/pro/processdesign/template'; |
| | | import type { VxeTableGridOptions } from "#/adapter/vxe-table"; |
| | | import type { MesPdTemplateApi } from "#/api/mes/pro/processdesign/template"; |
| | | |
| | | import { Page, useVbenModal } from '../../../../packages/effects/common-ui/src'; |
| | | import { Page, useVbenModal } from "../../../../packages/effects/common-ui/src"; |
| | | |
| | | import { Button, message } from 'ant-design-vue'; |
| | | import { Button, message } from "ant-design-vue"; |
| | | |
| | | import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { |
| | | deleteTemplate, |
| | | getTemplatePage, |
| | | } from '#/api/mes/pro/processdesign/template'; |
| | | import { $t } from '#/locales'; |
| | | import { ACTION_ICON, TableAction, useVbenVxeGrid } from "#/adapter/vxe-table"; |
| | | import { |
| | | deleteTemplate, |
| | | getTemplatePage, |
| | | exportTemplateExcel, |
| | | } from "#/api/mes/pro/processdesign/template"; |
| | | import { $t } from "#/locales"; |
| | | import { downloadFileFromBlobPart } from "../../../../packages/utils/src"; |
| | | |
| | | import { useGridColumns, useGridFormSchema } from './data'; |
| | | import Form from './modules/form.vue'; |
| | | import { useGridColumns, useGridFormSchema } from "./data"; |
| | | import Form from "./modules/form.vue"; |
| | | |
| | | const [FormModal, formModalApi] = useVbenModal({ |
| | | connectedComponent: Form, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | /** 刷新表格 */ |
| | | function handleRefresh() { |
| | | gridApi.query(); |
| | | } |
| | | |
| | | /** 创建工艺参数模板 */ |
| | | function handleCreate() { |
| | | formModalApi.setData({ formType: 'create' }).open(); |
| | | } |
| | | |
| | | /** 编辑工艺参数模板 */ |
| | | function handleEdit(row: MesPdTemplateApi.Template) { |
| | | formModalApi.setData({ id: row.id, formType: 'update' }).open(); |
| | | } |
| | | |
| | | /** 查看工艺参数模板详情 */ |
| | | function handleDetail(row: MesPdTemplateApi.Template) { |
| | | formModalApi.setData({ id: row.id, formType: 'detail' }).open(); |
| | | } |
| | | |
| | | /** 删除工艺参数模板 */ |
| | | async function handleDelete(row: MesPdTemplateApi.Template) { |
| | | const hideLoading = message.loading({ |
| | | content: $t('ui.actionMessage.deleting', [row.name]), |
| | | duration: 0, |
| | | const [FormModal, formModalApi] = useVbenModal({ |
| | | connectedComponent: Form, |
| | | destroyOnClose: true, |
| | | }); |
| | | try { |
| | | await deleteTemplate(row.id!); |
| | | message.success($t('ui.actionMessage.deleteSuccess', [row.name])); |
| | | handleRefresh(); |
| | | } finally { |
| | | hideLoading(); |
| | | } |
| | | } |
| | | |
| | | const [Grid, gridApi] = useVbenVxeGrid({ |
| | | formOptions: { |
| | | schema: useGridFormSchema(), |
| | | }, |
| | | gridOptions: { |
| | | columns: useGridColumns(), |
| | | height: 'auto', |
| | | keepSource: true, |
| | | proxyConfig: { |
| | | ajax: { |
| | | query: async ({ page }, formValues) => { |
| | | return await getTemplatePage({ |
| | | pageNo: page.currentPage, |
| | | pageSize: page.pageSize, |
| | | ...formValues, |
| | | }); |
| | | /** 刷新表格 */ |
| | | function handleRefresh() { |
| | | gridApi.query(); |
| | | } |
| | | |
| | | /** 创建工艺参数模板 */ |
| | | function handleCreate() { |
| | | formModalApi.setData({ formType: "create" }).open(); |
| | | } |
| | | |
| | | /** 编辑工艺参数模板 */ |
| | | function handleEdit(row: MesPdTemplateApi.Template) { |
| | | formModalApi.setData({ id: row.id, formType: "update" }).open(); |
| | | } |
| | | |
| | | /** 查看工艺参数模板详情 */ |
| | | function handleDetail(row: MesPdTemplateApi.Template) { |
| | | formModalApi.setData({ id: row.id, formType: "detail" }).open(); |
| | | } |
| | | |
| | | /** 删除工艺参数模板 */ |
| | | async function handleDelete(row: MesPdTemplateApi.Template) { |
| | | const hideLoading = message.loading({ |
| | | content: $t("ui.actionMessage.deleting", [row.templateName]), |
| | | duration: 0, |
| | | }); |
| | | try { |
| | | await deleteTemplate(row.id!); |
| | | message.success($t("ui.actionMessage.deleteSuccess", [row.templateName])); |
| | | handleRefresh(); |
| | | } finally { |
| | | hideLoading(); |
| | | } |
| | | } |
| | | |
| | | /** 导出工艺参数模板 */ |
| | | async function handleExport() { |
| | | const formValues = await gridApi.formApi.getValues(); |
| | | const data = await exportTemplateExcel(formValues); |
| | | downloadFileFromBlobPart({ fileName: "工艺参数模板.xlsx", source: data }); |
| | | } |
| | | |
| | | const [Grid, gridApi] = useVbenVxeGrid({ |
| | | formOptions: { |
| | | schema: useGridFormSchema(), |
| | | }, |
| | | gridOptions: { |
| | | columns: useGridColumns(), |
| | | height: "auto", |
| | | keepSource: true, |
| | | proxyConfig: { |
| | | ajax: { |
| | | query: async ({ page }, formValues) => { |
| | | return await getTemplatePage({ |
| | | pageNo: page.currentPage, |
| | | pageSize: page.pageSize, |
| | | ...formValues, |
| | | }); |
| | | }, |
| | | }, |
| | | }, |
| | | }, |
| | | rowConfig: { |
| | | isHover: true, |
| | | keyField: 'id', |
| | | }, |
| | | toolbarConfig: { |
| | | refresh: true, |
| | | search: true, |
| | | }, |
| | | } as VxeTableGridOptions<MesPdTemplateApi.Template>, |
| | | }); |
| | | rowConfig: { |
| | | isHover: true, |
| | | keyField: "id", |
| | | }, |
| | | toolbarConfig: { |
| | | refresh: true, |
| | | search: true, |
| | | }, |
| | | } as VxeTableGridOptions<MesPdTemplateApi.Template>, |
| | | }); |
| | | </script> |
| | | |
| | | <template> |
| | | <Page auto-content-height><FormModal @success="handleRefresh" /> |
| | | <Page auto-content-height> |
| | | <FormModal @success="handleRefresh" /> |
| | | <Grid table-title="工艺参数模板列表"> |
| | | <template #toolbar-tools> |
| | | <TableAction |
| | | :actions="[ |
| | | <TableAction :actions="[ |
| | | { |
| | | label: $t('ui.actionTitle.create', ['模板']), |
| | | type: 'primary', |
| | |
| | | auth: ['mes:pd:template:create'], |
| | | onClick: handleCreate, |
| | | }, |
| | | ]" |
| | | /> |
| | | { |
| | | label: $t('ui.actionTitle.export'), |
| | | type: 'primary', |
| | | icon: ACTION_ICON.DOWNLOAD, |
| | | auth: ['mes:pd:template:export'], |
| | | onClick: handleExport, |
| | | }, |
| | | ]" /> |
| | | </template> |
| | | <template #name="{ row }"> |
| | | <Button type="link" @click="handleDetail(row)">{{ row.name }}</Button> |
| | | <template #templateCode="{ row }"> |
| | | <Button type="link" |
| | | @click="handleDetail(row)">{{ row.templateCode }}</Button> |
| | | </template> |
| | | <template #actions="{ row }"> |
| | | <TableAction |
| | | :actions="[ |
| | | <TableAction :actions="[ |
| | | { |
| | | label: $t('common.detail'), |
| | | type: 'link', |
| | | icon: ACTION_ICON.VIEW, |
| | | onClick: handleDetail.bind(null, row), |
| | | }, |
| | | { |
| | | label: $t('common.edit'), |
| | | type: 'link', |
| | |
| | | icon: ACTION_ICON.DELETE, |
| | | auth: ['mes:pd:template:delete'], |
| | | popConfirm: { |
| | | title: $t('ui.actionMessage.deleteConfirm', [row.name]), |
| | | title: $t('ui.actionMessage.deleteConfirm', [row.templateName]), |
| | | confirm: handleDelete.bind(null, row), |
| | | }, |
| | | }, |
| | | ]" |
| | | /> |
| | | ]" /> |
| | | </template> |
| | | </Grid> |
| | | </Page> |