@bit-sun/business-component 4.0.13-alpha.34 → 4.0.13-alpha.35
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/Functional/DataValidation/index.d.ts +11 -1
- package/dist/index.esm.js +581 -432
- package/dist/index.js +582 -433
- package/package.json +1 -1
- package/src/components/Functional/DataValidation/index.tsx +127 -19
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
} from '@ant-design/icons';
|
|
29
29
|
import request from '@/utils/request';
|
|
30
30
|
import './index.less';
|
|
31
|
-
import _ from "lodash"
|
|
31
|
+
import _, { ceil, isNumber } from "lodash"
|
|
32
32
|
import { judgeIsRequestError } from '@/utils/requestUtils';
|
|
33
33
|
import { readerXlsxToList } from '@/utils/xlsxUtil';
|
|
34
34
|
|
|
@@ -179,10 +179,26 @@ class DataValidation extends React.Component {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
getCount = () => {
|
|
182
|
-
const { resultData } = this.state;
|
|
182
|
+
const { resultData = [] } = this.state;
|
|
183
|
+
const totalQuantity = resultData.reduce((total, item) => {
|
|
184
|
+
total += Number(item.quantity || 0);
|
|
185
|
+
return total;
|
|
186
|
+
}, 0);
|
|
187
|
+
const totalSuccessQuantity = resultData.filter(item => item.flag).reduce((total, item) => {
|
|
188
|
+
total += Number(item.quantity || 0);
|
|
189
|
+
return total;
|
|
190
|
+
}, 0);
|
|
191
|
+
const totalErrorQuantity = resultData.filter(item => !item.flag).reduce((total, item) => {
|
|
192
|
+
total += Number(item.quantity || 0);
|
|
193
|
+
return total;
|
|
194
|
+
}, 0);
|
|
183
195
|
return {
|
|
184
196
|
total: resultData.length,
|
|
197
|
+
totalQuantity,
|
|
198
|
+
totalSuccessQuantity,
|
|
199
|
+
totalErrorQuantity,
|
|
185
200
|
error: resultData.filter((item) => !item.flag).length,
|
|
201
|
+
success: resultData.filter((item) => item.flag).length,
|
|
186
202
|
};
|
|
187
203
|
};
|
|
188
204
|
|
|
@@ -191,7 +207,7 @@ class DataValidation extends React.Component {
|
|
|
191
207
|
const { notValid } = this.props;
|
|
192
208
|
return {
|
|
193
209
|
container: 'luckysheet',
|
|
194
|
-
showtoolbar: false,
|
|
210
|
+
// showtoolbar: false,
|
|
195
211
|
hook: {
|
|
196
212
|
columnTitleCellRenderBefore: function (columnAbc, postion, ctx) {
|
|
197
213
|
if (columnAbc.name) {
|
|
@@ -233,18 +249,9 @@ class DataValidation extends React.Component {
|
|
|
233
249
|
// console.info(data,sheetFile,ctx)
|
|
234
250
|
},
|
|
235
251
|
},
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
// currencyFormat: false, //货币格式
|
|
240
|
-
// percentageFormat: false, //百分比格式
|
|
241
|
-
// numberDecrease: false, // '减少小数位数'
|
|
242
|
-
// numberIncrease: false, // '增加小数位数
|
|
243
|
-
// moreFormats: false, // '更多格式'
|
|
244
|
-
// font: true, // '字体'
|
|
245
|
-
// fontSize: true, // '字号大小'
|
|
246
|
-
|
|
247
|
-
// },
|
|
252
|
+
showtoolbarConfig: {
|
|
253
|
+
sortAndFilter: true,
|
|
254
|
+
},
|
|
248
255
|
data: [
|
|
249
256
|
{
|
|
250
257
|
name: 'Cell', //工作表名称
|
|
@@ -365,7 +372,7 @@ class DataValidation extends React.Component {
|
|
|
365
372
|
showsheetbar: false,
|
|
366
373
|
optionstate: false,
|
|
367
374
|
showstatisticBarConfig: {
|
|
368
|
-
count:
|
|
375
|
+
count: true, // 计数栏
|
|
369
376
|
view: false, // 打印视图
|
|
370
377
|
zoom: false, // 缩放
|
|
371
378
|
},
|
|
@@ -422,6 +429,54 @@ class DataValidation extends React.Component {
|
|
|
422
429
|
return data.filter(d => _.compact(Object.values(d)).length);
|
|
423
430
|
};
|
|
424
431
|
|
|
432
|
+
naturalCompare = (a, b) => {
|
|
433
|
+
const checkNumber = (value) => {
|
|
434
|
+
return /^[-+]?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/.test(value.trim())
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
if (checkNumber(a) && checkNumber(b)) {
|
|
438
|
+
return Number(a) - Number(b);
|
|
439
|
+
}
|
|
440
|
+
// 优先处理 "通过" 的情况
|
|
441
|
+
if (a === "通过" && b !== "通过") return -1;
|
|
442
|
+
if (b === "通过" && a !== "通过") return 1;
|
|
443
|
+
|
|
444
|
+
return a.localeCompare(b);
|
|
445
|
+
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
customSort = (a, b) => {
|
|
449
|
+
|
|
450
|
+
// 处理空值
|
|
451
|
+
const aEmpty = !a;
|
|
452
|
+
|
|
453
|
+
const bEmpty = !b;
|
|
454
|
+
|
|
455
|
+
if (aEmpty && bEmpty) return 0;
|
|
456
|
+
|
|
457
|
+
if (aEmpty) return 1; // a空,排后面
|
|
458
|
+
|
|
459
|
+
if (bEmpty) return -1; // b空,a排前面
|
|
460
|
+
|
|
461
|
+
return this.naturalCompare(a, b);
|
|
462
|
+
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
sortData = (sorterKey: string) => {
|
|
466
|
+
let sheetData = luckysheet.getSheetData();
|
|
467
|
+
let newData = JSON.parse(JSON.stringify(sheetData)).sort((cur, prev) => {
|
|
468
|
+
let cellIndex = itemsTemp.findIndex(item => item.code === sorterKey);
|
|
469
|
+
if (sorterKey === 'checkresult') {
|
|
470
|
+
cellIndex = itemsTemp.length;
|
|
471
|
+
}
|
|
472
|
+
return this.customSort(cur[cellIndex]?.v, prev[cellIndex]?.v);
|
|
473
|
+
})
|
|
474
|
+
luckysheet.create(this.setConfig(luckysheet.transToCellData(newData)));
|
|
475
|
+
this.setState({
|
|
476
|
+
data: luckysheet.transToCellData(newData),
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
|
|
425
480
|
resetData = () => {
|
|
426
481
|
const { validDataUrl, validDataParams, updateData, columns, isBrandAuth, isCheckStockNum = true, customerColumnsMapping } = this.props;
|
|
427
482
|
const resultData = this.getData().filter(d => {
|
|
@@ -523,7 +578,6 @@ class DataValidation extends React.Component {
|
|
|
523
578
|
|
|
524
579
|
toggleData = () => {
|
|
525
580
|
const { showErrorData, data } = this.state;
|
|
526
|
-
|
|
527
581
|
if (showErrorData) {
|
|
528
582
|
luckysheet.create(this.setConfig(data));
|
|
529
583
|
} else {
|
|
@@ -615,6 +669,44 @@ class DataValidation extends React.Component {
|
|
|
615
669
|
</div>
|
|
616
670
|
</Menu>
|
|
617
671
|
);
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
getSortList = () => {
|
|
675
|
+
let sortList = []
|
|
676
|
+
if (this.props?.customerColumnsMapping?.length) {
|
|
677
|
+
sortList = this.props?.customerColumnsMapping?.map((item, index) => {
|
|
678
|
+
return createItem('item-0', index, item.title, item.name, this.format);
|
|
679
|
+
})||[]
|
|
680
|
+
} else {
|
|
681
|
+
sortList = this.props?.columns?.map((item, index) => {
|
|
682
|
+
if (!mapping.get(item))
|
|
683
|
+
throw Error(
|
|
684
|
+
`${item} is not in DataValidation component, please fix this error`,
|
|
685
|
+
);
|
|
686
|
+
return createItem('item-0', index, mapping.get(item), item, this.format);
|
|
687
|
+
})||[];
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
return (
|
|
691
|
+
<Menu>
|
|
692
|
+
{
|
|
693
|
+
(sortList || []).map((item, index) =>{
|
|
694
|
+
return (
|
|
695
|
+
<>
|
|
696
|
+
<Menu.Item key={index} className="sheet_table-menu_item_text">
|
|
697
|
+
<a onClick={() => this.sortData(item.code)}>{item.content}</a>
|
|
698
|
+
</Menu.Item>
|
|
699
|
+
<Menu.Divider />
|
|
700
|
+
</>
|
|
701
|
+
)
|
|
702
|
+
})
|
|
703
|
+
}
|
|
704
|
+
<Menu.Item key="checkresult" className="sheet_table-menu_item_text">
|
|
705
|
+
<a onClick={() => this.sortData('checkresult')}>校验结果</a>
|
|
706
|
+
</Menu.Item>
|
|
707
|
+
</Menu>
|
|
708
|
+
)
|
|
709
|
+
}
|
|
618
710
|
|
|
619
711
|
getSheetMap = () => {
|
|
620
712
|
const { customerColumnsMapping, columns } = this.props;
|
|
@@ -708,6 +800,8 @@ class DataValidation extends React.Component {
|
|
|
708
800
|
left: '0px',
|
|
709
801
|
top: '0px',
|
|
710
802
|
};
|
|
803
|
+
|
|
804
|
+
console.log('itemsTemp', itemsTemp)
|
|
711
805
|
return (
|
|
712
806
|
<>
|
|
713
807
|
<div className="sheet_table_top">
|
|
@@ -766,6 +860,16 @@ class DataValidation extends React.Component {
|
|
|
766
860
|
<DownOutlined />
|
|
767
861
|
</Button>
|
|
768
862
|
</Dropdown>
|
|
863
|
+
<Dropdown
|
|
864
|
+
trigger={['click']}
|
|
865
|
+
overlay={this.getSortList()}
|
|
866
|
+
placement="bottomRight"
|
|
867
|
+
>
|
|
868
|
+
<Button>
|
|
869
|
+
排序
|
|
870
|
+
<DownOutlined />
|
|
871
|
+
</Button>
|
|
872
|
+
</Dropdown>
|
|
769
873
|
|
|
770
874
|
{!notValid && <Button type="primary" onClick={this.resetData}>
|
|
771
875
|
识别
|
|
@@ -776,9 +880,13 @@ class DataValidation extends React.Component {
|
|
|
776
880
|
<div style={{ position: 'relative', height: '400px' }}>
|
|
777
881
|
<div id="luckysheet" style={luckyCss}></div>
|
|
778
882
|
</div>
|
|
779
|
-
{!this.props.notValid && <div className="sheet_table_footer">
|
|
883
|
+
{!this.props.notValid && !!totalSummary.total && <div className="sheet_table_footer">
|
|
780
884
|
<span className="sheet_table_footer_l">
|
|
781
|
-
共 {totalSummary.total}
|
|
885
|
+
共 {totalSummary.total} 条数据:
|
|
886
|
+
<span style={{color: 'green', marginLeft: '5px'}}> 成功条数:</span>{totalSummary.success}
|
|
887
|
+
<span style={{color: 'green', marginLeft: '5px'}}> 成功数量:</span>{totalSummary.totalSuccessQuantity || 0}
|
|
888
|
+
<span style={{color: 'red', marginLeft: '5px'}}> 失败条数:</span>{totalSummary.error || 0}
|
|
889
|
+
<span style={{color: 'red', marginLeft: '5px'}}> 失败数量:</span>{totalSummary.totalErrorQuantity || 0}
|
|
782
890
|
</span>
|
|
783
891
|
{!notValid && <Space className="sheet_table_footer_r">
|
|
784
892
|
<Checkbox
|