Explorar el Código

make_model: support date filename suffix when exporting

master
Bing Sun hace 5 años
padre
commit
3a245825c7
Firmado por: sunb ID de clave GPG: F7795F8C590626AB
Se han modificado 1 ficheros con 19 adiciones y 11 borrados
  1. +19
    -11
      src/util/make_model.js

+ 19
- 11
src/util/make_model.js Ver fichero

@@ -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


Cargando…
Cancelar
Guardar