|
|
|
|
@ -81,10 +81,27 @@
|
|
|
|
|
</el-row>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<el-table v-loading="loading" border :data="outStockBillList" @selection-change="handleSelectionChange">
|
|
|
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
|
|
|
<el-table
|
|
|
|
|
v-loading="loading"
|
|
|
|
|
border
|
|
|
|
|
:data="outStockBillList"
|
|
|
|
|
@selection-change="handleSelectionChange"
|
|
|
|
|
@expand-change="handleExpandChange"
|
|
|
|
|
:row-key="(row) => row.outStockBillId"
|
|
|
|
|
>
|
|
|
|
|
<el-table-column type="expand">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<el-table v-loading="row.loading" border :data="row.data" :style="{ width: '95%', margin: '0 auto' }">
|
|
|
|
|
<el-table-column label="物料ID" align="center" prop="materielId" v-if="columns[3].visible" />
|
|
|
|
|
<el-table-column label="批次号" align="center" prop="batchNumber" v-if="columns[4].visible" />
|
|
|
|
|
<el-table-column label="单价" align="center" prop="unitPrice" v-if="columns[5].visible" />
|
|
|
|
|
<el-table-column label="出库数量" align="center" prop="outStockAmount" v-if="columns[6].visible" />
|
|
|
|
|
<el-table-column label="单位" align="center" prop="unitName" v-if="columns[7].visible" />
|
|
|
|
|
<el-table-column label="总价" align="center" prop="totalPrice" v-if="columns[8].visible" />
|
|
|
|
|
</el-table>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="出库单ID" align="center" prop="outStockBillId" v-if="columns[0].visible" />
|
|
|
|
|
|
|
|
|
|
<el-table-column label="租户编号" align="center" prop="tenantId" v-if="columns[1].visible" />
|
|
|
|
|
<el-table-column label="出库单号" align="center" prop="outStockCode" v-if="columns[2].visible" />
|
|
|
|
|
<el-table-column label="仓库" align="center" prop="warehouseId" v-if="columns[12].visible">
|
|
|
|
|
@ -232,23 +249,53 @@
|
|
|
|
|
<div v-if="selectInventorys.length > 0" style="margin-top: 20px">
|
|
|
|
|
<h4>已选择的物料:</h4>
|
|
|
|
|
<el-table border :data="selectInventorys">
|
|
|
|
|
<el-table-column label="出库单明细ID" align="center" prop="outStockDetailsId" />
|
|
|
|
|
<el-table-column label="物料ID" align="center" prop="materielId" />
|
|
|
|
|
<el-table-column label="批次号" align="center" prop="batchNumber" />
|
|
|
|
|
<el-table-column label="单价" align="center" prop="unitPrice" />
|
|
|
|
|
<el-table-column label="出库数量" align="center" prop="outStockAmount" />
|
|
|
|
|
<el-table-column label="单位" align="center" prop="unitName" />
|
|
|
|
|
<el-table-column label="总价" align="center" prop="totalPrice" />
|
|
|
|
|
<el-table-column label="物料编码" align="center" prop="productCode" />
|
|
|
|
|
<el-table-column label="物料名称" align="center" prop="productName" />
|
|
|
|
|
<el-table-column label="单价" align="center" prop="unitPrice" width="80" />
|
|
|
|
|
<el-table-column label="当前库存" align="center" prop="inventoryAmount" width="90" />
|
|
|
|
|
<el-table-column label="出库数量" align="center" prop="outStockAmount" width="140">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<el-input-number
|
|
|
|
|
v-model="scope.row.outStockAmount"
|
|
|
|
|
:min="0"
|
|
|
|
|
:precision="2"
|
|
|
|
|
:step="0.5"
|
|
|
|
|
:max="scope.row.inventoryAmount"
|
|
|
|
|
@change="calculateTotalPrice(scope.row)"
|
|
|
|
|
controls-position="right"
|
|
|
|
|
size="small"
|
|
|
|
|
placeholder="请输入出库数量"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="单位" align="center" prop="unitName" width="80" />
|
|
|
|
|
<el-table-column label="总价" align="center" prop="totalPrice" width="80">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
{{ scope.row.totalPrice || '0.00' }}
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
|
|
|
|
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width" width="60">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<el-button link type="danger" icon="Delete" @click="removeOutDetail(scope.$index)"></el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</div>
|
|
|
|
|
</el-card>
|
|
|
|
|
<wms-inventory-select ref="inventorySelectRef" :multiple="true" @confirmCallBack="handleInventorySelect" />
|
|
|
|
|
<wms-inventory-select ref="inventorySelectRef" :multiple="true" :warehouse-id="form.warehouseId" @confirmCallBack="handleInventorySelect" />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
<div class="dialog-footer">
|
|
|
|
|
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
|
|
|
|
<el-button @click="cancel">取 消</el-button>
|
|
|
|
|
<div class="dialog-footer" style="display: flex; justify-content: space-between; align-items: center; width: 100%">
|
|
|
|
|
<div class="total-price-summary">
|
|
|
|
|
<span style="font-weight: bold; color: #409eff">总价合计: {{ totalPriceSum }} 元</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="dialog-footer">
|
|
|
|
|
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
|
|
|
|
<el-button @click="cancel">取 消</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
@ -256,12 +303,14 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup name="OutStockBill" lang="ts">
|
|
|
|
|
import { addOutStockBill, delOutStockBill, getOutStockBill, listOutStockBill, updateOutStockBill } from '@/api/wms/outStockBill';
|
|
|
|
|
import { addOutStockBill, delOutStockBill, getOutStockBill, listOutStockBill } from '@/api/wms/outStockBill';
|
|
|
|
|
import { OutStockBillForm, OutStockBillQuery, OutStockBillVO } from '@/api/wms/outStockBill/types';
|
|
|
|
|
import { getErpProjectInfoList } from '@/api/oa/erp/projectInfo';
|
|
|
|
|
import { getCrmCustomerInfoList } from '@/api/oa/crm/customerInfo';
|
|
|
|
|
import { getWmsWarehouseInfoList } from '@/api/wms/warehouseInfo';
|
|
|
|
|
import WmsInventorySelect from '@/components/WmsInventorySelect/index.vue';
|
|
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
|
|
import { getWmsOutStockDetailsList } from '@/api/wms/outStockDetails';
|
|
|
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
|
const { wms_in_stock_bill_status, out_stock_type, flow_status } = toRefs<any>(
|
|
|
|
|
@ -345,15 +394,34 @@ const data = reactive<PageData<OutStockBillForm, OutStockBillQuery>>({
|
|
|
|
|
outStockBillStatus: undefined,
|
|
|
|
|
warehouseId: undefined,
|
|
|
|
|
createTime: undefined,
|
|
|
|
|
orderByColumn: 'createTime',
|
|
|
|
|
isAsc: 'desc',
|
|
|
|
|
params: {}
|
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
outStockBillId: [{ required: true, message: '出库单ID不能为空', trigger: 'blur' }]
|
|
|
|
|
outStockBillId: [{ required: true, message: '出库单ID不能为空', trigger: 'blur' }],
|
|
|
|
|
warehouseId: [{ required: true, message: '请选择仓库', trigger: 'blur' }],
|
|
|
|
|
outStockType: [{ required: true, message: '请选择出库单类型', trigger: 'blur' }],
|
|
|
|
|
projectId: [{ required: true, message: '请选择项目', trigger: 'blur' }]
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const { queryParams, form, rules } = toRefs(data);
|
|
|
|
|
|
|
|
|
|
/**点击展开子表*/
|
|
|
|
|
// ... existing code ...
|
|
|
|
|
const handleExpandChange = async (row, expandedRows) => {
|
|
|
|
|
if (expandedRows.length && !row.data) {
|
|
|
|
|
try {
|
|
|
|
|
row.loading = true;
|
|
|
|
|
const res = await getWmsOutStockDetailsList({ outStockBillId: row.outStockBillId });
|
|
|
|
|
row.data = res.data;
|
|
|
|
|
} finally {
|
|
|
|
|
row.loading = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 获取项目列表 */
|
|
|
|
|
const getProjectInfoList = async () => {
|
|
|
|
|
const res = await getErpProjectInfoList({});
|
|
|
|
|
@ -389,16 +457,47 @@ const getWarehouseName = (warehouseId) => {
|
|
|
|
|
const warehouse = warehouseInfoList.value.find((item) => item.warehouseId === warehouseId);
|
|
|
|
|
return warehouse ? warehouse.warehouseName : warehouseId;
|
|
|
|
|
};
|
|
|
|
|
/** 打开库存选择器 */
|
|
|
|
|
const openInventorySelect = () => {
|
|
|
|
|
if (!form.value.warehouseId) {
|
|
|
|
|
ElMessage.warning('请先选择仓库');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
inventorySelectRef.value.warehouseId = form.value.warehouseId;
|
|
|
|
|
inventorySelectRef.value.open();
|
|
|
|
|
};
|
|
|
|
|
/** 处理库存选择器确认选择 */
|
|
|
|
|
const handleInventorySelect = (selectedInventorys) => {
|
|
|
|
|
// selectedInventorys 就是用户选择的库存数据数组
|
|
|
|
|
selectInventorys.value = selectedInventorys;
|
|
|
|
|
|
|
|
|
|
console.log(selectedInventorys);
|
|
|
|
|
// 这里可以进一步处理选中的库存数据
|
|
|
|
|
};
|
|
|
|
|
/** 删除选中的出库明细 */
|
|
|
|
|
const removeOutDetail = (index) => {
|
|
|
|
|
selectInventorys.value.splice(index, 1);
|
|
|
|
|
};
|
|
|
|
|
/** 计算每行总金额 */
|
|
|
|
|
const calculateTotalPrice = (data) => {
|
|
|
|
|
if (data.outStockAmount && data.unitPrice) {
|
|
|
|
|
data.totalPrice = (data.outStockAmount * data.unitPrice).toFixed(2);
|
|
|
|
|
} else {
|
|
|
|
|
data.totalPrice = 0;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
// 计算所有选中库存的总价合计
|
|
|
|
|
const totalPriceSum = computed(() => {
|
|
|
|
|
if (!selectInventorys.value || selectInventorys.value.length === 0) {
|
|
|
|
|
return '0.00';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const sum = selectInventorys.value.reduce((total, item) => {
|
|
|
|
|
const outStockAmount = item.outStockAmount || 0;
|
|
|
|
|
const unitPrice = item.unitPrice || 0;
|
|
|
|
|
return total + outStockAmount * unitPrice;
|
|
|
|
|
}, 0);
|
|
|
|
|
|
|
|
|
|
return sum.toFixed(2);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/** 查询出库单列表 */
|
|
|
|
|
const getList = async () => {
|
|
|
|
|
loading.value = true;
|
|
|
|
|
@ -443,6 +542,7 @@ const handleSelectionChange = (selection: OutStockBillVO[]) => {
|
|
|
|
|
/** 新增按钮操作 */
|
|
|
|
|
const handleAdd = () => {
|
|
|
|
|
reset();
|
|
|
|
|
selectInventorys.value = [];
|
|
|
|
|
dialog.visible = true;
|
|
|
|
|
dialog.title = '添加出库单';
|
|
|
|
|
};
|
|
|
|
|
@ -461,11 +561,38 @@ const handleUpdate = async (row?: OutStockBillVO) => {
|
|
|
|
|
const submitForm = () => {
|
|
|
|
|
outStockBillFormRef.value?.validate(async (valid: boolean) => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
if (selectInventorys.value.length === 0) {
|
|
|
|
|
ElMessage.warning('请选择出库明细');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 验证物料的出库数量都大于0
|
|
|
|
|
const validOutStockDetails = selectInventorys.value.every((item) => item.outStockAmount > 0);
|
|
|
|
|
if (!validOutStockDetails) {
|
|
|
|
|
ElMessage.warning('出库数量必须大于0');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
buttonLoading.value = true;
|
|
|
|
|
if (form.value.outStockBillId) {
|
|
|
|
|
await updateOutStockBill(form.value).finally(() => (buttonLoading.value = false));
|
|
|
|
|
ElMessage.error('暂不允许修改');
|
|
|
|
|
// await updateOutStockBill(form.value).finally(() => (buttonLoading.value = false));
|
|
|
|
|
} else {
|
|
|
|
|
await addOutStockBill(form.value).finally(() => (buttonLoading.value = false));
|
|
|
|
|
const submitFlowData = {
|
|
|
|
|
...form.value,
|
|
|
|
|
outStockDetailsList: selectInventorys.value.filter((item) => ({
|
|
|
|
|
warehouseId: form.value.warehouseId,
|
|
|
|
|
materielId: item.productId,
|
|
|
|
|
batchNumber: item.batchNumber,
|
|
|
|
|
unitPrice: item.unitPrice,
|
|
|
|
|
outStockAmount: item.outStockAmount,
|
|
|
|
|
unitName: item.unitName,
|
|
|
|
|
totalPrice: item.totalPrice,
|
|
|
|
|
inProjectId: item.projectId,
|
|
|
|
|
outProjectId: form.value.projectId,
|
|
|
|
|
inventoryDetailsId: item.inventoryDetailsId,
|
|
|
|
|
oldInventoryAmount: item.inventoryAmount
|
|
|
|
|
}))
|
|
|
|
|
};
|
|
|
|
|
await addOutStockBill(submitFlowData).finally(() => (buttonLoading.value = false));
|
|
|
|
|
}
|
|
|
|
|
proxy?.$modal.msgSuccess('操作成功');
|
|
|
|
|
dialog.visible = false;
|
|
|
|
|
|