widget.qw 1.0.74 → 1.0.76

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.
Files changed (104) hide show
  1. package/.env.development +10 -10
  2. package/.env.production +8 -8
  3. package/README.md +73 -73
  4. package/build/style.css +473 -487
  5. package/build/widget.qw.es.js +1516 -130
  6. package/build/widget.qw.umd.js +1515 -129
  7. package/index.html +17 -17
  8. package/package.json +47 -47
  9. package/src/App.vue +26 -26
  10. package/src/api/index.js +165 -165
  11. package/src/components/AuditBar.vue +396 -396
  12. package/src/components/BillCard.vue +164 -164
  13. package/src/components/CascaderPicker.vue +132 -132
  14. package/src/components/CascaderPop.vue +371 -371
  15. package/src/components/CheckGroup.vue +113 -113
  16. package/src/components/DatetimePicker/DatetimePop.vue +342 -342
  17. package/src/components/DatetimePicker/index.vue +124 -124
  18. package/src/components/DayDropdown.vue +56 -56
  19. package/src/components/FilePicker.vue +145 -136
  20. package/src/components/Input.vue +80 -80
  21. package/src/components/MonthDropdown.vue +51 -51
  22. package/src/components/MultiPicker.vue +123 -123
  23. package/src/components/ObjsEditor.vue +334 -334
  24. package/src/components/SecretNotify.js +5 -5
  25. package/src/components/Sheet.vue +92 -92
  26. package/src/components/SingleApiPicker.vue +108 -108
  27. package/src/components/SinglePicker.vue +102 -102
  28. package/src/components/SingleUserSelector.vue +425 -425
  29. package/src/components/Switch.vue +64 -64
  30. package/src/components/TreePicker.vue +113 -113
  31. package/src/components/UserPicker.vue +106 -106
  32. package/src/components/UserProfile.vue +129 -129
  33. package/src/components/UsersPicker.vue +118 -118
  34. package/src/components/YearDropdown.vue +59 -59
  35. package/src/components/data_selector.vue +303 -303
  36. package/src/components/image_picker.vue +123 -123
  37. package/src/components/images_picker.vue +159 -144
  38. package/src/components/index.js +162 -162
  39. package/src/components/mult_list_selector.vue +155 -155
  40. package/src/components/subdepartment_selector.vue +481 -481
  41. package/src/components/user_selector.vue +639 -639
  42. package/src/components/widget/DataPop.vue +95 -95
  43. package/src/components/widget/TreePop.vue +88 -88
  44. package/src/components/widget/UserPop.vue +347 -347
  45. package/src/env.d.ts +8 -8
  46. package/src/main.js +117 -117
  47. package/src/router/index.ts +173 -173
  48. package/src/util/array_util.js +32 -32
  49. package/src/util/auth_util.js +72 -72
  50. package/src/util/bool_util.js +5 -5
  51. package/src/util/bus.js +1 -1
  52. package/src/util/cache_util.js +18 -18
  53. package/src/util/errer_code.js +6 -6
  54. package/src/util/eval_util.js +19 -19
  55. package/src/util/icon_util.js +36 -36
  56. package/src/util/image_util.js +27 -27
  57. package/src/util/index.js +57 -57
  58. package/src/util/num_util.js +70 -70
  59. package/src/util/obj_util.js +28 -28
  60. package/src/util/request.js +73 -73
  61. package/src/util/request_json.js +71 -71
  62. package/src/util/request_json_mute.js +65 -65
  63. package/src/util/request_upload.js +79 -79
  64. package/src/util/route_util.js +31 -31
  65. package/src/util/str_util.js +143 -143
  66. package/src/util/time_util.js +406 -406
  67. package/src/util/toast_util.js +24 -24
  68. package/src/util/tree_util.js +153 -153
  69. package/src/util/uuid_util.js +9 -9
  70. package/src/util/validate.js +182 -182
  71. package/src/util/vue_filter.js +223 -223
  72. package/src/views/auditbar/index.vue +78 -78
  73. package/src/views/billcard/index.vue +48 -48
  74. package/src/views/cascaderpop/index.vue +90 -90
  75. package/src/views/checkgroup/index.vue +35 -35
  76. package/src/views/dataSelector/index.vue +48 -48
  77. package/src/views/datetimepicker/index.vue +34 -34
  78. package/src/views/daydropdown/index.vue +31 -31
  79. package/src/views/filepicker/index.vue +31 -31
  80. package/src/views/imagepicker/index.vue +31 -31
  81. package/src/views/imagespicker/index.vue +31 -31
  82. package/src/views/input/index.vue +35 -35
  83. package/src/views/monthdropdown/index.vue +31 -31
  84. package/src/views/multListSelector/index.vue +61 -61
  85. package/src/views/multipicker/index.vue +36 -36
  86. package/src/views/objseditor/index.vue +277 -277
  87. package/src/views/productSelector/index.vue +35 -35
  88. package/src/views/projectpicker/index.vue +41 -41
  89. package/src/views/secretnotify/index.vue +27 -27
  90. package/src/views/sheet/index.vue +45 -45
  91. package/src/views/singlepicker/index.vue +35 -35
  92. package/src/views/subdepartmentSelector/index.vue +40 -40
  93. package/src/views/switch/index.vue +34 -34
  94. package/src/views/treepicker/index.vue +41 -41
  95. package/src/views/userSelector/index.vue +54 -54
  96. package/src/views/userSelectorNew/index.vue +45 -45
  97. package/src/views/userpicker/index.vue +43 -43
  98. package/src/views/userprofile/index.vue +30 -30
  99. package/src/views/userspicker/index.vue +43 -43
  100. package/src/views/yeardropdown/index.vue +32 -32
  101. package/src/vm/index.js +1 -1
  102. package/tsconfig.json +19 -19
  103. package/tsconfig.node.json +8 -8
  104. package/vite.config.ts +122 -122
@@ -1,73 +1,73 @@
1
- import { setCacheValueByKey, getCacheValueByKey, removeCacheByKey } from "./cache_util.js";
2
- import { computed } from 'vue'
3
- import vm from '../vm'
4
-
5
- //登陆token的键名
6
- export const TOKEN_KEY = import.meta.env.VITE_TOKEN_KEY;
7
- export const TOKEN_PREFIX = import.meta.env.VITE_TOKEN_PREFIX;
8
-
9
- export function getToken() {
10
- if (import.meta.env.VITE_IS_DEBUG === 'true')
11
- return TOKEN_PREFIX + import.meta.env.VITE_DEBUG_TOKEN
12
- else if(vm.tokenCallback)
13
- return vm.tokenCallback()
14
- }
15
-
16
- export function setToken(token) {
17
- setCacheValueByKey(TOKEN_KEY, token)
18
- }
19
-
20
- export function removeToken() {
21
- removeCacheByKey(TOKEN_KEY)
22
- }
23
-
24
- export const props2auth = (props) => {
25
- return {
26
- isRequired: computed(() => {
27
- if (props.auth) {
28
- return props.auth == 'require'
29
- }
30
-
31
- return props.required
32
- }),
33
- isGone: computed(() => {
34
- if (props.auth)
35
- return props.auth == 'gone'
36
-
37
- return false
38
- }),
39
- isDisabled: computed(()=>{
40
- if (props.auth)
41
- return props.auth == 'readonly'
42
-
43
- if(props.required)
44
- return false
45
-
46
- if(props.disabled)
47
- return true
48
-
49
- if(props.readonly)
50
- return true
51
-
52
- return false
53
- }),
54
- isReadonly: computed(()=>{
55
- if (props.auth)
56
- return props.auth == 'readonly'
57
-
58
- if(props.readonly)
59
- return true
60
-
61
- if(props.required)
62
- return false
63
-
64
- if(props.disabled)
65
- return true
66
-
67
- return false
68
- }),
69
- rules: computed(()=>{
70
- return props.rules
71
- })
72
- }
1
+ import { setCacheValueByKey, getCacheValueByKey, removeCacheByKey } from "./cache_util.js";
2
+ import { computed } from 'vue'
3
+ import vm from '../vm'
4
+
5
+ //登陆token的键名
6
+ export const TOKEN_KEY = import.meta.env.VITE_TOKEN_KEY;
7
+ export const TOKEN_PREFIX = import.meta.env.VITE_TOKEN_PREFIX;
8
+
9
+ export function getToken() {
10
+ if (import.meta.env.VITE_IS_DEBUG === 'true')
11
+ return TOKEN_PREFIX + import.meta.env.VITE_DEBUG_TOKEN
12
+ else if(vm.tokenCallback)
13
+ return vm.tokenCallback()
14
+ }
15
+
16
+ export function setToken(token) {
17
+ setCacheValueByKey(TOKEN_KEY, token)
18
+ }
19
+
20
+ export function removeToken() {
21
+ removeCacheByKey(TOKEN_KEY)
22
+ }
23
+
24
+ export const props2auth = (props) => {
25
+ return {
26
+ isRequired: computed(() => {
27
+ if (props.auth) {
28
+ return props.auth == 'require'
29
+ }
30
+
31
+ return props.required
32
+ }),
33
+ isGone: computed(() => {
34
+ if (props.auth)
35
+ return props.auth == 'gone'
36
+
37
+ return false
38
+ }),
39
+ isDisabled: computed(()=>{
40
+ if (props.auth)
41
+ return props.auth == 'readonly'
42
+
43
+ if(props.required)
44
+ return false
45
+
46
+ if(props.disabled)
47
+ return true
48
+
49
+ if(props.readonly)
50
+ return true
51
+
52
+ return false
53
+ }),
54
+ isReadonly: computed(()=>{
55
+ if (props.auth)
56
+ return props.auth == 'readonly'
57
+
58
+ if(props.readonly)
59
+ return true
60
+
61
+ if(props.required)
62
+ return false
63
+
64
+ if(props.disabled)
65
+ return true
66
+
67
+ return false
68
+ }),
69
+ rules: computed(()=>{
70
+ return props.rules
71
+ })
72
+ }
73
73
  }
@@ -1,6 +1,6 @@
1
- /**
2
- * bool转中文
3
- */
4
- export function bool2chinese(value) {
5
- return value ? '是' : '否'
1
+ /**
2
+ * bool转中文
3
+ */
4
+ export function bool2chinese(value) {
5
+ return value ? '是' : '否'
6
6
  }
package/src/util/bus.js CHANGED
@@ -1,2 +1,2 @@
1
- import mitt from 'mitt';
1
+ import mitt from 'mitt';
2
2
  export default mitt();
@@ -1,19 +1,19 @@
1
- // 读
2
- export function getCacheValueByKey(key) {
3
- return localStorage.getItem(key);
4
- }
5
-
6
- // 写
7
- export function setCacheValueByKey(key, val) {
8
- localStorage.setItem(key, val);
9
- }
10
-
11
- //删除
12
- export function removeCacheByKey(key) {
13
- localStorage.removeItem(key);
14
- }
15
-
16
- // 清除所有缓存
17
- export function clearCache() {
18
- localStorage.clear()
1
+ // 读
2
+ export function getCacheValueByKey(key) {
3
+ return localStorage.getItem(key);
4
+ }
5
+
6
+ // 写
7
+ export function setCacheValueByKey(key, val) {
8
+ localStorage.setItem(key, val);
9
+ }
10
+
11
+ //删除
12
+ export function removeCacheByKey(key) {
13
+ localStorage.removeItem(key);
14
+ }
15
+
16
+ // 清除所有缓存
17
+ export function clearCache() {
18
+ localStorage.clear()
19
19
  }
@@ -1,7 +1,7 @@
1
- // 返回这些错误码都要清除cookie及local storage
2
- //未登录 错误码
3
- const NEED_LOGIN = Number(import.meta.env.VITE_NEED_LOGIN_CODE)
4
-
5
- export const NEED_LOGIN_CODES = [
6
- NEED_LOGIN,
1
+ // 返回这些错误码都要清除cookie及local storage
2
+ //未登录 错误码
3
+ const NEED_LOGIN = Number(import.meta.env.VITE_NEED_LOGIN_CODE)
4
+
5
+ export const NEED_LOGIN_CODES = [
6
+ NEED_LOGIN,
7
7
  ]
@@ -1,20 +1,20 @@
1
- import * as ToastUtil from './toast_util'
2
-
3
- function evaluateWithParams(express, obj) {
4
- const objStr = JSON.stringify(obj);
5
- const newExpress = `(function() { const form = ${objStr}; return ${express}; })()`;
6
- console.log('表达式:'+newExpress)
7
- return eval(newExpress);
8
- }
9
-
10
- export const executeExpress = (express, params) => {
11
- try {
12
- const result = evaluateWithParams(express, params);
13
- console.log(result);
14
- return result
15
- } catch (e) {
16
- console.log('解析表达式失败', e)
17
- ToastUtil.warnToast('解析表达式失败 '+ e)
18
- return false
19
- }
1
+ import * as ToastUtil from './toast_util'
2
+
3
+ function evaluateWithParams(express, obj) {
4
+ const objStr = JSON.stringify(obj);
5
+ const newExpress = `(function() { const form = ${objStr}; return ${express}; })()`;
6
+ console.log('表达式:'+newExpress)
7
+ return eval(newExpress);
8
+ }
9
+
10
+ export const executeExpress = (express, params) => {
11
+ try {
12
+ const result = evaluateWithParams(express, params);
13
+ console.log(result);
14
+ return result
15
+ } catch (e) {
16
+ console.log('解析表达式失败', e)
17
+ ToastUtil.warnToast('解析表达式失败 '+ e)
18
+ return false
19
+ }
20
20
  }
@@ -1,37 +1,37 @@
1
- import { reactive } from 'vue'
2
- // 引入全部图标
3
- import * as Icons from "@element-plus/icons-vue"
4
-
5
- // 按需引入图标
6
- // import {
7
- // CloseBold,
8
- // Close,
9
- // Plus,
10
- // Star,
11
- // UserFilled,
12
- // Loading,
13
- // Connection,
14
- // Edit,
15
- // FolderOpened
16
- // } from '@element-plus/icons'
17
-
18
- // const dictIcon = reactive({
19
- // 'CloseBold': CloseBold,
20
- // 'Close': Close,
21
- // 'Plus': Plus,
22
- // 'Star': Star,
23
- // 'UserFilled': UserFilled,
24
- // 'Loading': Loading,
25
- // 'Connection': Connection,
26
- // 'Edit': Edit,
27
- // 'FolderOpened': FolderOpened
28
- // })
29
-
30
- const installIcon = (app) => {
31
- // 便于模板获取
32
- //app.config.globalProperties.$icon = dictIcon
33
- // 使用全部图标
34
- app.config.globalProperties.$icon = Icons
35
- }
36
-
1
+ import { reactive } from 'vue'
2
+ // 引入全部图标
3
+ import * as Icons from "@element-plus/icons-vue"
4
+
5
+ // 按需引入图标
6
+ // import {
7
+ // CloseBold,
8
+ // Close,
9
+ // Plus,
10
+ // Star,
11
+ // UserFilled,
12
+ // Loading,
13
+ // Connection,
14
+ // Edit,
15
+ // FolderOpened
16
+ // } from '@element-plus/icons'
17
+
18
+ // const dictIcon = reactive({
19
+ // 'CloseBold': CloseBold,
20
+ // 'Close': Close,
21
+ // 'Plus': Plus,
22
+ // 'Star': Star,
23
+ // 'UserFilled': UserFilled,
24
+ // 'Loading': Loading,
25
+ // 'Connection': Connection,
26
+ // 'Edit': Edit,
27
+ // 'FolderOpened': FolderOpened
28
+ // })
29
+
30
+ const installIcon = (app) => {
31
+ // 便于模板获取
32
+ //app.config.globalProperties.$icon = dictIcon
33
+ // 使用全部图标
34
+ app.config.globalProperties.$icon = Icons
35
+ }
36
+
37
37
  export default installIcon
@@ -1,28 +1,28 @@
1
- import Compressor from 'compressorjs'
2
-
3
- // 图片压缩
4
- export const compress_image = async (file) => {
5
- return new Promise((resolve, reject) => {
6
- new Compressor(file, {
7
- quality: 0.7,
8
- maxWidth: 800,
9
- maxHeight: 800,
10
- success(result) {
11
- console.log('压缩后的图片', result);
12
- let compress_file = blob2file(result, result.name)
13
- return resolve(compress_file)
14
- },
15
- error(err) {
16
- console.error(err);
17
- return reject(err)
18
- }
19
- })
20
- })
21
- }
22
-
23
- function blob2file(blob, fileName, fileType = blob.type) {
24
- return new File([blob], fileName, {
25
- type: fileType,
26
- lastModified: new Date().getTime()
27
- });
1
+ import Compressor from 'compressorjs'
2
+
3
+ // 图片压缩
4
+ export const compress_image = async (file) => {
5
+ return new Promise((resolve, reject) => {
6
+ new Compressor(file, {
7
+ quality: 0.7,
8
+ maxWidth: 800,
9
+ maxHeight: 800,
10
+ success(result) {
11
+ console.log('压缩后的图片', result);
12
+ let compress_file = blob2file(result, result.name)
13
+ return resolve(compress_file)
14
+ },
15
+ error(err) {
16
+ console.error(err);
17
+ return reject(err)
18
+ }
19
+ })
20
+ })
21
+ }
22
+
23
+ function blob2file(blob, fileName, fileType = blob.type) {
24
+ return new File([blob], fileName, {
25
+ type: fileType,
26
+ lastModified: new Date().getTime()
27
+ });
28
28
  }
package/src/util/index.js CHANGED
@@ -1,58 +1,58 @@
1
- import * as ApiUtil from '@/api'
2
- import { successToast, warnToast } from './toast_util'
3
- import * as AuthUtil from './auth_util'
4
- import * as ArrayUtil from './array_util'
5
- import * as StrUtil from './str_util'
6
- import * as BoolUtil from './bool_util'
7
- import * as RouteUtil from './route_util'
8
- import * as TimeUtil from './time_util'
9
- import * as ToastUtil from './toast_util'
10
- import * as EvalUtil from './eval_util'
11
- import * as ImageUtil from './image_util'
12
- import * as TreeUtil from './tree_util'
13
- import * as UuidUtil from './uuid_util'
14
-
15
- export default {
16
- ...AuthUtil,
17
- ...ArrayUtil,
18
- ...StrUtil,
19
- ...BoolUtil,
20
- ...RouteUtil,
21
- ...TimeUtil,
22
- ...ApiUtil,
23
- ...ToastUtil,
24
- ...EvalUtil,
25
- ...ImageUtil,
26
- ...TreeUtil,
27
- ...UuidUtil,
28
-
29
- href(url) {
30
- window.location.href = url
31
- },
32
- hrefByNew(url) {
33
- window.open(url, '_blank')
34
- },
35
- gotoLogin() {
36
- let baseUrl = RouteUtil.getBaseUrl()
37
- window.location.href = baseUrl + '#/login'
38
- },
39
- gotoByNew(path, params) {
40
- const routeData = router.resolve({ path: path, query: params });
41
- window.open(routeData.href, '_blank')
42
- },
43
- warnToast(msg) {
44
- warnToast(msg)
45
- },
46
- successToast(msg) {
47
- successToast(msg)
48
- },
49
- isEmail(email) {
50
- return validateEmail(email)
51
- },
52
- isPhone(phone) {
53
- return validatePhone(phone)
54
- },
55
- scrollToTop() {
56
- document.documentElement.scrollTop = 0
57
- }
1
+ import * as ApiUtil from '@/api'
2
+ import { successToast, warnToast } from './toast_util'
3
+ import * as AuthUtil from './auth_util'
4
+ import * as ArrayUtil from './array_util'
5
+ import * as StrUtil from './str_util'
6
+ import * as BoolUtil from './bool_util'
7
+ import * as RouteUtil from './route_util'
8
+ import * as TimeUtil from './time_util'
9
+ import * as ToastUtil from './toast_util'
10
+ import * as EvalUtil from './eval_util'
11
+ import * as ImageUtil from './image_util'
12
+ import * as TreeUtil from './tree_util'
13
+ import * as UuidUtil from './uuid_util'
14
+
15
+ export default {
16
+ ...AuthUtil,
17
+ ...ArrayUtil,
18
+ ...StrUtil,
19
+ ...BoolUtil,
20
+ ...RouteUtil,
21
+ ...TimeUtil,
22
+ ...ApiUtil,
23
+ ...ToastUtil,
24
+ ...EvalUtil,
25
+ ...ImageUtil,
26
+ ...TreeUtil,
27
+ ...UuidUtil,
28
+
29
+ href(url) {
30
+ window.location.href = url
31
+ },
32
+ hrefByNew(url) {
33
+ window.open(url, '_blank')
34
+ },
35
+ gotoLogin() {
36
+ let baseUrl = RouteUtil.getBaseUrl()
37
+ window.location.href = baseUrl + '#/login'
38
+ },
39
+ gotoByNew(path, params) {
40
+ const routeData = router.resolve({ path: path, query: params });
41
+ window.open(routeData.href, '_blank')
42
+ },
43
+ warnToast(msg) {
44
+ warnToast(msg)
45
+ },
46
+ successToast(msg) {
47
+ successToast(msg)
48
+ },
49
+ isEmail(email) {
50
+ return validateEmail(email)
51
+ },
52
+ isPhone(phone) {
53
+ return validatePhone(phone)
54
+ },
55
+ scrollToTop() {
56
+ document.documentElement.scrollTop = 0
57
+ }
58
58
  }
@@ -1,71 +1,71 @@
1
- /**
2
- * 分钱转元,保留小数点后2位
3
- * @param value 调用过滤器时,调用的文本
4
- */
5
- export function cent2yuanByDot(value) {
6
- // 如果文本不存在,返回空字符
7
- // value === 0 ; !0 === true.
8
- if (!value) {
9
- return '0.00'
10
- }
11
-
12
- // 文本转化为 float
13
- const result = parseFloat(value) / 100;
14
-
15
- // 如果文本为 integer 类型的文本,表示当前文本没有小数
16
- // if (Number.isInteger(result)) {
17
- // return result
18
- // }
19
-
20
- // 文本包含小数,保留小数点后2位
21
- return result.toFixed(2);
22
- }
23
-
24
- /**
25
- * 分钱转元,不保留角、分
26
- * @param value 调用过滤器时,调用的文本
27
- */
28
- export function cent2yuan(value) {
29
- // 如果文本不存在,返回空字符
30
- // value === 0 ; !0 === true.
31
- if (!value) {
32
- return '0.00'
33
- }
34
-
35
- // 文本转化为 float
36
- const result = parseFloat(value) / 100;
37
-
38
- // 如果文本为 integer 类型的文本,表示当前文本没有小数
39
- // if (Number.isInteger(result)) {
40
- // return result
41
- // }
42
-
43
- // 文本包含小数,保留小数点后2位
44
- return result.toFixed(0);
45
- }
46
-
47
- export function num2boolean(value) {
48
- if (value > 0)
49
- return true
50
- else
51
- return false
52
- }
53
-
54
- export function percent(value) {
55
- // 如果文本不存在,返回空字符
56
- // value === 0 ; !0 === true.
57
- if (!value) {
58
- return '0.00'
59
- }
60
-
61
- // 文本转化为 float
62
- const result = parseFloat(value) * 100;
63
-
64
- // 如果文本为 integer 类型的文本,表示当前文本没有小数
65
- // if (Number.isInteger(result)) {
66
- // return result
67
- // }
68
-
69
- // 文本包含小数,保留小数点后2位
70
- return result.toFixed(2);
1
+ /**
2
+ * 分钱转元,保留小数点后2位
3
+ * @param value 调用过滤器时,调用的文本
4
+ */
5
+ export function cent2yuanByDot(value) {
6
+ // 如果文本不存在,返回空字符
7
+ // value === 0 ; !0 === true.
8
+ if (!value) {
9
+ return '0.00'
10
+ }
11
+
12
+ // 文本转化为 float
13
+ const result = parseFloat(value) / 100;
14
+
15
+ // 如果文本为 integer 类型的文本,表示当前文本没有小数
16
+ // if (Number.isInteger(result)) {
17
+ // return result
18
+ // }
19
+
20
+ // 文本包含小数,保留小数点后2位
21
+ return result.toFixed(2);
22
+ }
23
+
24
+ /**
25
+ * 分钱转元,不保留角、分
26
+ * @param value 调用过滤器时,调用的文本
27
+ */
28
+ export function cent2yuan(value) {
29
+ // 如果文本不存在,返回空字符
30
+ // value === 0 ; !0 === true.
31
+ if (!value) {
32
+ return '0.00'
33
+ }
34
+
35
+ // 文本转化为 float
36
+ const result = parseFloat(value) / 100;
37
+
38
+ // 如果文本为 integer 类型的文本,表示当前文本没有小数
39
+ // if (Number.isInteger(result)) {
40
+ // return result
41
+ // }
42
+
43
+ // 文本包含小数,保留小数点后2位
44
+ return result.toFixed(0);
45
+ }
46
+
47
+ export function num2boolean(value) {
48
+ if (value > 0)
49
+ return true
50
+ else
51
+ return false
52
+ }
53
+
54
+ export function percent(value) {
55
+ // 如果文本不存在,返回空字符
56
+ // value === 0 ; !0 === true.
57
+ if (!value) {
58
+ return '0.00'
59
+ }
60
+
61
+ // 文本转化为 float
62
+ const result = parseFloat(value) * 100;
63
+
64
+ // 如果文本为 integer 类型的文本,表示当前文本没有小数
65
+ // if (Number.isInteger(result)) {
66
+ // return result
67
+ // }
68
+
69
+ // 文本包含小数,保留小数点后2位
70
+ return result.toFixed(2);
71
71
  }