|
@@ -22,9 +22,9 @@
|
|
|
</div>
|
|
|
<div class="cy-div2">
|
|
|
<input ref="importFileNode" class="import-file-node" type="file" @change="loadExcel" style="display: none;"></input>
|
|
|
- <div class="cy-chart-div" @click="newReportTemplate" v-if="false">
|
|
|
- <svg-icon icon-class="report_new" style="width: 35px; height: 35px; margin-bottom: 6px;"/>
|
|
|
- <span>新建</span>
|
|
|
+ <div v-if="templateId && templateId != 0 && templateId != -999" class="cy-chart-div" @click="saveReportTemplate('saveAs')">
|
|
|
+ <svg-icon icon-class="report_save" style="width: 35px; height: 35px; margin-bottom: 6px;"/>
|
|
|
+ <span>另存为</span>
|
|
|
</div>
|
|
|
<div class="cy-chart-div" @click="saveReportTemplate">
|
|
|
<svg-icon icon-class="report_save" style="width: 35px; height: 35px; margin-bottom: 6px;"/>
|
|
@@ -576,10 +576,19 @@ export default {
|
|
|
/** 初始化操作 */
|
|
|
initLuckysheet(tempId, type) {
|
|
|
let _this = this
|
|
|
+ if (type) {
|
|
|
+ this.withTypeReportTemplate(type)
|
|
|
+ return
|
|
|
+ }
|
|
|
if (tempId && tempId != -999) {
|
|
|
_this.getTableTemplate(tempId, type)
|
|
|
return
|
|
|
}
|
|
|
+ this.templateId = null
|
|
|
+ this.templateVersion = null
|
|
|
+ this.templateName = ''
|
|
|
+ this.toolChart = []
|
|
|
+ this.toolTable = []
|
|
|
luckysheet.destroy()
|
|
|
let locItem = localStorage.getItem(_this.reportTemplateItem)
|
|
|
if (locItem && JSON.parse(locItem).data && Array.isArray(JSON.parse(locItem).data)) {
|
|
@@ -665,7 +674,11 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
/** 保存模版信息 */
|
|
|
- saveReportTemplate() {
|
|
|
+ saveReportTemplate(type) {
|
|
|
+ let _templateName = this.templateName
|
|
|
+ if (type == 'saveAs') {
|
|
|
+ this.templateName = '副本_' + _templateName
|
|
|
+ }
|
|
|
this.$prompt('请输入/确认报表模板名称', '保存', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
@@ -697,7 +710,7 @@ export default {
|
|
|
'templateName': value,
|
|
|
'templateData': JSON.stringify(result)
|
|
|
}
|
|
|
- if (this.templateId) {
|
|
|
+ if (this.templateId && type != 'saveAs') {
|
|
|
data.id = this.templateId
|
|
|
data.version = this.templateVersion
|
|
|
updateReportTemplate(data).then(res => {
|
|
@@ -708,7 +721,7 @@ export default {
|
|
|
message: msg,
|
|
|
type: msgType
|
|
|
})
|
|
|
- this.clearReportTemplate()
|
|
|
+ this.resetReport()
|
|
|
this.getTableTemplate(this.$route.query.id, this.$route.query.type)
|
|
|
this.$emit('refreshReportTemplateData', new Date().getTime())
|
|
|
}).catch((e) => {
|
|
@@ -724,7 +737,7 @@ export default {
|
|
|
message: msg,
|
|
|
type: msgType
|
|
|
})
|
|
|
- this.clearReportTemplate()
|
|
|
+ this.resetReport()
|
|
|
this.$emit('refreshReportTemplateData', new Date().getTime())
|
|
|
}).catch((e) => {
|
|
|
loading.close()
|
|
@@ -732,19 +745,16 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
}).catch(() => {
|
|
|
+ this.templateName = _templateName
|
|
|
})
|
|
|
},
|
|
|
- /** 新建报表内容 */
|
|
|
- newReportTemplate(type) {
|
|
|
- this.templateId = null
|
|
|
- this.templateVersion = null
|
|
|
- this.templateName = ''
|
|
|
- this.clearReportTemplate(type)
|
|
|
- // this.$emit('refreshReportTemplateData', true)
|
|
|
- },
|
|
|
+ /** 重置报表信息 */
|
|
|
resetReport() {
|
|
|
let _this = this
|
|
|
localStorage.removeItem(this.reportTemplateItem)
|
|
|
+ this.templateId = null
|
|
|
+ this.templateVersion = null
|
|
|
+ this.templateName = ''
|
|
|
this.toolChart = []
|
|
|
this.toolTable = []
|
|
|
luckysheet.destroy()
|
|
@@ -761,31 +771,12 @@ export default {
|
|
|
}
|
|
|
luckysheet.create(option)
|
|
|
},
|
|
|
- /** 取消报表内容 */
|
|
|
- clearReportTemplate(type) {
|
|
|
- let _this = this
|
|
|
- localStorage.removeItem(this.reportTemplateItem)
|
|
|
- this.toolChart = []
|
|
|
- this.toolTable = []
|
|
|
- this.templateName = ''
|
|
|
- // 报表模板导入
|
|
|
- if (type === 'import') {
|
|
|
+ /** 处理报表事件报表内容 */
|
|
|
+ withTypeReportTemplate(type) {
|
|
|
+ this.resetReport()
|
|
|
+ if (type === 'import') { // 报表模板导入
|
|
|
console.log('导入报表')
|
|
|
this.$refs.importFileNode.dispatchEvent(new MouseEvent('click'))
|
|
|
- } else {
|
|
|
- luckysheet.destroy()
|
|
|
- let option = JSON.parse(JSON.stringify(this.luckysheetOption))
|
|
|
- option.hook = {
|
|
|
- workbookCreateAfter() {
|
|
|
- _this.autoSaveReportInfo()
|
|
|
- },
|
|
|
- cellUpdated(r, c, newV, oldV) {
|
|
|
- if (!(r === 49 && c === 0)) {
|
|
|
- _this.forceRefreshLuckysheet()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- luckysheet.create(option)
|
|
|
}
|
|
|
},
|
|
|
/** 导入报表 */
|
|
@@ -1561,7 +1552,7 @@ export default {
|
|
|
getTableTemplate(id, type) {
|
|
|
let _this = this
|
|
|
if (!id || id == -999) {
|
|
|
- this.newReportTemplate(type)
|
|
|
+ this.resetReport()
|
|
|
return
|
|
|
}
|
|
|
getTableTemplateById(id).then(res => {
|