Files
iot-device-management-frontend/apps/web-antd/src/views/erp/purchase/order/data.ts

415 lines
9.5 KiB
TypeScript
Raw Normal View History

import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { erpCountInputFormatter, erpPriceInputFormatter } from '@vben/utils';
import { getAccountSimpleList } from '#/api/erp/finance/account';
import { getProductSimpleList } from '#/api/erp/product/product';
import { getSupplierSimpleList } from '#/api/erp/purchase/supplier';
import { getSimpleUserList } from '#/api/system/user';
import { DICT_TYPE, getDictOptions } from '#/utils';
/** 表单的配置项 */
export function useFormSchema(): VbenFormSchema[] {
return [
{
component: 'ApiSelect',
componentProps: {
placeholder: '请选择供应商',
allowClear: true,
showSearch: true,
api: getSupplierSimpleList,
fieldNames: {
label: 'name',
value: 'id',
},
},
fieldName: 'supplierId',
label: '供应商',
rules: 'required',
},
{
component: 'DatePicker',
componentProps: {
placeholder: '选择订单时间',
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
style: { width: '100%' },
},
fieldName: 'orderTime',
label: '订单时间',
rules: 'required',
},
{
component: 'Textarea',
componentProps: {
placeholder: '请输入备注',
autoSize: { minRows: 2, maxRows: 4 },
class: 'w-full',
},
fieldName: 'remark',
label: '备注',
formItemClass: 'col-span-2',
},
{
component: 'Input',
componentProps: {
placeholder: '请输入附件地址',
class: 'w-full',
},
fieldName: 'fileUrl',
label: '附件',
formItemClass: 'col-span-2',
},
{
component: 'InputNumber',
componentProps: {
placeholder: '请输入优惠率',
min: 0,
max: 100,
precision: 2,
formatter: erpPriceInputFormatter,
style: { width: '100%' },
},
fieldName: 'discountPercent',
label: '优惠率(%)',
},
{
component: 'InputNumber',
componentProps: {
placeholder: '付款优惠',
precision: 2,
formatter: erpPriceInputFormatter,
disabled: true,
style: { width: '100%' },
},
fieldName: 'discountPrice',
label: '付款优惠',
},
{
component: 'InputNumber',
componentProps: {
placeholder: '优惠后金额',
precision: 2,
formatter: erpPriceInputFormatter,
disabled: true,
style: { width: '100%' },
},
fieldName: 'totalPrice',
label: '优惠后金额',
},
{
component: 'ApiSelect',
componentProps: {
placeholder: '请选择结算账户',
allowClear: true,
showSearch: true,
api: getAccountSimpleList,
fieldNames: {
label: 'name',
value: 'id',
},
},
fieldName: 'accountId',
label: '结算账户',
},
{
component: 'InputNumber',
componentProps: {
placeholder: '请输入支付订金',
precision: 2,
formatter: erpPriceInputFormatter,
style: { width: '100%' },
},
fieldName: 'depositPrice',
label: '支付订金',
},
];
}
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'no',
label: '订单单号',
component: 'Input',
componentProps: {
placeholder: '请输入订单单号',
allowClear: true,
},
},
{
fieldName: 'productId',
label: '产品',
component: 'ApiSelect',
componentProps: {
placeholder: '请选择产品',
allowClear: true,
showSearch: true,
api: getProductSimpleList,
fieldNames: {
label: 'name',
value: 'id',
},
},
},
{
fieldName: 'orderTime',
label: '订单时间',
component: 'RangePicker',
componentProps: {
placeholder: ['开始时间', '结束时间'],
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
},
{
fieldName: 'supplierId',
label: '供应商',
component: 'ApiSelect',
componentProps: {
placeholder: '请选择供应商',
allowClear: true,
showSearch: true,
api: getSupplierSimpleList,
fieldNames: {
label: 'name',
value: 'id',
},
},
},
{
fieldName: 'creator',
label: '创建人',
component: 'ApiSelect',
componentProps: {
placeholder: '请选择创建人',
allowClear: true,
showSearch: true,
api: getSimpleUserList,
fieldNames: {
label: 'nickname',
value: 'id',
},
},
},
{
fieldName: 'status',
label: '状态',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.ERP_AUDIT_STATUS, 'number'),
placeholder: '请选择状态',
allowClear: true,
},
},
{
fieldName: 'returnStatus',
label: '退货状态',
component: 'Select',
componentProps: {
options: [
{ label: '未退货', value: 0 },
{ label: '部分退货', value: 1 },
{ label: '全部退货', value: 2 },
],
placeholder: '请选择退货状态',
allowClear: true,
},
},
];
}
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions['columns'] {
return [
{
type: 'checkbox',
width: 50,
fixed: 'left',
},
{
field: 'no',
title: '订单单号',
width: 260,
fixed: 'left',
},
{
field: 'productNames',
title: '产品信息',
showOverflow: 'tooltip',
},
{
field: 'supplierName',
title: '供应商',
},
{
field: 'orderTime',
title: '订单时间',
width: 160,
formatter: 'formatDateTime',
},
{
field: 'creatorName',
title: '创建人',
},
{
field: 'totalCount',
title: '总数量',
formatter: 'formatNumber',
},
{
field: 'inCount',
title: '入库数量',
formatter: 'formatNumber',
},
{
field: 'returnCount',
title: '退货数量',
formatter: 'formatNumber',
},
{
field: 'totalProductPrice',
title: '金额合计',
formatter: 'formatNumber',
},
{
field: 'totalPrice',
title: '含税金额',
formatter: 'formatNumber',
},
{
field: 'depositPrice',
title: '支付订金',
formatter: 'formatNumber',
},
{
field: 'status',
title: '状态',
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.ERP_AUDIT_STATUS },
},
},
{
title: '操作',
width: 220,
fixed: 'right',
slots: { default: 'actions' },
},
];
}
/** 采购订单明细项表单配置 */
export function useItemFormSchema(
onProductChange?: (productId: number) => void,
): VbenFormSchema[] {
return [
{
component: 'ApiSelect',
componentProps: {
placeholder: '请选择产品',
allowClear: true,
showSearch: true,
api: getProductSimpleList,
fieldNames: {
label: 'name',
value: 'id',
},
onChange: onProductChange,
},
fieldName: 'productId',
label: '产品名称',
rules: 'required',
},
{
component: 'InputNumber',
componentProps: {
placeholder: '请输入数量',
min: 1,
precision: 2,
formatter: erpCountInputFormatter,
style: { width: '100%' },
},
fieldName: 'count',
label: '数量',
rules: 'required',
},
{
component: 'InputNumber',
componentProps: {
placeholder: '请输入单价',
min: 0,
precision: 2,
formatter: erpPriceInputFormatter,
style: { width: '100%' },
},
fieldName: 'productPrice',
label: '产品单价',
rules: 'required',
},
{
component: 'InputNumber',
componentProps: {
placeholder: '金额',
precision: 2,
formatter: erpPriceInputFormatter,
disabled: true,
style: { width: '100%' },
},
fieldName: 'totalPrice',
label: '金额',
},
{
component: 'InputNumber',
componentProps: {
placeholder: '请输入税率',
min: 0,
max: 100,
precision: 2,
style: { width: '100%' },
},
fieldName: 'taxPercent',
label: '税率(%)',
},
{
component: 'InputNumber',
componentProps: {
placeholder: '税额',
precision: 2,
formatter: erpPriceInputFormatter,
disabled: true,
style: { width: '100%' },
},
fieldName: 'taxPrice',
label: '税额',
},
{
component: 'InputNumber',
componentProps: {
placeholder: '税额合计',
precision: 2,
formatter: erpPriceInputFormatter,
disabled: true,
style: { width: '100%' },
},
fieldName: 'totalTaxPrice',
label: '税额合计',
},
{
component: 'Textarea',
componentProps: {
placeholder: '请输入备注',
autoSize: { minRows: 2, maxRows: 4 },
class: 'w-full',
},
fieldName: 'remark',
label: '备注',
formItemClass: 'col-span-2',
},
];
}