# npm 方法库

#### 介绍

pc 移动端通用方法库

#### 安装教程

cnpm install commonts-toolkit --save

#### 使用说明

1.  在 tsconfig.json 中配置 "files": ["node_modules/commonts-toolkit/dist/index.d.ts"]
2.  在 src/global.tsx 中引入 import 'commonts-toolkit';

#### 注意事项

1.  如果是 js 版本使用，会提示找不到 TOOLS，那么我们需要在 .eslintrc.js 的 globals 对象中加入 TOOLS: true 解决
2.  并非所有方法都测试过，如果遇到报错，请及时联系我

#### 更新记录
2.7.0
1.优化里列表转树方法，保持原来的排序
2.org.get.OrgSelectAuto/getOrgSelect 新增maxLevel 组织层级过滤

2.6.5
修复dict.set.setDictList opts无效
2.6.4
修复DateUtil.isTimeBefore/isTimeAfter 缺少return
2.6.3
FunctionUtil.debounceFn解决作用域bug

2.6.2
1.org.del.delOrg 删除匹配异常
2.BaseUtil.isEmpty 完善判空

2.6.1
org.get.OrgSelectAuto 修复onChange报错

2.6.0
一、org
get: 
1.新增方法 OrgSelectAuto

```js
（🌟推荐使用🌟）获取组织树选择
传入传出自动做处理
@example
const App =()=>{
 const [form] = Form.useForm()
 const handleOk = ({oid})=>{
   console.log(oid) // 1
 }
 const {OrgSelectAuto} = TOOLS.org.get
 return (
   <Form form={form} onFinish={handleOk} initialValues={{oid:1}}>
     <Form.Item name="oid">
      <OrgSelectAuto placeholder="JSX使用" />
     </Form.Item>
     <Form.Item name="niubi">
      {((Item) => <Item placeholder='函数使用' />)(TOOLS.org.get.OrgSelectAuto)}
     </Form.Item>
   </Form>
 )
}
```

2.getDownOrgList 新增参数 level

```js
/**
 * 获取oid为1的部门下两级（包含本级）的树列表
 */
getDownOrgList({ type: 2, oid: 1, level: 2, isTree: true });
```

2.5.0

一、ArrayUtil
updates:
1.arrayWeightRemoval 添加泛型 ; 添加参数 isSaveLast 默认 true ，true 返回重复最后一个对象，false 返回重复第一个对象
2.sum 解决精度问题 0.1+1.1 ===1.2000000000000002

二、BaseUtil
updates: 1.修改所有校验方法校验，例子如下：
const data: {a:1}|[{a:1}]| undefined
if(BaseUtil.isArray(data)){
data[0] //[{ a: 1; }]
}
data[0] // {a:1}|[{a:1}]| undefined 对象可能为“未定义”

三、DateUtil
updates: 1.函数名规范 getAllDateList-> getSectionDateList
add：
1.getSectionMonthList 补全月份区间数组
2.getSectionYearList 补全年份区间数组

四、FunctionUtil
updates：
1.debounceFn、throttleFn、once 添加泛型

五、NumberUtil
add：
1.correctNumberInput 保留 n 位小数
2.floatAdd 解决两个数相加精度丢失问题
3.floatSub 解决两个数相减精度丢失问题
4.floatMul 解决两个数相乘精度丢失问题
5.floatDiv 解决两个数相除精度丢失问题

六、ObjectUtil
updates：
1.deepClone 添加泛型

