ledger.data.ts 3.97 KB
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Tooltip } from 'ant-design-vue';
import { handeleCopy } from '../../../device/profiles/step/topic';
import { useI18n } from '/@/hooks/web/useI18n';
import { SbStatusEnum } from '/@/enums/deviceEnum';

const { t } = useI18n();
import edgefornt from '/@/assets/icons/edgefornt.svg';

export enum DeviceListAuthEnum {
  /**
   * @description 新增
   */
  CREATE = 'api:yt:device:post',

  /**
   * @description 删除
   */
  DELETE = 'api:yt:device:delete',

  /**
   * @description 编辑
   */
  UPDATE = 'api:yt:device:update',

  /**
   * @description 详情
   */
  DETAIL = 'api:yt:device:get',

  /**
   * @description 导入
   */
  IMPORT = 'api:yt:device:import',

  /**
   * @description 公开
   */
  PUBLIC = 'api:yt:device:public',

  /**
   * @description 上下线
   */
  ONLINE = 'api:yt:device:online:record',

  /**
   * @description 管理设备凭证
   */
  EQUIPMENT = 'api:yt:device:equipment',

  /**
   * @description 分配客户
   */
  ASSIGN = 'api:yt:device:assign',

  /**
   * @description 命令下发
   */
  RPC = 'api:yt:device:rpc',

  /**
   * @description 更新产品
   */
  UPDATE_PRODUCT = 'api:yt:device:update:product',
}

// 表格列数据
export const columns: BasicColumn[] = [
  {
    title: t('repair.order.situationImg'),
    dataIndex: 'deviceImg',
    slots: { customRender: 'deviceImg' },
    width: 100,
  },
  {
    title: t('business.deviceStatusText'),
    dataIndex: 'status',
    width: 110,
    className: 'device-status',
    slots: { customRender: 'status' },
  },
  {
    title: t('business.codeText'),
    dataIndex: 'code',
    width: 100,
  },
  {
    dataIndex: 'name',
    title: t('deviceManagement.device.aliasNameText'),
    width: 210,
    slots: { customRender: 'name', title: 'deviceTitle' },
    className: 'device-name-edge',
    customRender: ({ record }) => {
      return h('div', { class: 'py-3 px-3.5' }, [
        record.alias &&
          h(
            'div',
            {
              class: 'cursor-pointer truncate',
            },
            h(
              Tooltip,
              {
                placement: 'topLeft',
                title: `${record.alias}`,
              },
              () => `${record.alias}`
            )
          ),
        h(
          'div',
          {
            class: 'cursor-pointer text-blue-500 truncate',
            onClick: () => {
              handeleCopy(`${record.name}`);
            },
          },
          h(
            Tooltip,
            {
              placement: 'topLeft',
              title: `${record.name}`,
            },
            () => `${record.name}`
          )
        ),
        record.isEdge
          ? h('div', { class: 'absolute top-0 left-0', fill: '#1890ff' }, [
              h('img', { src: edgefornt, class: 'w-12.5 h-12.5' }),
              h(
                'span',
                {
                  class:
                    'absolute top-0.5 left-0.5 text-light-50 transform -rotate-45 translate-y-0 !text-10px',
                },
                t('common.edgeFlag')
              ),
            ])
          : '',
      ]);
    },
  },
  {
    title: t('business.deviceTypeText'),
    dataIndex: 'categoryName',
    width: 120,
  },
  {
    title: t('business.directorName'),
    dataIndex: 'directorName',
    width: 120,
  },
  {
    title: t('business.brandText'),
    dataIndex: 'brand',
    width: 120,
  },
];

// 查询字段
export const searchFormSchema: FormSchema[] = [
  {
    field: 'code',
    label: t('equipment.ledger.deviceCode'),
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      maxLength: 255,
    },
  },
  {
    field: 'status',
    label: t('business.deviceStatusText'),
    component: 'Select',
    componentProps: {
      options: Object.values(SbStatusEnum).map((value) => ({
        label: t(`enum.sbStatus.${value}`),
        value,
      })),
    },
    colProps: { span: 6 },
  }
];