pps-formula-edit

0.9.57 • Public • Published

平台公式编辑器

组件介绍:公式编辑器为假勤,薪酬,继任,平台等业务线统一规范,进行业务公式编写的前端组件。

API

属性 说明 类型 默认值
configKey 编辑器内小键盘数据 Array 内置于编辑器内部
editComputingFormula 编辑器内默认回填数据 Object {Text(必填)}

编辑器方法

名称 描述
checkOutFun() 编辑器公式检查函数
emptyContent() 编辑器内容清空
saveAllData() 公式内容提交
// configKey格式 因业务需要,暂封装于组件内部,也可外部传入
// key 表示键盘显示内容  special 表示是否两侧有空格  equal 是否为比较操作  numberSign 是否为数字
const configObject ={};
// 左半按钮区
configObject.defaultSignKeys= [
    {key:'if',special:true},
    {key:'then',special:true},
    {key:'else',special:true},
    {key:'and',special:true},
    {key:'or',special:true},
    {key:'\"'},
    {key:'('},
    {key:')'},
    {key:'=',equal:true},
    {key:'<>',equal:true},
    {key:'>',equal:true},
    {key:'<',equal:true},
    {key:'<=',equal:true},
    {key:'>=',equal:true},
    {key:','}
]
// 右半按钮区
configObject.defaultNumberKeys= [
    {key:'1',numberSign:true},
    {key:'2',numberSign:true},
    {key:'3',numberSign:true},
    {key:'+'},
    {key:'-'},
    {key:'4',numberSign:true},
    {key:'5',numberSign:true},
    {key:'6',numberSign:true},
    {key:'*'},
    {key:'/'},
    {key:'7',numberSign:true},
    {key:'8',numberSign:true},
    {key:'9',numberSign:true},
    {key:'0',numberSign:true},
    {key:'.',numberSign:true}
]
代码演示
import React, {Component} from 'react';
import ComputationTable from 'pps-formula-edit';

export default class Index extends Component {
    //检查公式
    checkOutFun() {
        const { getCheckOut } = this.refs;
        getCheckOut.checkOutFun();
    }

   //置空
    emptyFun() {
        this.refs.getCheckOut.emptyContent()
    }

    //提交
    async submit(e) {
        let saveData = await this.refs.getCheckOut.saveAllData();
        if (saveData) {
            let saveParame = saveData.allParams;
            // 公式保存操作,调用平台SDK
            window.iTalentSDK.sendMessage({
                  publishEvent:this.props.cmp_data.field_name,
                  data:{
                      text:saveParame ? saveData.Text2 : '',
                      value:saveParame
                  }
            });
        }
    }

    

    render() {
        return (
            <ComputationTable ref='getCheckOut' editComputingFormula={EditComputingFormula} />
        )
    }
}

Readme

Keywords

none

Package Sidebar

Install

npm i pps-formula-edit

Weekly Downloads

2

Version

0.9.57

License

ISC

Unpacked Size

983 kB

Total Files

102

Last publish

Collaborators

  • beisencorp