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