From d40d81aa421c7cdb959556fedffef71fc62cde80 Mon Sep 17 00:00:00 2001 From: zhuguifei <zhuguifei@zhuguifeideiMac.local> Date: 星期三, 16 四月 2025 10:07:22 +0800 Subject: [PATCH] 完成备件模块 --- eims-ui/apps/web-antd/src/views/eims/spare-out/select-spare-table.vue | 121 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 121 insertions(+), 0 deletions(-) diff --git a/eims-ui/apps/web-antd/src/views/eims/spare-out/select-spare-table.vue b/eims-ui/apps/web-antd/src/views/eims/spare-out/select-spare-table.vue new file mode 100644 index 0000000..a84011c --- /dev/null +++ b/eims-ui/apps/web-antd/src/views/eims/spare-out/select-spare-table.vue @@ -0,0 +1,121 @@ +<script setup lang="ts"> +import type { Recordable } from '@vben/types'; + +import { reactive, ref, watch } from 'vue'; + +import { $t } from '@vben/locales'; +import { getVxePopupContainer } from '@vben/utils'; + +import { Popconfirm, Space } from 'ant-design-vue'; + +import { useVbenVxeGrid, type VxeGridProps, vxeSortEvent } from '#/adapter/vxe-table'; + + +interface Props { + title?: string; + columns?: VxeGridProps['columns']; + data: any; + isUpdate?: boolean; +} +const props = defineProps<Props>(); + +const responsiveData = reactive(props.data); +defineExpose({ + tableData +}); + +watch( + () => props.data, + (data) => { + responsiveData.splice(0, responsiveData.length, ...data); + } +); + +const gridOptions: VxeGridProps = { + checkboxConfig: { + // 楂樹寒 + highlight: true, + // 缈婚〉鏃朵繚鐣欓�変腑鐘舵�� + reserve: true + // 鐐瑰嚮琛岄�変腑 + // trigger: 'row' + }, + columns: props.columns, + height: 'auto', + keepSource: true, + data: responsiveData, + pagerConfig: { + enabled: false + }, + toolbarConfig: { + enabled: false + }, + rowConfig: { + isHover: true, + keyField: 'id' + }, + sortConfig: { + // 杩滅▼鎺掑簭 + remote: true, + // 鏀寔澶氬瓧娈垫帓搴� 榛樿鍏抽棴 + multiple: true + }, + editConfig: { + mode: 'cell', + trigger: 'click' + }, + id: 'local-table' +}; + +const [BasicTable, tableApi] = useVbenVxeGrid({ + gridOptions, + gridEvents: { + sortChange: (sortParams) => vxeSortEvent(tableApi, sortParams) + } +}); + +function handleDelete(row: Recordable<any>) { + const index = responsiveData.findIndex((item: any) => item.id === row.id); + if (index !== -1) { + responsiveData.splice(index, 1); + } +} +// 閫変腑鏁版嵁 +function tableData() { + return tableApi.grid.getData(); +} + + +/** + * TODO 鍚庣画鎵╁睍鐐瑰嚮浜嬩欢 + */ +const slotName = ref<string>('equName'); +</script> + +<template> + <div class="w-full h-min"> + <BasicTable :table-title="title" size="small"> + <template #[slotName]="{ row }"> + <Space> + <span>{{ row[slotName] }}</span> + </Space> + </template> + + <template #action="{ row }"> + <Space> + <Popconfirm :get-popup-container="getVxePopupContainer" placement="left" title="纭鍒犻櫎锛�" @confirm="handleDelete(row)"> + <ghost-button :disabled="isUpdate" danger @click.stop=""> + {{ $t('pages.common.delete') }} + </ghost-button> + </Popconfirm> + </Space> + </template> + </BasicTable> + </div> +</template> + +<style lang="scss" scoped> +:deep(.p-2) { + padding: 0; +} +</style> -- Gitblit v1.9.3