@bit-sun/business-component 1.0.4 → 1.0.9
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/.umirc.ts +1 -1
- package/dist/{DataValidation → components/DataValidation}/index.d.ts +1 -1
- package/dist/components/QueryInput/index.d.ts +5 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.esm.js +177 -65
- package/dist/index.js +175 -62
- package/package.json +2 -1
- package/src/{DataValidation → components/DataValidation}/index.less +0 -0
- package/src/components/DataValidation/index.md +36 -0
- package/src/{DataValidation → components/DataValidation}/index.tsx +10 -5
- package/src/components/QueryInput/index.less +21 -0
- package/src/components/QueryInput/index.md +33 -0
- package/src/components/QueryInput/index.tsx +131 -0
- package/src/index.ts +3 -2
- package/src/DataValidation/index.md +0 -32
package/.umirc.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare class DataValidation extends React.Component {
|
|
|
13
13
|
showtoolbar: boolean;
|
|
14
14
|
hook: {
|
|
15
15
|
columnTitleCellRenderBefore: (columnAbc: any, postion: any, ctx: any) => void;
|
|
16
|
-
|
|
16
|
+
cellRenderBefore: (cell: any, postion: any, sheetFile: any, ctx: any) => void;
|
|
17
17
|
cellAllRenderBefore: (data: any, sheetFile: any, ctx: any) => void;
|
|
18
18
|
};
|
|
19
19
|
data: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default as DataValidation } from './DataValidation';
|
|
1
|
+
export { default as DataValidation } from './components/DataValidation';
|
|
2
|
+
export { default as QueryInput } from './components/QueryInput';
|
package/dist/index.esm.js
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import React, { createContext, useContext, useEffect, forwardRef, createElement } from 'react';
|
|
3
|
-
import { message, Menu, Space, Dropdown, Tooltip, Button, Checkbox } from 'antd';
|
|
2
|
+
import React, { createContext, useContext, useEffect, forwardRef, createElement, useState } from 'react';
|
|
3
|
+
import { message, Menu, Space, Dropdown, Tooltip, Button, Checkbox, Input, Modal } from 'antd';
|
|
4
4
|
import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
|
|
5
5
|
import 'antd/dist/antd.css';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
+
import { useDebounceFn } from 'ahooks';
|
|
7
8
|
|
|
8
9
|
function ownKeys(object, enumerableOnly) {
|
|
9
10
|
var keys = Object.keys(object);
|
|
10
11
|
|
|
11
12
|
if (Object.getOwnPropertySymbols) {
|
|
12
13
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
keys.push.apply(keys, symbols);
|
|
14
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
15
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
16
|
+
})), keys.push.apply(keys, symbols);
|
|
21
17
|
}
|
|
22
18
|
|
|
23
19
|
return keys;
|
|
@@ -25,19 +21,12 @@ function ownKeys(object, enumerableOnly) {
|
|
|
25
21
|
|
|
26
22
|
function _objectSpread2(target) {
|
|
27
23
|
for (var i = 1; i < arguments.length; i++) {
|
|
28
|
-
var source = arguments[i]
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
35
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
36
|
-
} else {
|
|
37
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
38
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
39
|
-
});
|
|
40
|
-
}
|
|
24
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
25
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
26
|
+
_defineProperty(target, key, source[key]);
|
|
27
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
28
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
29
|
+
});
|
|
41
30
|
}
|
|
42
31
|
|
|
43
32
|
return target;
|
|
@@ -62,6 +51,9 @@ function _defineProperties(target, props) {
|
|
|
62
51
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
63
52
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
64
53
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
54
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
55
|
+
writable: false
|
|
56
|
+
});
|
|
65
57
|
return Constructor;
|
|
66
58
|
}
|
|
67
59
|
|
|
@@ -85,12 +77,15 @@ function _inherits(subClass, superClass) {
|
|
|
85
77
|
throw new TypeError("Super expression must either be null or a function");
|
|
86
78
|
}
|
|
87
79
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
80
|
+
Object.defineProperty(subClass, "prototype", {
|
|
81
|
+
value: Object.create(superClass && superClass.prototype, {
|
|
82
|
+
constructor: {
|
|
83
|
+
value: subClass,
|
|
84
|
+
writable: true,
|
|
85
|
+
configurable: true
|
|
86
|
+
}
|
|
87
|
+
}),
|
|
88
|
+
writable: false
|
|
94
89
|
});
|
|
95
90
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
96
91
|
}
|
|
@@ -294,14 +289,9 @@ function ownKeys$1(object, enumerableOnly) {
|
|
|
294
289
|
|
|
295
290
|
if (Object.getOwnPropertySymbols) {
|
|
296
291
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
keys.push.apply(keys, symbols);
|
|
292
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
293
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
294
|
+
})), keys.push.apply(keys, symbols);
|
|
305
295
|
}
|
|
306
296
|
|
|
307
297
|
return keys;
|
|
@@ -309,19 +299,12 @@ function ownKeys$1(object, enumerableOnly) {
|
|
|
309
299
|
|
|
310
300
|
function _objectSpread2$1(target) {
|
|
311
301
|
for (var i = 1; i < arguments.length; i++) {
|
|
312
|
-
var source = arguments[i]
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
319
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
320
|
-
} else {
|
|
321
|
-
ownKeys$1(Object(source)).forEach(function (key) {
|
|
322
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
323
|
-
});
|
|
324
|
-
}
|
|
302
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
303
|
+
i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) {
|
|
304
|
+
_defineProperty$1(target, key, source[key]);
|
|
305
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) {
|
|
306
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
307
|
+
});
|
|
325
308
|
}
|
|
326
309
|
|
|
327
310
|
return target;
|
|
@@ -425,17 +408,11 @@ function _objectWithoutProperties$1(source, excluded) {
|
|
|
425
408
|
function _typeof(obj) {
|
|
426
409
|
"@babel/helpers - typeof";
|
|
427
410
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
_typeof = function _typeof(obj) {
|
|
434
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
return _typeof(obj);
|
|
411
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
412
|
+
return typeof obj;
|
|
413
|
+
} : function (obj) {
|
|
414
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
415
|
+
}, _typeof(obj);
|
|
439
416
|
}
|
|
440
417
|
|
|
441
418
|
/**
|
|
@@ -1620,7 +1597,7 @@ var itemsTemp = []; // const mapping = [
|
|
|
1620
1597
|
// { "key": "price", "name": "单价", "rule": "price" }
|
|
1621
1598
|
// ]
|
|
1622
1599
|
|
|
1623
|
-
var mapping = new Map([['skuCode', 'SKU编码'], ['quantity', '数量'], ['price', '单价'], ['regionCode', '库区'], ['checkQuantity', '实盘数量']]); // for dnd
|
|
1600
|
+
var mapping = new Map([['skuCode', 'SKU编码'], ['quantity', '数量'], ['price', '单价'], ['regionCode', '库区'], ['checkQuantity', '实盘数量'], ['shareRatio', '共享比例']]); // for dnd
|
|
1624
1601
|
|
|
1625
1602
|
|
|
1626
1603
|
var reorder = function reorder(list, startIndex, endIndex) {
|
|
@@ -1703,9 +1680,13 @@ var DataValidation = /*#__PURE__*/function (_React$Component) {
|
|
|
1703
1680
|
}
|
|
1704
1681
|
}
|
|
1705
1682
|
},
|
|
1706
|
-
|
|
1683
|
+
cellRenderBefore: function cellRenderBefore(cell, postion, sheetFile, ctx) {
|
|
1707
1684
|
if (cell) {
|
|
1708
1685
|
cell.fs = 10;
|
|
1686
|
+
|
|
1687
|
+
if (typeof cell.v === 'string') {
|
|
1688
|
+
cell.m = cell.v = cell.m.trim();
|
|
1689
|
+
}
|
|
1709
1690
|
} // console.log(postion);
|
|
1710
1691
|
|
|
1711
1692
|
},
|
|
@@ -2015,12 +1996,14 @@ var DataValidation = /*#__PURE__*/function (_React$Component) {
|
|
|
2015
1996
|
};
|
|
2016
1997
|
|
|
2017
1998
|
_this.menuList = /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(Menu.Item, {
|
|
1999
|
+
key: "1",
|
|
2018
2000
|
className: "sheet_table-menu_item_text"
|
|
2019
2001
|
}, /*#__PURE__*/React.createElement("a", {
|
|
2020
2002
|
onClick: function onClick() {
|
|
2021
2003
|
return _this.filterData('all');
|
|
2022
2004
|
}
|
|
2023
2005
|
}, "\u6E05\u7A7A\u5168\u90E8\u6570\u636E")), /*#__PURE__*/React.createElement(Menu.Divider, null), /*#__PURE__*/React.createElement(Menu.Item, {
|
|
2006
|
+
key: "2",
|
|
2024
2007
|
className: "sheet_table-menu_item_text"
|
|
2025
2008
|
}, /*#__PURE__*/React.createElement("a", {
|
|
2026
2009
|
onClick: function onClick() {
|
|
@@ -2028,6 +2011,7 @@ var DataValidation = /*#__PURE__*/function (_React$Component) {
|
|
|
2028
2011
|
}
|
|
2029
2012
|
}, "\u4EC5\u6E05\u7A7A\u9519\u8BEF\u6570\u636E")));
|
|
2030
2013
|
_this.leftMenu = /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(Menu.Item, {
|
|
2014
|
+
key: "3",
|
|
2031
2015
|
className: "sheet_table-menu_item_text"
|
|
2032
2016
|
}, /*#__PURE__*/React.createElement("span", {
|
|
2033
2017
|
className: "sheet_table_text"
|
|
@@ -2161,14 +2145,142 @@ var DataValidation = /*#__PURE__*/function (_React$Component) {
|
|
|
2161
2145
|
return DataValidation;
|
|
2162
2146
|
}(React.Component);
|
|
2163
2147
|
|
|
2148
|
+
var css_248z$1 = ".query_input button {\n width: '50px';\n}\n.query_input_wrapper {\n display: flex;\n}\n.query_input_wrapper_left {\n width: 100px;\n}\n.query_input_wrapper_right {\n color: #9e9e9e;\n}\n.query_input_textArea {\n margin-top: 15px;\n}\n";
|
|
2149
|
+
styleInject(css_248z$1);
|
|
2150
|
+
|
|
2151
|
+
var QueryInput = function QueryInput(_ref) {
|
|
2152
|
+
var onValueChange = _ref.onValueChange;
|
|
2153
|
+
|
|
2154
|
+
var _useState = useState(false),
|
|
2155
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2156
|
+
isModalVisible = _useState2[0],
|
|
2157
|
+
setIsModalVisible = _useState2[1];
|
|
2158
|
+
|
|
2159
|
+
var _useState3 = useState(''),
|
|
2160
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
2161
|
+
value = _useState4[0],
|
|
2162
|
+
setValue = _useState4[1];
|
|
2163
|
+
|
|
2164
|
+
var _useState5 = useState(''),
|
|
2165
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
2166
|
+
popvalue = _useState6[0],
|
|
2167
|
+
setPopValue = _useState6[1];
|
|
2168
|
+
|
|
2169
|
+
var _useDebounceFn = useDebounceFn(function () {
|
|
2170
|
+
formaData(value);
|
|
2171
|
+
}, {
|
|
2172
|
+
wait: 1000
|
|
2173
|
+
}),
|
|
2174
|
+
run = _useDebounceFn.run;
|
|
2175
|
+
|
|
2176
|
+
useEffect(function () {
|
|
2177
|
+
setPopValue(value);
|
|
2178
|
+
onValueChange(value);
|
|
2179
|
+
}, [value]);
|
|
2180
|
+
|
|
2181
|
+
var showModal = function showModal() {
|
|
2182
|
+
setIsModalVisible(true);
|
|
2183
|
+
};
|
|
2184
|
+
|
|
2185
|
+
var handleOk = function handleOk() {
|
|
2186
|
+
formaData(popvalue);
|
|
2187
|
+
setIsModalVisible(false);
|
|
2188
|
+
};
|
|
2189
|
+
|
|
2190
|
+
var formaData = function formaData(value) {
|
|
2191
|
+
var formatValue = ToCDB(value).split(/[/\n/\s,;]/).filter(function (item) {
|
|
2192
|
+
return item;
|
|
2193
|
+
}).join(',');
|
|
2194
|
+
setValue(formatValue);
|
|
2195
|
+
};
|
|
2196
|
+
|
|
2197
|
+
var handleCancel = function handleCancel() {
|
|
2198
|
+
setIsModalVisible(false);
|
|
2199
|
+
};
|
|
2200
|
+
|
|
2201
|
+
var outerChange = function outerChange(e) {
|
|
2202
|
+
setValue(e.target.value);
|
|
2203
|
+
run();
|
|
2204
|
+
};
|
|
2205
|
+
|
|
2206
|
+
var onChange = function onChange(e) {
|
|
2207
|
+
setPopValue(e.target.value);
|
|
2208
|
+
};
|
|
2209
|
+
|
|
2210
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2211
|
+
className: css_248z$1.query_input
|
|
2212
|
+
}, /*#__PURE__*/React.createElement(Input.Group, {
|
|
2213
|
+
compact: true
|
|
2214
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
2215
|
+
value: value,
|
|
2216
|
+
onChange: outerChange,
|
|
2217
|
+
onBlur: function onBlur(e) {
|
|
2218
|
+
formaData(e.target.value);
|
|
2219
|
+
},
|
|
2220
|
+
onPaste: function onPaste(e) {
|
|
2221
|
+
formaData(e.clipboardData.getData('text'));
|
|
2222
|
+
e.preventDefault();
|
|
2223
|
+
},
|
|
2224
|
+
style: {
|
|
2225
|
+
width: 'calc(100% - 50px)'
|
|
2226
|
+
},
|
|
2227
|
+
placeholder: "\u8BF7\u8F93\u5165\uFF08\u67E5\u8BE2\u591A\u4E2A\u503C\u8BF7\u7528 ; \u6216 , \u5206\u5272\uFF09"
|
|
2228
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
2229
|
+
className: css_248z$1.button,
|
|
2230
|
+
onClick: showModal,
|
|
2231
|
+
type: "primary"
|
|
2232
|
+
}, "...")), /*#__PURE__*/React.createElement(Modal, {
|
|
2233
|
+
width: 600,
|
|
2234
|
+
title: "\u591A\u503C\u5F55\u5165",
|
|
2235
|
+
visible: isModalVisible,
|
|
2236
|
+
onOk: handleOk,
|
|
2237
|
+
onCancel: handleCancel,
|
|
2238
|
+
footer: [/*#__PURE__*/React.createElement(Button, {
|
|
2239
|
+
key: "back",
|
|
2240
|
+
onClick: handleCancel
|
|
2241
|
+
}, "\u53D6\u6D88"), /*#__PURE__*/React.createElement(Button, {
|
|
2242
|
+
key: "submit",
|
|
2243
|
+
type: "primary",
|
|
2244
|
+
onClick: handleOk
|
|
2245
|
+
}, "\u5F55\u5165")]
|
|
2246
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2247
|
+
className: css_248z$1.query_input_wrapper
|
|
2248
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2249
|
+
className: css_248z$1.query_input_wrapper_left
|
|
2250
|
+
}, "\u5F55\u5165\u533A\uFF1A"), /*#__PURE__*/React.createElement("div", {
|
|
2251
|
+
className: css_248z$1.query_input_wrapper_right
|
|
2252
|
+
}, /*#__PURE__*/React.createElement("div", null, "\u5982\u9700\u540C\u65F6\u4F7F\u7528\u591A\u4E2A\u503C\u8FDB\u884C\u67E5\u8BE2\uFF0C\u8BF7\u4F7F\u7528\u9017\u53F7\u3001\u5206\u53F7\u3001\u7A7A\u683C\u6216\u6362\u884C\u8FDB\u884C\u503C\u7684\u5206\u9694\uFF0C\u4E2D\u82F1\u6587\u683C\u5F0F\u7684\u7B26\u53F7\u5747\u652F\u6301"), /*#__PURE__*/React.createElement("div", {
|
|
2253
|
+
className: css_248z$1.query_input_textArea
|
|
2254
|
+
}, /*#__PURE__*/React.createElement(Input.TextArea, {
|
|
2255
|
+
value: popvalue,
|
|
2256
|
+
onChange: onChange,
|
|
2257
|
+
rows: 6,
|
|
2258
|
+
showCount: true
|
|
2259
|
+
}))))));
|
|
2260
|
+
};
|
|
2261
|
+
|
|
2262
|
+
function ToCDB(str) {
|
|
2263
|
+
var tmp = '';
|
|
2264
|
+
|
|
2265
|
+
for (var i = 0; i < str.length; i++) {
|
|
2266
|
+
if (str.charCodeAt(i) > 65248 && str.charCodeAt(i) < 65375) {
|
|
2267
|
+
tmp += String.fromCharCode(str.charCodeAt(i) - 65248);
|
|
2268
|
+
} else {
|
|
2269
|
+
tmp += String.fromCharCode(str.charCodeAt(i));
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
return tmp;
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2164
2276
|
/*
|
|
2165
2277
|
* @Description:
|
|
2166
2278
|
* @Author: rodchen
|
|
2167
2279
|
* @Date: 2021-11-30 22:59:39
|
|
2168
|
-
* @LastEditTime: 2021-12-
|
|
2280
|
+
* @LastEditTime: 2021-12-27 20:16:20
|
|
2169
2281
|
* @LastEditors: rodchen
|
|
2170
2282
|
*/
|
|
2171
2283
|
var resposne = JSON.parse(localStorage.getItem('userInfo') || '{}');
|
|
2172
2284
|
axios.defaults.headers.common['sso-sessionid'] = (resposne === null || resposne === void 0 ? void 0 : resposne.sessionId) || '';
|
|
2173
2285
|
|
|
2174
|
-
export { DataValidation };
|
|
2286
|
+
export { DataValidation, QueryInput };
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var antd = require('antd');
|
|
|
8
8
|
var reactBeautifulDnd = require('react-beautiful-dnd');
|
|
9
9
|
require('antd/dist/antd.css');
|
|
10
10
|
var classNames = require('classnames');
|
|
11
|
+
var ahooks = require('ahooks');
|
|
11
12
|
|
|
12
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
14
|
|
|
@@ -20,14 +21,9 @@ function ownKeys(object, enumerableOnly) {
|
|
|
20
21
|
|
|
21
22
|
if (Object.getOwnPropertySymbols) {
|
|
22
23
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
keys.push.apply(keys, symbols);
|
|
24
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
25
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
26
|
+
})), keys.push.apply(keys, symbols);
|
|
31
27
|
}
|
|
32
28
|
|
|
33
29
|
return keys;
|
|
@@ -35,19 +31,12 @@ function ownKeys(object, enumerableOnly) {
|
|
|
35
31
|
|
|
36
32
|
function _objectSpread2(target) {
|
|
37
33
|
for (var i = 1; i < arguments.length; i++) {
|
|
38
|
-
var source = arguments[i]
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
45
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
46
|
-
} else {
|
|
47
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
48
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
49
|
-
});
|
|
50
|
-
}
|
|
34
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
35
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
36
|
+
_defineProperty(target, key, source[key]);
|
|
37
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
38
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
39
|
+
});
|
|
51
40
|
}
|
|
52
41
|
|
|
53
42
|
return target;
|
|
@@ -72,6 +61,9 @@ function _defineProperties(target, props) {
|
|
|
72
61
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
73
62
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
74
63
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
64
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
65
|
+
writable: false
|
|
66
|
+
});
|
|
75
67
|
return Constructor;
|
|
76
68
|
}
|
|
77
69
|
|
|
@@ -95,12 +87,15 @@ function _inherits(subClass, superClass) {
|
|
|
95
87
|
throw new TypeError("Super expression must either be null or a function");
|
|
96
88
|
}
|
|
97
89
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
90
|
+
Object.defineProperty(subClass, "prototype", {
|
|
91
|
+
value: Object.create(superClass && superClass.prototype, {
|
|
92
|
+
constructor: {
|
|
93
|
+
value: subClass,
|
|
94
|
+
writable: true,
|
|
95
|
+
configurable: true
|
|
96
|
+
}
|
|
97
|
+
}),
|
|
98
|
+
writable: false
|
|
104
99
|
});
|
|
105
100
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
106
101
|
}
|
|
@@ -304,14 +299,9 @@ function ownKeys$1(object, enumerableOnly) {
|
|
|
304
299
|
|
|
305
300
|
if (Object.getOwnPropertySymbols) {
|
|
306
301
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
keys.push.apply(keys, symbols);
|
|
302
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
303
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
304
|
+
})), keys.push.apply(keys, symbols);
|
|
315
305
|
}
|
|
316
306
|
|
|
317
307
|
return keys;
|
|
@@ -319,19 +309,12 @@ function ownKeys$1(object, enumerableOnly) {
|
|
|
319
309
|
|
|
320
310
|
function _objectSpread2$1(target) {
|
|
321
311
|
for (var i = 1; i < arguments.length; i++) {
|
|
322
|
-
var source = arguments[i]
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
329
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
330
|
-
} else {
|
|
331
|
-
ownKeys$1(Object(source)).forEach(function (key) {
|
|
332
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
333
|
-
});
|
|
334
|
-
}
|
|
312
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
313
|
+
i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) {
|
|
314
|
+
_defineProperty$1(target, key, source[key]);
|
|
315
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) {
|
|
316
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
317
|
+
});
|
|
335
318
|
}
|
|
336
319
|
|
|
337
320
|
return target;
|
|
@@ -435,17 +418,11 @@ function _objectWithoutProperties$1(source, excluded) {
|
|
|
435
418
|
function _typeof(obj) {
|
|
436
419
|
"@babel/helpers - typeof";
|
|
437
420
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
_typeof = function _typeof(obj) {
|
|
444
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
return _typeof(obj);
|
|
421
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
422
|
+
return typeof obj;
|
|
423
|
+
} : function (obj) {
|
|
424
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
425
|
+
}, _typeof(obj);
|
|
449
426
|
}
|
|
450
427
|
|
|
451
428
|
/**
|
|
@@ -1630,7 +1607,7 @@ var itemsTemp = []; // const mapping = [
|
|
|
1630
1607
|
// { "key": "price", "name": "单价", "rule": "price" }
|
|
1631
1608
|
// ]
|
|
1632
1609
|
|
|
1633
|
-
var mapping = new Map([['skuCode', 'SKU编码'], ['quantity', '数量'], ['price', '单价'], ['regionCode', '库区'], ['checkQuantity', '实盘数量']]); // for dnd
|
|
1610
|
+
var mapping = new Map([['skuCode', 'SKU编码'], ['quantity', '数量'], ['price', '单价'], ['regionCode', '库区'], ['checkQuantity', '实盘数量'], ['shareRatio', '共享比例']]); // for dnd
|
|
1634
1611
|
|
|
1635
1612
|
|
|
1636
1613
|
var reorder = function reorder(list, startIndex, endIndex) {
|
|
@@ -1713,9 +1690,13 @@ var DataValidation = /*#__PURE__*/function (_React$Component) {
|
|
|
1713
1690
|
}
|
|
1714
1691
|
}
|
|
1715
1692
|
},
|
|
1716
|
-
|
|
1693
|
+
cellRenderBefore: function cellRenderBefore(cell, postion, sheetFile, ctx) {
|
|
1717
1694
|
if (cell) {
|
|
1718
1695
|
cell.fs = 10;
|
|
1696
|
+
|
|
1697
|
+
if (typeof cell.v === 'string') {
|
|
1698
|
+
cell.m = cell.v = cell.m.trim();
|
|
1699
|
+
}
|
|
1719
1700
|
} // console.log(postion);
|
|
1720
1701
|
|
|
1721
1702
|
},
|
|
@@ -2025,12 +2006,14 @@ var DataValidation = /*#__PURE__*/function (_React$Component) {
|
|
|
2025
2006
|
};
|
|
2026
2007
|
|
|
2027
2008
|
_this.menuList = /*#__PURE__*/React__default['default'].createElement(antd.Menu, null, /*#__PURE__*/React__default['default'].createElement(antd.Menu.Item, {
|
|
2009
|
+
key: "1",
|
|
2028
2010
|
className: "sheet_table-menu_item_text"
|
|
2029
2011
|
}, /*#__PURE__*/React__default['default'].createElement("a", {
|
|
2030
2012
|
onClick: function onClick() {
|
|
2031
2013
|
return _this.filterData('all');
|
|
2032
2014
|
}
|
|
2033
2015
|
}, "\u6E05\u7A7A\u5168\u90E8\u6570\u636E")), /*#__PURE__*/React__default['default'].createElement(antd.Menu.Divider, null), /*#__PURE__*/React__default['default'].createElement(antd.Menu.Item, {
|
|
2016
|
+
key: "2",
|
|
2034
2017
|
className: "sheet_table-menu_item_text"
|
|
2035
2018
|
}, /*#__PURE__*/React__default['default'].createElement("a", {
|
|
2036
2019
|
onClick: function onClick() {
|
|
@@ -2038,6 +2021,7 @@ var DataValidation = /*#__PURE__*/function (_React$Component) {
|
|
|
2038
2021
|
}
|
|
2039
2022
|
}, "\u4EC5\u6E05\u7A7A\u9519\u8BEF\u6570\u636E")));
|
|
2040
2023
|
_this.leftMenu = /*#__PURE__*/React__default['default'].createElement(antd.Menu, null, /*#__PURE__*/React__default['default'].createElement(antd.Menu.Item, {
|
|
2024
|
+
key: "3",
|
|
2041
2025
|
className: "sheet_table-menu_item_text"
|
|
2042
2026
|
}, /*#__PURE__*/React__default['default'].createElement("span", {
|
|
2043
2027
|
className: "sheet_table_text"
|
|
@@ -2171,14 +2155,143 @@ var DataValidation = /*#__PURE__*/function (_React$Component) {
|
|
|
2171
2155
|
return DataValidation;
|
|
2172
2156
|
}(React__default['default'].Component);
|
|
2173
2157
|
|
|
2158
|
+
var css_248z$1 = ".query_input button {\n width: '50px';\n}\n.query_input_wrapper {\n display: flex;\n}\n.query_input_wrapper_left {\n width: 100px;\n}\n.query_input_wrapper_right {\n color: #9e9e9e;\n}\n.query_input_textArea {\n margin-top: 15px;\n}\n";
|
|
2159
|
+
styleInject(css_248z$1);
|
|
2160
|
+
|
|
2161
|
+
var QueryInput = function QueryInput(_ref) {
|
|
2162
|
+
var onValueChange = _ref.onValueChange;
|
|
2163
|
+
|
|
2164
|
+
var _useState = React.useState(false),
|
|
2165
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2166
|
+
isModalVisible = _useState2[0],
|
|
2167
|
+
setIsModalVisible = _useState2[1];
|
|
2168
|
+
|
|
2169
|
+
var _useState3 = React.useState(''),
|
|
2170
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
2171
|
+
value = _useState4[0],
|
|
2172
|
+
setValue = _useState4[1];
|
|
2173
|
+
|
|
2174
|
+
var _useState5 = React.useState(''),
|
|
2175
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
2176
|
+
popvalue = _useState6[0],
|
|
2177
|
+
setPopValue = _useState6[1];
|
|
2178
|
+
|
|
2179
|
+
var _useDebounceFn = ahooks.useDebounceFn(function () {
|
|
2180
|
+
formaData(value);
|
|
2181
|
+
}, {
|
|
2182
|
+
wait: 1000
|
|
2183
|
+
}),
|
|
2184
|
+
run = _useDebounceFn.run;
|
|
2185
|
+
|
|
2186
|
+
React.useEffect(function () {
|
|
2187
|
+
setPopValue(value);
|
|
2188
|
+
onValueChange(value);
|
|
2189
|
+
}, [value]);
|
|
2190
|
+
|
|
2191
|
+
var showModal = function showModal() {
|
|
2192
|
+
setIsModalVisible(true);
|
|
2193
|
+
};
|
|
2194
|
+
|
|
2195
|
+
var handleOk = function handleOk() {
|
|
2196
|
+
formaData(popvalue);
|
|
2197
|
+
setIsModalVisible(false);
|
|
2198
|
+
};
|
|
2199
|
+
|
|
2200
|
+
var formaData = function formaData(value) {
|
|
2201
|
+
var formatValue = ToCDB(value).split(/[/\n/\s,;]/).filter(function (item) {
|
|
2202
|
+
return item;
|
|
2203
|
+
}).join(',');
|
|
2204
|
+
setValue(formatValue);
|
|
2205
|
+
};
|
|
2206
|
+
|
|
2207
|
+
var handleCancel = function handleCancel() {
|
|
2208
|
+
setIsModalVisible(false);
|
|
2209
|
+
};
|
|
2210
|
+
|
|
2211
|
+
var outerChange = function outerChange(e) {
|
|
2212
|
+
setValue(e.target.value);
|
|
2213
|
+
run();
|
|
2214
|
+
};
|
|
2215
|
+
|
|
2216
|
+
var onChange = function onChange(e) {
|
|
2217
|
+
setPopValue(e.target.value);
|
|
2218
|
+
};
|
|
2219
|
+
|
|
2220
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
2221
|
+
className: css_248z$1.query_input
|
|
2222
|
+
}, /*#__PURE__*/React__default['default'].createElement(antd.Input.Group, {
|
|
2223
|
+
compact: true
|
|
2224
|
+
}, /*#__PURE__*/React__default['default'].createElement(antd.Input, {
|
|
2225
|
+
value: value,
|
|
2226
|
+
onChange: outerChange,
|
|
2227
|
+
onBlur: function onBlur(e) {
|
|
2228
|
+
formaData(e.target.value);
|
|
2229
|
+
},
|
|
2230
|
+
onPaste: function onPaste(e) {
|
|
2231
|
+
formaData(e.clipboardData.getData('text'));
|
|
2232
|
+
e.preventDefault();
|
|
2233
|
+
},
|
|
2234
|
+
style: {
|
|
2235
|
+
width: 'calc(100% - 50px)'
|
|
2236
|
+
},
|
|
2237
|
+
placeholder: "\u8BF7\u8F93\u5165\uFF08\u67E5\u8BE2\u591A\u4E2A\u503C\u8BF7\u7528 ; \u6216 , \u5206\u5272\uFF09"
|
|
2238
|
+
}), /*#__PURE__*/React__default['default'].createElement(antd.Button, {
|
|
2239
|
+
className: css_248z$1.button,
|
|
2240
|
+
onClick: showModal,
|
|
2241
|
+
type: "primary"
|
|
2242
|
+
}, "...")), /*#__PURE__*/React__default['default'].createElement(antd.Modal, {
|
|
2243
|
+
width: 600,
|
|
2244
|
+
title: "\u591A\u503C\u5F55\u5165",
|
|
2245
|
+
visible: isModalVisible,
|
|
2246
|
+
onOk: handleOk,
|
|
2247
|
+
onCancel: handleCancel,
|
|
2248
|
+
footer: [/*#__PURE__*/React__default['default'].createElement(antd.Button, {
|
|
2249
|
+
key: "back",
|
|
2250
|
+
onClick: handleCancel
|
|
2251
|
+
}, "\u53D6\u6D88"), /*#__PURE__*/React__default['default'].createElement(antd.Button, {
|
|
2252
|
+
key: "submit",
|
|
2253
|
+
type: "primary",
|
|
2254
|
+
onClick: handleOk
|
|
2255
|
+
}, "\u5F55\u5165")]
|
|
2256
|
+
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
2257
|
+
className: css_248z$1.query_input_wrapper
|
|
2258
|
+
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
2259
|
+
className: css_248z$1.query_input_wrapper_left
|
|
2260
|
+
}, "\u5F55\u5165\u533A\uFF1A"), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
2261
|
+
className: css_248z$1.query_input_wrapper_right
|
|
2262
|
+
}, /*#__PURE__*/React__default['default'].createElement("div", null, "\u5982\u9700\u540C\u65F6\u4F7F\u7528\u591A\u4E2A\u503C\u8FDB\u884C\u67E5\u8BE2\uFF0C\u8BF7\u4F7F\u7528\u9017\u53F7\u3001\u5206\u53F7\u3001\u7A7A\u683C\u6216\u6362\u884C\u8FDB\u884C\u503C\u7684\u5206\u9694\uFF0C\u4E2D\u82F1\u6587\u683C\u5F0F\u7684\u7B26\u53F7\u5747\u652F\u6301"), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
2263
|
+
className: css_248z$1.query_input_textArea
|
|
2264
|
+
}, /*#__PURE__*/React__default['default'].createElement(antd.Input.TextArea, {
|
|
2265
|
+
value: popvalue,
|
|
2266
|
+
onChange: onChange,
|
|
2267
|
+
rows: 6,
|
|
2268
|
+
showCount: true
|
|
2269
|
+
}))))));
|
|
2270
|
+
};
|
|
2271
|
+
|
|
2272
|
+
function ToCDB(str) {
|
|
2273
|
+
var tmp = '';
|
|
2274
|
+
|
|
2275
|
+
for (var i = 0; i < str.length; i++) {
|
|
2276
|
+
if (str.charCodeAt(i) > 65248 && str.charCodeAt(i) < 65375) {
|
|
2277
|
+
tmp += String.fromCharCode(str.charCodeAt(i) - 65248);
|
|
2278
|
+
} else {
|
|
2279
|
+
tmp += String.fromCharCode(str.charCodeAt(i));
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
return tmp;
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2174
2286
|
/*
|
|
2175
2287
|
* @Description:
|
|
2176
2288
|
* @Author: rodchen
|
|
2177
2289
|
* @Date: 2021-11-30 22:59:39
|
|
2178
|
-
* @LastEditTime: 2021-12-
|
|
2290
|
+
* @LastEditTime: 2021-12-27 20:16:20
|
|
2179
2291
|
* @LastEditors: rodchen
|
|
2180
2292
|
*/
|
|
2181
2293
|
var resposne = JSON.parse(localStorage.getItem('userInfo') || '{}');
|
|
2182
2294
|
axios__default['default'].defaults.headers.common['sso-sessionid'] = (resposne === null || resposne === void 0 ? void 0 : resposne.sessionId) || '';
|
|
2183
2295
|
|
|
2184
2296
|
exports.DataValidation = DataValidation;
|
|
2297
|
+
exports.QueryInput = QueryInput;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bit-sun/business-component",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"start": "dumi dev",
|
|
6
6
|
"docs:build": "dumi build",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
]
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
+
"ahooks": "^3.1.2",
|
|
30
31
|
"antd": "4.17.2",
|
|
31
32
|
"axios": "^0.24.0",
|
|
32
33
|
"bs-business-component": "^1.0.1",
|
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav:
|
|
3
|
+
title: '组件'
|
|
4
|
+
order: 1
|
|
5
|
+
group:
|
|
6
|
+
title: 组件
|
|
7
|
+
order: 0
|
|
8
|
+
title: 数据校验
|
|
9
|
+
order: 1
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## DataValidation
|
|
13
|
+
|
|
14
|
+
Demo:
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import React, { useRef } from 'react';
|
|
18
|
+
import { DataValidation } from '../../index';
|
|
19
|
+
|
|
20
|
+
export default () => {
|
|
21
|
+
let dataValidationRef: DataValidation = useRef();
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div>
|
|
25
|
+
<DataValidation
|
|
26
|
+
columns={['skuCode', 'quantity', 'price']}
|
|
27
|
+
onRef={(ref) => {
|
|
28
|
+
dataValidationRef = ref;
|
|
29
|
+
}}
|
|
30
|
+
/>
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
More skills for writing demo: https://d.umijs.org/guide/demo-principle
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Description:
|
|
3
3
|
* @Author: rodchen
|
|
4
4
|
* @Date: 2021-12-01 10:52:08
|
|
5
|
-
* @LastEditTime: 2021-12-
|
|
5
|
+
* @LastEditTime: 2021-12-22 14:24:35
|
|
6
6
|
* @LastEditors: rodchen
|
|
7
7
|
*/
|
|
8
8
|
// @ts-nocheck
|
|
@@ -45,6 +45,7 @@ const mapping = new Map([
|
|
|
45
45
|
['price', '单价'],
|
|
46
46
|
['regionCode', '库区'],
|
|
47
47
|
['checkQuantity', '实盘数量'],
|
|
48
|
+
['shareRatio', '共享比例'],
|
|
48
49
|
]);
|
|
49
50
|
|
|
50
51
|
// for dnd
|
|
@@ -165,9 +166,13 @@ class DataValidation extends React.Component {
|
|
|
165
166
|
}
|
|
166
167
|
}
|
|
167
168
|
},
|
|
168
|
-
|
|
169
|
+
cellRenderBefore: function (cell, postion, sheetFile, ctx) {
|
|
169
170
|
if (cell) {
|
|
170
171
|
cell.fs = 10;
|
|
172
|
+
|
|
173
|
+
if (typeof cell.v === 'string') {
|
|
174
|
+
cell.m = cell.v = cell.m.trim();
|
|
175
|
+
}
|
|
171
176
|
}
|
|
172
177
|
// console.log(postion);
|
|
173
178
|
},
|
|
@@ -471,11 +476,11 @@ class DataValidation extends React.Component {
|
|
|
471
476
|
|
|
472
477
|
menuList = (
|
|
473
478
|
<Menu>
|
|
474
|
-
<Menu.Item className="sheet_table-menu_item_text">
|
|
479
|
+
<Menu.Item key="1" className="sheet_table-menu_item_text">
|
|
475
480
|
<a onClick={() => this.filterData('all')}>清空全部数据</a>
|
|
476
481
|
</Menu.Item>
|
|
477
482
|
<Menu.Divider />
|
|
478
|
-
<Menu.Item className="sheet_table-menu_item_text">
|
|
483
|
+
<Menu.Item key="2" className="sheet_table-menu_item_text">
|
|
479
484
|
<a onClick={() => this.filterData('error')}>仅清空错误数据</a>
|
|
480
485
|
</Menu.Item>
|
|
481
486
|
</Menu>
|
|
@@ -483,7 +488,7 @@ class DataValidation extends React.Component {
|
|
|
483
488
|
|
|
484
489
|
leftMenu = (
|
|
485
490
|
<Menu>
|
|
486
|
-
<Menu.Item className="sheet_table-menu_item_text">
|
|
491
|
+
<Menu.Item key="3" className="sheet_table-menu_item_text">
|
|
487
492
|
<span className="sheet_table_text">请拖动字段来对应列</span>
|
|
488
493
|
</Menu.Item>
|
|
489
494
|
<Menu.Divider />
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav:
|
|
3
|
+
title: '组件'
|
|
4
|
+
order: 1
|
|
5
|
+
group:
|
|
6
|
+
title: 组件
|
|
7
|
+
order: 0
|
|
8
|
+
title: 批量查询组件
|
|
9
|
+
order: 1
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## QueryInput
|
|
13
|
+
|
|
14
|
+
Demo:
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import React, { useRef } from 'react';
|
|
18
|
+
import { QueryInput } from '../../index';
|
|
19
|
+
|
|
20
|
+
export default () => {
|
|
21
|
+
const handleOnChange = (value) => {
|
|
22
|
+
console.log(value);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div>
|
|
27
|
+
<QueryInput onValueChange={handleOnChange} />
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
More skills for writing demo: https://d.umijs.org/guide/demo-principle
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Description:
|
|
3
|
+
* @Author: rodchen
|
|
4
|
+
* @Date: 2021-12-01 10:52:08
|
|
5
|
+
* @LastEditTime: 2021-12-29 14:19:32
|
|
6
|
+
* @LastEditors: rodchen
|
|
7
|
+
*/
|
|
8
|
+
// @ts-nocheck
|
|
9
|
+
import React, { useState, useEffect } from 'react';
|
|
10
|
+
import { useDebounceFn } from 'ahooks';
|
|
11
|
+
import { Input, Button, Modal } from 'antd';
|
|
12
|
+
import 'antd/dist/antd.css';
|
|
13
|
+
import styles from './index.less';
|
|
14
|
+
|
|
15
|
+
const QueryInput = ({ onValueChange }) => {
|
|
16
|
+
const [isModalVisible, setIsModalVisible] = useState(false);
|
|
17
|
+
const [value, setValue] = useState('');
|
|
18
|
+
const [popvalue, setPopValue] = useState('');
|
|
19
|
+
const { run } = useDebounceFn(
|
|
20
|
+
() => {
|
|
21
|
+
formaData(value);
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
wait: 1000,
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
setPopValue(value);
|
|
30
|
+
onValueChange(value);
|
|
31
|
+
}, [value]);
|
|
32
|
+
|
|
33
|
+
const showModal = () => {
|
|
34
|
+
setIsModalVisible(true);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const handleOk = () => {
|
|
38
|
+
formaData(popvalue);
|
|
39
|
+
setIsModalVisible(false);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const formaData = (value) => {
|
|
43
|
+
let formatValue = ToCDB(value)
|
|
44
|
+
.split(/[/\n/\s,;]/)
|
|
45
|
+
.filter((item) => item)
|
|
46
|
+
.join(',');
|
|
47
|
+
setValue(formatValue);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const handleCancel = () => {
|
|
51
|
+
setIsModalVisible(false);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const outerChange = (e) => {
|
|
55
|
+
setValue(e.target.value);
|
|
56
|
+
run();
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const onChange = (e) => {
|
|
60
|
+
setPopValue(e.target.value);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div className={styles.query_input}>
|
|
65
|
+
<Input.Group compact>
|
|
66
|
+
<Input
|
|
67
|
+
value={value}
|
|
68
|
+
onChange={outerChange}
|
|
69
|
+
onBlur={(e) => {
|
|
70
|
+
formaData(e.target.value);
|
|
71
|
+
}}
|
|
72
|
+
onPaste={(e) => {
|
|
73
|
+
formaData(e.clipboardData.getData('text'));
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
}}
|
|
76
|
+
style={{ width: 'calc(100% - 50px)' }}
|
|
77
|
+
placeholder="请输入(查询多个值请用 ; 或 , 分割)"
|
|
78
|
+
/>
|
|
79
|
+
<Button className={styles.button} onClick={showModal} type="primary">
|
|
80
|
+
...
|
|
81
|
+
</Button>
|
|
82
|
+
</Input.Group>
|
|
83
|
+
<Modal
|
|
84
|
+
width={600}
|
|
85
|
+
title="多值录入"
|
|
86
|
+
visible={isModalVisible}
|
|
87
|
+
onOk={handleOk}
|
|
88
|
+
onCancel={handleCancel}
|
|
89
|
+
footer={[
|
|
90
|
+
<Button key="back" onClick={handleCancel}>
|
|
91
|
+
取消
|
|
92
|
+
</Button>,
|
|
93
|
+
<Button key="submit" type="primary" onClick={handleOk}>
|
|
94
|
+
录入
|
|
95
|
+
</Button>,
|
|
96
|
+
]}
|
|
97
|
+
>
|
|
98
|
+
<div className={styles.query_input_wrapper}>
|
|
99
|
+
<div className={styles.query_input_wrapper_left}>录入区:</div>
|
|
100
|
+
<div className={styles.query_input_wrapper_right}>
|
|
101
|
+
<div>
|
|
102
|
+
如需同时使用多个值进行查询,请使用逗号、分号、空格或换行进行值的分隔,中英文格式的符号均支持
|
|
103
|
+
</div>
|
|
104
|
+
<div className={styles.query_input_textArea}>
|
|
105
|
+
<Input.TextArea
|
|
106
|
+
value={popvalue}
|
|
107
|
+
onChange={onChange}
|
|
108
|
+
rows={6}
|
|
109
|
+
showCount
|
|
110
|
+
/>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
</Modal>
|
|
115
|
+
</div>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
function ToCDB(str) {
|
|
120
|
+
var tmp = '';
|
|
121
|
+
for (var i = 0; i < str.length; i++) {
|
|
122
|
+
if (str.charCodeAt(i) > 65248 && str.charCodeAt(i) < 65375) {
|
|
123
|
+
tmp += String.fromCharCode(str.charCodeAt(i) - 65248);
|
|
124
|
+
} else {
|
|
125
|
+
tmp += String.fromCharCode(str.charCodeAt(i));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return tmp;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export default QueryInput;
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Description:
|
|
3
3
|
* @Author: rodchen
|
|
4
4
|
* @Date: 2021-11-30 22:59:39
|
|
5
|
-
* @LastEditTime: 2021-12-
|
|
5
|
+
* @LastEditTime: 2021-12-27 20:16:20
|
|
6
6
|
* @LastEditors: rodchen
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -12,4 +12,5 @@ const resposne = JSON.parse(localStorage.getItem('userInfo') || '{}');
|
|
|
12
12
|
|
|
13
13
|
axios.defaults.headers.common['sso-sessionid'] = resposne?.sessionId || '';
|
|
14
14
|
|
|
15
|
-
export { default as DataValidation } from './DataValidation';
|
|
15
|
+
export { default as DataValidation } from './components/DataValidation';
|
|
16
|
+
export { default as QueryInput } from './components/QueryInput';
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
nav:
|
|
3
|
-
title: Components
|
|
4
|
-
path: /components
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## DataValidation
|
|
8
|
-
|
|
9
|
-
Demo:
|
|
10
|
-
|
|
11
|
-
```tsx
|
|
12
|
-
import React from 'react';
|
|
13
|
-
import { DataValidation } from '../index';
|
|
14
|
-
|
|
15
|
-
export default () => (
|
|
16
|
-
<div>
|
|
17
|
-
<DataValidation
|
|
18
|
-
columns={[
|
|
19
|
-
['商品编码', 'skuCode'],
|
|
20
|
-
['商品名称', 'skuName'],
|
|
21
|
-
['商品名称1', 'skuName'],
|
|
22
|
-
]}
|
|
23
|
-
validDataFunction={(data, resolve) => {
|
|
24
|
-
resolve([]);
|
|
25
|
-
}}
|
|
26
|
-
title="商品录入"
|
|
27
|
-
/>
|
|
28
|
-
</div>
|
|
29
|
-
);
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
More skills for writing demo: https://d.umijs.org/guide/demo-principle
|