From 3baaad59171ded6aca17340fcc907acbeeb45b7b Mon Sep 17 00:00:00 2001 From: zhuguifei <zhuguifei@zhuguifeideiMac.local> Date: 星期二, 08 四月 2025 08:14:43 +0800 Subject: [PATCH] Merge branch 'main' of http://lanpucloud.cn:1111/r/eims-master --- eims-ui/apps/web-antd/src/views/eims/spare-in/index.vue | 237 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 237 insertions(+), 0 deletions(-) diff --git a/eims-ui/apps/web-antd/src/views/eims/spare-in/index.vue b/eims-ui/apps/web-antd/src/views/eims/spare-in/index.vue new file mode 100644 index 0000000..7a054c4 --- /dev/null +++ b/eims-ui/apps/web-antd/src/views/eims/spare-in/index.vue @@ -0,0 +1,237 @@ +<script setup lang="ts"> +import type { Recordable } from '@vben/types'; + +import { onMounted } from 'vue'; + +import { Page, useVbenDrawer, type VbenFormProps } from '@vben/common-ui'; +import { $t } from '@vben/locales'; +import { addFullName, getPopupContainer, getVxePopupContainer } from '@vben/utils'; + +import { Modal, Popconfirm, Space } from 'ant-design-vue'; + +import { useVbenVxeGrid, vxeCheckboxChecked, type VxeGridProps, vxeSortEvent } from '#/adapter/vxe-table'; +import { delSpareInout, listSpareInout, spareInoutExport } from '#/api/eims/spare-inout'; +import { getDeptTree, userList } from '#/api/system/user'; +import { commonDownloadExcel } from '#/utils/file/download'; + +import { columns, querySchema } from './data'; +import drawer from './spare-in-drawer.vue'; + +const formOptions: VbenFormProps = { + commonConfig: { + labelWidth: 80, + componentProps: { + allowClear: true + } + }, + schema: querySchema(), + collapsed: true, + wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4', + // 鏃ユ湡閫夋嫨鏍煎紡鍖� + fieldMappingTime: [['orderTime', ['params[beginOrderTime]', 'params[endOrderTime]'], ['YYYY-MM-DD 00:00:00', 'YYYY-MM-DD 23:59:59']]] +}; + +const gridOptions: VxeGridProps = { + checkboxConfig: { + // 楂樹寒 + highlight: true, + // 缈婚〉鏃朵繚鐣欓�変腑鐘舵�� + reserve: true + // 鐐瑰嚮琛岄�変腑 + // trigger: 'row' + }, + columns, + height: 'auto', + keepSource: true, + pagerConfig: {}, + proxyConfig: { + ajax: { + query: async ({ page }, formValues = {}) => { + // 1-鍏ュ簱鍗� 2-鍑哄簱鍗� + formValues.type = '1'; + return await listSpareInout({ + pageNum: page.currentPage, + pageSize: page.pageSize, + ...formValues + }); + } + } + }, + rowConfig: { + isHover: true, + keyField: 'id' + }, + sortConfig: { + // 杩滅▼鎺掑簭 + remote: true, + // 鏀寔澶氬瓧娈垫帓搴� 榛樿鍏抽棴 + multiple: true + }, + id: 'spre-inout-index' +}; + +const [BasicTable, tableApi] = useVbenVxeGrid({ + formOptions, + gridOptions, + gridEvents: { + sortChange: (sortParams) => vxeSortEvent(tableApi, sortParams) + } +}); + +const [Drawer, drawerApi] = useVbenDrawer({ + connectedComponent: drawer +}); + +function handleAdd() { + drawerApi.setData({}); + drawerApi.open(); +} + +async function handleEdit(record: Recordable<any>) { + drawerApi.setData({ id: record.id }); + drawerApi.open(); +} + +async function handleDelete(row: Recordable<any>) { + await delSpareInout(row.id); + await tableApi.query(); +} + +function handleMultiDelete() { + const rows = tableApi.grid.getCheckboxRecords(); + const ids = rows.map((row: any) => row.id); + Modal.confirm({ + title: '鎻愮ず', + okType: 'danger', + content: `纭鍒犻櫎閫変腑鐨�${ids.length}鏉¤褰曞悧锛焋, + onOk: async () => { + await delSpareInout(ids); + await tableApi.query(); + } + }); +} + +function handleDownloadExcel() { + commonDownloadExcel(spareInoutExport, '澶囦欢鍏ュ簱鍗曡褰�', tableApi.formApi.form.values, { + fieldMappingTime: formOptions.fieldMappingTime + }); +} +/** + * 鐢ㄦ埛鐨勫姞杞� + */ +async function setupUserOptions(deptId: any) { + const params = { deptId }; + const userPageResult = await userList({ + pageNum: 1, + pageSize: 500, + ...params + }); + const options = userPageResult.rows.map((item) => ({ + label: item.nickName || item.userName, + value: item.userId + })); + // 绛涢�� + const filterOption = (input: string, option: any) => { + return option.label.toLowerCase().includes(input.toLowerCase()); + }; + + const placeholder = options.length > 0 ? '璇烽�夋嫨' : '璇ラ儴闂ㄤ笅鏆傛棤鐢ㄦ埛'; + tableApi.formApi.updateSchema([ + { + componentProps: { options, placeholder, filterOption }, + fieldName: 'chargeUser' + } + ]); +} + +/** + * 鍒濆鍖栭儴闂ㄩ�夋嫨 + */ +async function setupDeptSelect() { + // updateSchema + const deptTree = await getDeptTree(); + // 閫変腑鍚庢樉绀哄湪杈撳叆妗嗙殑鍊� 鍗崇埗鑺傜偣 / 瀛愯妭鐐� + addFullName(deptTree, 'label', ' / '); + tableApi.formApi.updateSchema([ + { + componentProps: (formModel) => ({ + class: 'w-full', + fieldNames: { + key: 'id', + value: 'id', + children: 'children' + }, + getPopupContainer, + async onSelect(deptId: number | string) { + /** 鏍规嵁閮ㄩ棬ID鍔犺浇鐢ㄦ埛 */ + await setupUserOptions(deptId); + /** 鍙樺寲鍚庨渶瑕侀噸鏂伴�夋嫨鐢ㄦ埛 */ + formModel.chargeUser = undefined; + }, + placeholder: '璇烽�夋嫨', + showSearch: true, + treeData: deptTree, + treeDefaultExpandAll: true, + treeLine: { showLeafIcon: false }, + // 绛涢�夌殑瀛楁 + treeNodeFilterProp: 'label', + // 閫変腑鍚庢樉绀哄湪杈撳叆妗嗙殑鍊� + treeNodeLabelProp: 'fullName' + }), + fieldName: 'chargeDept' + } + ]); +} + +onMounted(async () => { + await setupDeptSelect(); +}); +</script> + +<template> + <Page :auto-content-height="true"> + <div class="flex h-full gap-[8px]"> + <BasicTable class="flex-1 overflow-hidden" table-title="澶囦欢鍏ュ簱鍗曞垪琛�"> + <template #toolbar-tools> + <Space> + <a-button v-access:code="['eims:spareInout:export']" @click="handleDownloadExcel"> + {{ $t('pages.common.export') }} + </a-button> + <a-button + :disabled="!vxeCheckboxChecked(tableApi)" + danger + type="primary" + v-access:code="['eims:spareInout:remove']" + @click="handleMultiDelete" + > + {{ $t('pages.common.delete') }} + </a-button> + <a-button type="primary" v-access:code="['eims:spareInout:add']" @click="handleAdd"> + {{ $t('pages.common.add') }} + </a-button> + </Space> + </template> + + <template #orderCode="{ row }"> + <Space> + <a-button type="link"> {{ row.orderCode }}</a-button> + </Space> + </template> + + <template #action="{ row }"> + <Space> + <ghost-button v-access:code="['eims:spareInout:edit']" @click.stop="handleEdit(row)"> + {{ $t('pages.common.edit') }} + </ghost-button> + <Popconfirm :get-popup-container="getVxePopupContainer" placement="left" title="纭鍒犻櫎锛�" @confirm="handleDelete(row)"> + <ghost-button danger v-access:code="['eims:spareInout:remove']" @click.stop=""> + {{ $t('pages.common.delete') }} + </ghost-button> + </Popconfirm> + </Space> + </template> + </BasicTable> + </div> + <Drawer @reload="tableApi.query()" /> + </Page> +</template> -- Gitblit v1.9.3