const Magix = require('magix'); const View = require('dmp-new/view') Magix.applyStyle('@./lbs.less') module.exports = View.extend({ tmpl: '@upload-shop-batch.html', init(options) { this.options = options }, render() { let loc = Magix.Router.parse(); let apiPrefix = 'api' const user = this.updater.get('user') if (!window.__isRap__ && user.loginUser.operType != 7) { apiPrefix = 'api_2' } this.updater.digest({ dmpApiHost: Magix.config('dmp-new.api.host') || '', apiPrefix, text: `1. 仅支持 txt 或 csv 格式文件上传,文件须采用 UTF-8(WITHOUT BOM)编码格式;
列信息区隔符号为英文逗号“,”;
请"下载模板"并根据指定列填写,模板填写请参考 操作手册。
2. 批量门店有效数据不少于50条,最多2000条。`, uploading: false, complete: false }) }, 'cancel'(e) { this.options.dialog.close() }, 'add'(e) { let lbsPois = this.updater.get('lbsPois') let fileName = this.updater.get('fileName') if (!lbsPois || !lbsPois.length) { return this.alert('提示', `请先上传文件`, null, { mask: true }) } this.options.addCallback(fileName, lbsPois) this.options.dialog.close() }, 'uploadSuccess'(e) { const Accounting = this.updater.get('Accounting') this.updater.digest({ percent: 100 }) setTimeout(() => { this.updater.set({ uploading: false, complete: true }) if (!e.response.info.ok) { return this.updater.digest({ uploadSuccess: false, uploadFailMsg: e.response.info.message || e.response.info.msg }) // return this.alert('错误提示', `上传失败,失败原因:${e.response.info.message || e.response.info.msg}`, null, { mask: true }) } const data = e.response.data let failPercent if (data.fail) { failPercent = Accounting.formatNumber(data.fail / data.total * 100, 2) } this.updater.digest({ fileName: e.files[0].name, failPercent, fileId: data.fileId, lbsPois: data.lbsPois, uploadSuccess: true }) }, 800); }, 'uploadProgress'(e) { const Accounting = this.updater.get('Accounting') let percent = e.percent > 0.9 ? 0.9 : e.percent this.updater.digest({ uploading: true, percent: Accounting.formatNumber(percent * 100, 2) }) }, 'uploadError'(e) { return this.updater.digest({ uploading: false, uploadSuccess: false, uploadFailMsg: e.error }) // this.alert('错误提示', `上传失败,失败原因:${e.error}`, null, { mask: true }) } });