入库单展开行显示

main
HUOJIN\92525 2025-03-28 18:03:49 +08:00
parent 03eda3fa78
commit ece5371380
9 changed files with 829 additions and 15 deletions

View File

@ -0,0 +1,48 @@
/**
* api
*
* @Author:
* @Date: 2025-03-26 15:16:28
* @Copyright
*/
import {postRequest, getRequest} from '/@/lib/axios';
export const asnDetailApi = {
/**
* @author
*/
queryPage: (param: object) => {
return postRequest('/asnDetail/queryPage', param);
},
/**
* @author
*/
add: (param: object) => {
return postRequest('/asnDetail/add', param);
},
/**
* @author
*/
update: (param: object) => {
return postRequest('/asnDetail/update', param);
},
/**
* @author
*/
delete: (asnDetailId: number) => {
return getRequest('/asnDetail/delete', {asnDetailId});
},
/**
* @author
*/
batchDelete: (idList: number[]) => {
return postRequest('/asnDetail/batchDelete', idList);
},
};

View File

@ -0,0 +1,11 @@
/**
*
*
* @Author:
* @Date: 2025-03-26 15:16:28
* @Copyright
*/
export default {
};

View File

@ -46,6 +46,7 @@ export const TABLE_ID_CONST = {
}, },
RECEIVE:{ RECEIVE:{
ASN:businessRECEIVEInitTableId+1,//入库单 ASN:businessRECEIVEInitTableId+1,//入库单
ASN_DETAIL:businessRECEIVEInitTableId+2,//入库明细
} }
}, },

View File

@ -110,6 +110,7 @@
</a-button> </a-button>
</div> </div>
</template> </template>
</template> </template>
</a-table> </a-table>
<!---------- 表格 end -----------> <!---------- 表格 end ----------->

View File

@ -82,17 +82,13 @@
</div> </div>
<a-card class="smart-margin-top10" size="small"> <a-card class="smart-margin-top10" size="small">
<a-tabs> <a-tabs>
<a-tab-pane key="employee" tab="员工信息"> <a-tab-pane key="asnDetail" tab="入库明细">
<EmployeeList :enterpriseId="enterpriseId"/> <ReceiveDetailList :asnId="form.asnId"/>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="bank" tab="银行信息"> <a-tab-pane key="asnTask" tab="收货详情">
<BankList :enterpriseId="enterpriseId"/>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="invoice" tab="发票信息"> <a-tab-pane key="dataTracer" tab="操作记录">
<InvoiceList :enterpriseId="enterpriseId"/> <DataTracer :dataId="form.asnId" :type="DATA_TRACER_TYPE_ENUM.OA_ENTERPRISE.value"/>
</a-tab-pane>
<a-tab-pane key="dataTracer" tab="变更记录">
<DataTracer :dataId="enterpriseId" :type="DATA_TRACER_TYPE_ENUM.OA_ENTERPRISE.value"/>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
</a-card> </a-card>
@ -112,6 +108,7 @@ import {message} from "ant-design-vue";
import {SmartLoading} from "/@/components/framework/smart-loading"; import {SmartLoading} from "/@/components/framework/smart-loading";
import {asnApi} from "/@/api/business/receive/asn/asn-api"; import {asnApi} from "/@/api/business/receive/asn/asn-api";
import {smartSentry} from "/@/lib/smart-sentry"; import {smartSentry} from "/@/lib/smart-sentry";
import ReceiveDetailList from "/@/views/business/receive/asn/receive-detail-list.vue";
// //
const formRef = ref(); const formRef = ref();
@ -163,9 +160,9 @@ onMounted(() => {
const id = route.query.id; const id = route.query.id;
if (typeof id === 'string') { if (typeof id === 'string') {
// sessionStorage // sessionStorage
const res = JSON.parse(sessionStorage.getItem(id) as string); const res = getDataFromSessionStorage(id);
// //
if (res.asnId) { if (res) {
form.asnId = res.asnId; form.asnId = res.asnId;
form.customerId = res.customerId; form.customerId = res.customerId;
form.customerNumber = res.customerNumber; form.customerNumber = res.customerNumber;
@ -176,12 +173,22 @@ onMounted(() => {
form.telephone = res.telephone; form.telephone = res.telephone;
form.address = res.address; form.address = res.address;
} }
sessionStorage.removeItem(id); // //
sessionStorage.removeItem(id);
} }
}); });
//sessionStorage
function getDataFromSessionStorage(id: string) {
try {
const data = sessionStorage.getItem(id);
return data ? JSON.parse(data) : null;
} catch (error) {
message.error('解析 sessionStorage 数据时出错:');
return null;
}
}
// //
async function onSubmit() { async function onSubmit() {
try { try {

View File

@ -64,7 +64,32 @@
:loading="tableLoading" :loading="tableLoading"
:pagination="false" :pagination="false"
:row-selection="{ selectedRowKeys: selectedRowKeyList, onChange: onSelectChange }" :row-selection="{ selectedRowKeys: selectedRowKeyList, onChange: onSelectChange }"
@expand="querySubTableData"
> >
<template #expandedRowRender="{ record }">
<a-table
size="small"
:columns="subColumns"
:data-source="subTableData"
:pagination="false"
rowKey="asnDetailId"
>
<template #summary>
<a-table-summary-row style="font-weight: bold">
<a-table-summary-cell :index="0" align="center">合计</a-table-summary-cell>
<a-table-summary-cell :index="1">&nbsp;</a-table-summary-cell>
<a-table-summary-cell :index="2" align="center">
<a-typography-text type="danger">{{ totals.totalOrderQuantity }}</a-typography-text>
</a-table-summary-cell>
<a-table-summary-cell :index="3" align="center">
<a-typography-text type="danger">{{ totals.totalReceivedQuantity }}</a-typography-text>
</a-table-summary-cell>
</a-table-summary-row>
</template>
</a-table>
</template>
<template #bodyCell="{ text, record, column }"> <template #bodyCell="{ text, record, column }">
<template v-if="column.dataIndex === 'orderType'"> <template v-if="column.dataIndex === 'orderType'">
@ -117,13 +142,14 @@
</a-card> </a-card>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import {reactive, ref, onMounted, watch} from 'vue'; import {computed, reactive, ref, onMounted, watch} from 'vue';
import {message, Modal} from 'ant-design-vue'; import {message, Modal} from 'ant-design-vue';
import {SmartLoading} from '/@/components/framework/smart-loading'; import {SmartLoading} from '/@/components/framework/smart-loading';
import {PAGE_SIZE_OPTIONS} from '/@/constants/common-const'; import {PAGE_SIZE_OPTIONS} from '/@/constants/common-const';
import {smartSentry} from '/@/lib/smart-sentry'; import {smartSentry} from '/@/lib/smart-sentry';
import TableOperator from '/@/components/support/table-operator/index.vue'; import TableOperator from '/@/components/support/table-operator/index.vue';
import {asnApi} from '/@/api/business/receive/asn/asn-api'; import {asnApi} from '/@/api/business/receive/asn/asn-api';
import {asnDetailApi} from '/@/api/business/receive/asnDetail/asn-detail-api'
import {TABLE_ID_CONST} from "/@/constants/support/table-id-const"; import {TABLE_ID_CONST} from "/@/constants/support/table-id-const";
import {useRoute, useRouter} from "vue-router"; import {useRoute, useRouter} from "vue-router";
@ -193,6 +219,62 @@ const columns = ref([
}, },
]); ]);
//
const subColumns = [
{
title: '物料编码',
dataIndex: 'itemCode',
align: 'center',
ellipsis: true,
},
{
title: '物料名称',
dataIndex: 'itemName',
align: 'center',
ellipsis: true,
},
{
title: '订单数量',
align: 'center',
dataIndex: 'orderQuantity',
ellipsis: true,
},
{
title: '收货数量',
align: 'center',
dataIndex: 'receivedQuantity',
ellipsis: true,
},
];
//
const subTableData = ref([]);
async function querySubTableData(expanded: boolean, record: any) {
if (expanded && !record.children) {
try {
const res = await asnDetailApi.queryPage({asnId: record.asnId, pageNum: 1, pageSize: 100});
subTableData.value = res.data.list;
} catch (e) {
smartSentry.captureError(e);
}
}
}
//
const totals = computed(() => {
let totalOrderQuantity = 0;
let totalReceivedQuantity = 0;
subTableData.value.forEach(({orderQuantity, receivedQuantity}) => {
totalOrderQuantity += orderQuantity;
totalReceivedQuantity += receivedQuantity;
});
return {totalOrderQuantity, totalReceivedQuantity};
});
// ---------------------------- ---------------------------- // ---------------------------- ----------------------------
const queryFormState = { const queryFormState = {
@ -357,3 +439,4 @@ watch(
onMounted(queryData); onMounted(queryData);
</script> </script>

View File

@ -0,0 +1,251 @@
<!--
* 入库明细
*
* @Author: 1024创新实验室-主任卓大
* @Date: 2022-08-15 20:15:49
* @Wechat: zhuda1024
* @Email: lab1024@163.com
* @Copyright 1024创新实验室 https://1024lab.net Since 2012
-->
<template>
<div>
<div class="header">
<div>
关键字
<a-input style="width: 250px" v-model:value="queryForm.keyword" placeholder="姓名/手机号/登录账号"/>
<a-button class="button-style" type="primary" @click="onSearch"></a-button>
<a-button class="button-style" type="default" @click="resetQuery"></a-button>
</div>
<div class="smart-table-setting-block">
<a-button class="button-style" type="primary" @click="showForm" :disabled="props.asnId==0">
<template #icon>
<PlusOutlined/>
</template>
添加明细
</a-button>
<a-button class="button-style" type="primary" danger
:disabled="props.asnId==0 || selectedRowKeyList.length == 0">
<template #icon>
<DeleteOutlined/>
</template>
批量移除
</a-button>
<TableOperator v-model="columns" :tableId="TABLE_ID_CONST.BUSINESS.RECEIVE.ASN_DETAIL" :refresh="queryData"/>
</div>
</div>
<a-table
:loading="tableLoading"
:dataSource="tableData"
:columns="columns"
:pagination="false"
rowKey="asnDetailId"
:row-selection="{ selectedRowKeys: selectedRowKeyList, onChange: onSelectChange }"
size="small"
bordered
>
<template #bodyCell="{ text, record, index, column }">
<template v-if="column.dataIndex === 'action'">
<div class="smart-table-operate">
<a-button @click="showForm(record)" type="link" v-privilege="'asnDetail:update'">
<template #icon>
<EditOutlined/>
</template>
编辑
</a-button>
<a-button @click="onDelete(record)" danger type="link" v-privilege="'asnDetail:delete'">
<template #icon>
<DeleteOutlined/>
</template>
删除
</a-button>
</div>
</template>
</template>
</a-table>
<div class="smart-query-table-page">
<a-pagination
showSizeChanger
showQuickJumper
show-less-items
:pageSizeOptions="PAGE_SIZE_OPTIONS"
:defaultPageSize="queryForm.pageSize"
v-model:current="queryForm.pageNum"
v-model:pageSize="queryForm.pageSize"
:total="total"
@change="queryData"
@showSizeChange="queryData"
:show-total="(total:number) => `共${total}条`"
/>
</div>
<!--新建/编辑-->
<AsnDetailForm ref="formRef" @reloadList="queryData"/>
</div>
</template>
<script setup lang="ts">
import _ from 'lodash';
import {reactive, ref, watch} from 'vue';
import {PAGE_SIZE, PAGE_SIZE_OPTIONS} from '/@/constants/common-const';
import {smartSentry} from '/@/lib/smart-sentry';
import {TABLE_ID_CONST} from "/@/constants/support/table-id-const";
import TableOperator from "/@/components/support/table-operator/index.vue";
import {asnDetailApi} from "/@/api/business/receive/asnDetail/asn-detail-api";
import AsnDetailForm from "/@/views/business/receive/asnDetail/asn-detail-form.vue";
import {message, Modal} from "ant-design-vue";
import {SmartLoading} from '/@/components/framework/smart-loading';
const props = defineProps({
asnId: {
type: Number,
default: 0,
},
});
const columns = reactive([
{
title: '入库明细id',
dataIndex: 'asnDetailId',
ellipsis: true,
},
{
title: '物料编码',
dataIndex: 'itemCode',
ellipsis: true,
},
{
title: '物料名称',
dataIndex: 'itemName',
ellipsis: true,
},
{
title: '订单数量',
dataIndex: 'orderQuantity',
ellipsis: true,
},
{
title: '收货数量',
dataIndex: 'receivedQuantity',
ellipsis: true,
},
{
title: '操作',
dataIndex: 'action',
width: 140,
},
]);
// --------------------------- ---------------------------
const defaultQueryForm = {
pageNum: 1,
pageSize: PAGE_SIZE,
asnId: undefined,
keyword: undefined,
}
//
const queryForm = reactive({...defaultQueryForm});
// loading
const tableLoading = ref(false);
//
const tableData = ref([]);
//
const total = ref(0);
//
function resetQuery() {
let pageSize = queryForm.pageSize;
Object.assign(queryForm, defaultQueryForm);
queryForm.pageSize = pageSize;
queryData();
}
//
function onSearch() {
queryForm.pageNum = 1;
queryData();
}
//
async function queryData() {
tableLoading.value = true;
try {
queryForm.asnId = props.asnId;
let queryResult = await asnDetailApi.queryPage(queryForm);
tableData.value = queryResult.data.list;
total.value = queryResult.data.total;
} catch (e) {
smartSentry.captureError(e);
} finally {
tableLoading.value = false;
}
}
//
const selectedRowKeyList = ref([]);
function onSelectChange(selectedRowKeys: any) {
selectedRowKeyList.value = selectedRowKeys;
}
///
const formRef = ref();
function showForm(data: object) {
formRef.value.show(data, props.asnId);
}
//
function onDelete(data) {
Modal.confirm({
title: '提示',
content: '确定要删除选吗?',
okText: '删除',
okType: 'danger',
onOk() {
requestDelete(data);
},
cancelText: '取消',
onCancel() {
},
});
}
//
async function requestDelete(data) {
SmartLoading.show();
try {
await asnDetailApi.delete(data.asnDetailId);
message.success('删除成功');
await queryData();
} catch (e) {
smartSentry.captureError(e);
} finally {
SmartLoading.hide();
}
}
watch(
() => props.asnId,
(e) => {
if (e) {
queryData();
}
},
{immediate: true}
);
</script>
<style scoped lang="less">
.header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px
}
.button-style {
margin-left: 10px;
}
</style>

View File

@ -0,0 +1,130 @@
<!--
* 入库明细
*
* @Author: 霍锦
* @Date: 2025-03-26 15:16:28
* @Copyright 友仓
-->
<template>
<a-modal
:title="form.asnDetailId ? '编辑明细' : '添加明细'"
:width="600"
:open="visibleFlag"
@cancel="onClose"
:maskClosable="false"
:destroyOnClose="true"
>
<a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 5 }">
<a-form-item label="物料" name="itemId">
<ItemSelect style="width: 100%" v-model:value="form.itemId" :disabledFlag="true" @change="changeItemSelect"/>
</a-form-item>
<a-form-item label="数量" name="orderQuantity">
<a-input-number style="width: 100%" v-model:value="form.orderQuantity" :min="1" :max="9999"/>
</a-form-item>
</a-form>
<template #footer>
<a-space>
<a-button @click="onClose"></a-button>
<a-button type="primary" @click="onSubmit"></a-button>
</a-space>
</template>
</a-modal>
</template>
<script setup lang="ts">
import {reactive, ref, nextTick} from 'vue';
import _ from 'lodash';
import {message} from 'ant-design-vue';
import {SmartLoading} from '/@/components/framework/smart-loading';
import {asnDetailApi} from '/@/api/business/receive/asnDetail/asn-detail-api';
import {smartSentry} from '/@/lib/smart-sentry';
import ItemSelect from "/@/views/business/base/item/item-select.vue";
// ------------------------ ------------------------
const emits = defineEmits(['reloadList']);
// ------------------------ ------------------------
//
const visibleFlag = ref(false);
function show(rowData: object, asnId: number) {
Object.assign(form, formDefault);
if (rowData && !_.isEmpty(rowData)) {
Object.assign(form, rowData);
}
//id
form.asnId = asnId;
visibleFlag.value = true;
nextTick(() => {
formRef.value.clearValidate();
});
}
function onClose() {
Object.assign(form, formDefault);
visibleFlag.value = false;
}
//
function changeItemSelect(selectValue: any) {
if (selectValue) {
form.itemId = selectValue.itemId;
}
}
// ------------------------ ------------------------
// ref
const formRef = ref();
const formDefault = {
asnDetailId: undefined, //id
asnId: undefined,//id
itemId: undefined, //id
orderQuantity: 1, //
};
let form = reactive({...formDefault});
const rules = {
itemId: [{required: true, message: '物料id 必填'}],
orderQuantity: [{required: true, message: '订单数量 必填'}],
};
//
async function onSubmit() {
try {
await formRef.value.validateFields();
await save();
} catch (err) {
message.error('参数验证错误,请仔细填写表单数据!');
}
}
// API
async function save() {
SmartLoading.show();
try {
if (form.asnDetailId) {
await asnDetailApi.update(form);
} else {
await asnDetailApi.add(form);
}
message.success('操作成功');
emits('reloadList');
onClose();
} catch (err) {
smartSentry.captureError(err);
} finally {
SmartLoading.hide();
}
}
defineExpose({
show,
});
</script>

View File

@ -0,0 +1,282 @@
<!--
* 入库明细
*
* @Author: 霍锦
* @Date: 2025-03-26 15:16:28
* @Copyright 友仓
-->
<template>
<!---------- 查询表单form begin ----------->
<a-form class="smart-query-form">
<a-row class="smart-query-form-row">
<a-form-item label="物料" class="smart-query-form-item">
<a-input style="width: 200px" v-model:value="queryForm.itemId" placeholder="物料" />
</a-form-item>
<a-form-item class="smart-query-form-item">
<a-button type="primary" @click="onSearch">
<template #icon>
<SearchOutlined />
</template>
查询
</a-button>
<a-button @click="resetQuery" class="smart-margin-left10">
<template #icon>
<ReloadOutlined />
</template>
重置
</a-button>
</a-form-item>
</a-row>
</a-form>
<!---------- 查询表单form end ----------->
<a-card size="small" :bordered="false" :hoverable="true">
<!---------- 表格操作行 begin ----------->
<a-row class="smart-table-btn-block">
<div class="smart-table-operate-block">
<a-button @click="showForm" type="primary" size="small">
<template #icon>
<PlusOutlined />
</template>
新建
</a-button>
<a-button @click="confirmBatchDelete" type="primary" danger size="small" :disabled="selectedRowKeyList.length == 0">
<template #icon>
<DeleteOutlined />
</template>
批量删除
</a-button>
</div>
<div class="smart-table-setting-block">
<TableOperator v-model="columns" :tableId="null" :refresh="queryData" />
</div>
</a-row>
<!---------- 表格操作行 end ----------->
<!---------- 表格 begin ----------->
<a-table
size="small"
:dataSource="tableData"
:columns="columns"
rowKey="asnDetailId"
bordered
:loading="tableLoading"
:pagination="false"
:row-selection="{ selectedRowKeys: selectedRowKeyList, onChange: onSelectChange }"
>
<template #bodyCell="{ text, record, column }">
<!-- 有图片预览时 注释解开并把下面的'picture'修改成自己的图片字段名即可 -->
<!-- <template v-if="column.dataIndex === 'picture'">
<FilePreview :fileList="text" type="picture" />
</template> -->
<!-- 使用字典时 注释解开并把下面的'dict'修改成自己的字典字段名即可 有多个字典字段就复制多份同理修改 不然不显示字典 -->
<!-- 方便修改tag的颜色 orange green purple success processing error default warning -->
<!-- <template v-if="column.dataIndex === 'dict'">
<a-tag color="cyan">
{{ text && text.length > 0 ? text.map((e) => e.valueName).join(',') : '暂无' }}
</a-tag>
</template> -->
<template v-if="column.dataIndex === 'action'">
<div class="smart-table-operate">
<a-button @click="showForm(record)" type="link">编辑</a-button>
<a-button @click="onDelete(record)" danger type="link">删除</a-button>
</div>
</template>
</template>
</a-table>
<!---------- 表格 end ----------->
<div class="smart-query-table-page">
<a-pagination
showSizeChanger
showQuickJumper
show-less-items
:pageSizeOptions="PAGE_SIZE_OPTIONS"
:defaultPageSize="queryForm.pageSize"
v-model:current="queryForm.pageNum"
v-model:pageSize="queryForm.pageSize"
:total="total"
@change="queryData"
@showSizeChange="queryData"
:show-total="(total) => `共${total}条`"
/>
</div>
<AsnDetailForm ref="formRef" @reloadList="queryData"/>
</a-card>
</template>
<script setup lang="ts">
import { reactive, ref, onMounted } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { SmartLoading } from '/@/components/framework/smart-loading';
import { asnDetailApi } from '/@/api/business/receive/asnDetail/asn-detail-api';
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
import { smartSentry } from '/@/lib/smart-sentry';
import TableOperator from '/@/components/support/table-operator/index.vue';
import AsnDetailForm from '/@/views/business/receive/asnDetail/asn-detail-form.vue';
// ---------------------------- ----------------------------
const columns = ref([
{
title: '入库明细id',
dataIndex: 'asnDetailId',
ellipsis: true,
},
{
title: '物料id',
dataIndex: 'itemId',
ellipsis: true,
},
{
title: '订单数量',
dataIndex: 'orderQuantity',
ellipsis: true,
},
{
title: '收货数量',
dataIndex: 'receivedQuantity',
ellipsis: true,
},
{
title: '创建时间',
dataIndex: 'createTime',
ellipsis: true,
},
{
title: '操作',
dataIndex: 'action',
fixed: 'right',
width: 90,
},
]);
// ---------------------------- ----------------------------
const queryFormState = {
itemId: undefined, //
pageNum: 1,
pageSize: 10,
};
// form
const queryForm = reactive({ ...queryFormState });
// loading
const tableLoading = ref(false);
//
const tableData = ref([]);
//
const total = ref(0);
//
function resetQuery() {
let pageSize = queryForm.pageSize;
Object.assign(queryForm, queryFormState);
queryForm.pageSize = pageSize;
queryData();
}
//
function onSearch(){
queryForm.pageNum = 1;
queryData();
}
//
async function queryData() {
tableLoading.value = true;
try {
let queryResult = await asnDetailApi.queryPage(queryForm);
tableData.value = queryResult.data.list;
total.value = queryResult.data.total;
} catch (e) {
smartSentry.captureError(e);
} finally {
tableLoading.value = false;
}
}
onMounted(queryData);
// ---------------------------- / ----------------------------
const formRef = ref();
function showForm(data) {
formRef.value.show(data);
}
// ---------------------------- ----------------------------
//
function onDelete(data){
Modal.confirm({
title: '提示',
content: '确定要删除选吗?',
okText: '删除',
okType: 'danger',
onOk() {
requestDelete(data);
},
cancelText: '取消',
onCancel() {},
});
}
//
async function requestDelete(data){
SmartLoading.show();
try {
let deleteForm = {
goodsIdList: selectedRowKeyList.value,
};
await asnDetailApi.delete(data.asnDetailId);
message.success('删除成功');
queryData();
} catch (e) {
smartSentry.captureError(e);
} finally {
SmartLoading.hide();
}
}
// ---------------------------- ----------------------------
//
const selectedRowKeyList = ref([]);
function onSelectChange(selectedRowKeys) {
selectedRowKeyList.value = selectedRowKeys;
}
//
function confirmBatchDelete() {
Modal.confirm({
title: '提示',
content: '确定要批量删除这些数据吗?',
okText: '删除',
okType: 'danger',
onOk() {
requestBatchDelete();
},
cancelText: '取消',
onCancel() {},
});
}
//
async function requestBatchDelete() {
try {
SmartLoading.show();
await asnDetailApi.batchDelete(selectedRowKeyList.value);
message.success('删除成功');
queryData();
} catch (e) {
smartSentry.captureError(e);
} finally {
SmartLoading.hide();
}
}
</script>