|
@@ -49,8 +49,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import Api from '@/api'
|
|
|
-import System from '@/utils/system'
|
|
|
+import {CommonApi} from '@/api'
|
|
|
+import System from '@/utils/system'
|
|
|
import {mapState, mapActions} from "pinia";
|
|
|
import {globalStore, modeStore} from "@/store";
|
|
|
import YvanPrintContainer from "@/components/yvan-ui/YvanPrintContainer.vue";
|
|
@@ -185,23 +185,31 @@ export default {
|
|
|
|
|
|
},
|
|
|
exportJSON() {
|
|
|
- let eleA = document.createElement('a')
|
|
|
- eleA.download = `${this.pageConfig.title + "_" + Date.now()}.json`
|
|
|
- eleA.style.display = 'none'
|
|
|
- const saveData = this.getTemplateJSON()
|
|
|
- const blob = new Blob([JSON.stringify(saveData)])
|
|
|
- eleA.href = URL.createObjectURL(blob)
|
|
|
- document.body.appendChild(eleA)
|
|
|
- eleA.click()
|
|
|
- document.body.removeChild(eleA)
|
|
|
- // window['system'].toast('导出成功!', 'success')
|
|
|
+ const loadingId = System.loading();
|
|
|
+ try {
|
|
|
+ let eleA = document.createElement('a')
|
|
|
+ eleA.download = `${this.pageConfig.title + "_" + Date.now()}.json`
|
|
|
+ eleA.style.display = 'none'
|
|
|
+ const saveData = this.getTemplateJSON()
|
|
|
+ const blob = new Blob([JSON.stringify(saveData)])
|
|
|
+ eleA.href = URL.createObjectURL(blob)
|
|
|
+ document.body.appendChild(eleA)
|
|
|
+ eleA.click()
|
|
|
+ document.body.removeChild(eleA)
|
|
|
+ System.alert('导出成功!', 'success')
|
|
|
+ } catch (e) {
|
|
|
+ System.alert('导出失败!', 'error')
|
|
|
+ } finally {
|
|
|
+ System.unloading(loadingId);
|
|
|
+ }
|
|
|
},
|
|
|
uploadTemplate() {
|
|
|
|
|
|
},
|
|
|
previewTemplate() {
|
|
|
const saveData = this.getTemplateJSON();
|
|
|
- Api.previewTemplate(JSON.stringify(saveData), {}, (res) => {
|
|
|
+ const loadingId = System.loading();
|
|
|
+ CommonApi.previewTemplate(JSON.stringify(saveData), {}, (res) => {
|
|
|
if (res.status === 200) {
|
|
|
let URL = window.URL || window.webkitURL;
|
|
|
const url = URL.createObjectURL(res.data);
|
|
@@ -209,7 +217,9 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
System.toast("打印模板预览异常, 请稍后再试")
|
|
|
- }).finally();
|
|
|
+ }).finally(() => {
|
|
|
+ System.unloading(loadingId);
|
|
|
+ });
|
|
|
},
|
|
|
getTemplateJSON() {
|
|
|
const saveData = {
|