0.0.4 • Published 9 months ago

cj-formula-react v0.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

cj-formula-react

安装依赖

npm install cj-formula-react

使用

import { FormulaEditor } from "cj-formula-react";
import React, { useState } from "react";

const varList = [
   {
        code: 'MAIN_BUSINESS_INCOME',
        name: '主营业务收入',
    },
    {
        code: 'MATERIAL_SALES_INCOME',
        name: '材料销售收入',
    },
    {
        code: 'OTHER_BUSINESS_INCOME',
        name: '其他业务收入',
    },
    {
        code: 'MAIN_BUSINESS_COST',
        name: '主营业务成本',
    },
    {
        code: 'BUSINESS_TAX_SURCHARGE',
        name: '营业税金及附加',
    },
    {
        code: 'OPERATING_EXPENSES',
        name: '营业费用',
    },
    {
        code: 'PERFORMANCE_COEFFICIENT',
        name: '绩效系数',
      },
      {
        code: 'ANNUAL',
        name: '年度',
      },
      {
        code: 'QUARTERLY',
        name: '季度',
      },
      {
        code: 'MONTHLY',
        name: '月度',
      },
]

const App = () => {
  const [editorValue, setEditorValue] = useState("#主营业务收入#+#材料销售收入#");
  const [editorValueExp, setEditorValueExp] = useState("MAIN_BUSINESS_INCOME+MATERIAL_SALES_INCOME");
  const [editorValue1, setEditorValue1] = useState("#主营业务收入#");

  const handleChange = (val, valProps) =>{
    setEditorValue(val)
    setEditorValueExp(valProps.calcExpression)
  }

  return <div>
    <Editor key="1" initialValue="2323" value={editorValue} onChangeValue={(val, valProps) => handleChange(val, valProps)} variableList={varList as any}/>
    <Editor key="2" initialValue="2323" value={editorValue1} onChangeValue={setEditorValue1} variableList={varList as any}/>
    <div>{editorValue}  {editorValueExp}</div>
    <div>{editorValue1}</div>
  </div>
}

export default App;
0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago