Comparing version 1.3.8 to 1.3.9
@@ -15,2 +15,6 @@ import { TableProps, ColumnProps } from 'antd/lib/table/interface'; | ||
/** | ||
* 类型,默认是Radio | ||
*/ | ||
type?: 'raido' | 'checkbox' | 'daterange'; | ||
/** | ||
* 过滤器的选项列表,{name:xx,value:xx}[] | ||
@@ -23,9 +27,9 @@ */ | ||
/** | ||
* 是否多选,为 true 时,以复选框的形式展示 | ||
* 是否显示 | ||
*/ | ||
muti?: boolean; | ||
show?: boolean; | ||
/** | ||
* 当为多选时,每条记录的分隔符 | ||
* 自定义ClassName | ||
*/ | ||
mutisplit?: string; | ||
className?: string; | ||
/** | ||
@@ -32,0 +36,0 @@ * 后面后一个过滤器是否与本过滤器显示在同一行 |
@@ -9,11 +9,5 @@ /// <reference types="react" /> | ||
export default class TableHeader<T> extends React.Component<TableHeaderProps<T>, { | ||
hasFilter: boolean; | ||
hasSearch: boolean; | ||
hasAction: boolean; | ||
showSearch: boolean; | ||
}> { | ||
state: { | ||
hasFilter: boolean; | ||
hasSearch: boolean; | ||
hasAction: boolean; | ||
showSearch: boolean; | ||
@@ -25,3 +19,2 @@ }; | ||
constructor(props: any); | ||
componentDidMount(): void; | ||
/** | ||
@@ -46,3 +39,3 @@ * 条件过滤 | ||
tags(): JSX.Element[]; | ||
render(): JSX.Element; | ||
render(): any[] | JSX.Element; | ||
} |
@@ -23,2 +23,4 @@ "use strict"; | ||
var antd_1 = require("antd"); | ||
var DateRange_1 = require("./DateRange"); | ||
var utils_1 = require("../../../utils"); | ||
var _ = require("lodash"); | ||
@@ -30,5 +32,6 @@ var TableHeader = /** @class */ (function (_super) { | ||
_this.state = { | ||
hasFilter: false, | ||
hasSearch: false, | ||
hasAction: false, | ||
// hasFilter: false, | ||
// hasSearch: false, | ||
// hasAction: false, | ||
// showSearch: false, | ||
showSearch: false, | ||
@@ -46,15 +49,2 @@ }; | ||
} | ||
TableHeader.prototype.componentDidMount = function () { | ||
var _a = [false, false, false], hasFilter = _a[0], hasSearch = _a[1], hasAction = _a[2]; | ||
if (_.isArray(this.props.filters) && this.props.filters.length > 0) { | ||
hasFilter = true; | ||
} | ||
if (_.isArray(this.props.searchs) && this.props.searchs.length > 0) { | ||
hasSearch = true; | ||
} | ||
if (_.isArray(this.props.actions) && this.props.actions.length > 0) { | ||
hasAction = true; | ||
} | ||
this.setState({ hasFilter: hasFilter, hasSearch: hasSearch, hasAction: hasAction }); | ||
}; | ||
/** | ||
@@ -66,7 +56,22 @@ * 条件过滤 | ||
var query = {}; | ||
if (filter.muti) { | ||
if (filter.type == 'checkbox') { | ||
this.FilterMap[filter.field] = value; | ||
var mutisplit = filter.mutisplit || ','; | ||
query[filter.field] = value.join(mutisplit); | ||
query[filter.field] = value.join(','); | ||
} | ||
else if (filter.type == 'daterange') { | ||
var _a = filter.field.split(','), start = _a[0], end = _a[1]; | ||
var _b = value.split(','), startime = _b[0], endtime = _b[1]; | ||
if (startime != 'null' && startime.length == 13) { | ||
query[start] = utils_1.Format.formatDate(new Date(parseInt(startime))); | ||
} | ||
else { | ||
query[start] = ''; | ||
} | ||
if (endtime != 'null' && endtime.length == 13) { | ||
query[end] = utils_1.Format.formatDate(new Date(parseInt(endtime))); | ||
} | ||
else { | ||
query[end] = ''; | ||
} | ||
} | ||
else { | ||
@@ -100,2 +105,5 @@ this.FilterMap[filter.field] = value.target.value; | ||
}; | ||
var dateRangeGroup = function (filter) { | ||
return React.createElement(DateRange_1.default, { onChange: function (start, end) { return _this.doFilter(filter, start + ',' + end); } }); | ||
}; | ||
var gloupFilters = function (filters) { | ||
@@ -124,9 +132,19 @@ var filterGroup = []; | ||
var displayFilters = gloupFilters(filters); | ||
var buildFilter = function (filter) { | ||
switch (filter.type) { | ||
case 'checkbox': | ||
return checkboxGroup(filter); | ||
case 'daterange': | ||
return dateRangeGroup(filter); | ||
default: | ||
return radioGroup(filter); | ||
} | ||
}; | ||
return displayFilters.map(function (filterGroup, i) { return (React.createElement(antd_1.Row, { type: "flex", className: "table-filter " + (i == (displayFilters.length - 1) ? 'table-filter-end' : '') }, | ||
" ", | ||
filterGroup.map(function (filter) { return (React.createElement(antd_1.Col, { className: filter.inline ? "table-filter-liline" : "" }, | ||
filterGroup.map(function (filter) { return (React.createElement(antd_1.Col, { className: (filter.inline ? "table-filter-liline" : "") + (filter.className ? " " + filter.className : '') }, | ||
React.createElement("span", { className: "table-filter-label" }, | ||
filter.name, | ||
" :"), | ||
filter.muti ? checkboxGroup(filter) : radioGroup(filter))); }))); }); | ||
buildFilter(filter))); }))); }); | ||
}; | ||
@@ -199,5 +217,8 @@ TableHeader.prototype.clearSearch = function (key) { | ||
} | ||
if (action.className) { | ||
param.className = action.className; | ||
} | ||
return React.createElement(antd_1.Button, __assign({ size: "small" }, param), name); | ||
}; | ||
return React.createElement("div", null, _.filter(actions, function (item) { return item.show === undefined || item.show == true; }).map(function (action) { return btn(action); })); | ||
return React.createElement("div", null, actions.map(function (action) { return btn(action); })); | ||
}; | ||
@@ -216,12 +237,20 @@ TableHeader.prototype.tags = function () { | ||
TableHeader.prototype.render = function () { | ||
if (this.state.hasFilter || this.state.hasSearch || this.state.hasAction) { | ||
var _a = [[], this.props.searchs, []], filters = _a[0], searchs = _a[1], actions = _a[2]; | ||
if (_.isArray(this.props.filters) && this.props.filters.length > 0) { | ||
filters = _.filter(this.props.filters, function (item) { return item.show === undefined || item.show == true; }); | ||
} | ||
if (_.isArray(this.props.actions) && this.props.actions.length > 0) { | ||
actions = _.filter(this.props.actions, function (item) { return item.show === undefined || item.show == true; }); | ||
} | ||
var show = _.isArray(this.props.filters) || _.isArray(this.props.filters) || _.isArray(this.props.filters); | ||
if (filters.length > 0 || this.props.searchs.length > 0 || actions.length > 0) { | ||
return React.createElement(antd_1.Layout.Header, { className: "table-header" }, | ||
this.state.hasFilter && this.filters(this.props.filters), | ||
(this.state.hasSearch || this.state.hasAction) && | ||
filters.length > 0 && this.filters(filters), | ||
(searchs.length > 0 || actions.length > 0) && | ||
React.createElement(antd_1.Row, { type: "flex", className: "table-action" }, | ||
React.createElement(antd_1.Col, { className: "table-action-search" }, this.state.hasSearch && this.searchs(this.props.searchs)), | ||
React.createElement(antd_1.Col, { className: "table-action-search" }, searchs.length > 0 && this.searchs(searchs)), | ||
React.createElement(antd_1.Col, null, this.tags()), | ||
React.createElement(antd_1.Col, { className: "table-action-group" }, this.state.hasAction && this.actions(this.props.actions)))); | ||
React.createElement(antd_1.Col, { className: "table-action-group" }, actions.length > 0 && this.actions(actions)))); | ||
} | ||
return React.createElement("div", { style: { display: 'none' } }); | ||
return []; | ||
}; | ||
@@ -228,0 +257,0 @@ return TableHeader; |
{ | ||
"name": "vap", | ||
"version": "1.3.8", | ||
"version": "1.3.9", | ||
"description": "vap", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
228811
99
6007