Merge branch 'develop'
Former-commit-id: edaa328c0d38115b8a857804684686cecdcf6e6d [formerly edaa328c0d38115b8a857804684686cecdcf6e6d [formerly edaa328c0d38115b8a857804684686cecdcf6e6d [formerly edaa328c0d38115b8a857804684686cecdcf6e6d [formerly c7986af4ef37c27eff081acf56ac9335bc5ba19c [formerly 466d1ae95b50b49b77f5f8b7f4c977b609027d90]]]]] Former-commit-id: 01fd860e1b3ba16c2a0b8b393dd029f0ebc0e247 Former-commit-id: 5e3f36bcf1f0cb2c101e8623d30994091eca7155 Former-commit-id: 4e81b0b2ff790460c87965ace5007912fbb70b00 [formerly e811ae9754b9959178fb1eba3c72e9595da13e9f] Former-commit-id: 0e5079a82d3a892432a2b241b71942444f668c6b Former-commit-id: 279dfc6ac6650ca03ccc53ca17523f71343b68d4 Former-commit-id: fedaade859a0c2e8abb537305884dd8ea77f9d8f Former-commit-id: 280bc731ef1ca07d0fbea59d47ee0062fd807b21 Former-commit-id: 4a13279df1a4fc6315365aab4daf3c52e5fa5465
This commit is contained in:
@@ -1 +1 @@
|
||||
14be1e768a4e072ad8ea5ff5bfec5535088a3e4b
|
||||
2b614609fc8311fc059d290422304b490e9a3abc
|
||||
@@ -14,6 +14,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@d2-projects/d2-crud": "^1.3.4",
|
||||
"@d2-projects/vue-filters-date": "^1.0.2",
|
||||
"@d2-projects/vue-table-export": "^1.0.1",
|
||||
"@d2-projects/vue-table-import": "^1.0.0",
|
||||
"axios": "^0.17.1",
|
||||
"babel-polyfill": "^6.26.0",
|
||||
"better-scroll": "^1.12.1",
|
||||
@@ -22,7 +25,6 @@
|
||||
"dayjs": "^1.6.7",
|
||||
"echarts": "^4.1.0",
|
||||
"element-ui": "^2.4.4",
|
||||
"file-saver": "^1.3.3",
|
||||
"flex.css": "^1.1.7",
|
||||
"fuse.js": "^3.2.1",
|
||||
"github-markdown-css": "^2.10.0",
|
||||
@@ -34,7 +36,6 @@
|
||||
"marked": "^0.3.9",
|
||||
"mockjs": "^1.0.1-beta3",
|
||||
"nprogress": "^0.2.0",
|
||||
"papaparse": "^4.3.6",
|
||||
"qs": "^6.6.0",
|
||||
"quill": "^1.3.4",
|
||||
"screenfull": "^3.3.2",
|
||||
@@ -49,8 +50,7 @@
|
||||
"vue-router": "^3.0.1",
|
||||
"vue-splitpane": "^1.0.2",
|
||||
"vue-ueditor-wrap": "^1.5.0",
|
||||
"vuex": "^3.0.1",
|
||||
"xlsx": "^0.12.0"
|
||||
"vuex": "^3.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kazupon/vue-i18n-loader": "^0.3.0",
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import log from './util.log.js'
|
||||
import cookies from './util.cookies.js'
|
||||
import cookies from './util.cookies'
|
||||
import db from './util.db'
|
||||
import log from './util.log'
|
||||
|
||||
let util = {
|
||||
const util = {
|
||||
cookies,
|
||||
db,
|
||||
log
|
||||
}
|
||||
|
||||
@@ -23,10 +25,10 @@ util.open = function (url) {
|
||||
var a = document.createElement('a')
|
||||
a.setAttribute('href', url)
|
||||
a.setAttribute('target', '_blank')
|
||||
a.setAttribute('id', 'd2admin-menu-link')
|
||||
a.setAttribute('id', 'd2admin-link-temp')
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(document.getElementById('d2admin-menu-link'))
|
||||
document.body.removeChild(document.getElementById('d2admin-link-temp'))
|
||||
}
|
||||
|
||||
export default util
|
||||
|
||||
@@ -6,6 +6,8 @@ import demoComponents from './modules/demo-components'
|
||||
import demoCharts from './modules/demo-charts'
|
||||
// 组件库
|
||||
import demoElement from './modules/demo-element'
|
||||
// 组件库
|
||||
import demoFilters from './modules/demo-filters'
|
||||
// 试验台
|
||||
import demoPlayground from './modules/demo-playground'
|
||||
// 示例
|
||||
@@ -21,6 +23,7 @@ export const menuAside = [
|
||||
demoPlugins,
|
||||
demoCharts,
|
||||
demoElement,
|
||||
demoFilters,
|
||||
demoPlayground,
|
||||
demoBusiness,
|
||||
demoD2Crud,
|
||||
@@ -40,6 +43,7 @@ export const menuHeader = [
|
||||
children: [
|
||||
demoD2Crud,
|
||||
demoComponents,
|
||||
demoFilters,
|
||||
demoElement,
|
||||
demoCharts,
|
||||
demoPlugins,
|
||||
|
||||
@@ -3,7 +3,7 @@ export default {
|
||||
title: '示例',
|
||||
icon: 'flask',
|
||||
children: (pre => [
|
||||
{ path: `${pre}index`, title: '示例首页', icon: 'home' },
|
||||
{ path: `${pre}index`, title: '示例', icon: 'home' },
|
||||
{
|
||||
title: '表格',
|
||||
icon: 'table',
|
||||
|
||||
@@ -3,7 +3,7 @@ export default {
|
||||
title: '图表',
|
||||
icon: 'line-chart',
|
||||
children: (pre => [
|
||||
{ path: `${pre}index`, title: '图表首页', icon: 'home' },
|
||||
{ path: `${pre}index`, title: '图表', icon: 'home' },
|
||||
{
|
||||
path: `${pre}list`,
|
||||
title: '图表',
|
||||
|
||||
@@ -3,7 +3,7 @@ export default {
|
||||
title: '内置组件',
|
||||
icon: 'puzzle-piece',
|
||||
children: (pre => [
|
||||
{ path: `${pre}index`, title: '扩展组件首页', icon: 'home' },
|
||||
{ path: `${pre}index`, title: '扩展组件', icon: 'home' },
|
||||
{
|
||||
path: `${pre}container`,
|
||||
title: '布局容器',
|
||||
|
||||
@@ -3,7 +3,7 @@ export default {
|
||||
title: 'D2 CRUD',
|
||||
iconSvg: 'd2-crud',
|
||||
children: (pre => [
|
||||
{ path: `${pre}index`, title: 'D2 CRUD 首页', icon: 'home' },
|
||||
{ path: `${pre}index`, title: 'D2 CRUD ', icon: 'home' },
|
||||
{
|
||||
title: '基础功能',
|
||||
children: [
|
||||
|
||||
@@ -3,7 +3,7 @@ export default {
|
||||
title: '基础组件库',
|
||||
icon: 'cubes',
|
||||
children: (pre => [
|
||||
{ path: `${pre}index`, title: '基础组件库首页', icon: 'home' },
|
||||
{ path: `${pre}index`, title: '基础组件库', icon: 'home' },
|
||||
{
|
||||
path: `${pre}basic`,
|
||||
title: '基础',
|
||||
|
||||
9
src/menu/modules/demo-filters.js
Normal file
9
src/menu/modules/demo-filters.js
Normal file
@@ -0,0 +1,9 @@
|
||||
export default {
|
||||
path: '/demo/filters',
|
||||
title: '内置过滤器',
|
||||
icon: 'flask',
|
||||
children: (pre => [
|
||||
{ path: `${pre}index`, title: '内置过滤器', icon: 'home' },
|
||||
{ path: `${pre}day`, title: '日期和时间', icon: 'calendar' }
|
||||
])('/demo/filters/')
|
||||
}
|
||||
@@ -3,7 +3,7 @@ export default {
|
||||
title: '内嵌网页',
|
||||
icon: 'globe',
|
||||
children: (pre => [
|
||||
{ path: `${pre}index`, title: 'Frame 首页', icon: 'home' },
|
||||
{ path: `${pre}index`, title: 'Frame ', icon: 'home' },
|
||||
{ path: `${pre}d2-doc`, title: 'D2Admin 中文文档', iconSvg: 'd2-admin' },
|
||||
{ path: `${pre}html`, title: '静态 HTML', icon: 'code' }
|
||||
])('/demo/frame/')
|
||||
|
||||
@@ -3,7 +3,7 @@ export default {
|
||||
title: '试验台',
|
||||
icon: 'flask',
|
||||
children: (pre => [
|
||||
{ path: `${pre}index`, title: '试验台首页', icon: 'home' },
|
||||
{ path: `${pre}index`, title: '试验台', icon: 'home' },
|
||||
{
|
||||
title: 'svg 菜单图标',
|
||||
iconSvg: 'd2-admin',
|
||||
|
||||
@@ -3,7 +3,7 @@ export default {
|
||||
title: '插件',
|
||||
icon: 'plug',
|
||||
children: (pre => [
|
||||
{ path: `${pre}index`, title: '插件首页', icon: 'home' },
|
||||
{ path: `${pre}index`, title: '插件', icon: 'home' },
|
||||
{
|
||||
path: `${pre}mock`,
|
||||
title: '模拟数据',
|
||||
|
||||
@@ -40,8 +40,7 @@ export default {
|
||||
vm.resetFormData()
|
||||
vm.getFormData(id)
|
||||
})
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
next(new Error('未指定ID'))
|
||||
}
|
||||
},
|
||||
|
||||
@@ -59,7 +59,9 @@ export default {
|
||||
// 请求表格数据
|
||||
getTableData () {
|
||||
fetch()
|
||||
.then(res => this.crud.data = res.list)
|
||||
.then(res => {
|
||||
this.crud.data = res.list
|
||||
})
|
||||
.catch(err => console.log(err))
|
||||
},
|
||||
// 跳转到编辑页面
|
||||
|
||||
69
src/pages/demo/filters/day/components/code-and-result.vue
Normal file
69
src/pages/demo/filters/day/components/code-and-result.vue
Normal file
@@ -0,0 +1,69 @@
|
||||
<template>
|
||||
<div class="d2-mb-10">
|
||||
<el-button-group>
|
||||
<el-button
|
||||
class="code-and-result--button"
|
||||
size="mini">
|
||||
原值
|
||||
</el-button>
|
||||
</el-button-group>
|
||||
<d2-icon name="plus" class="code-and-result--icon"/>
|
||||
<el-button-group>
|
||||
<el-button
|
||||
v-for="(label, index) in labelList"
|
||||
:key="index"
|
||||
class="code-and-result--button"
|
||||
size="mini"
|
||||
type="primary"
|
||||
@click="handleClip(label)">
|
||||
{{label}}
|
||||
</el-button>
|
||||
</el-button-group>
|
||||
<d2-icon name="arrow-right" class="code-and-result--icon"/>
|
||||
<span class="code-and-result--value">{{value}}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import clipboard from 'clipboard-polyfill'
|
||||
export default {
|
||||
props: {
|
||||
label: {
|
||||
default: ''
|
||||
},
|
||||
value: {
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
labelList () {
|
||||
return this.label.split('|')
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleClip (value) {
|
||||
clipboard.writeText(value)
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: `${value} 已经复制到剪贴板`,
|
||||
type: 'success'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.code-and-result--button {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
.code-and-result--icon {
|
||||
color: $color-info;
|
||||
margin: 0px 20px;
|
||||
}
|
||||
.code-and-result--value {
|
||||
font-size: 14px;
|
||||
color: $color-text-main;
|
||||
}
|
||||
</style>
|
||||
41
src/pages/demo/filters/day/components/code-title.vue
Normal file
41
src/pages/demo/filters/day/components/code-title.vue
Normal file
@@ -0,0 +1,41 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1 class="code-title">{{title}}</h1>
|
||||
<h2 class="code-title--sub">{{subTitle}}</h2>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
subTitle: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.code-title {
|
||||
margin: 0px;
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
color: $color-text-main;
|
||||
margin: 10px 0;
|
||||
&:first-child {
|
||||
margin-top: 0px;
|
||||
}
|
||||
}
|
||||
.code-title--sub {
|
||||
margin: 0px;
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
color: $color-text-sub;
|
||||
margin: 10px 0;
|
||||
}
|
||||
</style>
|
||||
95
src/pages/demo/filters/day/index.vue
Normal file
95
src/pages/demo/filters/day/index.vue
Normal file
@@ -0,0 +1,95 @@
|
||||
<template>
|
||||
<d2-container>
|
||||
<div slot="header" flex="main:justify">
|
||||
<el-date-picker size="mini" type="datetime" v-model="value" placeholder="选择一个日期"/>
|
||||
<el-button size="mini" type="primary">原值 value : {{value}}</el-button>
|
||||
</div>
|
||||
<code-title title="获取" sub-title="获取日期的指定部分"/>
|
||||
<code-and-result label="date_year" :value="value|date_year"/>
|
||||
<code-and-result label="date_month" :value="value|date_month"/>
|
||||
<code-and-result label="date_date" :value="value|date_date"/>
|
||||
<code-and-result label="date_day" :value="value|date_day"/>
|
||||
<code-and-result label="date_hour" :value="value|date_hour"/>
|
||||
<code-and-result label="date_minute" :value="value|date_minute"/>
|
||||
<code-and-result label="date_second" :value="value|date_second"/>
|
||||
<code-and-result label="date_millisecond" :value="value|date_millisecond"/>
|
||||
<code-title title="设置" sub-title="设置日期指定部分的值"/>
|
||||
<code-and-result label="date_set('year', 2020)|date_format('< YYYY > - MM - DD')" :value="value|date_set('year', 2020)|date_format('< YYYY > - MM - DD')"/>
|
||||
<code-and-result label="date_set('month', 0)|date_format('YYYY - < MM > - DD')" :value="value|date_set('month', 0)|date_format('YYYY - < MM > - DD')"/>
|
||||
<code-and-result label="date_set('date', 1)|date_format('YYYY - MM - < DD >')" :value="value|date_set('date', 1)|date_format('YYYY - MM - < DD >')"/>
|
||||
<code-and-result label="date_set('hour', 0)|date_format('< HH > : mm : ss')" :value="value|date_set('hour', 0)|date_format('< HH > : mm : ss')"/>
|
||||
<code-and-result label="date_set('minute', 0)|date_format('HH : < mm > : ss')" :value="value|date_set('minute', 0)|date_format('HH : < mm > : ss')"/>
|
||||
<code-and-result label="date_set('second', 0)|date_format('HH : mm : < ss >')" :value="value|date_set('second', 0)|date_format('HH : mm : < ss >')"/>
|
||||
<code-title title="增加" sub-title="增加时间并返回一个新的 Dayjs 对象"/>
|
||||
<code-and-result label="date_add(1, 'year')|date_format('< YYYY > - MM - DD')" :value="value|date_add(1, 'year')|date_format('< YYYY > - MM - DD')"/>
|
||||
<code-and-result label="date_add(1, 'month')|date_format('YYYY - < MM > - DD')" :value="value|date_add(1, 'month')|date_format('YYYY - < MM > - DD')"/>
|
||||
<code-and-result label="date_add(1, 'day')|date_format('YYYY - MM - < DD >')" :value="value|date_add(1, 'day')|date_format('YYYY - MM - < DD >')"/>
|
||||
<code-and-result label="date_add(1, 'hour')|date_format('< HH > : mm : ss')" :value="value|date_add(1, 'hour')|date_format('< HH > : mm : ss')"/>
|
||||
<code-and-result label="date_add(1, 'minute')|date_format('HH : < mm > : ss')" :value="value|date_add(1, 'minute')|date_format('HH : < mm > : ss')"/>
|
||||
<code-and-result label="date_add(1, 'second')|date_format('HH : mm : < ss >')" :value="value|date_add(1, 'second')|date_format('HH : mm : < ss >')"/>
|
||||
<code-title title="减少" sub-title="减少时间并返回一个新的 Dayjs 对象"/>
|
||||
<code-and-result label="date_subtract(1, 'year')|date_format('< YYYY > - MM - DD')" :value="value|date_subtract(1, 'year')|date_format('< YYYY > - MM - DD')"/>
|
||||
<code-and-result label="date_subtract(1, 'month')|date_format('YYYY - < MM > - DD')" :value="value|date_subtract(1, 'month')|date_format('YYYY - < MM > - DD')"/>
|
||||
<code-and-result label="date_subtract(1, 'day')|date_format('YYYY - MM - < DD >')" :value="value|date_subtract(1, 'day')|date_format('YYYY - MM - < DD >')"/>
|
||||
<code-and-result label="date_subtract(1, 'hour')|date_format('< HH > : mm : ss')" :value="value|date_subtract(1, 'hour')|date_format('< HH > : mm : ss')"/>
|
||||
<code-and-result label="date_subtract(1, 'minute')|date_format('HH : < mm > : ss')" :value="value|date_subtract(1, 'minute')|date_format('HH : < mm > : ss')"/>
|
||||
<code-and-result label="date_subtract(1, 'second')|date_format('HH : mm : < ss >')" :value="value|date_subtract(1, 'second')|date_format('HH : mm : < ss >')"/>
|
||||
<code-title title="开头时间" sub-title="返回当前时间的开头时间的 Dayjs 对象,如月份的第一天"/>
|
||||
<code-and-result label="date_startof('year')|date_format" :value="value|date_startof('year')|date_format"/>
|
||||
<code-and-result label="date_startof('month')|date_format" :value="value|date_startof('month')|date_format"/>
|
||||
<code-and-result label="date_startof('date')|date_format" :value="value|date_startof('date')|date_format"/>
|
||||
<code-and-result label="date_startof('hour')|date_format" :value="value|date_startof('hour')|date_format"/>
|
||||
<code-and-result label="date_startof('minute')|date_format" :value="value|date_startof('minute')|date_format"/>
|
||||
<code-title title="末尾时间" sub-title="返回当前时间的末尾时间的 Dayjs 对象,如月份的最后一天"/>
|
||||
<code-and-result label="date_endof('year')|date_format" :value="value|date_endof('year')|date_format"/>
|
||||
<code-and-result label="date_endof('month')|date_format" :value="value|date_endof('month')|date_format"/>
|
||||
<code-and-result label="date_endof('date')|date_format" :value="value|date_endof('date')|date_format"/>
|
||||
<code-and-result label="date_endof('hour')|date_format" :value="value|date_endof('hour')|date_format"/>
|
||||
<code-and-result label="date_endof('minute')|date_format" :value="value|date_endof('minute')|date_format"/>
|
||||
<code-title title="显示" sub-title="格式化 Dayjs 对象并展示"/>
|
||||
<code-and-result label="date_format" :value="value|date_format"/>
|
||||
<code-and-result label="date_format('YY-MM-DD')" :value="value|date_format('YY-MM-DD')"/>
|
||||
<code-and-result label="date_format('YYYY-M-D')" :value="value|date_format('YYYY-M-D')"/>
|
||||
<code-and-result label="date_format('YYYY-M-D H:m:s')" :value="value|date_format('YYYY-M-D H:m:s')"/>
|
||||
<code-title title="时间差" sub-title="获取两个 Dayjs 对象的时间差,默认毫秒"/>
|
||||
<code-and-result label="date_diff('2012-10-31', 'year')" :value="value|date_diff('2012-10-31', 'year')"/>
|
||||
<code-and-result label="date_diff('2012-10-31', 'month')" :value="value|date_diff('2012-10-31', 'month')"/>
|
||||
<code-and-result label="date_diff('2012-10-31', 'day')" :value="value|date_diff('2012-10-31', 'day')"/>
|
||||
<code-and-result label="date_diff('2012-10-31', 'hour')" :value="value|date_diff('2012-10-31', 'hour')"/>
|
||||
<code-and-result label="date_diff('2012-10-31', 'minute')" :value="value|date_diff('2012-10-31', 'minute')"/>
|
||||
<code-and-result label="date_diff('2012-10-31', 'second')" :value="value|date_diff('2012-10-31', 'second')"/>
|
||||
<code-title title="Unix 时间戳" sub-title="返回毫秒和秒"/>
|
||||
<code-and-result label="date_value_millisecond" :value="value|date_value_millisecond"/>
|
||||
<code-and-result label="date_value_second" :value="value|date_value_second"/>
|
||||
<code-title title="月份天数" sub-title="返回传入日期月份的天数"/>
|
||||
<code-and-result label="date_days_in_month" :value="value|date_days_in_month"/>
|
||||
<code-title title="处理为其它格式" sub-title="原生的 Date 对象,数组,json,ios 标准,对象,字符串"/>
|
||||
<code-and-result label="date_to_date" :value="value|date_to_date"/>
|
||||
<code-and-result label="date_to_array" :value="value|date_to_array"/>
|
||||
<code-and-result label="date_to_json" :value="value|date_to_json"/>
|
||||
<code-and-result label="date_to_iso" :value="value|date_to_iso"/>
|
||||
<code-and-result label="date_to_object" :value="value|date_to_object"/>
|
||||
<code-and-result label="date_to_string" :value="value|date_to_string"/>
|
||||
<code-title title="查询" sub-title="是否之前,之后,或者相同"/>
|
||||
<code-and-result label="date_is_before('2020-1-1')" :value="value|date_is_before('2020-1-1')"/>
|
||||
<code-and-result label="date_is_after('2012-1-1')" :value="value|date_is_after('2012-1-1')"/>
|
||||
<code-and-result label="date_is_same(new Date())" :value="value|date_is_same(new Date())"/>
|
||||
<code-and-result label="date_is_same(new Date(), 'date')" :value="value|date_is_same(new Date(), 'date')"/>
|
||||
</d2-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import codeTitle from './components/code-title'
|
||||
import codeAndResult from './components/code-and-result'
|
||||
export default {
|
||||
components: {
|
||||
codeTitle,
|
||||
codeAndResult
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
value: new Date()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
22
src/pages/demo/filters/index/index.vue
Normal file
22
src/pages/demo/filters/index/index.vue
Normal file
@@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<d2-container :filename="filename" type="ghost">
|
||||
<d2-module-index-banner slot="header" v-bind="banner"/>
|
||||
<d2-module-index-menu :menu="menu"/>
|
||||
</d2-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import menu from '@/menu/modules/demo-filters'
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
filename: __filename,
|
||||
menu,
|
||||
banner: {
|
||||
title: 'FILTERS',
|
||||
subTitle: '内置过滤器'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -16,7 +16,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import db from '@/libs/db.js'
|
||||
import util from '@/libs/util'
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
@@ -29,7 +29,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
load () {
|
||||
this.dbData = JSON.stringify(db.value(), null, 2)
|
||||
this.dbData = JSON.stringify(util.db.value(), null, 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,12 @@ import 'flex.css'
|
||||
import '@/components'
|
||||
// svg 图标
|
||||
import '@/assets/svg-icons'
|
||||
// 过滤器
|
||||
import d2VueFiltersDate from '@d2-projects/vue-filters-date'
|
||||
// 功能插件
|
||||
import pluginError from '@/plugin/error'
|
||||
import pluginExport from '@/plugin/export'
|
||||
import pluginImport from '@/plugin/import'
|
||||
import pluginExport from '@d2-projects/vue-table-export'
|
||||
import pluginImport from '@d2-projects/vue-table-import'
|
||||
import pluginLog from '@/plugin/log'
|
||||
import pluginOpen from '@/plugin/open'
|
||||
|
||||
@@ -29,6 +31,8 @@ export default {
|
||||
Vue.prototype.$buildTime = process.env.VUE_APP_BUILD_TIME
|
||||
// Element
|
||||
Vue.use(ElementUI)
|
||||
// 过滤器 日期模块
|
||||
Vue.use(d2VueFiltersDate)
|
||||
// 插件
|
||||
Vue.use(pluginError)
|
||||
Vue.use(pluginExport)
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
/* eslint-disable */
|
||||
/* Blob.js
|
||||
* A Blob implementation.
|
||||
* 2014-05-27
|
||||
*
|
||||
* By Eli Grey, http://eligrey.com
|
||||
* By Devin Samarin, https://github.com/eboyjr
|
||||
* License: X11/MIT
|
||||
* See LICENSE.md
|
||||
*/
|
||||
|
||||
/*global self, unescape */
|
||||
/*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true,
|
||||
plusplus: true */
|
||||
|
||||
/*! @source http://purl.eligrey.com/github/Blob.js/blob/master/Blob.js */
|
||||
|
||||
(function (view) {
|
||||
"use strict";
|
||||
|
||||
view.URL = view.URL || view.webkitURL;
|
||||
|
||||
if (view.Blob && view.URL) {
|
||||
try {
|
||||
new Blob;
|
||||
return;
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// Internally we use a BlobBuilder implementation to base Blob off of
|
||||
// in order to support older browsers that only have BlobBuilder
|
||||
var BlobBuilder = view.BlobBuilder || view.WebKitBlobBuilder || view.MozBlobBuilder || (function(view) {
|
||||
var
|
||||
get_class = function(object) {
|
||||
return Object.prototype.toString.call(object).match(/^\[object\s(.*)\]$/)[1];
|
||||
}
|
||||
, FakeBlobBuilder = function BlobBuilder() {
|
||||
this.data = [];
|
||||
}
|
||||
, FakeBlob = function Blob(data, type, encoding) {
|
||||
this.data = data;
|
||||
this.size = data.length;
|
||||
this.type = type;
|
||||
this.encoding = encoding;
|
||||
}
|
||||
, FBB_proto = FakeBlobBuilder.prototype
|
||||
, FB_proto = FakeBlob.prototype
|
||||
, FileReaderSync = view.FileReaderSync
|
||||
, FileException = function(type) {
|
||||
this.code = this[this.name = type];
|
||||
}
|
||||
, file_ex_codes = (
|
||||
"NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR "
|
||||
+ "NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR"
|
||||
).split(" ")
|
||||
, file_ex_code = file_ex_codes.length
|
||||
, real_URL = view.URL || view.webkitURL || view
|
||||
, real_create_object_URL = real_URL.createObjectURL
|
||||
, real_revoke_object_URL = real_URL.revokeObjectURL
|
||||
, URL = real_URL
|
||||
, btoa = view.btoa
|
||||
, atob = view.atob
|
||||
|
||||
, ArrayBuffer = view.ArrayBuffer
|
||||
, Uint8Array = view.Uint8Array
|
||||
;
|
||||
FakeBlob.fake = FB_proto.fake = true;
|
||||
while (file_ex_code--) {
|
||||
FileException.prototype[file_ex_codes[file_ex_code]] = file_ex_code + 1;
|
||||
}
|
||||
if (!real_URL.createObjectURL) {
|
||||
URL = view.URL = {};
|
||||
}
|
||||
URL.createObjectURL = function(blob) {
|
||||
var
|
||||
type = blob.type
|
||||
, data_URI_header
|
||||
;
|
||||
if (type === null) {
|
||||
type = "application/octet-stream";
|
||||
}
|
||||
if (blob instanceof FakeBlob) {
|
||||
data_URI_header = "data:" + type;
|
||||
if (blob.encoding === "base64") {
|
||||
return data_URI_header + ";base64," + blob.data;
|
||||
} else if (blob.encoding === "URI") {
|
||||
return data_URI_header + "," + decodeURIComponent(blob.data);
|
||||
} if (btoa) {
|
||||
return data_URI_header + ";base64," + btoa(blob.data);
|
||||
} else {
|
||||
return data_URI_header + "," + encodeURIComponent(blob.data);
|
||||
}
|
||||
} else if (real_create_object_URL) {
|
||||
return real_create_object_URL.call(real_URL, blob);
|
||||
}
|
||||
};
|
||||
URL.revokeObjectURL = function(object_URL) {
|
||||
if (object_URL.substring(0, 5) !== "data:" && real_revoke_object_URL) {
|
||||
real_revoke_object_URL.call(real_URL, object_URL);
|
||||
}
|
||||
};
|
||||
FBB_proto.append = function(data/*, endings*/) {
|
||||
var bb = this.data;
|
||||
// decode data to a binary string
|
||||
if (Uint8Array && (data instanceof ArrayBuffer || data instanceof Uint8Array)) {
|
||||
var
|
||||
str = ""
|
||||
, buf = new Uint8Array(data)
|
||||
, i = 0
|
||||
, buf_len = buf.length
|
||||
;
|
||||
for (; i < buf_len; i++) {
|
||||
str += String.fromCharCode(buf[i]);
|
||||
}
|
||||
bb.push(str);
|
||||
} else if (get_class(data) === "Blob" || get_class(data) === "File") {
|
||||
if (FileReaderSync) {
|
||||
var fr = new FileReaderSync;
|
||||
bb.push(fr.readAsBinaryString(data));
|
||||
} else {
|
||||
// async FileReader won't work as BlobBuilder is sync
|
||||
throw new FileException("NOT_READABLE_ERR");
|
||||
}
|
||||
} else if (data instanceof FakeBlob) {
|
||||
if (data.encoding === "base64" && atob) {
|
||||
bb.push(atob(data.data));
|
||||
} else if (data.encoding === "URI") {
|
||||
bb.push(decodeURIComponent(data.data));
|
||||
} else if (data.encoding === "raw") {
|
||||
bb.push(data.data);
|
||||
}
|
||||
} else {
|
||||
if (typeof data !== "string") {
|
||||
data += ""; // convert unsupported types to strings
|
||||
}
|
||||
// decode UTF-16 to binary string
|
||||
bb.push(unescape(encodeURIComponent(data)));
|
||||
}
|
||||
};
|
||||
FBB_proto.getBlob = function(type) {
|
||||
if (!arguments.length) {
|
||||
type = null;
|
||||
}
|
||||
return new FakeBlob(this.data.join(""), type, "raw");
|
||||
};
|
||||
FBB_proto.toString = function() {
|
||||
return "[object BlobBuilder]";
|
||||
};
|
||||
FB_proto.slice = function(start, end, type) {
|
||||
var args = arguments.length;
|
||||
if (args < 3) {
|
||||
type = null;
|
||||
}
|
||||
return new FakeBlob(
|
||||
this.data.slice(start, args > 1 ? end : this.data.length)
|
||||
, type
|
||||
, this.encoding
|
||||
);
|
||||
};
|
||||
FB_proto.toString = function() {
|
||||
return "[object Blob]";
|
||||
};
|
||||
FB_proto.close = function() {
|
||||
this.size = this.data.length = 0;
|
||||
};
|
||||
return FakeBlobBuilder;
|
||||
}(view));
|
||||
|
||||
view.Blob = function Blob(blobParts, options) {
|
||||
var type = options ? (options.type || "") : "";
|
||||
var builder = new BlobBuilder();
|
||||
if (blobParts) {
|
||||
for (var i = 0, len = blobParts.length; i < len; i++) {
|
||||
builder.append(blobParts[i]);
|
||||
}
|
||||
}
|
||||
return builder.getBlob(type);
|
||||
};
|
||||
}(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this.content || this));
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
inspired by https://www.npmjs.com/package/react-csv-downloader
|
||||
now removed from Github
|
||||
inspired by https://github.com/iview/iview
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
|
||||
const newLine = '\r\n';
|
||||
const appendLine = (content, row, { separator, quoted }) => {
|
||||
const line = row.map(data => {
|
||||
if (!quoted) return data;
|
||||
// quote data
|
||||
data = typeof data === 'string' ? data.replace(/"/g, '"') : data;
|
||||
return `"${data}"`;
|
||||
});
|
||||
content.push(line.join(separator));
|
||||
};
|
||||
|
||||
const defaults = {
|
||||
separator: ',',
|
||||
quoted: false
|
||||
};
|
||||
|
||||
export default function csv(columns, datas, options, noHeader = false) {
|
||||
options = Object.assign({}, defaults, options);
|
||||
let columnOrder;
|
||||
const content = [];
|
||||
const column = [];
|
||||
|
||||
if (columns) {
|
||||
columnOrder = columns.map(v => {
|
||||
if (typeof v === 'string') return v;
|
||||
if (!noHeader) {
|
||||
column.push(typeof v.label !== 'undefined' ? v.label : v.prop);
|
||||
}
|
||||
return v.prop;
|
||||
});
|
||||
if (column.length > 0) appendLine(content, column, options);
|
||||
} else {
|
||||
columnOrder = [];
|
||||
datas.forEach(v => {
|
||||
if (!Array.isArray(v)) {
|
||||
columnOrder = columnOrder.concat(Object.keys(v));
|
||||
}
|
||||
});
|
||||
if (columnOrder.length > 0) {
|
||||
columnOrder = columnOrder.filter((value, index, self) => self.indexOf(value) === index);
|
||||
if (!noHeader) appendLine(content, columnOrder, options);
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(datas)) {
|
||||
datas.forEach(row => {
|
||||
if (!Array.isArray(row)) {
|
||||
row = columnOrder.map(k => (typeof row[k] !== 'undefined' ? row[k] : ''));
|
||||
}
|
||||
appendLine(content, row, options);
|
||||
});
|
||||
}
|
||||
return content.join(newLine);
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
/* eslint-disable */
|
||||
|
||||
/*
|
||||
此代码来源于iview表格组件的CSV导出部分
|
||||
https://github.com/iview/iview
|
||||
*/
|
||||
|
||||
function has (browser) {
|
||||
const ua = navigator.userAgent;
|
||||
if (browser === 'ie') {
|
||||
const isIE = ua.indexOf('compatible') > -1 && ua.indexOf('MSIE') > -1;
|
||||
if (isIE) {
|
||||
const reIE = new RegExp('MSIE (\\d+\\.\\d+);');
|
||||
reIE.test(ua);
|
||||
return parseFloat(RegExp['$1']);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return ua.indexOf(browser) > -1;
|
||||
}
|
||||
}
|
||||
|
||||
const csv = {
|
||||
_isIE11 () {
|
||||
let iev = 0;
|
||||
const ieold = (/MSIE (\d+\.\d+);/.test(navigator.userAgent));
|
||||
const trident = !!navigator.userAgent.match(/Trident\/7.0/);
|
||||
const rv = navigator.userAgent.indexOf('rv:11.0');
|
||||
|
||||
if (ieold) {
|
||||
iev = Number(RegExp.$1);
|
||||
}
|
||||
if (navigator.appVersion.indexOf('MSIE 10') !== -1) {
|
||||
iev = 10;
|
||||
}
|
||||
if (trident && rv !== -1) {
|
||||
iev = 11;
|
||||
}
|
||||
|
||||
return iev === 11;
|
||||
},
|
||||
|
||||
_isEdge () {
|
||||
return /Edge/.test(navigator.userAgent);
|
||||
},
|
||||
|
||||
_getDownloadUrl (text) {
|
||||
const BOM = '\uFEFF';
|
||||
// Add BOM to text for open in excel correctly
|
||||
if (window.Blob && window.URL && window.URL.createObjectURL) {
|
||||
const csvData = new Blob([BOM + text], { type: 'text/csv' });
|
||||
return URL.createObjectURL(csvData);
|
||||
} else {
|
||||
return 'data:attachment/csv;charset=utf-8,' + BOM + encodeURIComponent(text);
|
||||
}
|
||||
},
|
||||
|
||||
download (filename, text) {
|
||||
if (has('ie') && has('ie') < 10) {
|
||||
// has module unable identify ie11 and Edge
|
||||
const oWin = window.top.open('about:blank', '_blank');
|
||||
oWin.document.charset = 'utf-8';
|
||||
oWin.document.write(text);
|
||||
oWin.document.close();
|
||||
oWin.document.execCommand('SaveAs', filename + '.csv');
|
||||
oWin.close();
|
||||
} else if (has('ie') === 10 || this._isIE11() || this._isEdge()) {
|
||||
const BOM = '\uFEFF';
|
||||
const csvData = new Blob([BOM + text], { type: 'text/csv' });
|
||||
navigator.msSaveBlob(csvData, filename + '.csv');
|
||||
} else {
|
||||
const link = document.createElement('a');
|
||||
link.download = filename + '.csv';
|
||||
link.href = this._getDownloadUrl(text);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default csv;
|
||||
@@ -1,151 +0,0 @@
|
||||
/* eslint-disable */
|
||||
|
||||
// 来源于网络 有细微改动
|
||||
|
||||
import './_blob'
|
||||
import FileSaver from 'file-saver'
|
||||
import XLSX from 'xlsx'
|
||||
|
||||
function generateArray(table) {
|
||||
var out = [];
|
||||
var rows = table.querySelectorAll('tr');
|
||||
var ranges = [];
|
||||
for (var R = 0; R < rows.length; ++R) {
|
||||
var outRow = [];
|
||||
var row = rows[R];
|
||||
var columns = row.querySelectorAll('td');
|
||||
for (var C = 0; C < columns.length; ++C) {
|
||||
var cell = columns[C];
|
||||
var colspan = cell.getAttribute('colspan');
|
||||
var rowspan = cell.getAttribute('rowspan');
|
||||
var cellValue = cell.innerText;
|
||||
if (cellValue !== "" && cellValue == +cellValue) cellValue = +cellValue;
|
||||
|
||||
//Skip ranges
|
||||
ranges.forEach(function (range) {
|
||||
if (R >= range.s.r && R <= range.e.r && outRow.length >= range.s.c && outRow.length <= range.e.c) {
|
||||
for (var i = 0; i <= range.e.c - range.s.c; ++i) outRow.push(null);
|
||||
}
|
||||
});
|
||||
|
||||
//Handle Row Span
|
||||
if (rowspan || colspan) {
|
||||
rowspan = rowspan || 1;
|
||||
colspan = colspan || 1;
|
||||
ranges.push({s: {r: R, c: outRow.length}, e: {r: R + rowspan - 1, c: outRow.length + colspan - 1}});
|
||||
}
|
||||
;
|
||||
|
||||
//Handle Value
|
||||
outRow.push(cellValue !== "" ? cellValue : null);
|
||||
|
||||
//Handle Colspan
|
||||
if (colspan) for (var k = 0; k < colspan - 1; ++k) outRow.push(null);
|
||||
}
|
||||
out.push(outRow);
|
||||
}
|
||||
return [out, ranges];
|
||||
};
|
||||
|
||||
function datenum(v, date1904) {
|
||||
if (date1904) v += 1462;
|
||||
var epoch = Date.parse(v);
|
||||
return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000);
|
||||
}
|
||||
|
||||
function sheet_from_array_of_arrays(data, opts) {
|
||||
var ws = {};
|
||||
var range = {s: {c: 10000000, r: 10000000}, e: {c: 0, r: 0}};
|
||||
for (var R = 0; R != data.length; ++R) {
|
||||
for (var C = 0; C != data[R].length; ++C) {
|
||||
if (range.s.r > R) range.s.r = R;
|
||||
if (range.s.c > C) range.s.c = C;
|
||||
if (range.e.r < R) range.e.r = R;
|
||||
if (range.e.c < C) range.e.c = C;
|
||||
var cell = {v: data[R][C]};
|
||||
if (cell.v == null) continue;
|
||||
var cell_ref = XLSX.utils.encode_cell({c: C, r: R});
|
||||
|
||||
if (typeof cell.v === 'number') cell.t = 'n';
|
||||
else if (typeof cell.v === 'boolean') cell.t = 'b';
|
||||
else if (cell.v instanceof Date) {
|
||||
cell.t = 'n';
|
||||
cell.z = XLSX.SSF._table[14];
|
||||
cell.v = datenum(cell.v);
|
||||
}
|
||||
else cell.t = 's';
|
||||
|
||||
ws[cell_ref] = cell;
|
||||
}
|
||||
}
|
||||
if (range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range);
|
||||
return ws;
|
||||
}
|
||||
|
||||
function Workbook() {
|
||||
if (!(this instanceof Workbook)) return new Workbook();
|
||||
this.SheetNames = [];
|
||||
this.Sheets = {};
|
||||
}
|
||||
|
||||
function s2ab(s) {
|
||||
var buf = new ArrayBuffer(s.length);
|
||||
var view = new Uint8Array(buf);
|
||||
for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
|
||||
return buf;
|
||||
}
|
||||
|
||||
export function export_table_to_excel(id) {
|
||||
var theTable = document.getElementById(id);
|
||||
console.log('a')
|
||||
var oo = generateArray(theTable);
|
||||
var ranges = oo[1];
|
||||
|
||||
/* original data */
|
||||
var data = oo[0];
|
||||
var ws_name = "SheetJS";
|
||||
console.log(data);
|
||||
|
||||
var wb = new Workbook(), ws = sheet_from_array_of_arrays(data);
|
||||
|
||||
/* add ranges to worksheet */
|
||||
// ws['!cols'] = ['apple', 'banan'];
|
||||
ws['!merges'] = ranges;
|
||||
|
||||
/* add worksheet to workbook */
|
||||
wb.SheetNames.push(ws_name);
|
||||
wb.Sheets[ws_name] = ws;
|
||||
|
||||
var wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: false, type: 'binary'});
|
||||
|
||||
FileSaver.saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), "test.xlsx")
|
||||
}
|
||||
|
||||
function formatJson(jsonData) {
|
||||
console.log(jsonData)
|
||||
}
|
||||
export function export_json_to_excel(th, jsonData, defaultTitle, options = { merges: [], header: null }) {
|
||||
|
||||
/* original data */
|
||||
|
||||
var data = jsonData;
|
||||
data.unshift(th);
|
||||
if (options.header) data.unshift([options.header]);
|
||||
var ws_name = "SheetJS";
|
||||
|
||||
var wb = new Workbook(), ws = sheet_from_array_of_arrays(data);
|
||||
|
||||
/* add merges area to worksheet */
|
||||
let { merges } = options;
|
||||
if (typeof merges[0] == 'string' && merges.length == 2) merges = [merges] // just one # ['A1', 'C1'] = > [['A1', 'C1']]
|
||||
merges = merges.map(i => i instanceof Array ? { s: i[0], e: i[1] } : i); // be sort :) # ['A1', 'C1'] => { s: 'A1', e: 'C3' }
|
||||
ws['!merges'] = merges;
|
||||
|
||||
/* add worksheet to workbook */
|
||||
wb.SheetNames.push(ws_name);
|
||||
wb.Sheets[ws_name] = ws;
|
||||
|
||||
var wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: false, type: 'binary'});
|
||||
var title = defaultTitle || '列表'
|
||||
FileSaver.saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), title + ".xlsx")
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/* eslint-disable */
|
||||
|
||||
// 库
|
||||
import Csv from './_csv'
|
||||
import ExportCsv from './_export-csv'
|
||||
import FileSaver from 'file-saver'
|
||||
import * as Excel from './_export2Excel'
|
||||
|
||||
export default {
|
||||
install (Vue, options) {
|
||||
Vue.prototype.$export = {
|
||||
// 导出 csv
|
||||
csv (params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 默认值
|
||||
const paramsDefault = {
|
||||
columns: [],
|
||||
data: [],
|
||||
title: 'table',
|
||||
noHeader: false
|
||||
}
|
||||
// 合并参数
|
||||
const _params = Object.assign({}, paramsDefault, params)
|
||||
// 生成数据
|
||||
const data = Csv(_params.columns, _params.data, params, _params.noHeader)
|
||||
// 下载数据
|
||||
ExportCsv.download(_params.title, data)
|
||||
// 完成
|
||||
resolve()
|
||||
})
|
||||
},
|
||||
// 导出 excel
|
||||
excel (params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 默认值
|
||||
const paramsDefault = {
|
||||
columns: [],
|
||||
data: [],
|
||||
title: 'table',
|
||||
header: null,
|
||||
merges: []
|
||||
}
|
||||
// 合并参数
|
||||
const _params = Object.assign({}, paramsDefault, params)
|
||||
// 从参数中派生数据
|
||||
const header = _params.columns.map(e => e.label)
|
||||
const data = _params.data.map(row => _params.columns.map(col => row[col.prop]))
|
||||
// 导出
|
||||
Excel.export_json_to_excel(header, data, _params.title, { merges: _params.merges, header: _params.header })
|
||||
// 完成
|
||||
resolve()
|
||||
})
|
||||
},
|
||||
// 导出 文本文档
|
||||
txt (params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 默认值
|
||||
const paramsDefault = {
|
||||
text: '',
|
||||
title: '文本'
|
||||
}
|
||||
// 合并参数
|
||||
const _params = Object.assign({}, paramsDefault, params)
|
||||
// 导出
|
||||
const blob = new Blob([_params.text], {type: 'text/plain;charset=utf-8'})
|
||||
FileSaver.saveAs(blob, _params.title + '.txt')
|
||||
// 完成
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/* eslint-disable */
|
||||
|
||||
// 库
|
||||
import papa from 'papaparse'
|
||||
import xlsx from 'xlsx'
|
||||
|
||||
export default {
|
||||
install (Vue, options) {
|
||||
Vue.prototype.$import = {
|
||||
// 导入 csv
|
||||
csv (file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
papa.parse(file, {
|
||||
header: true,
|
||||
skipEmptyLines: true,
|
||||
complete: (results, file) => {
|
||||
resolve(results)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
// 导入 xlsx
|
||||
xlsx (file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader()
|
||||
const fixdata = data => {
|
||||
let o = ''
|
||||
let l = 0
|
||||
const w = 10240
|
||||
for (; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)))
|
||||
o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)))
|
||||
return o
|
||||
}
|
||||
const getHeaderRow = sheet => {
|
||||
const headers = []
|
||||
const range = xlsx.utils.decode_range(sheet['!ref'])
|
||||
let C
|
||||
const R = range.s.r
|
||||
for (C = range.s.c; C <= range.e.c; ++C) {
|
||||
var cell = sheet[xlsx.utils.encode_cell({ c: C, r: R })]
|
||||
var hdr = 'UNKNOWN ' + C
|
||||
if (cell && cell.t) hdr = xlsx.utils.format_cell(cell)
|
||||
headers.push(hdr)
|
||||
}
|
||||
return headers
|
||||
}
|
||||
reader.onload = e => {
|
||||
const data = e.target.result
|
||||
const fixedData = fixdata(data)
|
||||
const workbook = xlsx.read(btoa(fixedData), { type: 'base64' })
|
||||
const firstSheetName = workbook.SheetNames[0]
|
||||
const worksheet = workbook.Sheets[firstSheetName]
|
||||
const header = getHeaderRow(worksheet)
|
||||
const results = xlsx.utils.sheet_to_json(worksheet)
|
||||
resolve({header, results})
|
||||
}
|
||||
reader.readAsArrayBuffer(file)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
25
src/router/modules/filters.js
Normal file
25
src/router/modules/filters.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import layoutHeaderAside from '@/layout/header-aside'
|
||||
|
||||
const meta = { auth: true }
|
||||
|
||||
export default {
|
||||
path: '/demo/filters',
|
||||
name: 'demo-filters',
|
||||
meta,
|
||||
redirect: { name: 'demo-filters-index' },
|
||||
component: layoutHeaderAside,
|
||||
children: (pre => [
|
||||
{
|
||||
path: 'index',
|
||||
name: `${pre}index`,
|
||||
component: () => import('@/pages/demo/filters/index'),
|
||||
meta: { ...meta, title: '过滤器首页' }
|
||||
},
|
||||
{
|
||||
path: 'day',
|
||||
name: `${pre}day`,
|
||||
component: () => import('@/pages/demo/filters/day'),
|
||||
meta: { ...meta, title: '日期和时间' }
|
||||
}
|
||||
])('demo-filters-')
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import plugins from './modules/plugins'
|
||||
import charts from './modules/charts'
|
||||
import components from './modules/components'
|
||||
import element from './modules/element'
|
||||
import filters from './modules/filters'
|
||||
import business from './modules/business'
|
||||
|
||||
import layoutHeaderAside from '@/layout/header-aside'
|
||||
@@ -60,6 +61,7 @@ const frameIn = [
|
||||
charts,
|
||||
components,
|
||||
element,
|
||||
filters,
|
||||
business
|
||||
]
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import db from '@/libs/db.js'
|
||||
import util from '@/libs/util.js'
|
||||
import util from '@/libs/util'
|
||||
import { cloneDeep } from 'lodash'
|
||||
|
||||
/**
|
||||
@@ -20,7 +19,7 @@ function pathInit ({
|
||||
}) {
|
||||
const uuid = util.cookies.get('uuid') || 'ghost-uuid'
|
||||
const currentPath = `${dbName}.${user ? `user.${uuid}` : 'public'}${path ? `.${path}` : ''}`
|
||||
const value = db.get(currentPath).value()
|
||||
const value = util.db.get(currentPath).value()
|
||||
// console.group('pathInit')
|
||||
// console.log('dbName', dbName)
|
||||
// console.log('path', path)
|
||||
@@ -29,7 +28,7 @@ function pathInit ({
|
||||
// console.log('value', value)
|
||||
// console.groupEnd()
|
||||
if (!(value !== undefined && validator(value))) {
|
||||
db
|
||||
util.db
|
||||
.set(currentPath, defaultValue)
|
||||
.write()
|
||||
}
|
||||
@@ -53,7 +52,7 @@ export default {
|
||||
value = '',
|
||||
user = false
|
||||
}) {
|
||||
db.set(pathInit({
|
||||
util.db.set(pathInit({
|
||||
dbName,
|
||||
path,
|
||||
user
|
||||
@@ -74,7 +73,7 @@ export default {
|
||||
user = false
|
||||
}) {
|
||||
return new Promise(resolve => {
|
||||
resolve(cloneDeep(db.get(pathInit({
|
||||
resolve(cloneDeep(util.db.get(pathInit({
|
||||
dbName,
|
||||
path,
|
||||
user,
|
||||
@@ -91,7 +90,7 @@ export default {
|
||||
user = false
|
||||
} = {}) {
|
||||
return new Promise(resolve => {
|
||||
resolve(db.get(pathInit({
|
||||
resolve(util.db.get(pathInit({
|
||||
dbName: 'database',
|
||||
path: '',
|
||||
user,
|
||||
@@ -108,7 +107,7 @@ export default {
|
||||
user = false
|
||||
} = {}) {
|
||||
return new Promise(resolve => {
|
||||
resolve(db.get(pathInit({
|
||||
resolve(util.db.get(pathInit({
|
||||
dbName: 'database',
|
||||
path: '',
|
||||
user,
|
||||
@@ -130,7 +129,7 @@ export default {
|
||||
user = false
|
||||
} = {}) {
|
||||
return new Promise(resolve => {
|
||||
resolve(db.get(pathInit({
|
||||
resolve(util.db.get(pathInit({
|
||||
dbName: 'database',
|
||||
path: `$page.${vm.$route[basis]}`,
|
||||
user,
|
||||
@@ -151,7 +150,7 @@ export default {
|
||||
user = false
|
||||
} = {}) {
|
||||
return new Promise(resolve => {
|
||||
resolve(db.get(pathInit({
|
||||
resolve(util.db.get(pathInit({
|
||||
dbName: 'database',
|
||||
path: `$page.${vm.$route[basis]}`,
|
||||
user,
|
||||
@@ -173,7 +172,7 @@ export default {
|
||||
user = false
|
||||
}) {
|
||||
return new Promise(resolve => {
|
||||
resolve(db.get(pathInit({
|
||||
resolve(util.db.get(pathInit({
|
||||
dbName: 'database',
|
||||
path: `$page.${vm.$route[basis]}.$data`,
|
||||
user,
|
||||
@@ -195,7 +194,7 @@ export default {
|
||||
user = false
|
||||
}) {
|
||||
return new Promise(resolve => {
|
||||
resolve(cloneDeep(db.get(pathInit({
|
||||
resolve(cloneDeep(util.db.get(pathInit({
|
||||
dbName: 'database',
|
||||
path: `$page.${vm.$route[basis]}.$data`,
|
||||
user,
|
||||
@@ -216,7 +215,7 @@ export default {
|
||||
user = false
|
||||
}) {
|
||||
return new Promise(resolve => {
|
||||
resolve(db.get(pathInit({
|
||||
resolve(util.db.get(pathInit({
|
||||
dbName: 'database',
|
||||
path: `$page.${vm.$route[basis]}.$data`,
|
||||
user,
|
||||
|
||||
Reference in New Issue
Block a user