Commit 794f2e06 by jml0128

feat

1 parent 98a9e556
No preview for this file type
...@@ -27,8 +27,7 @@ ...@@ -27,8 +27,7 @@
"vue-awesome-swiper": "^4.1.1", "vue-awesome-swiper": "^4.1.1",
"vue-echarts": "^6.0.0-rc.5", "vue-echarts": "^6.0.0-rc.5",
"vue-photo-preview": "^1.1.3", "vue-photo-preview": "^1.1.3",
"vuedraggable": "^2.24.3", "vuedraggable": "^2.24.3"
"xrk-tools": "^1.0.11"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-eslint": "~4.5.0", "@vue/cli-plugin-eslint": "~4.5.0",
......
...@@ -130,3 +130,61 @@ export const getInterval = axisData => { ...@@ -130,3 +130,61 @@ export const getInterval = axisData => {
} }
return 'auto'; return 'auto';
}; };
export const check = {
isFunction: fn => {
return typeof fn === 'function';
}
};
export const base = {
numberFormat: (num, divisor = 100, decimalPlaces = 2, unit = '') => {
if (num == 0) {
return Number(num).toFixed(decimalPlaces) + unit;
}
return (Number(num) / divisor).toFixed(decimalPlaces) + unit;
}
};
export const date = {
dateFormat: (date = new Date(), fmt = 'Y-M-D H:m:s', autoFillZero = true) => {
let _date = new Date();
if (toString.call(date) === '[object Number]') {
// 时间戳
_date = new Date(Math.round(Number(String(date).padEnd(13, '0'))));
} else if (toString.call(date) === '[object Date]') {
// 时间对象
_date = date;
} else {
// 错误传参
console.warn(`入参${date}不是正确的时间对象或时间戳`);
return date;
}
const fillZero = (number, count = 2) => {
return String(number).padStart(count, '0');
};
const _fullYear = _date.getFullYear();
const _month = _date.getMonth() + 1;
const _day = _date.getDate();
const _hours = _date.getHours();
const _minutes = _date.getMinutes();
const _seconds = _date.getSeconds();
const fmtMap = {
Y: _fullYear,
M: autoFillZero ? fillZero(_month) : _month,
D: autoFillZero ? fillZero(_day) : _day,
H: autoFillZero ? fillZero(_hours) : _hours,
m: autoFillZero ? fillZero(_minutes) : _minutes,
s: autoFillZero ? fillZero(_seconds) : _seconds
};
let _fmt = String(fmt);
for (const key in fmtMap) {
if (Object.hasOwnProperty.call(fmtMap, key)) {
_fmt = _fmt.replace(
new RegExp(`${key}`),
String(Reflect.get(fmtMap, key))
);
}
}
return _fmt;
}
};
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
</template> </template>
<script> <script>
import { check } from 'xrk-tools'; import { check } from '../chart-type/common';
import mixin from '../mixin/index'; import mixin from '../mixin/index';
import { Dialog, Button, Checkbox, CheckboxGroup, Message } from 'element-ui'; import { Dialog, Button, Checkbox, CheckboxGroup, Message } from 'element-ui';
export default { export default {
......
...@@ -71,7 +71,7 @@ import mixin, { printWidth } from '../mixin/index'; ...@@ -71,7 +71,7 @@ import mixin, { printWidth } from '../mixin/index';
import project from '../mixin/project'; import project from '../mixin/project';
import { chartConfig } from '../mock/index'; import { chartConfig } from '../mock/index';
import { date } from 'xrk-tools'; import { date } from '../chart-type/common';
const ChartConfigFn = chartConfig(); const ChartConfigFn = chartConfig();
import { import {
......
...@@ -80,7 +80,7 @@ import project from '../mixin/project'; ...@@ -80,7 +80,7 @@ import project from '../mixin/project';
import { chartConfig } from '../mock/index'; import { chartConfig } from '../mock/index';
const ChartConfigFn = chartConfig(); const ChartConfigFn = chartConfig();
import { date, check } from 'xrk-tools'; import { date, check } from '../chart-type/common';
import { import {
dealAxis, dealAxis,
dealLegends, dealLegends,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Description: * @Description:
* @Date: 2021-07-02 10:57:34 * @Date: 2021-07-02 10:57:34
*/ */
import { base } from 'xrk-tools'; import { base } from '../chart-type/common';
export const dealAxis = (arr = []) => { export const dealAxis = (arr = []) => {
return arr.map(item => ({ return arr.map(item => ({
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!