原材料车间剩余量

This commit is contained in:
2026-05-15 15:10:25 +08:00
parent b4b550a3de
commit 5678ab82ba
9 changed files with 478 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import { defHttp } from '/@/utils/http/axios';
enum Api {
list = '/xslmes/mesXslRawMaterialWorkshopRemain/list',
exportXls = '/xslmes/mesXslRawMaterialWorkshopRemain/exportXls',
batchUpdatePriority = '/xslmes/mesXslRawMaterialWorkshopRemain/batchUpdatePriority',
}
export const getExportUrl = Api.exportXls;
export const list = (params) => defHttp.get({ url: Api.list, params });
export const batchUpdatePriority = (ids: string[], priorityPickup: '0' | '1') =>
defHttp.put(
{
url: Api.batchUpdatePriority,
params: { ids: ids.join(','), priorityPickup },
},
{ joinParamsToUrl: true },
);

View File

@@ -0,0 +1,72 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
export const columns: BasicColumn[] = [
{ title: '条码', align: 'center', dataIndex: 'barcode', width: 180 },
{ title: '批次号', align: 'center', dataIndex: 'batchNo', width: 160 },
{
title: '入场日期',
align: 'center',
dataIndex: 'entryDate',
width: 120,
customRender: ({ text }) => (!text ? '' : text.length > 10 ? text.substring(0, 10) : text),
},
{ title: '物料名称', align: 'center', dataIndex: 'materialName', width: 160, ellipsis: true },
{ title: '供应商', align: 'center', dataIndex: 'supplierName', width: 160, ellipsis: true },
{ title: '保质期', align: 'center', dataIndex: 'shelfLife', width: 120 },
{ title: '总重', align: 'center', dataIndex: 'totalWeight', width: 110 },
{ title: '剩余重量', align: 'center', dataIndex: 'remainingWeight', width: 110 },
{ title: '剩余数量', align: 'center', dataIndex: 'remainingQuantity', width: 110 },
{ title: '检测结果', align: 'center', dataIndex: 'testResult_dictText', width: 110 },
{ title: '状态', align: 'center', dataIndex: 'status_dictText', width: 100 },
{
title: '优先使用',
align: 'center',
dataIndex: 'priorityPickup',
width: 100,
customRender: ({ text }) => render.renderSwitch(text, [{ text: '是', value: '1' }, { text: '否', value: '0' }]),
},
];
export const searchFormSchema: FormSchema[] = [
{ label: '条码', field: 'barcode', component: 'JInput', colProps: { span: 6 } },
{ label: '批次号', field: 'batchNo', component: 'JInput', colProps: { span: 6 } },
{ label: '物料名称', field: 'materialName', component: 'JInput', colProps: { span: 6 } },
{ label: '供应商', field: 'supplierName', component: 'JInput', colProps: { span: 6 } },
{
label: '入场日期',
field: 'entryDate',
component: 'RangePicker',
componentProps: { showTime: false, valueFormat: 'YYYY-MM-DD' },
colProps: { span: 8 },
},
{
label: '检测结果',
field: 'testResult',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_test_result' },
colProps: { span: 6 },
},
{
label: '状态',
field: 'status',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_card_status' },
colProps: { span: 6 },
},
];
export const superQuerySchema = {
barcode: { title: '条码', order: 0, view: 'text' },
batchNo: { title: '批次号', order: 1, view: 'text' },
entryDate: { title: '入场日期', order: 2, view: 'date' },
materialName: { title: '物料名称', order: 3, view: 'text' },
supplierName: { title: '供应商', order: 4, view: 'text' },
shelfLife: { title: '保质期', order: 5, view: 'text' },
totalWeight: { title: '总重', order: 6, view: 'number' },
remainingWeight: { title: '剩余重量', order: 7, view: 'number' },
remainingQuantity: { title: '剩余数量', order: 8, view: 'number' },
testResult: { title: '检测结果', order: 9, view: 'list', dictCode: 'xslmes_test_result' },
status: { title: '状态', order: 10, view: 'list', dictCode: 'xslmes_card_status' },
priorityPickup: { title: '优先使用', order: 11, view: 'list', dictCode: 'yn' },
};

View File

@@ -0,0 +1,84 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button
type="primary"
ghost
v-auth="'xslmes:mes_xsl_raw_material_workshop_remain:edit'"
:disabled="selectedRowKeys.length === 0"
@click="() => handleBatchPriorityUpdate('1')"
>
设为优先使用
</a-button>
<a-button
danger
ghost
v-auth="'xslmes:mes_xsl_raw_material_workshop_remain:edit'"
:disabled="selectedRowKeys.length === 0"
@click="() => handleBatchPriorityUpdate('0')"
>
取消优先使用
</a-button>
<a-button type="primary" v-auth="'xslmes:mes_xsl_raw_material_workshop_remain:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls">
导出
</a-button>
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
</template>
</BasicTable>
</div>
</template>
<script lang="ts" name="xslmes-mesXslRawMaterialWorkshopRemain" setup>
import { reactive } from 'vue';
import { BasicTable } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { useMessage } from '/@/hooks/web/useMessage';
import { columns, searchFormSchema, superQuerySchema } from './MesXslRawMaterialWorkshopRemain.data';
import { batchUpdatePriority, list, getExportUrl } from './MesXslRawMaterialWorkshopRemain.api';
const { createMessage } = useMessage();
const queryParam = reactive<any>({});
const { tableContext, onExportXls } = useListPage({
tableProps: {
title: '原材料车间剩余量',
api: list,
columns,
canResize: true,
formConfig: {
schemas: searchFormSchema,
autoSubmitOnEnter: true,
showAdvancedButton: true,
fieldMapToTime: [['entryDate', ['entryDate_begin', 'entryDate_end'], 'YYYY-MM-DD']],
},
beforeFetch: (params) => Object.assign(params, queryParam),
},
exportConfig: {
name: '原材料车间剩余量',
url: getExportUrl,
params: queryParam,
},
});
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
const superQueryConfig = reactive(superQuerySchema);
function handleSuperQuery(params) {
Object.keys(params).forEach((k) => {
queryParam[k] = params[k];
});
reload();
}
async function handleBatchPriorityUpdate(priorityPickup: '0' | '1') {
if (!selectedRowKeys.value.length) {
createMessage.warning('请先勾选记录');
return;
}
await batchUpdatePriority(selectedRowKeys.value as string[], priorityPickup);
createMessage.success(priorityPickup === '1' ? '已设为优先使用' : '已取消优先使用');
selectedRowKeys.value = [];
reload();
}
</script>