feat:【antd】【erp 系统】sale 重构代码风格(增加已出库等动态列)
This commit is contained in:
@@ -214,7 +214,9 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 表单的明细表格列 */
|
/** 表单的明细表格列 */
|
||||||
export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
export function useFormItemColumns(
|
||||||
|
formData?: any[],
|
||||||
|
): VxeTableGridOptions['columns'] {
|
||||||
return [
|
return [
|
||||||
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||||
{
|
{
|
||||||
@@ -250,6 +252,22 @@ export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
|||||||
minWidth: 150,
|
minWidth: 150,
|
||||||
slots: { default: 'remark' },
|
slots: { default: 'remark' },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
field: 'totalCount',
|
||||||
|
title: '原数量',
|
||||||
|
formatter: 'formatAmount3',
|
||||||
|
minWidth: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
visible: formData && formData[0]?.outCount !== undefined,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'outCount',
|
||||||
|
title: '已出库',
|
||||||
|
formatter: 'formatAmount3',
|
||||||
|
minWidth: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
visible: formData && formData[0]?.returnCount !== undefined,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
field: 'count',
|
field: 'count',
|
||||||
title: '数量',
|
title: '数量',
|
||||||
|
|||||||
@@ -94,6 +94,9 @@ watch(
|
|||||||
tableData.value = [...items];
|
tableData.value = [...items];
|
||||||
await nextTick(); // 特殊:保证 gridApi 已经初始化
|
await nextTick(); // 特殊:保证 gridApi 已经初始化
|
||||||
await gridApi.grid.reloadData(tableData.value);
|
await gridApi.grid.reloadData(tableData.value);
|
||||||
|
// 更新表格列配置(目的:原数量、已出库动态列)
|
||||||
|
const columns = useFormItemColumns(tableData.value);
|
||||||
|
await gridApi.grid.reloadColumn(columns);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
|
|||||||
@@ -213,7 +213,9 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 表单的明细表格列 */
|
/** 表单的明细表格列 */
|
||||||
export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
export function useFormItemColumns(
|
||||||
|
formData?: any[],
|
||||||
|
): VxeTableGridOptions['columns'] {
|
||||||
return [
|
return [
|
||||||
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||||
{
|
{
|
||||||
@@ -249,21 +251,21 @@ export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
|||||||
minWidth: 150,
|
minWidth: 150,
|
||||||
slots: { default: 'remark' },
|
slots: { default: 'remark' },
|
||||||
},
|
},
|
||||||
// TODO @AI:formData[0]?.outCount != null
|
|
||||||
{
|
{
|
||||||
field: 'totalCount',
|
field: 'totalCount',
|
||||||
title: '已出库',
|
title: '已出库',
|
||||||
formatter: 'formatAmount3',
|
formatter: 'formatAmount3',
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
|
visible: formData && formData[0]?.outCount !== undefined,
|
||||||
},
|
},
|
||||||
// TODO @AI:formData[0]?.returnCount != null
|
|
||||||
{
|
{
|
||||||
field: 'returnCount',
|
field: 'returnCount',
|
||||||
title: '已退货',
|
title: '已退货',
|
||||||
formatter: 'formatAmount3',
|
formatter: 'formatAmount3',
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
|
visible: formData && formData[0]?.returnCount !== undefined,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'count',
|
field: 'count',
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ const summaries = computed(() => {
|
|||||||
/** 表格配置 */
|
/** 表格配置 */
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
columns: useFormItemColumns(),
|
columns: useFormItemColumns(tableData.value),
|
||||||
data: tableData.value,
|
data: tableData.value,
|
||||||
minHeight: 250,
|
minHeight: 250,
|
||||||
autoResize: true,
|
autoResize: true,
|
||||||
@@ -94,6 +94,9 @@ watch(
|
|||||||
tableData.value = [...items];
|
tableData.value = [...items];
|
||||||
await nextTick(); // 特殊:保证 gridApi 已经初始化
|
await nextTick(); // 特殊:保证 gridApi 已经初始化
|
||||||
await gridApi.grid.reloadData(tableData.value);
|
await gridApi.grid.reloadData(tableData.value);
|
||||||
|
// 更新表格列配置(目的:已出库、已出库动态列)
|
||||||
|
const columns = useFormItemColumns(tableData.value);
|
||||||
|
await gridApi.grid.reloadColumn(columns);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user