@bit-sun/business-component 2.1.0 → 2.1.1-alpha.0

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.
@@ -9,6 +9,8 @@ import _ from "lodash"
9
9
  import './index.less';
10
10
  import { BusinessSearchSelect, QueryMutipleInput } from '@/index';
11
11
  import { Resizable } from 'react-resizable';
12
+ import { checkQuantityAccuracy, precisionQuantity } from '@/utils/checkUtils';
13
+ import { getModalContainer } from '@/utils/utils';
12
14
 
13
15
  const loadSelectSource = (url: string, params?: any) => {
14
16
  return new Promise((resolve, reject) => {
@@ -715,15 +717,44 @@ const AddSelect = (props: any) => {
715
717
  // let
716
718
  if(record.needFocus === true && currentIndex === 0) {
717
719
 
720
+ }
721
+ let precisionObj={};
722
+ const unitAccuracy = record.packingUnitList?.[0]?.unitAccuracy
723
+ const isCountUnitAccuracyCheck = item.dataIndex =='count' && unitAccuracy !== undefined
724
+ if(isCountUnitAccuracyCheck) {
725
+ precisionObj = {
726
+ onBlur: (e: any) => {
727
+ const { target: { value } } = e;
728
+ if(!checkQuantityAccuracy(value,Number(unitAccuracy))) {
729
+ record[item.dataIndex] = precisionQuantity(value,Number(unitAccuracy))
730
+ const newPopValue = popvalue.map((i: any, innerIndex: number) => {
731
+ if(innerIndex == index) {
732
+ i[item.dataIndex] = record[item.dataIndex]
733
+ }
734
+ return i
735
+ })
736
+ setPopValue(newPopValue)
737
+ }
738
+ }
739
+ // precision: unitAccuracy
740
+ }
718
741
  }
719
742
  return (
720
743
  <InputNumber
721
- defaultValue={text || ''}
744
+ value={text || ''}
722
745
  min={0}
723
746
  autoFocus={record.needFocus}
724
747
  keyboard={false}
748
+ {...precisionObj}
725
749
  onChange={(value) => {
726
750
  record[item.dataIndex] = value
751
+ const newPopValue = popvalue.map((i: any, innerIndex: number) => {
752
+ if(innerIndex == index) {
753
+ i[item.dataIndex] = record[item.dataIndex]
754
+ }
755
+ return i
756
+ })
757
+ setPopValue(newPopValue)
727
758
  }}
728
759
  // onFocus={(e)=> {
729
760
  // let dom1 = e.currentTarget;
@@ -845,6 +876,7 @@ const AddSelect = (props: any) => {
845
876
  bodyStyle={{ padding: '0px' }}
846
877
  // title={modalTableProps?.modalTableTitle}
847
878
  visible={isModalVisible}
879
+ getContainer={getModalContainer}
848
880
  closable={false}
849
881
  onCancel={handleCancel}
850
882
  footer={selectMode ? [
@@ -5,6 +5,7 @@ import { SearchOutlined, CopyOutlined, CloseCircleOutlined } from '@ant-design/i
5
5
  import { stringify } from 'querystring';
6
6
  import './index.less';
7
7
  import axios from 'axios';
8
+ import { checkQuantityAccuracy, precisionQuantity } from '@/utils/checkUtils';
8
9
 
9
10
  const InputElement = ({
10
11
  record, text, currentIndex, inputLength, index, setData, data, item, callSelectItem
@@ -212,6 +213,27 @@ const InputElement = ({
212
213
  </div>
213
214
  }
214
215
 
216
+ let precisionObj={};
217
+ const unitAccuracy = record.packingUnitList?.[0]?.unitAccuracy
218
+ const isCountUnitAccuracyCheck = item.dataIndex =='count' && unitAccuracy !== undefined
219
+ if(isCountUnitAccuracyCheck) {
220
+ precisionObj = {
221
+ onBlur: (e: any) => {
222
+ const { target: { value } } = e;
223
+ if(!checkQuantityAccuracy(value,Number(unitAccuracy))) {
224
+ record[item.dataIndex] = precisionQuantity(value,Number(unitAccuracy))
225
+ const newData = data.map((i: any, innerIndex: number) => {
226
+ if(innerIndex == index) {
227
+ i[item.dataIndex] = record[item.dataIndex]
228
+ }
229
+ return i
230
+ })
231
+ setData(newData)
232
+ }
233
+ }
234
+ // precision: unitAccuracy
235
+ }
236
+ }
215
237
 
216
238
  return (
217
239
  <Popover placement="bottomLeft" destroyTooltipOnHide={{ keepParent: false }} title="" trigger="" content={SearchDataTable(hoverVisibled)} visible={hoverVisibled} onVisibleChange={(disabled) => { updateHoverVisibled(disabled) }}>
@@ -313,11 +335,19 @@ const InputElement = ({
313
335
  :
314
336
  <InputNumber
315
337
  // onBlur={() => {updateHoverVisibled(false)}}
316
- defaultValue={text || ''}
338
+ value={text || ''}
317
339
  min={0}
318
340
  keyboard={false}
341
+ {...precisionObj}
319
342
  onChange={(value) => {
320
343
  record[item.dataIndex] = value
344
+ const newData = data.map((i: any, innerIndex: number) => {
345
+ if(innerIndex == index) {
346
+ i[item.dataIndex] = record[item.dataIndex]
347
+ }
348
+ return i
349
+ })
350
+ setData(newData)
321
351
  }}
322
352
  onKeyDown={(e) => {
323
353
  // if (e.keyCode === 13 && e.ctrlKey) {
@@ -10,6 +10,7 @@ import React, { useState, useEffect } from 'react';
10
10
  import { useDebounceFn } from 'ahooks';
11
11
  import { Input, Button, Modal } from 'antd';
12
12
  import './index.less';
13
+ import { getModalContainer } from '@/utils/utils';
13
14
 
14
15
  const QueryMutipleInput = ({ onValueChange }) => {
15
16
  const [isModalVisible, setIsModalVisible] = useState(false);
@@ -79,6 +80,7 @@ const QueryMutipleInput = ({ onValueChange }) => {
79
80
  </div>
80
81
  <Modal
81
82
  width={600}
83
+ getContainer={getModalContainer}
82
84
  title="多值录入"
83
85
  visible={isModalVisible}
84
86
  onOk={handleOk}
@@ -8,6 +8,7 @@ import { stringify } from 'querystring';
8
8
  import _ from "lodash"
9
9
  import './index.less';
10
10
  import { BusinessSearchSelect, QueryMutipleInput } from '@/index';
11
+ import { getModalContainer } from '@/utils/utils';
11
12
 
12
13
  const { Option } = Select;
13
14
 
@@ -743,6 +744,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
743
744
  <Modal
744
745
  width='80%'
745
746
  title={modalTableProps?.modalTableTitle}
747
+ getContainer={getModalContainer}
746
748
  visible={isModalVisible}
747
749
  onOk={handleOk}
748
750
  onCancel={handleCancel}
package/src/index.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * @LastEditors: rodchen
7
7
  */
8
8
  // import 'antd/dist/antd.css';
9
- import './utils/requestUtils';
9
+ import './utils/index';
10
10
 
11
11
  export { default as DataValidation } from './components/Functional/DataValidation';
12
12
  export { default as DataImport } from './components/Functional/DataImport';
@@ -28,4 +28,4 @@ export { default as ColumnSettingTable} from './components/Business/columnSettin
28
28
  export { default as DetailPageWrapper } from './components/Business/DetailPageWrapper';
29
29
  export { default as HomePageWrapper } from './components/Business/HomePageWrapper';
30
30
  export { default as BsSulaQueryTable } from './components/Business/BsSulaQueryTable';
31
- export { default as BsLayout } from './components/Business/BsLayouts';
31
+ export { default as BsLayout } from './components/Business/BsLayouts'
@@ -0,0 +1,39 @@
1
+ import { message } from 'antd';
2
+ import _ from 'lodash';
3
+
4
+ const checkQuantityAccuracy = (value: any, accuracy: any, errorInfo?: any) => {
5
+ let errorMessage= {showTips: true, tipsMessage: null,...errorInfo}
6
+ if (_.trim(value)) {
7
+ const target = `${value}`;
8
+ if (target.includes(".")) {
9
+ if (target.split(".")[1].length > accuracy) {
10
+ if(errorMessage?.showTips) {
11
+ message.warning(errorMessage?.tipsMessage || `系统设置数量最大精度为${accuracy}位`)
12
+ }
13
+ return false;
14
+ }
15
+ }
16
+ }
17
+ return true;
18
+ }
19
+
20
+ const precisionQuantity = (num: any, accuracy: any) => {
21
+ if (_.trim(num)) {
22
+ const target = `${num}`;
23
+ if (target.includes(".")) {
24
+ if (target.split(".")[1].length > accuracy) {
25
+ const beforeDot = target.split(".")[0];
26
+ const afterDot = target.split(".")[1]?.slice(0,accuracy)
27
+ const result = accuracy == 0 ? Number(`${beforeDot}`) : Number(`${beforeDot}.${afterDot}`)
28
+ return result
29
+ } else if (target.split(".")[1].length < accuracy) {
30
+ return Number(Number(num).toFixed(Math.abs(accuracy)))
31
+ } else {
32
+ return Number(num)
33
+ }
34
+ }
35
+ }
36
+ return ''
37
+ }
38
+
39
+ export { checkQuantityAccuracy, precisionQuantity }
@@ -6,5 +6,6 @@ export default {
6
6
  LIMIT_MENU_DATA: 'limitedMenuData', //权限过滤后的菜单数据
7
7
  USER_INFO: 'userInfo', //用户信息
8
8
  DICT_CODES: 'dicData', //数据字典数据
9
+ CHILD_APP_BACK: 'child_app_back', //标记子应用goback事件
9
10
  }
10
11
  }
@@ -0,0 +1,2 @@
1
+ import './requestUtils';
2
+ import './checkUtils';
@@ -1,7 +1,8 @@
1
1
  // @ts-nocheck
2
2
  import memoizeOne from 'memoize-one';
3
- import { formatMessage } from 'umi';
3
+ import { formatMessage, history } from 'umi';
4
4
  import isEqual from 'lodash/isEqual';
5
+ import ENUM from './enumConfig';
5
6
 
6
7
  export function downloadExcel(data: any, fileName?: any, isResUrl?: boolean) {
7
8
  const resUrl = isResUrl
@@ -49,4 +50,20 @@ export const formatter = (data, parentAuthority, parentName) => {
49
50
  .filter((item) => item);
50
51
  };
51
52
 
52
- export const memoizeOneFormatter = memoizeOne(formatter, isEqual);
53
+ export const memoizeOneFormatter = memoizeOne(formatter, isEqual);
54
+
55
+ export const go2BackAndClose = () => {
56
+ localStorage.setItem(ENUM.BROWSER_CACHE.CHILD_APP_BACK, 1);
57
+ history.goBack();
58
+ }
59
+
60
+ export const getModalContainer = () => {
61
+ try {
62
+ if (window.top != window && window.parent.document) {
63
+ return window.parent.document.body
64
+ }
65
+ } catch (error) {
66
+ console.log(error)
67
+ }
68
+ return document.body
69
+ }