Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rbc-demo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王衍超
rbc-demo
Commits
0443998e
Commit
0443998e
authored
Feb 18, 2022
by
fengjiansheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format(@gms/gms-plugin-billexpend): 修改外部依赖引入方式
parent
346986cb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
258 deletions
+3
-258
package.json
develop/@gms/gms-plugin-billexpand/package.json
+2
-1
AmountComp.js
develop/@gms/gms-plugin-billexpand/src/formula/AmountComp.js
+1
-1
currencyUtil.js
...op/@gms/gms-plugin-billexpand/src/formula/currencyUtil.js
+0
-256
No files found.
develop/@gms/gms-plugin-billexpand/package.json
View file @
0443998e
...
...
@@ -21,7 +21,8 @@
"viewerjs"
:
"^1.10.2"
,
"vue"
:
"^2.6.11"
,
"vue-router"
:
"^3.2.0"
,
"vuex"
:
"^3.4.0"
"vuex"
:
"^3.4.0"
,
"currency.js"
:
"^1.2.2"
},
"files"
:
[
"dist"
,
...
...
develop/@gms/gms-plugin-billexpand/src/formula/AmountComp.js
View file @
0443998e
import
_
from
"./FormulaConstants"
;
import
currency
from
"./currencyUtil.js"
import
currency
from
'currency.js/dist/currency.js'
/**
* 金额比较公式
* 比较左右两个操作数是否相等 参数可以是返回值类型为number的公式
...
...
develop/@gms/gms-plugin-billexpand/src/formula/currencyUtil.js
deleted
100644 → 0
View file @
346986cb
/*!
* currency.js - v2.0.4
* http://scurker.github.io/currency.js
*
* Copyright (c) 2021 Jason Wilson
* Released under MIT license
*/
'use strict'
;
var
defaults
=
{
symbol
:
'$'
,
separator
:
','
,
decimal
:
'.'
,
errorOnInvalid
:
false
,
precision
:
2
,
pattern
:
'!#'
,
negativePattern
:
'-!#'
,
format
:
format
,
fromCents
:
false
};
var
round
=
function
round
(
v
)
{
return
Math
.
round
(
v
);
};
var
pow
=
function
pow
(
p
)
{
return
Math
.
pow
(
10
,
p
);
};
var
rounding
=
function
rounding
(
value
,
increment
)
{
return
round
(
value
/
increment
)
*
increment
;
};
var
groupRegex
=
/
(\d)(?=(\d{3})
+
\b)
/g
;
var
vedicRegex
=
/
(\d)(?=(\d\d)
+
\d\b)
/g
;
/**
* Create a new instance of currency.js
* @param {number|string|currency} value
* @param {object} [opts]
*/
function
currency
(
value
,
opts
)
{
var
that
=
this
;
if
(
!
(
that
instanceof
currency
))
{
return
new
currency
(
value
,
opts
);
}
var
settings
=
Object
.
assign
({},
defaults
,
opts
),
precision
=
pow
(
settings
.
precision
),
v
=
parse
(
value
,
settings
);
that
.
intValue
=
v
;
that
.
value
=
v
/
precision
;
// Set default incremental value
settings
.
increment
=
settings
.
increment
||
1
/
precision
;
// Support vedic numbering systems
// see: https://en.wikipedia.org/wiki/Indian_numbering_system
if
(
settings
.
useVedic
)
{
settings
.
groups
=
vedicRegex
;
}
else
{
settings
.
groups
=
groupRegex
;
}
// Intended for internal usage only - subject to change
this
.
s
=
settings
;
this
.
p
=
precision
;
}
function
parse
(
value
,
opts
)
{
var
useRounding
=
arguments
.
length
>
2
&&
arguments
[
2
]
!==
undefined
?
arguments
[
2
]
:
true
;
var
v
=
0
,
decimal
=
opts
.
decimal
,
errorOnInvalid
=
opts
.
errorOnInvalid
,
decimals
=
opts
.
precision
,
fromCents
=
opts
.
fromCents
,
precision
=
pow
(
decimals
),
isNumber
=
typeof
value
===
'number'
,
isCurrency
=
value
instanceof
currency
;
if
(
isCurrency
&&
fromCents
)
{
return
value
.
intValue
;
}
if
(
isNumber
||
isCurrency
)
{
v
=
isCurrency
?
value
.
value
:
value
;
}
else
if
(
typeof
value
===
'string'
)
{
var
regex
=
new
RegExp
(
'[^-
\\
d'
+
decimal
+
']'
,
'g'
),
decimalString
=
new
RegExp
(
'
\
\'
+ decimal, '
g
');
v = value.replace(/
\
((.*)
\
)/, '
-
$1
') // allow negative e.g. (1.99)
.replace(regex, '') // replace any non numeric values
.replace(decimalString, '
.
'); // convert any decimal values
v = v || 0;
} else {
if (errorOnInvalid) {
throw Error('
Invalid
Input
');
}
v = 0;
}
if (!fromCents) {
v *= precision; // scale number to integer value
v = v.toFixed(4); // Handle additional decimal for proper rounding.
}
return useRounding ? round(v) : v;
}
/**
* Formats a currency object
* @param currency
* @param {object} [opts]
*/
function format(currency, settings) {
var pattern = settings.pattern,
negativePattern = settings.negativePattern,
symbol = settings.symbol,
separator = settings.separator,
decimal = settings.decimal,
groups = settings.groups,
split = ('' + currency).replace(/^-/, '').split('
.
'),
dollars = split[0],
cents = split[1];
return (currency.value >= 0 ? pattern : negativePattern).replace('
!
', symbol).replace('
#
', dollars.replace(groups, '
$1
' + separator) + (cents ? decimal + cents : ''));
}
currency.prototype = {
/**
* Adds values together.
* @param {number} number
* @returns {currency}
*/
add: function add(number) {
var intValue = this.intValue,
_settings = this.s,
_precision = this.p;
return currency((intValue += parse(number, _settings)) / (_settings.fromCents ? 1 : _precision), _settings);
},
/**
* Subtracts value.
* @param {number} number
* @returns {currency}
*/
subtract: function subtract(number) {
var intValue = this.intValue,
_settings = this.s,
_precision = this.p;
return currency((intValue -= parse(number, _settings)) / (_settings.fromCents ? 1 : _precision), _settings);
},
/**
* Multiplies values.
* @param {number} number
* @returns {currency}
*/
multiply: function multiply(number) {
var intValue = this.intValue,
_settings = this.s;
return currency((intValue *= number) / (_settings.fromCents ? 1 : pow(_settings.precision)), _settings);
},
/**
* Divides value.
* @param {number} number
* @returns {currency}
*/
divide: function divide(number) {
var intValue = this.intValue,
_settings = this.s;
return currency(intValue /= parse(number, _settings, false), _settings);
},
/**
* Takes the currency amount and distributes the values evenly. Any extra pennies
* left over from the distribution will be stacked onto the first set of entries.
* @param {number} count
* @returns {array}
*/
distribute: function distribute(count) {
var intValue = this.intValue,
_precision = this.p,
_settings = this.s,
distribution = [],
split = Math[intValue >= 0 ? '
floor
' : '
ceil
'](intValue / count),
pennies = Math.abs(intValue - split * count),
precision = _settings.fromCents ? 1 : _precision;
for (; count !== 0; count--) {
var item = currency(split / precision, _settings); // Add any left over pennies
pennies-- > 0 && (item = item[intValue >= 0 ? '
add
' : '
subtract
'](1 / precision));
distribution.push(item);
}
return distribution;
},
/**
* Returns the dollar value.
* @returns {number}
*/
dollars: function dollars() {
return ~~this.value;
},
/**
* Returns the cent value.
* @returns {number}
*/
cents: function cents() {
var intValue = this.intValue,
_precision = this.p;
return ~~(intValue % _precision);
},
/**
* Formats the value as a string according to the formatting settings.
* @param {boolean} useSymbol - format with currency symbol
* @returns {string}
*/
format: function format(options) {
var _settings = this.s;
if (typeof options === '
function
') {
return options(this, _settings);
}
return _settings.format(this, Object.assign({}, _settings, options));
},
/**
* Formats the value as a string according to the formatting settings.
* @returns {string}
*/
toString: function toString() {
var intValue = this.intValue,
_precision = this.p,
_settings = this.s;
return rounding(intValue / _precision, _settings.increment).toFixed(_settings.precision);
},
/**
* Value for JSON serialization.
* @returns {float}
*/
toJSON: function toJSON() {
return this.value;
}
};
module.exports = currency;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment