tuqin
4 天以前 5cd5a5baa076377f3136338db7a9336d0d570d33
src/views/hrm/salary/social-security-scheme/data.ts
@@ -5,10 +5,23 @@
/** 表单类型 */
export type FormType = 'create' | 'update';
/** 格式化比例输入 */
/** 格式化比例输入(统一显示两位小数百分比,如 8.25%) */
function createRatioFormatter(step: number = 0.01) {
  return {
    formatter: (value: number) => value !== undefined && value !== null ? `${(value * 100).toFixed(step === 0.001 ? 1 : 0)}%` : '',
    formatter: (value: number) =>
      value !== undefined && value !== null ? `${(value * 100).toFixed(2)}%` : '',
    parser: (value: string) => {
      const num = parseFloat(String(value).replace('%', ''));
      return isNaN(num) ? 0 : num / 100;
    },
  };
}
/** 格式化比例输入(显示两位小数,如 0.50%) */
function createRatioFormatter2() {
  return {
    formatter: (value: number) =>
      value !== undefined && value !== null ? `${(value * 100).toFixed(2)}%` : '',
    parser: (value: string) => {
      const num = parseFloat(value.replace('%', ''));
      return isNaN(num) ? 0 : num / 100;
@@ -200,6 +213,76 @@
        ...createRatioFormatter(0.001),
      },
    },
    // 大病医疗
    {
      fieldName: 'divider_serious_illness',
      label: '大病医疗',
      component: 'Divider',
      formItemClass: 'col-span-2',
    },
    {
      fieldName: 'seriousIllnessCompanyRatio',
      label: '企业比例',
      component: 'InputNumber',
      componentProps: {
        placeholder: '企业缴纳比例',
        min: 0,
        max: 1,
        step: 0.0001,
        precision: 4,
        style: { width: '100%' },
        ...createRatioFormatter2(),
      },
    },
    {
      fieldName: 'seriousIllnessPersonalRatio',
      label: '个人比例',
      component: 'InputNumber',
      componentProps: {
        placeholder: '个人缴纳比例',
        min: 0,
        max: 1,
        step: 0.0001,
        precision: 4,
        style: { width: '100%' },
        ...createRatioFormatter2(),
      },
    },
    // 长期护理
    {
      fieldName: 'divider_long_term_care',
      label: '长期护理',
      component: 'Divider',
      formItemClass: 'col-span-2',
    },
    {
      fieldName: 'longTermCareCompanyRatio',
      label: '企业比例',
      component: 'InputNumber',
      componentProps: {
        placeholder: '企业缴纳比例',
        min: 0,
        max: 1,
        step: 0.0001,
        precision: 4,
        style: { width: '100%' },
        ...createRatioFormatter2(),
      },
    },
    {
      fieldName: 'longTermCarePersonalRatio',
      label: '个人比例',
      component: 'InputNumber',
      componentProps: {
        placeholder: '个人缴纳比例',
        min: 0,
        max: 1,
        step: 0.0001,
        precision: 4,
        style: { width: '100%' },
        ...createRatioFormatter2(),
      },
    },
    // 公积金
    {
      fieldName: 'divider_housing',
@@ -307,6 +390,18 @@
      slots: { default: 'housingFundPersonalRatio' },
    },
    {
      field: 'seriousIllnessPersonalRatio',
      title: '大病医疗(个人)',
      width: 120,
      slots: { default: 'seriousIllnessPersonalRatio' },
    },
    {
      field: 'longTermCarePersonalRatio',
      title: '长期护理(个人)',
      width: 120,
      slots: { default: 'longTermCarePersonalRatio' },
    },
    {
      field: 'status',
      title: '状态',
      width: 80,
@@ -316,7 +411,7 @@
      field: 'createTime',
      title: '创建时间',
      width: 180,
      formatter: 'formatDate',
      formatter: 'formatDateTime',
    },
    {
      title: '操作',