列表计量单位显示

 列表计量单位显示

E:\javaDev\tender-project-vben5\apps\web-antd\src\views\tender\material\data.ts

import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';
import { materialUnitList } from '#/api/tender/materialUnit';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'materialCategoryId',
    label: '物料分组id',
  },
  {
    component: 'Input',
    fieldName: 'materialNumber',
    label: '物料名称',
  },
  {
    component: 'Input',
    fieldName: 'materialName',
    label: '物料编码',
  },
  {
    component: 'Input',
    fieldName: 'orderNum',
    label: '显示顺序',
  },
  {
    component: 'Select',
    componentProps: {
      // 可选从DictEnum中获取 DictEnum.BILL_STATUS 便于维护
      options: getDictOptions('bill_status'),
    },
    fieldName: 'status',
    label: '物料状态',
  },
  {
    component: 'Input',
    fieldName: 'materialModel',
    label: '型号',
  },
  {
    component: 'Input',
    fieldName: 'materialUnit',
    label: '计量单位',
  },
];

// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [

// 单位id到名称的映射     计量单位实现
export const materialUnitMap: Record<string | number, string> = {};

// 异步加载单位映射        计量单位实现
export async function loadMaterialUnitMap() {
  const res = await materialUnitList();
  (res.rows || []).forEach((item: any) => {
    materialUnitMap[item.materialUnitId] = item.materialUnitName;
  });
}

export const columns: VxeGridProps['columns'] = [
  {
    title: '物料分组id',
    field: 'materialCategoryId',
    width: 120,
    visible: false,
  },
  {
    title: '物料id',
    field: 'materialId',
    width: 120,
    visible: false,
  },
  {
    title: '物料编码',
    field: 'materialNumber',
    width: 150,
  },
  {
    title: '物料名称',
    field: 'materialName',
    width: 200,
  },
  {
    title: '型号',
    field: 'materialModel',
    width: 150,
  },
  {
    title: '计量单位',
    field: 'materialUnit',
    width: 100,
    slots: {
      default: ({ row }) => {
        // 优先显示 materialUnitName 字段,否则用映射   计量单位实现
        return row.materialUnitName || materialUnitMap[row.materialUnit] || row.materialUnit || '-';
      },
    },
  },
  {
    title: '显示顺序',
    field: 'orderNum',
    width: 100,
  },
  {
    title: '状态',
    field: 'status',
    width: 100,
    slots: {
      default: ({ row }) => {
        return renderDict(row.status, 'bill_status');
      },
    },
  },
  {
    field: 'action',
    fixed: 'right',
    title: '操作',
    width: 180,
    slots: { default: 'action' },
  },
];

E:\javaDev\tender-project-vben5\apps\web-antd\src\views\tender\material\components\MaterialTable.vue

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值