Revert "fix: 修复前端报错 — VxeTable组件、MaterialSelectModal路径、dayjs类型"
This reverts commit ec05ee98d0.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import type { WmsIostorInvApi } from '#/api/wms/iostorinv';
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
@@ -7,7 +9,6 @@ import dayjs from 'dayjs';
|
||||
import { message } from 'antdv-next';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
|
||||
import {
|
||||
type OutboundCreateReq,
|
||||
type OutboundDetail,
|
||||
@@ -23,7 +24,9 @@ import ManualDetailModalComponent from './manual-detail.vue';
|
||||
const emit = defineEmits(['success']);
|
||||
|
||||
// ========== 仓库选项 ==========
|
||||
const storOptions = ref<any[]>([]);
|
||||
const storOptions = ref<
|
||||
{ label: string; value: string; storCode: string; storName: string }[]
|
||||
>([]);
|
||||
async function loadStorOptions() {
|
||||
const list = await getBsrealStorAttrSimpleList();
|
||||
storOptions.value = (list || []).map((item: any) => ({
|
||||
@@ -35,7 +38,7 @@ async function loadStorOptions() {
|
||||
}
|
||||
|
||||
// ========== 业务类型选项 ==========
|
||||
const billTypeOptions = ref<any[]>([]);
|
||||
const billTypeOptions = ref<{ label: string; value: string }[]>([]);
|
||||
async function loadBillTypeOptions() {
|
||||
const list = await getSimpleDictDataList();
|
||||
billTypeOptions.value = (list || [])
|
||||
@@ -122,13 +125,16 @@ const [Form, formApi] = useVbenForm({
|
||||
});
|
||||
|
||||
// ========== 明细数据 ==========
|
||||
const detailList = ref<any[]>([]);
|
||||
type DetailRow = OutboundDetail & { vehicleCode?: string; materialName?: string };
|
||||
const detailList = ref<DetailRow[]>([]);
|
||||
|
||||
function updateSummary() {
|
||||
const total = detailList.value.reduce((sum, d) => sum + (Number(d.planQty) || 0), 0);
|
||||
const totalWeight = detailList.value
|
||||
.reduce((sum, d) => sum + (Number(d.planQty) || 0), 0)
|
||||
.toFixed(3);
|
||||
formApi.setValues({
|
||||
detailCount: detailList.value.length,
|
||||
totalWeight: total.toFixed(3),
|
||||
totalWeight: String(totalWeight),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -141,13 +147,34 @@ watch(
|
||||
},
|
||||
);
|
||||
|
||||
// ========== 明细表格 ==========
|
||||
const vxeGridRef = ref();
|
||||
const gridOptions = computed(() => ({
|
||||
columns: [
|
||||
{ type: 'seq', title: '序号', width: 50 },
|
||||
{ field: 'vehicleCode', title: '箱号', width: 100 },
|
||||
{ field: 'materialCode', title: '物料编码', width: 120 },
|
||||
{ field: 'materialName', title: '物料名称', width: 150 },
|
||||
{ field: 'pcsn', title: '子卷号', width: 100 },
|
||||
{ field: 'planQty', title: '出库重量', width: 100 },
|
||||
{ field: 'qtyUnitName', title: '单位', width: 60 },
|
||||
{ field: 'remark', title: '备注', width: 120 },
|
||||
{ title: '操作', width: 80, slots: { default: 'actions' } },
|
||||
],
|
||||
data: detailList.value,
|
||||
height: 'auto',
|
||||
rowConfig: { keyField: 'materialCode', isHover: true },
|
||||
toolbarConfig: false,
|
||||
pagerConfig: false,
|
||||
}));
|
||||
|
||||
function handleDeleteDetail(index: number) {
|
||||
detailList.value.splice(index, 1);
|
||||
updateSummary();
|
||||
}
|
||||
|
||||
// ========== 库存选择弹窗 ==========
|
||||
const inventorySelectRef = ref<any>();
|
||||
// ========== 库存选择弹窗(子组件自带 Modal,用 ref 调用 open) ==========
|
||||
const inventorySelectRef = ref<InstanceType<typeof InventorySelectModalComponent>>();
|
||||
|
||||
function handleSelectFromInventory() {
|
||||
const storId = formApi.getValues().storId;
|
||||
@@ -177,8 +204,8 @@ function onInventorySelected(rows: any[]) {
|
||||
updateSummary();
|
||||
}
|
||||
|
||||
// ========== 手动新增弹窗 ==========
|
||||
const manualDetailRef = ref<any>();
|
||||
// ========== 手动新增弹窗(子组件自带 Modal,用 ref 调用 open) ==========
|
||||
const manualDetailRef = ref<InstanceType<typeof ManualDetailModalComponent>>();
|
||||
|
||||
function handleManualAdd() {
|
||||
manualDetailRef.value?.open();
|
||||
@@ -220,7 +247,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
storName: stor?.storName,
|
||||
bizDate: masterValues.bizDate,
|
||||
remark: masterValues.remark,
|
||||
details: detailList.value.map((d: any) => ({
|
||||
details: detailList.value.map((d) => ({
|
||||
materialCode: d.materialCode,
|
||||
materialId: d.materialId,
|
||||
pcsn: d.pcsn,
|
||||
@@ -247,7 +274,10 @@ const [Modal, modalApi] = useVbenModal({
|
||||
if (isOpen) {
|
||||
await loadStorOptions();
|
||||
await loadBillTypeOptions();
|
||||
formApi.setValues({ bizDate: dayjs().format('YYYY-MM-DD HH:mm:ss') });
|
||||
// 业务日期默认当天
|
||||
formApi.setValues({
|
||||
bizDate: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
});
|
||||
}
|
||||
if (!isOpen) {
|
||||
detailList.value = [];
|
||||
@@ -273,26 +303,17 @@ const [Modal, modalApi] = useVbenModal({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<VxeTable :data="detailList" show-overflow>
|
||||
<VxeColumn type="seq" title="序号" width="50" align="center" />
|
||||
<VxeColumn field="vehicleCode" title="箱号" width="100" />
|
||||
<VxeColumn field="materialCode" title="物料编码" width="120" />
|
||||
<VxeColumn field="materialName" title="物料名称" width="150" />
|
||||
<VxeColumn field="pcsn" title="子卷号" width="100" />
|
||||
<VxeColumn field="planQty" title="出库重量" width="100" />
|
||||
<VxeColumn field="qtyUnitName" title="单位" width="60" />
|
||||
<VxeColumn field="remark" title="备注" min-width="120" />
|
||||
<VxeColumn title="操作" width="80" align="center" fixed="right">
|
||||
<template #default="{ rowIndex }">
|
||||
<a-button type="link" danger size="small" @click="handleDeleteDetail(rowIndex)">
|
||||
<vxe-grid ref="vxeGridRef" v-bind="gridOptions">
|
||||
<template #actions="{ rowIndex }">
|
||||
<a-button type="link" danger @click="handleDeleteDetail(rowIndex)">
|
||||
删除
|
||||
</a-button>
|
||||
</template>
|
||||
</VxeColumn>
|
||||
</VxeTable>
|
||||
</vxe-grid>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 子弹窗:不通过 connectedComponent,而是通过 ref 调用 -->
|
||||
<InventorySelectModalComponent
|
||||
ref="inventorySelectRef"
|
||||
@select="onInventorySelected"
|
||||
|
||||
@@ -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']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user