| ¶Ô±ÈÐÂÎļþ |
| | |
| | | import type { PageParam, PageResult } from '@vben/request'; |
| | | |
| | | import { requestClient } from '#/api/request'; |
| | | |
| | | export namespace MesWmTransactionApi { |
| | | /** åºåäºå¡æµæ°´ */ |
| | | export interface Transaction { |
| | | id?: number; |
| | | type?: number; // äºå¡ç±»åï¼1-å
¥åº 2-åºåºï¼ |
| | | typeName?: string; // äºå¡ç±»ååç§° |
| | | bizType?: number; // ä¸å¡ç±»åç¼ç |
| | | bizTypeName?: string; // ä¸å¡ç±»ååç§° |
| | | bizCode?: string; // ä¸å¡åå· |
| | | itemId?: number; // ç©æID |
| | | itemCode?: string; // ç©æç¼ç |
| | | itemName?: string; // ç©æåç§° |
| | | quantity?: number; // å卿°é |
| | | batchId?: number; // æ¹æ¬¡ID |
| | | batchCode?: string; // æ¹æ¬¡å· |
| | | warehouseId?: number; // ä»åºID |
| | | warehouseName?: string; // ä»åºåç§° |
| | | locationId?: number; // åºåºID |
| | | locationName?: string; // åºåºåç§° |
| | | areaId?: number; // åºä½ID |
| | | areaName?: string; // åºä½åç§° |
| | | transactionTime?: string; // äºå¡åçæ¶é´ |
| | | createTime?: string; // å建æ¶é´ |
| | | } |
| | | |
| | | /** å页æ¥è¯¢åæ° */ |
| | | export interface PageParams extends PageParam { |
| | | itemId?: number; |
| | | batchCode?: string; |
| | | warehouseId?: number; |
| | | locationId?: number; |
| | | areaId?: number; |
| | | type?: number; |
| | | bizType?: number; |
| | | bizCode?: string; |
| | | materialStockId?: number; |
| | | startTime?: string; |
| | | endTime?: string; |
| | | } |
| | | } |
| | | |
| | | /** å页æ¥è¯¢åºåäºå¡æµæ°´ */ |
| | | export function getTransactionPage(params: MesWmTransactionApi.PageParams) { |
| | | return requestClient.get<PageResult<MesWmTransactionApi.Transaction>>( |
| | | '/mes/wm/transaction/page', |
| | | { params }, |
| | | ); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | import type { VbenFormSchema } from '#/adapter/form'; |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { MesWmTransactionApi } from '#/api/mes/wm/transaction'; |
| | | |
| | | import { markRaw } from 'vue'; |
| | | |
| | | import { MdmItemSelect } from '#/views/basicData/mdm/components'; |
| | | import { |
| | | WmWarehouseAreaSelect, |
| | | WmWarehouseLocationSelect, |
| | | WmWarehouseSelect, |
| | | } from '#/views/wls/warehouse/components'; |
| | | |
| | | /** ä¸å¡ç±»åé项 */ |
| | | const bizTypeOptions = [ |
| | | { label: 'èªå®ä¹å
¥åº', value: 126 }, |
| | | { label: 'èªå®ä¹åºåº', value: 127 }, |
| | | { label: 'éè´å
¥åº', value: 110 }, |
| | | { label: 'éå®åºåº', value: 119 }, |
| | | { label: 'è°æ¨åºåº', value: 112 }, |
| | | { label: 'è°æ¨å
¥åº', value: 113 }, |
| | | { label: 'å
¶ä»å
¥åº', value: 115 }, |
| | | { label: 'å
¶ä»åºåº', value: 114 }, |
| | | { label: 'çäº§é¢æ', value: 116 }, |
| | | { label: 'ç产éæ', value: 117 }, |
| | | { label: 'ç产å
¥åº', value: 118 }, |
| | | { label: 'ç产æ¶è', value: 123 }, |
| | | { label: '产å产åº', value: 124 }, |
| | | { label: 'ä¾åºåéè´§', value: 125 }, |
| | | { label: 'éå®éè´§', value: 120 }, |
| | | { label: 'å¤ååæ', value: 121 }, |
| | | { label: 'å¤åå
¥åº', value: 122 }, |
| | | ]; |
| | | |
| | | /** å表çæç´¢è¡¨å */ |
| | | export function useGridFormSchema(): VbenFormSchema[] { |
| | | return [ |
| | | { |
| | | fieldName: 'itemId', |
| | | label: 'ç©æ', |
| | | component: markRaw(MdmItemSelect), |
| | | componentProps: { |
| | | placeholder: 'è¯·éæ©ç©æ', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'batchCode', |
| | | label: 'æ¹æ¬¡å·', |
| | | component: 'Input', |
| | | componentProps: { |
| | | allowClear: true, |
| | | placeholder: '请è¾å
¥æ¹æ¬¡å·', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'warehouseId', |
| | | label: 'ä»åº', |
| | | component: markRaw(WmWarehouseSelect), |
| | | componentProps: { |
| | | placeholder: 'è¯·éæ©ä»åº', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'locationId', |
| | | label: 'åºåº', |
| | | component: markRaw(WmWarehouseLocationSelect), |
| | | dependencies: { |
| | | triggerFields: ['warehouseId'], |
| | | componentProps: (values) => ({ |
| | | warehouseId: values.warehouseId, |
| | | placeholder: 'è¯·éæ©åºåº', |
| | | }), |
| | | trigger: (values, formApi) => { |
| | | if (values.locationId !== undefined) { |
| | | void formApi.setFieldValue('locationId', undefined); |
| | | } |
| | | }, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'areaId', |
| | | label: 'åºä½', |
| | | component: markRaw(WmWarehouseAreaSelect), |
| | | dependencies: { |
| | | triggerFields: ['warehouseId', 'locationId'], |
| | | componentProps: (values) => ({ |
| | | locationId: values.locationId, |
| | | placeholder: 'è¯·éæ©åºä½', |
| | | }), |
| | | trigger: (values, formApi) => { |
| | | if (values.areaId !== undefined) { |
| | | void formApi.setFieldValue('areaId', undefined); |
| | | } |
| | | }, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'type', |
| | | label: 'äºå¡ç±»å', |
| | | component: 'Select', |
| | | componentProps: { |
| | | allowClear: true, |
| | | options: [ |
| | | { label: 'å
¥åº', value: 1 }, |
| | | { label: 'åºåº', value: 2 }, |
| | | ], |
| | | placeholder: 'è¯·éæ©äºå¡ç±»å', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'bizType', |
| | | label: 'ä¸å¡ç±»å', |
| | | component: 'Select', |
| | | componentProps: { |
| | | allowClear: true, |
| | | options: bizTypeOptions, |
| | | placeholder: 'è¯·éæ©ä¸å¡ç±»å', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'bizCode', |
| | | label: 'ä¸å¡åå·', |
| | | component: 'Input', |
| | | componentProps: { |
| | | allowClear: true, |
| | | placeholder: '请è¾å
¥ä¸å¡åå·', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'transactionTime', |
| | | label: 'äºå¡æ¶é´', |
| | | component: 'RangePicker', |
| | | componentProps: { |
| | | allowClear: true, |
| | | format: 'YYYY-MM-DD HH:mm:ss', |
| | | showTime: true, |
| | | valueFormat: 'YYYY-MM-DD HH:mm:ss', |
| | | }, |
| | | }, |
| | | ]; |
| | | } |
| | | |
| | | /** å表çåæ®µ */ |
| | | export function useGridColumns(): VxeTableGridOptions<MesWmTransactionApi.Transaction>['columns'] { |
| | | return [ |
| | | { |
| | | field: 'typeName', |
| | | title: 'äºå¡ç±»å', |
| | | width: 80, |
| | | slots: { default: 'typeName' }, |
| | | }, |
| | | { |
| | | field: 'bizTypeName', |
| | | title: 'ä¸å¡ç±»å', |
| | | width: 100, |
| | | }, |
| | | { |
| | | field: 'bizCode', |
| | | title: 'ä¸å¡åå·', |
| | | minWidth: 150, |
| | | }, |
| | | { |
| | | field: 'itemCode', |
| | | title: 'ç©æç¼ç ', |
| | | width: 120, |
| | | }, |
| | | { |
| | | field: 'itemName', |
| | | title: 'ç©æåç§°', |
| | | minWidth: 150, |
| | | }, |
| | | { |
| | | field: 'batchCode', |
| | | title: 'æ¹æ¬¡å·', |
| | | width: 120, |
| | | }, |
| | | { |
| | | field: 'quantity', |
| | | title: 'æ°é', |
| | | width: 100, |
| | | slots: { default: 'quantity' }, |
| | | }, |
| | | { |
| | | field: 'warehouseName', |
| | | title: 'ä»åº', |
| | | width: 100, |
| | | }, |
| | | { |
| | | field: 'locationName', |
| | | title: 'åºåº', |
| | | width: 100, |
| | | }, |
| | | { |
| | | field: 'areaName', |
| | | title: 'åºä½', |
| | | width: 100, |
| | | }, |
| | | { |
| | | field: 'transactionTime', |
| | | title: 'äºå¡æ¶é´', |
| | | width: 160, |
| | | formatter: 'formatDateTime', |
| | | }, |
| | | ]; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <script lang="ts" setup> |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { MesWmTransactionApi } from '#/api/mes/wm/transaction'; |
| | | |
| | | import { Page } from '@vben/common-ui'; |
| | | |
| | | import { Tag } from 'ant-design-vue'; |
| | | |
| | | import { useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { getTransactionPage } from '#/api/mes/wm/transaction'; |
| | | |
| | | import { useGridColumns, useGridFormSchema } from './data'; |
| | | |
| | | const [Grid, gridApi] = useVbenVxeGrid({ |
| | | formOptions: { |
| | | schema: useGridFormSchema(), |
| | | }, |
| | | gridOptions: { |
| | | columns: useGridColumns(), |
| | | height: 'auto', |
| | | keepSource: true, |
| | | proxyConfig: { |
| | | ajax: { |
| | | query: async ({ page }, formValues) => { |
| | | const params: MesWmTransactionApi.PageParams = { |
| | | pageNo: page.currentPage, |
| | | pageSize: page.pageSize, |
| | | ...formValues, |
| | | }; |
| | | if (formValues.transactionTime?.length === 2) { |
| | | params.startTime = formValues.transactionTime[0]; |
| | | params.endTime = formValues.transactionTime[1]; |
| | | } |
| | | delete (params as any).transactionTime; |
| | | return await getTransactionPage(params); |
| | | }, |
| | | }, |
| | | }, |
| | | rowConfig: { |
| | | keyField: 'id', |
| | | isHover: true, |
| | | }, |
| | | toolbarConfig: { |
| | | refresh: true, |
| | | search: true, |
| | | }, |
| | | } as VxeTableGridOptions<MesWmTransactionApi.Transaction>, |
| | | }); |
| | | </script> |
| | | |
| | | <template> |
| | | <Page auto-content-height> |
| | | <Grid table-title="åºåäºå¡æµæ°´"> |
| | | <template #typeName="{ row }"> |
| | | <Tag :color="row.type === 1 ? 'green' : 'red'"> |
| | | {{ row.typeName || '-' }} |
| | | </Tag> |
| | | </template> |
| | | <template #quantity="{ row }"> |
| | | <span |
| | | :class="{ |
| | | 'text-green-600 font-bold': (row.quantity ?? 0) > 0, |
| | | 'text-red-600 font-bold': (row.quantity ?? 0) < 0, |
| | | }" |
| | | > |
| | | {{ (row.quantity ?? 0).toFixed(2) }} |
| | | </span> |
| | | </template> |
| | | </Grid> |
| | | </Page> |
| | | </template> |