quest.data.tsx 4.05 KB
import { BasicColumn, FormSchema } from '/@/components/Table';

import { useUserStoreWithOut } from '/@/store/modules/user';
import { ROLE } from '../order/type.d';
import { computed } from 'vue';
const userStore = useUserStoreWithOut();
const user=userStore.getUserInfo;

// 基础列定义(包含所有可能的列)
const baseColumns: BasicColumn[] = [
  {
    title: '标题',
    dataIndex: 'title',
    key: 'title',
    width: 350, // 减小宽度
    customHeaderCell: () => ({ style: { color: 'red' ,fontSize:'16px'} }), // 让表头变红
  },
  {
    title: '问题类型',
    dataIndex: 'questType',
    key: 'questType',
    width: 150, // 设置适当宽度
    customHeaderCell: () => ({ style: { color: 'red', fontSize:'16px' } }), // 让表头变红
    customRender: ({ text, record }) => {
      // 正常显示财务专用信息
      if (record.deductAmount > 0 && record.deductAmount !== undefined) {
        // 根据isRmb字段决定显示$还是¥
        const currencySymbol = record.isRmb === '1' ? '¥' : '$';
        
        // 格式化金额为$xxx.xx或¥xxx.xx格式
        const formattedAmount = typeof record.deductAmount === 'number' 
          ? `${currencySymbol}${record.deductAmount.toFixed(2)}`
          : `${currencySymbol}${Number(record.deductAmount).toFixed(2)}`;
        
        return `${text}(${formattedAmount})`;
      }
      return text;
    },
  },
  {
    title: '内容',
    dataIndex: 'contentText',
    key: 'contentText',
    width: 350, // 减小宽度
    format: (text) => {
      if (!text) return '';
      const div = document.createElement('div');
      div.innerHTML = text;
      const plainText = div.textContent || div.innerText || '';
      return plainText.length > 30 ? plainText.substring(0, 30) + '...' : plainText;
    },
    customHeaderCell: () => ({ style: { color: 'red',fontSize:'16px' } }), // 让表头变红
  },
  {
    title: '状态',
    dataIndex: 'status',
    key: 'status',
    width: 100,
    customRender: ({ text }) => {
      if (text === 10) return '已解决';
      if (text === 20) return '已驳回';
      return '待审核';
    },
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: 160,
    key: 'action',
    fixed: 'right', // 固定在右侧
  },
];
const role=computed(() =>{
  return user?.roleSmallVO?.code;
});

// 问题列表表格列定义(不包含状态列)
export const columns: BasicColumn[] = [
  baseColumns[0], // 标题
  baseColumns[1], // 问题类型
  baseColumns[2], // 内容
  baseColumns[4], // 操作
];

// 审核列表表格列定义(包含状态列)
export const reviewColumns: BasicColumn[] = [
  baseColumns[0], // 标题
  baseColumns[1], // 问题类型
  baseColumns[2], // 内容
  baseColumns[3], // 状态
  {
    title: '操作',
    dataIndex: 'action',
    width: 320, // 增加宽度以容纳更多按钮
    key: 'action',
    fixed: 'right', // 固定在右侧
  },
];

// 表单配置
export const searchFormSchema: FormSchema[] = [
  {
    field: 'title',
    label: '标题',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'contentText',
    label: '内容关键字',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'questType',
    label: '问题类型',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: `createStartTime`,
    label: `生成开始时间`,
    component: 'DatePicker',
    colProps: {
      span: 6,
    },
    labelWidth: 150,
  },
  {
    field: `createEndTime`,
    label: `生成结束时间`,
    component: 'DatePicker',
    colProps: {
      span: 6,
    },
    labelWidth: 150,
  },
];

// 导出返回所有数据的方法
export const filterFinancialData = (dataList: any[]) => {
  // const currentRole = user?.roleSmallVO?.code;
  // console.log('角色'+currentRole);
  // // 如果用户是管理员或财务,返回所有数据
  // if (currentRole === ROLE.ADMIN || currentRole === ROLE.FINANCE) {
  //   return dataList;
  // }
  // 否则过滤掉财务专用的数据
  // return dataList.filter(item => item.questType !== '财务专用');
  return dataList
};