wargerm 0.5.3 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Table/example/demo1.d.ts +3 -0
- package/dist/components/Table/example/demo2.d.ts +3 -0
- package/dist/components/Table/example/demo3.d.ts +3 -0
- package/dist/components/Table/example/demo4.d.ts +3 -0
- package/dist/components/Table/example/demo5.d.ts +3 -0
- package/dist/components/WForm/index.d.ts +1 -0
- package/dist/components/useEventEmitter/example/demo1.d.ts +2 -0
- package/dist/hooks/useEventEmitter.d.ts +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +170 -13
- package/dist/index.js +168 -10
- package/dist/utils/event.d.ts +15 -0
- package/package.json +1 -1
@@ -16,6 +16,7 @@ export interface ColumnProps {
|
|
16
16
|
valueType?: 'text' | 'textarea' | 'inputNumber' | 'select' | 'treeSelect' | 'date' | 'dateTime' | 'dateMonth' | 'dateYear' | 'dateRange' | 'dateTimeRange' | 'checkbox' | 'radio' | 'radioButton' | 'switch' | 'digit' | 'cascader';
|
17
17
|
valueEnum?: Record<string, any>;
|
18
18
|
options?: Record<string, any>[];
|
19
|
+
useFirstIteminitialValue?: boolean;
|
19
20
|
fieldProps?: Record<string, any>;
|
20
21
|
formItemProps?: Record<string, any>;
|
21
22
|
order?: number;
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import './styles/index-dark.less';
|
2
2
|
import './styles/index-light.less';
|
3
|
+
export { default as useEventEmitter } from '@/hooks/useEventEmitter';
|
3
4
|
export { default as Button } from './components/Button';
|
4
5
|
export { default as IconFont } from './components/IconFont';
|
5
6
|
export { default as Input } from './components/Input';
|
package/dist/index.esm.js
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
import React, { useRef, useEffect, useMemo, memo, useState, useImperativeHandle, forwardRef, createRef, useCallback } from 'react';
|
2
|
+
import { cloneDeep, isEmpty } from 'lodash';
|
1
3
|
import 'antd/es/button/style';
|
2
4
|
import _Button from 'antd/es/button';
|
3
5
|
import 'antd/es/dropdown/style';
|
4
6
|
import _Dropdown from 'antd/es/dropdown';
|
5
7
|
import 'antd/es/menu/style';
|
6
8
|
import _Menu from 'antd/es/menu';
|
7
|
-
import React, { memo, useState, useEffect, useMemo, useImperativeHandle, useRef, forwardRef, createRef, useCallback } from 'react';
|
8
9
|
import { createFromIconfontCN, SearchOutlined, ReloadOutlined, CloseCircleOutlined, PlusOutlined, EllipsisOutlined, ExclamationCircleOutlined, EyeOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons';
|
9
10
|
import 'antd/es/input/style';
|
10
11
|
import _Input from 'antd/es/input';
|
@@ -38,7 +39,7 @@ import 'antd/es/tree-select/style';
|
|
38
39
|
import _TreeSelect from 'antd/es/tree-select';
|
39
40
|
import 'antd/es/cascader/style';
|
40
41
|
import _Cascader from 'antd/es/cascader';
|
41
|
-
import cloneDeep from 'lodash/cloneDeep';
|
42
|
+
import cloneDeep$1 from 'lodash/cloneDeep';
|
42
43
|
import CountUp from 'react-countup';
|
43
44
|
import { Swiper, SwiperSlide } from 'swiper/react';
|
44
45
|
import SwiperCore, { Pagination, Navigation, Autoplay, Virtual } from 'swiper';
|
@@ -51,7 +52,6 @@ import ProTable from '@ant-design/pro-table';
|
|
51
52
|
import Player from 'xgplayer';
|
52
53
|
import FlvPlayer from 'xgplayer-flv.js';
|
53
54
|
import HlsJsPlayer from 'xgplayer-hls.js';
|
54
|
-
import { isEmpty } from 'lodash';
|
55
55
|
import ReactEChartsCore from 'echarts-for-react/lib/core';
|
56
56
|
import * as echarts from 'echarts/core';
|
57
57
|
import { use, registerTheme, graphic } from 'echarts/core';
|
@@ -441,6 +441,91 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
441
441
|
};
|
442
442
|
}
|
443
443
|
|
444
|
+
var EventEmitter = /*#__PURE__*/_createClass(function EventEmitter() {
|
445
|
+
var _this = this;
|
446
|
+
|
447
|
+
_classCallCheck(this, EventEmitter);
|
448
|
+
|
449
|
+
this.subscriptions = new Map();
|
450
|
+
|
451
|
+
this.useSubscription = function (event, listener) {
|
452
|
+
var callbackRef = useRef();
|
453
|
+
useEffect(function () {
|
454
|
+
callbackRef.current = listener;
|
455
|
+
|
456
|
+
function subscription(val) {
|
457
|
+
if (callbackRef.current) {
|
458
|
+
callbackRef.current(val);
|
459
|
+
}
|
460
|
+
}
|
461
|
+
|
462
|
+
_this.subscriptions.set(event, subscription);
|
463
|
+
|
464
|
+
return function () {
|
465
|
+
_this.subscriptions.delete(event);
|
466
|
+
};
|
467
|
+
}, []);
|
468
|
+
};
|
469
|
+
|
470
|
+
this.emit = function (event) {
|
471
|
+
if (typeof event === 'string' || typeof event === 'number') {
|
472
|
+
var subscriptionValuesCallback = _this.subscriptions.get(event);
|
473
|
+
|
474
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
475
|
+
args[_key - 1] = arguments[_key];
|
476
|
+
}
|
477
|
+
|
478
|
+
subscriptionValuesCallback === null || subscriptionValuesCallback === void 0 ? void 0 : subscriptionValuesCallback({
|
479
|
+
params: cloneDeep(args),
|
480
|
+
event: event
|
481
|
+
});
|
482
|
+
} else throw new TypeError('event must be string or number !');
|
483
|
+
};
|
484
|
+
|
485
|
+
this.removeListener = function (event) {
|
486
|
+
_this.subscriptions.delete(event);
|
487
|
+
};
|
488
|
+
|
489
|
+
this.clear = function () {
|
490
|
+
_this.subscriptions.clear();
|
491
|
+
};
|
492
|
+
|
493
|
+
this.clear();
|
494
|
+
});
|
495
|
+
|
496
|
+
var eventEmitterOverall = new EventEmitter();
|
497
|
+
|
498
|
+
/*
|
499
|
+
* @Author: lijin
|
500
|
+
* @Date: 2022-07-22 14:29:31
|
501
|
+
* @LastEditTime: 2022-07-22 14:29:31
|
502
|
+
* @LastEditors: lijin
|
503
|
+
* @Description:
|
504
|
+
* @FilePath: \wargerm-components\src\hooks\useEventEmitter.tsx
|
505
|
+
* 可以输入预定的版权声明、个性签名、空行等
|
506
|
+
*/
|
507
|
+
function useEventEmitter(options) {
|
508
|
+
var ref = useRef();
|
509
|
+
var eventEmitterOptions = useMemo(function () {
|
510
|
+
return options !== null && options !== void 0 ? options : {
|
511
|
+
global: false
|
512
|
+
};
|
513
|
+
}, [options]);
|
514
|
+
|
515
|
+
if (!ref.current) {
|
516
|
+
ref.current = eventEmitterOptions.global ? ref.current = eventEmitterOverall : ref.current = new EventEmitter();
|
517
|
+
}
|
518
|
+
|
519
|
+
useEffect(function () {
|
520
|
+
return function () {
|
521
|
+
var _ref$current;
|
522
|
+
|
523
|
+
return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.clear();
|
524
|
+
};
|
525
|
+
}, []);
|
526
|
+
return ref.current;
|
527
|
+
}
|
528
|
+
|
444
529
|
var _excluded = ["multiple", "children", "disabled"];
|
445
530
|
|
446
531
|
var WButton = function WButton(props) {
|
@@ -546,10 +631,10 @@ Index$3.Group = _Checkbox.Group;
|
|
546
631
|
/*
|
547
632
|
* @Author: lijin
|
548
633
|
* @Date: 2021-10-27 22:18:49
|
549
|
-
* @LastEditTime: 2022-
|
550
|
-
* @LastEditors:
|
634
|
+
* @LastEditTime: 2022-07-22 15:17:01
|
635
|
+
* @LastEditors: lijin
|
551
636
|
* @Description:
|
552
|
-
* @FilePath: \wargerm\src\utils\index.ts
|
637
|
+
* @FilePath: \wargerm-components\src\utils\index.ts
|
553
638
|
* 可以输入预定的版权声明、个性签名、空行等
|
554
639
|
*/
|
555
640
|
|
@@ -6791,12 +6876,12 @@ var WForm = function WForm(props, ref) {
|
|
6791
6876
|
columnsFields = _useState4[0],
|
6792
6877
|
setColumnsFields = _useState4[1];
|
6793
6878
|
|
6794
|
-
var filterFormColumns = cloneDeep(columns).filter(function (c) {
|
6879
|
+
var filterFormColumns = cloneDeep$1(columns).filter(function (c) {
|
6795
6880
|
return !c.hideInSearch || disabledHideInSearch;
|
6796
6881
|
}).sort(function (a, b) {
|
6797
6882
|
return (b.order || 0) - (a.order || 0);
|
6798
6883
|
});
|
6799
|
-
var filterExtraFormColumns = cloneDeep(extraColumns || []).filter(function (c) {
|
6884
|
+
var filterExtraFormColumns = cloneDeep$1(extraColumns || []).filter(function (c) {
|
6800
6885
|
return !c.hideInSearch || disabledHideInSearch;
|
6801
6886
|
}).sort(function (a, b) {
|
6802
6887
|
return (b.order || 0) - (a.order || 0);
|
@@ -6857,6 +6942,12 @@ var WForm = function WForm(props, ref) {
|
|
6857
6942
|
setColumnsFields(function (preColumnsFields) {
|
6858
6943
|
return _objectSpread2(_objectSpread2({}, preColumnsFields), {}, _defineProperty({}, c.dataIndex, opt));
|
6859
6944
|
});
|
6945
|
+
|
6946
|
+
if (c.useFirstIteminitialValue) {
|
6947
|
+
var _form$setFieldsValue, _opt$0$value, _opt$;
|
6948
|
+
|
6949
|
+
form === null || form === void 0 ? void 0 : (_form$setFieldsValue = form.setFieldsValue) === null || _form$setFieldsValue === void 0 ? void 0 : _form$setFieldsValue.call(form, _defineProperty({}, c.dataIndex, (_opt$0$value = opt === null || opt === void 0 ? void 0 : (_opt$ = opt[0]) === null || _opt$ === void 0 ? void 0 : _opt$.value) !== null && _opt$0$value !== void 0 ? _opt$0$value : ''));
|
6950
|
+
}
|
6860
6951
|
}
|
6861
6952
|
}, c.fieldProps), _extraProps))));
|
6862
6953
|
} else if (c.valueType == 'cascader') {
|
@@ -7324,6 +7415,12 @@ var WForm = function WForm(props, ref) {
|
|
7324
7415
|
setColumnsFields(function (preColumnsFields) {
|
7325
7416
|
return _objectSpread2(_objectSpread2({}, preColumnsFields), {}, _defineProperty({}, c.dataIndex, opt));
|
7326
7417
|
});
|
7418
|
+
|
7419
|
+
if (c.useFirstIteminitialValue) {
|
7420
|
+
var _form$setFieldsValue2, _opt$0$value2, _opt$2;
|
7421
|
+
|
7422
|
+
form === null || form === void 0 ? void 0 : (_form$setFieldsValue2 = form.setFieldsValue) === null || _form$setFieldsValue2 === void 0 ? void 0 : _form$setFieldsValue2.call(form, _defineProperty({}, c.dataIndex, (_opt$0$value2 = opt === null || opt === void 0 ? void 0 : (_opt$2 = opt[0]) === null || _opt$2 === void 0 ? void 0 : _opt$2.value) !== null && _opt$0$value2 !== void 0 ? _opt$0$value2 : ''));
|
7423
|
+
}
|
7327
7424
|
}
|
7328
7425
|
}, c.fieldProps), _extraProps4))));
|
7329
7426
|
} else if (c.valueType == 'cascader') {
|
@@ -7795,6 +7892,65 @@ var WForm = function WForm(props, ref) {
|
|
7795
7892
|
return filterObj(searchForm);
|
7796
7893
|
};
|
7797
7894
|
|
7895
|
+
var getFormValues = function getFormValues() {
|
7896
|
+
var searchForm = form.getFieldsValue();
|
7897
|
+
filterFormColumns.forEach(function (c) {
|
7898
|
+
if (c.search && c.search.transform) {
|
7899
|
+
var transformObj = c.search.transform(searchForm[c.dataIndex]);
|
7900
|
+
searchForm = _objectSpread2(_objectSpread2({}, searchForm), transformObj);
|
7901
|
+
|
7902
|
+
if (!transformObj[c.dataIndex]) {
|
7903
|
+
delete searchForm[c.dataIndex];
|
7904
|
+
}
|
7905
|
+
|
7906
|
+
return false;
|
7907
|
+
}
|
7908
|
+
|
7909
|
+
if (c.valueType && ['date', 'dateTime', 'dateMonth', 'dateYear', 'dateRange', 'dateTimeRange'].includes(c.valueType)) {
|
7910
|
+
if (c.valueType === 'date' && searchForm[c.dataIndex]) {
|
7911
|
+
var _c$fieldProps7;
|
7912
|
+
|
7913
|
+
searchForm[c.dataIndex] = searchForm[c.dataIndex] && hooks(searchForm[c.dataIndex]).format((c === null || c === void 0 ? void 0 : (_c$fieldProps7 = c.fieldProps) === null || _c$fieldProps7 === void 0 ? void 0 : _c$fieldProps7.format) || 'YYYY-MM-DD');
|
7914
|
+
}
|
7915
|
+
|
7916
|
+
if (c.valueType === 'dateTime' && searchForm[c.dataIndex]) {
|
7917
|
+
var _c$fieldProps8;
|
7918
|
+
|
7919
|
+
searchForm[c.dataIndex] = searchForm[c.dataIndex] && hooks(searchForm[c.dataIndex]).format((c === null || c === void 0 ? void 0 : (_c$fieldProps8 = c.fieldProps) === null || _c$fieldProps8 === void 0 ? void 0 : _c$fieldProps8.format) || 'YYYY-MM-DD HH:mm:ss');
|
7920
|
+
}
|
7921
|
+
|
7922
|
+
if (c.valueType === 'dateMonth' && searchForm[c.dataIndex]) {
|
7923
|
+
var _c$fieldProps9;
|
7924
|
+
|
7925
|
+
searchForm[c.dataIndex] = searchForm[c.dataIndex] && hooks(searchForm[c.dataIndex]).format((c === null || c === void 0 ? void 0 : (_c$fieldProps9 = c.fieldProps) === null || _c$fieldProps9 === void 0 ? void 0 : _c$fieldProps9.format) || 'YYYY-MM');
|
7926
|
+
}
|
7927
|
+
|
7928
|
+
if (c.valueType === 'dateYear' && searchForm[c.dataIndex]) {
|
7929
|
+
var _c$fieldProps10;
|
7930
|
+
|
7931
|
+
searchForm[c.dataIndex] = searchForm[c.dataIndex] && hooks(searchForm[c.dataIndex]).format((c === null || c === void 0 ? void 0 : (_c$fieldProps10 = c.fieldProps) === null || _c$fieldProps10 === void 0 ? void 0 : _c$fieldProps10.format) || 'YYYY');
|
7932
|
+
}
|
7933
|
+
|
7934
|
+
if (c.valueType === 'dateRange' && searchForm[c.dataIndex]) {
|
7935
|
+
searchForm[c.dataIndex] = searchForm[c.dataIndex].map(function (item) {
|
7936
|
+
var _c$fieldProps11;
|
7937
|
+
|
7938
|
+
return item && searchForm[c.dataIndex] && hooks(item).format((c === null || c === void 0 ? void 0 : (_c$fieldProps11 = c.fieldProps) === null || _c$fieldProps11 === void 0 ? void 0 : _c$fieldProps11.format) || 'YYYY-MM-DD');
|
7939
|
+
});
|
7940
|
+
}
|
7941
|
+
|
7942
|
+
if (c.valueType === 'dateTimeRange' && searchForm[c.dataIndex]) {
|
7943
|
+
searchForm[c.dataIndex] = searchForm[c.dataIndex].map(function (item) {
|
7944
|
+
var _c$fieldProps12;
|
7945
|
+
|
7946
|
+
return item && hooks(item).format((c === null || c === void 0 ? void 0 : (_c$fieldProps12 = c.fieldProps) === null || _c$fieldProps12 === void 0 ? void 0 : _c$fieldProps12.format) || 'YYYY-MM-DD HH:mm:ss');
|
7947
|
+
});
|
7948
|
+
}
|
7949
|
+
}
|
7950
|
+
});
|
7951
|
+
return filterObj(searchForm);
|
7952
|
+
};
|
7953
|
+
|
7798
7954
|
var handleRest = function handleRest() {
|
7799
7955
|
var _form$resetFields;
|
7800
7956
|
|
@@ -7803,7 +7959,7 @@ var WForm = function WForm(props, ref) {
|
|
7803
7959
|
};
|
7804
7960
|
|
7805
7961
|
var setFieldsValue = function setFieldsValue(record) {
|
7806
|
-
var _form$
|
7962
|
+
var _form$setFieldsValue4;
|
7807
7963
|
|
7808
7964
|
var setFieldsValues = _objectSpread2({}, record);
|
7809
7965
|
|
@@ -7819,7 +7975,7 @@ var WForm = function WForm(props, ref) {
|
|
7819
7975
|
return false;
|
7820
7976
|
}
|
7821
7977
|
});
|
7822
|
-
form === null || form === void 0 ? void 0 : (_form$
|
7978
|
+
form === null || form === void 0 ? void 0 : (_form$setFieldsValue4 = form.setFieldsValue) === null || _form$setFieldsValue4 === void 0 ? void 0 : _form$setFieldsValue4.call(form, setFieldsValues);
|
7823
7979
|
};
|
7824
7980
|
|
7825
7981
|
useImperativeHandle(ref, function () {
|
@@ -7829,7 +7985,8 @@ var WForm = function WForm(props, ref) {
|
|
7829
7985
|
handleSubmit: form.submit,
|
7830
7986
|
handleRest: handleRest,
|
7831
7987
|
resetFields: handleRest,
|
7832
|
-
setFieldsValue: setFieldsValue
|
7988
|
+
setFieldsValue: setFieldsValue,
|
7989
|
+
getFormValues: getFormValues
|
7833
7990
|
};
|
7834
7991
|
});
|
7835
7992
|
useEffect(function () {
|
@@ -8351,7 +8508,7 @@ function Table(_ref) {
|
|
8351
8508
|
}
|
8352
8509
|
}, _callee);
|
8353
8510
|
}))();
|
8354
|
-
}, [params, pageParams, pagination, tableList, formSearch, columns]);
|
8511
|
+
}, [JSON.stringify(params), JSON.stringify(pageParams), JSON.stringify(pagination), JSON.stringify(tableList), formSearch, JSON.stringify(columns)]);
|
8355
8512
|
|
8356
8513
|
var onFormSubmit = function onFormSubmit(values) {
|
8357
8514
|
onSubmit && onSubmit(values);
|
@@ -12537,4 +12694,4 @@ function WaterLevelCharts(config) {
|
|
12537
12694
|
});
|
12538
12695
|
}
|
12539
12696
|
|
12540
|
-
export { Index$9 as AutoScroll, Index$b as Breadcrumb, WButton as Button, index$2 as Card, WCascader as Cascader, Index$3 as Checkbox, Index$8 as CountUp, Index$1 as DatePicker, DragBox, index as IconFont, Index as Input, WInputNumber as InputNumber, LineEcharts, Modal, ModalForm$1 as ModalForm, Modal$1 as ModalTips, Index$7 as Number, NumericInput, Index$2 as Radio, Select, Index$a as Swiper, WSwitch as Switch, index$3 as TabelCard, index$1 as Table, Index$6 as TreeSelect, index$5 as Video, index$4 as VideoPlayer, Index$5 as WDatePicker, WForm$1 as WForm, WaterLevelCharts, WebsocketHeart };
|
12697
|
+
export { Index$9 as AutoScroll, Index$b as Breadcrumb, WButton as Button, index$2 as Card, WCascader as Cascader, Index$3 as Checkbox, Index$8 as CountUp, Index$1 as DatePicker, DragBox, index as IconFont, Index as Input, WInputNumber as InputNumber, LineEcharts, Modal, ModalForm$1 as ModalForm, Modal$1 as ModalTips, Index$7 as Number, NumericInput, Index$2 as Radio, Select, Index$a as Swiper, WSwitch as Switch, index$3 as TabelCard, index$1 as Table, Index$6 as TreeSelect, index$5 as Video, index$4 as VideoPlayer, Index$5 as WDatePicker, WForm$1 as WForm, WaterLevelCharts, WebsocketHeart, useEventEmitter };
|
package/dist/index.js
CHANGED
@@ -2,13 +2,14 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
+
var React = require('react');
|
6
|
+
var lodash = require('lodash');
|
5
7
|
require('antd/es/button/style');
|
6
8
|
var _Button = require('antd/es/button');
|
7
9
|
require('antd/es/dropdown/style');
|
8
10
|
var _Dropdown = require('antd/es/dropdown');
|
9
11
|
require('antd/es/menu/style');
|
10
12
|
var _Menu = require('antd/es/menu');
|
11
|
-
var React = require('react');
|
12
13
|
var icons = require('@ant-design/icons');
|
13
14
|
require('antd/es/input/style');
|
14
15
|
var _Input = require('antd/es/input');
|
@@ -55,7 +56,6 @@ var ProTable = require('@ant-design/pro-table');
|
|
55
56
|
var Player = require('xgplayer');
|
56
57
|
var FlvPlayer = require('xgplayer-flv.js');
|
57
58
|
var HlsJsPlayer = require('xgplayer-hls.js');
|
58
|
-
var lodash = require('lodash');
|
59
59
|
var ReactEChartsCore = require('echarts-for-react/lib/core');
|
60
60
|
var echarts = require('echarts/core');
|
61
61
|
var charts = require('echarts/charts');
|
@@ -84,10 +84,10 @@ function _interopNamespace(e) {
|
|
84
84
|
return Object.freeze(n);
|
85
85
|
}
|
86
86
|
|
87
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
87
88
|
var _Button__default = /*#__PURE__*/_interopDefaultLegacy(_Button);
|
88
89
|
var _Dropdown__default = /*#__PURE__*/_interopDefaultLegacy(_Dropdown);
|
89
90
|
var _Menu__default = /*#__PURE__*/_interopDefaultLegacy(_Menu);
|
90
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
91
91
|
var _Input__default = /*#__PURE__*/_interopDefaultLegacy(_Input);
|
92
92
|
var _InputNumber__default = /*#__PURE__*/_interopDefaultLegacy(_InputNumber);
|
93
93
|
var _Pagination__default = /*#__PURE__*/_interopDefaultLegacy(_Pagination);
|
@@ -500,6 +500,91 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
500
500
|
};
|
501
501
|
}
|
502
502
|
|
503
|
+
var EventEmitter = /*#__PURE__*/_createClass(function EventEmitter() {
|
504
|
+
var _this = this;
|
505
|
+
|
506
|
+
_classCallCheck(this, EventEmitter);
|
507
|
+
|
508
|
+
this.subscriptions = new Map();
|
509
|
+
|
510
|
+
this.useSubscription = function (event, listener) {
|
511
|
+
var callbackRef = React.useRef();
|
512
|
+
React.useEffect(function () {
|
513
|
+
callbackRef.current = listener;
|
514
|
+
|
515
|
+
function subscription(val) {
|
516
|
+
if (callbackRef.current) {
|
517
|
+
callbackRef.current(val);
|
518
|
+
}
|
519
|
+
}
|
520
|
+
|
521
|
+
_this.subscriptions.set(event, subscription);
|
522
|
+
|
523
|
+
return function () {
|
524
|
+
_this.subscriptions.delete(event);
|
525
|
+
};
|
526
|
+
}, []);
|
527
|
+
};
|
528
|
+
|
529
|
+
this.emit = function (event) {
|
530
|
+
if (typeof event === 'string' || typeof event === 'number') {
|
531
|
+
var subscriptionValuesCallback = _this.subscriptions.get(event);
|
532
|
+
|
533
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
534
|
+
args[_key - 1] = arguments[_key];
|
535
|
+
}
|
536
|
+
|
537
|
+
subscriptionValuesCallback === null || subscriptionValuesCallback === void 0 ? void 0 : subscriptionValuesCallback({
|
538
|
+
params: lodash.cloneDeep(args),
|
539
|
+
event: event
|
540
|
+
});
|
541
|
+
} else throw new TypeError('event must be string or number !');
|
542
|
+
};
|
543
|
+
|
544
|
+
this.removeListener = function (event) {
|
545
|
+
_this.subscriptions.delete(event);
|
546
|
+
};
|
547
|
+
|
548
|
+
this.clear = function () {
|
549
|
+
_this.subscriptions.clear();
|
550
|
+
};
|
551
|
+
|
552
|
+
this.clear();
|
553
|
+
});
|
554
|
+
|
555
|
+
var eventEmitterOverall = new EventEmitter();
|
556
|
+
|
557
|
+
/*
|
558
|
+
* @Author: lijin
|
559
|
+
* @Date: 2022-07-22 14:29:31
|
560
|
+
* @LastEditTime: 2022-07-22 14:29:31
|
561
|
+
* @LastEditors: lijin
|
562
|
+
* @Description:
|
563
|
+
* @FilePath: \wargerm-components\src\hooks\useEventEmitter.tsx
|
564
|
+
* 可以输入预定的版权声明、个性签名、空行等
|
565
|
+
*/
|
566
|
+
function useEventEmitter(options) {
|
567
|
+
var ref = React.useRef();
|
568
|
+
var eventEmitterOptions = React.useMemo(function () {
|
569
|
+
return options !== null && options !== void 0 ? options : {
|
570
|
+
global: false
|
571
|
+
};
|
572
|
+
}, [options]);
|
573
|
+
|
574
|
+
if (!ref.current) {
|
575
|
+
ref.current = eventEmitterOptions.global ? ref.current = eventEmitterOverall : ref.current = new EventEmitter();
|
576
|
+
}
|
577
|
+
|
578
|
+
React.useEffect(function () {
|
579
|
+
return function () {
|
580
|
+
var _ref$current;
|
581
|
+
|
582
|
+
return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.clear();
|
583
|
+
};
|
584
|
+
}, []);
|
585
|
+
return ref.current;
|
586
|
+
}
|
587
|
+
|
503
588
|
var _excluded = ["multiple", "children", "disabled"];
|
504
589
|
|
505
590
|
var WButton = function WButton(props) {
|
@@ -605,10 +690,10 @@ Index$3.Group = _Checkbox__default['default'].Group;
|
|
605
690
|
/*
|
606
691
|
* @Author: lijin
|
607
692
|
* @Date: 2021-10-27 22:18:49
|
608
|
-
* @LastEditTime: 2022-
|
609
|
-
* @LastEditors:
|
693
|
+
* @LastEditTime: 2022-07-22 15:17:01
|
694
|
+
* @LastEditors: lijin
|
610
695
|
* @Description:
|
611
|
-
* @FilePath: \wargerm\src\utils\index.ts
|
696
|
+
* @FilePath: \wargerm-components\src\utils\index.ts
|
612
697
|
* 可以输入预定的版权声明、个性签名、空行等
|
613
698
|
*/
|
614
699
|
|
@@ -6916,6 +7001,12 @@ var WForm = function WForm(props, ref) {
|
|
6916
7001
|
setColumnsFields(function (preColumnsFields) {
|
6917
7002
|
return _objectSpread2(_objectSpread2({}, preColumnsFields), {}, _defineProperty({}, c.dataIndex, opt));
|
6918
7003
|
});
|
7004
|
+
|
7005
|
+
if (c.useFirstIteminitialValue) {
|
7006
|
+
var _form$setFieldsValue, _opt$0$value, _opt$;
|
7007
|
+
|
7008
|
+
form === null || form === void 0 ? void 0 : (_form$setFieldsValue = form.setFieldsValue) === null || _form$setFieldsValue === void 0 ? void 0 : _form$setFieldsValue.call(form, _defineProperty({}, c.dataIndex, (_opt$0$value = opt === null || opt === void 0 ? void 0 : (_opt$ = opt[0]) === null || _opt$ === void 0 ? void 0 : _opt$.value) !== null && _opt$0$value !== void 0 ? _opt$0$value : ''));
|
7009
|
+
}
|
6919
7010
|
}
|
6920
7011
|
}, c.fieldProps), _extraProps))));
|
6921
7012
|
} else if (c.valueType == 'cascader') {
|
@@ -7383,6 +7474,12 @@ var WForm = function WForm(props, ref) {
|
|
7383
7474
|
setColumnsFields(function (preColumnsFields) {
|
7384
7475
|
return _objectSpread2(_objectSpread2({}, preColumnsFields), {}, _defineProperty({}, c.dataIndex, opt));
|
7385
7476
|
});
|
7477
|
+
|
7478
|
+
if (c.useFirstIteminitialValue) {
|
7479
|
+
var _form$setFieldsValue2, _opt$0$value2, _opt$2;
|
7480
|
+
|
7481
|
+
form === null || form === void 0 ? void 0 : (_form$setFieldsValue2 = form.setFieldsValue) === null || _form$setFieldsValue2 === void 0 ? void 0 : _form$setFieldsValue2.call(form, _defineProperty({}, c.dataIndex, (_opt$0$value2 = opt === null || opt === void 0 ? void 0 : (_opt$2 = opt[0]) === null || _opt$2 === void 0 ? void 0 : _opt$2.value) !== null && _opt$0$value2 !== void 0 ? _opt$0$value2 : ''));
|
7482
|
+
}
|
7386
7483
|
}
|
7387
7484
|
}, c.fieldProps), _extraProps4))));
|
7388
7485
|
} else if (c.valueType == 'cascader') {
|
@@ -7854,6 +7951,65 @@ var WForm = function WForm(props, ref) {
|
|
7854
7951
|
return filterObj(searchForm);
|
7855
7952
|
};
|
7856
7953
|
|
7954
|
+
var getFormValues = function getFormValues() {
|
7955
|
+
var searchForm = form.getFieldsValue();
|
7956
|
+
filterFormColumns.forEach(function (c) {
|
7957
|
+
if (c.search && c.search.transform) {
|
7958
|
+
var transformObj = c.search.transform(searchForm[c.dataIndex]);
|
7959
|
+
searchForm = _objectSpread2(_objectSpread2({}, searchForm), transformObj);
|
7960
|
+
|
7961
|
+
if (!transformObj[c.dataIndex]) {
|
7962
|
+
delete searchForm[c.dataIndex];
|
7963
|
+
}
|
7964
|
+
|
7965
|
+
return false;
|
7966
|
+
}
|
7967
|
+
|
7968
|
+
if (c.valueType && ['date', 'dateTime', 'dateMonth', 'dateYear', 'dateRange', 'dateTimeRange'].includes(c.valueType)) {
|
7969
|
+
if (c.valueType === 'date' && searchForm[c.dataIndex]) {
|
7970
|
+
var _c$fieldProps7;
|
7971
|
+
|
7972
|
+
searchForm[c.dataIndex] = searchForm[c.dataIndex] && hooks(searchForm[c.dataIndex]).format((c === null || c === void 0 ? void 0 : (_c$fieldProps7 = c.fieldProps) === null || _c$fieldProps7 === void 0 ? void 0 : _c$fieldProps7.format) || 'YYYY-MM-DD');
|
7973
|
+
}
|
7974
|
+
|
7975
|
+
if (c.valueType === 'dateTime' && searchForm[c.dataIndex]) {
|
7976
|
+
var _c$fieldProps8;
|
7977
|
+
|
7978
|
+
searchForm[c.dataIndex] = searchForm[c.dataIndex] && hooks(searchForm[c.dataIndex]).format((c === null || c === void 0 ? void 0 : (_c$fieldProps8 = c.fieldProps) === null || _c$fieldProps8 === void 0 ? void 0 : _c$fieldProps8.format) || 'YYYY-MM-DD HH:mm:ss');
|
7979
|
+
}
|
7980
|
+
|
7981
|
+
if (c.valueType === 'dateMonth' && searchForm[c.dataIndex]) {
|
7982
|
+
var _c$fieldProps9;
|
7983
|
+
|
7984
|
+
searchForm[c.dataIndex] = searchForm[c.dataIndex] && hooks(searchForm[c.dataIndex]).format((c === null || c === void 0 ? void 0 : (_c$fieldProps9 = c.fieldProps) === null || _c$fieldProps9 === void 0 ? void 0 : _c$fieldProps9.format) || 'YYYY-MM');
|
7985
|
+
}
|
7986
|
+
|
7987
|
+
if (c.valueType === 'dateYear' && searchForm[c.dataIndex]) {
|
7988
|
+
var _c$fieldProps10;
|
7989
|
+
|
7990
|
+
searchForm[c.dataIndex] = searchForm[c.dataIndex] && hooks(searchForm[c.dataIndex]).format((c === null || c === void 0 ? void 0 : (_c$fieldProps10 = c.fieldProps) === null || _c$fieldProps10 === void 0 ? void 0 : _c$fieldProps10.format) || 'YYYY');
|
7991
|
+
}
|
7992
|
+
|
7993
|
+
if (c.valueType === 'dateRange' && searchForm[c.dataIndex]) {
|
7994
|
+
searchForm[c.dataIndex] = searchForm[c.dataIndex].map(function (item) {
|
7995
|
+
var _c$fieldProps11;
|
7996
|
+
|
7997
|
+
return item && searchForm[c.dataIndex] && hooks(item).format((c === null || c === void 0 ? void 0 : (_c$fieldProps11 = c.fieldProps) === null || _c$fieldProps11 === void 0 ? void 0 : _c$fieldProps11.format) || 'YYYY-MM-DD');
|
7998
|
+
});
|
7999
|
+
}
|
8000
|
+
|
8001
|
+
if (c.valueType === 'dateTimeRange' && searchForm[c.dataIndex]) {
|
8002
|
+
searchForm[c.dataIndex] = searchForm[c.dataIndex].map(function (item) {
|
8003
|
+
var _c$fieldProps12;
|
8004
|
+
|
8005
|
+
return item && hooks(item).format((c === null || c === void 0 ? void 0 : (_c$fieldProps12 = c.fieldProps) === null || _c$fieldProps12 === void 0 ? void 0 : _c$fieldProps12.format) || 'YYYY-MM-DD HH:mm:ss');
|
8006
|
+
});
|
8007
|
+
}
|
8008
|
+
}
|
8009
|
+
});
|
8010
|
+
return filterObj(searchForm);
|
8011
|
+
};
|
8012
|
+
|
7857
8013
|
var handleRest = function handleRest() {
|
7858
8014
|
var _form$resetFields;
|
7859
8015
|
|
@@ -7862,7 +8018,7 @@ var WForm = function WForm(props, ref) {
|
|
7862
8018
|
};
|
7863
8019
|
|
7864
8020
|
var setFieldsValue = function setFieldsValue(record) {
|
7865
|
-
var _form$
|
8021
|
+
var _form$setFieldsValue4;
|
7866
8022
|
|
7867
8023
|
var setFieldsValues = _objectSpread2({}, record);
|
7868
8024
|
|
@@ -7878,7 +8034,7 @@ var WForm = function WForm(props, ref) {
|
|
7878
8034
|
return false;
|
7879
8035
|
}
|
7880
8036
|
});
|
7881
|
-
form === null || form === void 0 ? void 0 : (_form$
|
8037
|
+
form === null || form === void 0 ? void 0 : (_form$setFieldsValue4 = form.setFieldsValue) === null || _form$setFieldsValue4 === void 0 ? void 0 : _form$setFieldsValue4.call(form, setFieldsValues);
|
7882
8038
|
};
|
7883
8039
|
|
7884
8040
|
React.useImperativeHandle(ref, function () {
|
@@ -7888,7 +8044,8 @@ var WForm = function WForm(props, ref) {
|
|
7888
8044
|
handleSubmit: form.submit,
|
7889
8045
|
handleRest: handleRest,
|
7890
8046
|
resetFields: handleRest,
|
7891
|
-
setFieldsValue: setFieldsValue
|
8047
|
+
setFieldsValue: setFieldsValue,
|
8048
|
+
getFormValues: getFormValues
|
7892
8049
|
};
|
7893
8050
|
});
|
7894
8051
|
React.useEffect(function () {
|
@@ -8410,7 +8567,7 @@ function Table(_ref) {
|
|
8410
8567
|
}
|
8411
8568
|
}, _callee);
|
8412
8569
|
}))();
|
8413
|
-
}, [params, pageParams, pagination, tableList, formSearch, columns]);
|
8570
|
+
}, [JSON.stringify(params), JSON.stringify(pageParams), JSON.stringify(pagination), JSON.stringify(tableList), formSearch, JSON.stringify(columns)]);
|
8414
8571
|
|
8415
8572
|
var onFormSubmit = function onFormSubmit(values) {
|
8416
8573
|
onSubmit && onSubmit(values);
|
@@ -12627,3 +12784,4 @@ exports.WDatePicker = Index$5;
|
|
12627
12784
|
exports.WForm = WForm$1;
|
12628
12785
|
exports.WaterLevelCharts = WaterLevelCharts;
|
12629
12786
|
exports.WebsocketHeart = WebsocketHeart;
|
12787
|
+
exports.useEventEmitter = useEventEmitter;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
declare type SubscriptionParams<T = any> = {
|
2
|
+
params: T;
|
3
|
+
event: string | number;
|
4
|
+
};
|
5
|
+
declare type Subscription<T> = ({ params, event }: SubscriptionParams<T>) => void;
|
6
|
+
declare class EventEmitter<T> {
|
7
|
+
private subscriptions;
|
8
|
+
constructor();
|
9
|
+
useSubscription: (event: string, listener?: Subscription<T> | undefined) => void;
|
10
|
+
emit: (event: string | number, ...args: T extends any[] ? any[] : any) => void;
|
11
|
+
removeListener: (event: string) => void;
|
12
|
+
clear: () => void;
|
13
|
+
}
|
14
|
+
declare const eventEmitterOverall: EventEmitter<unknown>;
|
15
|
+
export { EventEmitter, eventEmitterOverall };
|