YbFormulaInput 简单运算公式输入
编写加减乘除基本的运算公式,并且运算数值可以用字段占位,再使用 yb-value-formaula 库得到计算结果
# 基本使用
公式JSON:["#预估费用 #","(","totalCost","/","2420","-","1",")","*","profitLossConfigChildren.diseasePrice","# 元#"]
显示结果的文本:
复制
# 公式输入框的特性或者编辑规则:
- [字段名] 用中括号包裹的表示字段引用,例如:[cost] / ( [core] * 1 0 . 9 6 ) ,字段名必须非数字(英文字母等)开头,不能用纯数字:[8437374],中括号内第一个字符不能再是中括号符:[[myanynone]
- #文本# 表示常量文本的引用,例如计算公式与常量文本结合:#费用:# [cost] / ( [core] * 1 0 . 9 6 ) ,显示的结果如同:费用:49000
- 多段计算公式中间用"-"分隔,例如:( [totalCost]/[quotas]-1 )_ [score] _ [diseasePrice] # - # ( [totalCost]/[quotas] ) _ [score] _ [diseasePrice],显示结果如同:5600 - 7800
- 计算运算符:. + - * / ( ) ,小括号必须要闭合;条件运算符:< (小于)> (大于)<= (小于等于)>=(大于等于)!= (不等于);
- 输入框可以任意输入和删除文本,输入的文本无法认定为数字、运算符、常量文本时,都会认定为字段名;
- 当输入框内的文本不是有效的公式时,有一定的提醒;
- 字段名、常量文本、运算符之间的空格或者换行,不会影响公式计算;[字 段名 ]内的空格会认为是字段名的一部分;# 文 本# 内的空格会认为是常量文本的一部分;
# Props
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
value/v-model | 绑定值 | array | -- | -- |
inputType | 输入框类型 | string | 原生 input 的 type 值 | 'textarea' |
rows | textarea 的 rows | number | - | 2 |
disabled | 输入框 的 disabled | boolean | - | - |
clearable | 输入框 的 clearable ,是否可清空 | boolean | - | - |
autosize | textarea 的 autosize ,自适应内容高度 | boolean |object | - | - |
fields | 设置额外字段 | array | -- | [] |
fields[].label | 字段显示中文名称 | string | -- | -- |
fields[].prop | 字段名 | string | -- | -- |
fields[].rowKey | rowKey | string | -- | -- |
fields[].children | 字段子集 | array | -- | -- |
currentFieldsRowKey | 设置当前字段的 rowKey | string | -- | -- |
showConditionKeys | 是否显示条件运算符 | boolean | -- | true |
showOperatorKeys | 是否显示算术运算符 | boolean | -- | true |
width | 软键盘宽度 | string | number | -- | 1200 |
request | 异步加载fields,返回 Promise , 提供搜索框的值 queryWord | function({queryWord}){return Promise.resolve(fields)} | -- | -- |
# Events
参数 | 说明 | 回调参数 |
---|---|---|
change | 值改变时触发 | value,errorMsgs |
# Slots
name | 说明 |
---|---|
buttonAppended | 清空全部按钮后面插入的内容 |
上次更新: 2024/09/25, 19:33:20