烘胶房库位新增

This commit is contained in:
2026-07-03 15:21:10 +08:00
parent 99987d9d2e
commit dde35d639b
15 changed files with 1040 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage();
enum Api {
list = '/xslmes/mesXslDryingRoomSlot/list',
checkSlotName = '/xslmes/mesXslDryingRoomSlot/checkSlotName',
save = '/xslmes/mesXslDryingRoomSlot/add',
edit = '/xslmes/mesXslDryingRoomSlot/edit',
deleteOne = '/xslmes/mesXslDryingRoomSlot/delete',
deleteBatch = '/xslmes/mesXslDryingRoomSlot/deleteBatch',
queryById = '/xslmes/mesXslDryingRoomSlot/queryById',
exportXls = '/xslmes/mesXslDryingRoomSlot/exportXls',
}
export const getExportUrl = Api.exportXls;
export const list = (params) => defHttp.get({ url: Api.list, params });
export const queryById = (params: { id: string }) => defHttp.get({ url: Api.queryById, params });
export const checkSlotName = (params: { slotName: string; dryingRoomId: string; dataId?: string }) =>
defHttp.get(
{ url: Api.checkSlotName, params },
{
successMessageMode: 'none',
errorMessageMode: 'none',
},
);
export const deleteOne = (params, handleSuccess) => {
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
};
export const batchDelete = (params, handleSuccess) => {
createConfirm({
iconType: 'warning',
title: '确认删除',
content: '是否删除选中数据',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
},
});
};
export const saveOrUpdate = (params, isUpdate) => {
const url = isUpdate ? Api.edit : Api.save;
return defHttp.post({ url, params });
};

View File

@@ -0,0 +1,85 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
import { checkSlotName } from './MesXslDryingRoomSlot.api';
export const columns: BasicColumn[] = [
{ title: '烘胶房库位', align: 'center', dataIndex: 'slotName', width: 140 },
{ title: '所属烘胶房', align: 'center', dataIndex: 'dryingRoomName', width: 160 },
{ title: '存放物料', align: 'center', dataIndex: 'categoryName', width: 160 },
{ title: '库位容量', align: 'center', dataIndex: 'slotCapacity', width: 110 },
{ title: '创建人', align: 'center', dataIndex: 'createBy', width: 100 },
{
title: '创建时间',
align: 'center',
dataIndex: 'createTime',
width: 165,
customRender: ({ text }) => (!text ? '' : String(text).length > 19 ? String(text).substring(0, 19) : text),
},
];
export const searchFormSchema: FormSchema[] = [
{ label: '烘胶房库位', field: 'slotName', component: 'JInput', colProps: { span: 6 } },
{ label: '所属烘胶房', field: 'dryingRoomName', component: 'JInput', colProps: { span: 6 } },
{ label: '存放物料', field: 'categoryName', component: 'JInput', colProps: { span: 6 } },
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{ label: '', field: 'dryingRoomId', component: 'Input', show: false },
{ label: '', field: 'dryingCategoryId', component: 'Input', show: false },
{
label: '烘胶房库位',
field: 'slotName',
component: 'Input',
componentProps: { placeholder: '同烘胶房内未删除数据中不可重复' },
dynamicRules: ({ model }) => [
{ required: true, message: '请输入烘胶房库位' },
{
validator: async (_rule, value) => {
const v = value == null ? '' : String(value).trim();
if (!v) {
return Promise.resolve();
}
if (!model?.dryingRoomId) {
return Promise.reject('请先选择所属烘胶房');
}
try {
await checkSlotName({ slotName: v, dryingRoomId: model.dryingRoomId, dataId: model?.id });
return Promise.resolve();
} catch (e: any) {
const msg = e?.response?.data?.message || e?.message || '该烘胶房内库位名称不能重复';
return Promise.reject(msg);
}
},
trigger: 'blur',
},
],
},
{
label: '所属烘胶房',
field: 'dryingRoomName',
component: 'Input',
slot: 'dryingRoomPicker',
dynamicRules: () => [{ required: true, message: '请选择所属烘胶房' }],
},
{
label: '存放物料',
field: 'categoryName',
component: 'Input',
slot: 'dryingCategoryPicker',
dynamicRules: () => [{ required: true, message: '请选择存放物料(烘胶分类)' }],
},
{
label: '库位容量',
field: 'slotCapacity',
component: 'InputNumber',
componentProps: { min: 0.0001, precision: 4, style: { width: '100%' }, placeholder: '须大于0' },
dynamicRules: () => [{ required: true, message: '请输入库位容量' }],
},
];
export const superQuerySchema = {
slotName: { title: '烘胶房库位', order: 0, view: 'text' },
dryingRoomName: { title: '所属烘胶房', order: 1, view: 'text' },
categoryName: { title: '存放物料', order: 2, view: 'text' },
slotCapacity: { title: '库位容量', order: 3, view: 'number' },
};

View File

@@ -0,0 +1,135 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button
type="primary"
v-auth="'mes:mes_xsl_drying_room_slot:add'"
@click="handleAdd"
preIcon="ant-design:plus-outlined"
>
新增
</a-button>
<a-button
type="primary"
v-auth="'mes:mes_xsl_drying_room_slot:exportXls'"
preIcon="ant-design:export-outlined"
@click="onExportXls"
>
导出
</a-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined" />
删除
</a-menu-item>
</a-menu>
</template>
<a-button v-auth="'mes:mes_xsl_drying_room_slot:deleteBatch'">
批量操作
<Icon icon="mdi:chevron-down" />
</a-button>
</a-dropdown>
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
</template>
<template #action="{ record }">
<TableAction
:actions="[
{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'mes:mes_xsl_drying_room_slot:edit' },
]"
:dropDownActions="getDropDownAction(record)"
/>
</template>
</BasicTable>
<MesXslDryingRoomSlotModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="xslmes-mesXslDryingRoomSlot" setup>
import { reactive } from 'vue';
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import Icon from '/@/components/Icon';
import MesXslDryingRoomSlotModal from './components/MesXslDryingRoomSlotModal.vue';
import { columns, searchFormSchema, superQuerySchema } from './MesXslDryingRoomSlot.data';
import { list, deleteOne, batchDelete, getExportUrl } from './MesXslDryingRoomSlot.api';
const queryParam = reactive<any>({});
const [registerModal, { openModal }] = useModal();
const { tableContext, onExportXls } = useListPage({
tableProps: {
title: '烘胶房库位',
api: list,
columns,
canResize: true,
formConfig: {
schemas: searchFormSchema,
labelWidth: 100,
autoSubmitOnEnter: true,
showAdvancedButton: true,
},
actionColumn: {
width: 200,
fixed: 'right',
slots: { customRender: 'action' },
},
beforeFetch: (params) => {
return Object.assign(params, queryParam);
},
},
exportConfig: {
name: '烘胶房库位',
url: getExportUrl,
},
});
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
const superQueryConfig = reactive(superQuerySchema);
function handleSuperQuery(params) {
Object.keys(params).forEach((k) => {
queryParam[k] = params[k];
});
reload();
}
function handleAdd() {
openModal(true, { isUpdate: false, showFooter: true });
}
function handleEdit(record: Recordable) {
openModal(true, { record, isUpdate: true, showFooter: true });
}
function handleDetail(record: Recordable) {
openModal(true, { record, isUpdate: true, showFooter: false });
}
async function handleDelete(record) {
await deleteOne({ id: record.id }, handleSuccess);
}
async function batchHandleDelete() {
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
}
function handleSuccess() {
selectedRowKeys.value = [];
reload();
}
function getDropDownAction(record) {
return [
{ label: '详情', onClick: handleDetail.bind(null, record) },
{
label: '删除',
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
auth: 'mes:mes_xsl_drying_room_slot:delete',
},
];
}
</script>

View File

@@ -0,0 +1,88 @@
<template>
<BasicModal v-bind="$attrs" title="选择烘胶分类" :width="900" @register="registerModal" @ok="handleOk">
<BasicTable @register="registerTable" />
</BasicModal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicTable, useTable } from '/@/components/Table';
import { list, queryById } from '/@/views/xslmes/mesXslDryingCategory/MesXslDryingCategory.api';
const emit = defineEmits(['register', 'select']);
const selectedRow = ref<Recordable | null>(null);
function handleSelectionChange(_keys: string[], rows: Recordable[]) {
selectedRow.value = rows?.[0] ?? null;
}
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
api: list,
columns: [
{ title: '分类名称', dataIndex: 'categoryName', width: 220 },
{ title: '创建人', dataIndex: 'createBy', width: 100 },
{ title: '创建时间', dataIndex: 'createTime', width: 165 },
],
rowKey: 'id',
useSearchForm: true,
formConfig: {
labelWidth: 90,
schemas: [{ label: '分类名称', field: 'categoryName', component: 'Input', colProps: { span: 8 } }],
},
pagination: { pageSize: 10 },
canResize: false,
showIndexColumn: false,
immediate: true,
rowSelection: {
type: 'radio',
columnWidth: 48,
onChange: handleSelectionChange,
},
clickToRowSelect: true,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
selectedRow.value = null;
clearSelectedRowKeys?.();
setModalProps({ confirmLoading: false });
const cid = data?.dryingCategoryId as string | undefined;
if (cid) {
setSelectedRowKeys?.([cid]);
try {
const raw = await queryById({ id: cid });
const row = (raw as any)?.id != null ? raw : (raw as any)?.result;
if (row) {
selectedRow.value = row;
}
} catch {
// 忽略
}
}
reload();
});
async function handleOk() {
const keys = (getSelectRowKeys?.() || []) as string[];
let row = selectedRow.value || ((getSelectRows?.() || []) as Recordable[])[0];
if (!row && keys.length) {
try {
const raw = await queryById({ id: keys[0] });
row = (raw as any)?.id != null ? raw : (raw as any)?.result;
} catch {
// 忽略
}
}
if (!row?.id) {
emit('select', { dryingCategoryId: '', categoryName: '' });
closeModal();
return;
}
emit('select', {
dryingCategoryId: row.id,
categoryName: row.categoryName || '',
});
closeModal();
}
</script>

View File

@@ -0,0 +1,92 @@
<template>
<BasicModal v-bind="$attrs" title="选择烘胶房" :width="900" @register="registerModal" @ok="handleOk">
<BasicTable @register="registerTable" />
</BasicModal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicTable, useTable } from '/@/components/Table';
import { list, queryById } from '/@/views/xslmes/mesXslDryingRoom/MesXslDryingRoom.api';
const emit = defineEmits(['register', 'select']);
const selectedRow = ref<Recordable | null>(null);
function handleSelectionChange(_keys: string[], rows: Recordable[]) {
selectedRow.value = rows?.[0] ?? null;
}
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
api: list,
columns: [
{ title: '烘胶房编码', dataIndex: 'roomCode', width: 140 },
{ title: '烘胶房名称', dataIndex: 'roomName', width: 180 },
{ title: '烘胶开始日期', dataIndex: 'dryingStartMd', width: 120 },
{ title: '烘胶结束日期', dataIndex: 'dryingEndMd', width: 120 },
],
rowKey: 'id',
useSearchForm: true,
formConfig: {
labelWidth: 100,
schemas: [
{ label: '烘胶房编码', field: 'roomCode', component: 'Input', colProps: { span: 8 } },
{ label: '烘胶房名称', field: 'roomName', component: 'Input', colProps: { span: 8 } },
],
},
pagination: { pageSize: 10 },
canResize: false,
showIndexColumn: false,
immediate: true,
rowSelection: {
type: 'radio',
columnWidth: 48,
onChange: handleSelectionChange,
},
clickToRowSelect: true,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
selectedRow.value = null;
clearSelectedRowKeys?.();
setModalProps({ confirmLoading: false });
const rid = data?.dryingRoomId as string | undefined;
if (rid) {
setSelectedRowKeys?.([rid]);
try {
const raw = await queryById({ id: rid });
const row = (raw as any)?.id != null ? raw : (raw as any)?.result;
if (row) {
selectedRow.value = row;
}
} catch {
// 忽略
}
}
reload();
});
async function handleOk() {
const keys = (getSelectRowKeys?.() || []) as string[];
let row = selectedRow.value || ((getSelectRows?.() || []) as Recordable[])[0];
if (!row && keys.length) {
try {
const raw = await queryById({ id: keys[0] });
row = (raw as any)?.id != null ? raw : (raw as any)?.result;
} catch {
// 忽略
}
}
if (!row?.id) {
emit('select', { dryingRoomId: '', dryingRoomName: '' });
closeModal();
return;
}
emit('select', {
dryingRoomId: row.id,
dryingRoomName: row.roomName || '',
});
closeModal();
}
</script>

View File

@@ -0,0 +1,116 @@
<template>
<BasicModal
v-bind="$attrs"
destroyOnClose
:title="title"
width="720px"
@register="registerModal"
@ok="handleSubmit"
>
<BasicForm @register="registerForm">
<template #dryingRoomPicker="{ model, field }">
<a-input-group compact style="display: flex; width: 100%">
<a-input v-model:value="model[field]" read-only placeholder="请选择烘胶房" style="flex: 1" />
<a-button type="primary" :disabled="isDetail" @click="openRoomSelect">选择</a-button>
<a-button v-if="model.dryingRoomId && !isDetail" @click="clearRoom(model)">清除</a-button>
</a-input-group>
</template>
<template #dryingCategoryPicker="{ model, field }">
<a-input-group compact style="display: flex; width: 100%">
<a-input v-model:value="model[field]" read-only placeholder="请选择烘胶分类" style="flex: 1" />
<a-button type="primary" :disabled="isDetail" @click="openCategorySelect">选择</a-button>
<a-button v-if="model.dryingCategoryId && !isDetail" @click="clearCategory(model)">清除</a-button>
</a-input-group>
</template>
</BasicForm>
<MesXslDryingRoomSelectModal @register="registerRoomModal" @select="onRoomSelect" />
<MesXslDryingCategorySelectModal @register="registerCategoryModal" @select="onCategorySelect" />
</BasicModal>
</template>
<script lang="ts" setup>
import { computed, ref, unref } from 'vue';
import { BasicModal, useModalInner, useModal } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from '../MesXslDryingRoomSlot.data';
import { saveOrUpdate, queryById } from '../MesXslDryingRoomSlot.api';
import MesXslDryingRoomSelectModal from './MesXslDryingRoomSelectModal.vue';
import MesXslDryingCategorySelectModal from './MesXslDryingCategorySelectModal.vue';
const emit = defineEmits(['register', 'success']);
const isUpdate = ref(false);
const isDetail = ref(false);
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue }] = useForm({
labelWidth: 110,
schemas: formSchema,
showActionButtonGroup: false,
baseColProps: { span: 24 },
});
const [registerRoomModal, { openModal: openRoomModal }] = useModal();
const [registerCategoryModal, { openModal: openCategoryModal }] = useModal();
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
await resetFields();
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
isUpdate.value = !!data?.isUpdate;
isDetail.value = !data?.showFooter;
setProps({ disabled: !data?.showFooter });
if (unref(isUpdate) && data?.record?.id) {
const raw = await queryById({ id: data.record.id });
const m = (raw as any)?.id != null ? raw : (raw as any)?.result ?? raw;
await setFieldsValue({ ...m });
}
});
const title = computed(() =>
!unref(isUpdate) ? '新增烘胶房库位' : unref(isDetail) ? '烘胶房库位详情' : '编辑烘胶房库位',
);
function openRoomSelect() {
const values = getFieldsValue();
openRoomModal(true, { dryingRoomId: values?.dryingRoomId });
}
function openCategorySelect() {
const values = getFieldsValue();
openCategoryModal(true, { dryingCategoryId: values?.dryingCategoryId });
}
function onRoomSelect(payload: Recordable) {
setFieldsValue({
dryingRoomId: payload?.dryingRoomId || '',
dryingRoomName: payload?.dryingRoomName || '',
});
}
function onCategorySelect(payload: Recordable) {
setFieldsValue({
dryingCategoryId: payload?.dryingCategoryId || '',
categoryName: payload?.categoryName || '',
});
}
function clearRoom(model: Recordable) {
model.dryingRoomId = '';
model.dryingRoomName = '';
}
function clearCategory(model: Recordable) {
model.dryingCategoryId = '';
model.categoryName = '';
}
async function handleSubmit() {
try {
const values = await validate();
setModalProps({ confirmLoading: true });
await saveOrUpdate(values, unref(isUpdate));
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>