浏览代码

make_model: support date filename suffix when exporting

master
Bing Sun 5 年前
父节点
当前提交
3a245825c7
签署人:: sunb GPG 密钥 ID: F7795F8C590626AB
共有 1 个文件被更改,包括 19 次插入11 次删除
  1. +19
    -11
      src/util/make_model.js

+ 19
- 11
src/util/make_model.js 查看文件

@@ -211,7 +211,6 @@ export default (options={}) => {
},

export(options={}) {
options.filename = options.filename || _configs.endpoint
let _data = this.data()

if (options.type == 'csv') {
@@ -226,16 +225,25 @@ export default (options={}) => {
let blob = new Blob([_data], {type: options.type})
let url = URL.createObjectURL(blob)

if (options.timestamp)
options.filename = options.filename + (new Date()).toLocaleTimeString(undefined, {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: false
})
options.filename = options.filename || _configs.endpoint
if (options.filename_suffix) {
if (options.filename_suffix == 'datetime')
options.filename = options.filename + (new Date()).toLocaleTimeString(undefined, {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: false
})
else if (options.filename_suffix == 'date')
options.filename = options.filename + (new Date()).toLocaleDateString(undefined, {
year: "numeric",
month: "2-digit",
day: "2-digit"
})
}

let anchor = document.createElement('a')
anchor.href = url


正在加载...
取消
保存