@@ -5,10 +5,10 @@ import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import { message } from 'antdv-next';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
type OutboundCreateReq,
|
||||
type OutboundDetail,
|
||||
@@ -18,10 +18,11 @@ import { getBsrealStorAttrSimpleList } from '#/api/wms/bsrealstorattr';
|
||||
import { getSimpleDictDataList } from '#/api/system/dict/data';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import InventorySelectModalComponent from './inventory-select.vue';
|
||||
import ManualDetailModalComponent from './manual-detail.vue';
|
||||
import InventorySelect from './inventory-select.vue';
|
||||
import ManualDetail from './manual-detail.vue';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<WmsIostorInvApi.IostorInv>();
|
||||
|
||||
// ========== 仓库选项 ==========
|
||||
const storOptions = ref<
|
||||
@@ -50,7 +51,7 @@ async function loadBillTypeOptions() {
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: { class: 'w-full' },
|
||||
formItemClass: 'col-span-1',
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
@@ -86,6 +87,7 @@ const [Form, formApi] = useVbenForm({
|
||||
fieldName: 'bizDate',
|
||||
label: '业务日期',
|
||||
rules: 'required',
|
||||
defaultValue: new Date(),
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
showTime: true,
|
||||
@@ -125,8 +127,7 @@ const [Form, formApi] = useVbenForm({
|
||||
});
|
||||
|
||||
// ========== 明细数据 ==========
|
||||
type DetailRow = OutboundDetail & { vehicleCode?: string; materialName?: string };
|
||||
const detailList = ref<DetailRow[]>([]);
|
||||
const detailList = ref<(OutboundDetail & { vehicleCode?: string; materialName?: string })[]>([]);
|
||||
|
||||
function updateSummary() {
|
||||
const totalWeight = detailList.value
|
||||
@@ -148,7 +149,6 @@ watch(
|
||||
);
|
||||
|
||||
// ========== 明细表格 ==========
|
||||
const vxeGridRef = ref();
|
||||
const gridOptions = computed(() => ({
|
||||
columns: [
|
||||
{ type: 'seq', title: '序号', width: 50 },
|
||||
@@ -164,8 +164,6 @@ const gridOptions = computed(() => ({
|
||||
data: detailList.value,
|
||||
height: 'auto',
|
||||
rowConfig: { keyField: 'materialCode', isHover: true },
|
||||
toolbarConfig: false,
|
||||
pagerConfig: false,
|
||||
}));
|
||||
|
||||
function handleDeleteDetail(index: number) {
|
||||
@@ -173,8 +171,11 @@ function handleDeleteDetail(index: number) {
|
||||
updateSummary();
|
||||
}
|
||||
|
||||
// ========== 库存选择弹窗(子组件自带 Modal,用 ref 调用 open) ==========
|
||||
const inventorySelectRef = ref<InstanceType<typeof InventorySelectModalComponent>>();
|
||||
// ========== 库存选择弹窗 ==========
|
||||
const [InventorySelectModal, inventorySelectModalApi] = useVbenModal({
|
||||
connectedComponent: InventorySelect,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
function handleSelectFromInventory() {
|
||||
const storId = formApi.getValues().storId;
|
||||
@@ -182,7 +183,7 @@ function handleSelectFromInventory() {
|
||||
message.warning('请先选择仓库');
|
||||
return;
|
||||
}
|
||||
inventorySelectRef.value?.open({ storId });
|
||||
inventorySelectModalApi.setData({ storId }).open();
|
||||
}
|
||||
|
||||
function onInventorySelected(rows: any[]) {
|
||||
@@ -204,24 +205,18 @@ function onInventorySelected(rows: any[]) {
|
||||
updateSummary();
|
||||
}
|
||||
|
||||
// ========== 手动新增弹窗(子组件自带 Modal,用 ref 调用 open) ==========
|
||||
const manualDetailRef = ref<InstanceType<typeof ManualDetailModalComponent>>();
|
||||
// ========== 手动新增弹窗 ==========
|
||||
const [ManualDetailModal, manualDetailModalApi] = useVbenModal({
|
||||
connectedComponent: ManualDetail,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
function handleManualAdd() {
|
||||
manualDetailRef.value?.open();
|
||||
manualDetailModalApi.setData({}).open();
|
||||
}
|
||||
|
||||
function onManualAdded(detail: any) {
|
||||
detailList.value.push({
|
||||
materialCode: detail.materialCode,
|
||||
materialId: String(detail.materialId ?? ''),
|
||||
materialName: detail.materialName,
|
||||
planQty: detail.planQty,
|
||||
qtyUnitId: String(detail.qtyUnitId ?? ''),
|
||||
qtyUnitName: detail.qtyUnitName,
|
||||
pcsn: detail.pcsn,
|
||||
remark: detail.remark,
|
||||
});
|
||||
detailList.value.push(detail);
|
||||
updateSummary();
|
||||
}
|
||||
|
||||
@@ -274,10 +269,6 @@ const [Modal, modalApi] = useVbenModal({
|
||||
if (isOpen) {
|
||||
await loadStorOptions();
|
||||
await loadBillTypeOptions();
|
||||
// 业务日期默认当天
|
||||
formApi.setValues({
|
||||
bizDate: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
});
|
||||
}
|
||||
if (!isOpen) {
|
||||
detailList.value = [];
|
||||
@@ -303,7 +294,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<vxe-grid ref="vxeGridRef" v-bind="gridOptions">
|
||||
<vxe-grid v-bind="gridOptions">
|
||||
<template #actions="{ rowIndex }">
|
||||
<a-button type="link" danger @click="handleDeleteDetail(rowIndex)">
|
||||
删除
|
||||
@@ -313,14 +304,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 子弹窗:不通过 connectedComponent,而是通过 ref 调用 -->
|
||||
<InventorySelectModalComponent
|
||||
ref="inventorySelectRef"
|
||||
@select="onInventorySelected"
|
||||
/>
|
||||
<ManualDetailModalComponent
|
||||
ref="manualDetailRef"
|
||||
@confirm="onManualAdded"
|
||||
/>
|
||||
<InventorySelectModal @select="onInventorySelected" />
|
||||
<ManualDetailModal @confirm="onManualAdded" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -101,12 +101,6 @@ const [Modal, modalApi] = useVbenModal({
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
/** 暴露给父组件调用 */
|
||||
function open(data: { storId: string }) {
|
||||
modalApi.setData(data).open();
|
||||
}
|
||||
defineExpose({ open });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
|
||||
import MaterialSelectModalComponent from '../../base/materialbase/components/MaterialSelectModal.vue';
|
||||
import MaterialSelectModalComponent from '../../../base/materialbase/components/MaterialSelectModal.vue';
|
||||
|
||||
const emit = defineEmits(['confirm']);
|
||||
|
||||
@@ -14,7 +14,7 @@ const [MaterialSelectModal, materialSelectModalApi] = useVbenModal({
|
||||
connectedComponent: MaterialSelectModalComponent,
|
||||
});
|
||||
|
||||
/** 已选物料信息 */
|
||||
/** 已选物料信息(不在表单中展示的额外字段) */
|
||||
const selectedMaterial = ref<{
|
||||
materialId: number;
|
||||
materialName: string;
|
||||
@@ -44,7 +44,9 @@ function handleMaterialSelect(rows: any[]) {
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: { class: 'w-full' },
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
},
|
||||
@@ -109,7 +111,9 @@ const [Modal, modalApi] = useVbenModal({
|
||||
width: 500,
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) return;
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
if (!selectedMaterial.value) {
|
||||
return;
|
||||
}
|
||||
@@ -121,8 +125,8 @@ const [Modal, modalApi] = useVbenModal({
|
||||
planQty: values.planQty,
|
||||
qtyUnitId: selectedMaterial.value.qtyUnitId,
|
||||
qtyUnitName: selectedMaterial.value.qtyUnitName,
|
||||
pcsn: values.pcsn || '',
|
||||
remark: values.remark || '',
|
||||
pcsn: values.pcsn,
|
||||
remark: values.remark,
|
||||
});
|
||||
modalApi.close();
|
||||
},
|
||||
@@ -131,16 +135,11 @@ const [Modal, modalApi] = useVbenModal({
|
||||
selectedMaterial.value = null;
|
||||
return;
|
||||
}
|
||||
// 弹窗打开时重置表单
|
||||
selectedMaterial.value = null;
|
||||
await formApi.resetForm();
|
||||
},
|
||||
});
|
||||
|
||||
/** 暴露给父组件调用 */
|
||||
function open() {
|
||||
modalApi.open();
|
||||
}
|
||||
defineExpose({ open });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user