diff --git a/CHANGELOG.md b/CHANGELOG.md index e0ab30755..e71106fd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,31 @@ # 更新日志 +## 3.3.0 +- 新增 `Card` 模式模式下 loading 加载中状态 [#1454](https://github.com/XiaoMi/hiui/issues/1454) +- 新增 `Table` loading 加载中状态 [#1466](https://github.com/XiaoMi/hiui/issues/1466) +- 新增 `Table` 列冻结结合树形使用 [#1424](https://github.com/XiaoMi/hiui/issues/1424) +- 新增 `Table` rowSelection getCheckboxConfig 方法配置行选择 [#1444](https://github.com/XiaoMi/hiui/issues/1444) +- 新增 `SelectTree` valueRender 自定义渲染 Input 中展示内容 [#1407](https://github.com/XiaoMi/hiui/issues/1407) +- 新增 `SelectTree` 通过关键字异步搜索功能 [#1479](https://github.com/XiaoMi/hiui/issues/1479) +- 修复 `Input` type = textarea 的时候,className 设置无效 [#1458](https://github.com/XiaoMi/hiui/issues/1458) +- 修复 `Form` 在页面渲染完成后 调用中 setFieldsValue 无效问题 [#1408](https://github.com/XiaoMi/hiui/issues/1408) +- 修复 `Form` 在 Form.Item 中调用 setFieldsValue 数据获取错误 [#1456](https://github.com/XiaoMi/hiui/issues/1456) +- 修复 `Rate` 组件在快速移动显示异常问题 [#1410](https://github.com/XiaoMi/hiui/issues/1410) +- 修复 `DatePicker` type 不受控问题 [#1401](https://github.com/XiaoMi/hiui/issues/1401) +- 修复 `DatePicker` 点击空白区域触发 onChange 问题 [#1477](https://github.com/XiaoMi/hiui/issues/1477) +- 修复 `DatePicker` 跨年或跨月选择周,数据显示错误 [#1476](https://github.com/XiaoMi/hiui/issues/1476) +- 修复 `Select` 下拉框默认选中行显示错误 [#1405](https://github.com/XiaoMi/hiui/issues/1405) +- 修复 `DatePicker` 在 type 为 daterange 时候,传入不合法日期,面板显示异常 [#1418](https://github.com/XiaoMi/hiui/issues/1418) +- 修复 `Table` 对其他组件造成的样式污染问题 [#1428](https://github.com/XiaoMi/hiui/issues/1428) +- 修复 `Table` 数据为空时右侧冻结展示不正确的问题 [#1473](https://github.com/XiaoMi/hiui/issues/1473) +- 修复 `Tree` onDrop 回调函数参数不正确的问题 [#1425](https://github.com/XiaoMi/hiui/issues/1425) +- 修复 `Select` 异步多选值返显问题 [#1425](https://github.com/XiaoMi/hiui/issues/1425) +- 修复 `Modal` confirm 方法为适配主题色的问题 [#1446](https://github.com/XiaoMi/hiui/issues/1446) +- 修复 `Loading` children 不存在时,设置 visible 为 false 无效的问题 [#1461](https://github.com/XiaoMi/hiui/issues/1461) +- 优化 `Tabs` 组件弹出层样式[#1437](https://github.com/XiaoMi/hiui/issues/1437) +- 优化 `DatePicker` 类型为 week 时输入框显示内容以及周起始方式 [#1475](https://github.com/XiaoMi/hiui/issues/1475) +- 优化 `Progress` width、height 属性支持传入String类型 [#1480](https://github.com/XiaoMi/hiui/issues/1480) + ## 3.2.0 - 新增 HiUI 基础样式 css 文件 [#1338](https://github.com/XiaoMi/hiui/issues/1338) diff --git a/components/_util/EventEmitter.js b/components/_util/EventEmitter.js new file mode 100644 index 000000000..a271531ea --- /dev/null +++ b/components/_util/EventEmitter.js @@ -0,0 +1,27 @@ +class EventEmitter { + constructor() { + this.event = {} + } + + // 监听 + on(type, listener) { + this.event[type] = listener + } + + // 触发事件 + emit(type, ...arg) { + console.log(this.event) + this.event[type] && this.event[type](...arg) + } + + removeListener(type) { + if (this.event[type]) { + delete this.event[type] + } + } + + removeAll(type) { + this.event = {} + } +} +export default new EventEmitter() diff --git a/components/_util/hi-request/axios.js b/components/_util/hi-request/axios.js index fef34fe31..4d6e0c875 100644 --- a/components/_util/hi-request/axios.js +++ b/components/_util/hi-request/axios.js @@ -4,8 +4,7 @@ const callBackInter = new Map() const axiosInstance = axios.create({ type: 'basics', - url: '', - responseType: 'json' + url: '' }) axiosInstance.interceptors.request.use( diff --git a/components/_util/hi-request/download.js b/components/_util/hi-request/download.js index e99c479fb..e7a472bdd 100644 --- a/components/_util/hi-request/download.js +++ b/components/_util/hi-request/download.js @@ -1,24 +1,33 @@ import axiosIns from './axios' const download = (options, host) => { - const { filename = '未命名' } = options + const { filename } = options const url = host ? host + options.url : options.url // 设置类型,防止出现乱码 Object.assign(options, { responseType: 'blob' }) - axiosIns({ ...options, url }).then( + return axiosIns({ ...options, url }).then( (res) => { - const { downloadSuccess } = options + const { downloadSuccess, fileType } = options const blob = new window.Blob([res.data]) const downloadElement = document.createElement('a') - const href = window.URL.createObjectURL(blob) // 创建下载的链接 + let serverFilename = filename + if (!filename) { + const contentdisposition = res && res.headers && res.headers['content-disposition'] + serverFilename = contentdisposition && decodeURI(contentdisposition.split(';')[1].split('filename=')[1]) + } + + const href = window.URL.createObjectURL(blob, { + type: fileType + }) // 创建下载的链接 downloadElement.href = href - downloadElement.download = filename // 下载后文件名 + downloadElement.download = serverFilename || '未命名' // 下载后文件名 document.body.appendChild(downloadElement) downloadElement.click() // 点击下载 document.body.removeChild(downloadElement) // 下载完成移除元素 window.URL.revokeObjectURL(href) // 释放blob对象 downloadSuccess && downloadSuccess(res) + return res }, (error) => { const { downloadFail } = options diff --git a/components/_util/hi-request/index.js b/components/_util/hi-request/index.js index a8bd0e2ef..e0725769f 100644 --- a/components/_util/hi-request/index.js +++ b/components/_util/hi-request/index.js @@ -10,21 +10,23 @@ import axiosIns, { axios } from './axios' */ const InternalRequest = (options, host) => { - const { type = 'basics' } = options + const { type = 'basics', responseType = 'json' } = options const url = host ? host + options.url : options.url if (type === 'jsonp' || type === 'download') { - return type === 'jsonp' ? jsonp : download + return type === 'jsonp' ? jsonp(options, host) : download(options, host) } return axiosIns( type === 'upload' ? { url, method: 'post', + responseType, ...upload(options).options } : { url, type: 'basics', + responseType, ...options } ) diff --git a/components/card/NormalCard.jsx b/components/card/NormalCard.jsx index 6715622c9..9ab50fa35 100644 --- a/components/card/NormalCard.jsx +++ b/components/card/NormalCard.jsx @@ -1,7 +1,19 @@ import React from 'react' import classNames from 'classnames' +import Loading from '../loading' -const NormalCard = ({ children, size, title, extra, showHeaderDivider, style, className, hoverable, bordered }) => { +const NormalCard = ({ + children, + size, + title, + extra, + showHeaderDivider, + style, + className, + hoverable, + bordered, + loading +}) => { return (