| @@ -8,7 +8,8 @@ export default { | |||||
| data() { | data() { | ||||
| return { | return { | ||||
| tenantId: '', | tenantId: '', | ||||
| printData: [], | |||||
| templateId: '', | |||||
| // printData: [], | |||||
| value: { | value: { | ||||
| title: 'demo', | title: 'demo', | ||||
| width: 750, | width: 750, | ||||
| @@ -52,20 +53,20 @@ export default { | |||||
| .then(res => { | .then(res => { | ||||
| console.log(res, 'res') | console.log(res, 'res') | ||||
| if (res.data.code == 200) { | if (res.data.code == 200) { | ||||
| this.$message.success("新增成功!") | |||||
| this.$router.back() | |||||
| this.$message.success("保存成功!") | |||||
| // this.$router.back() | |||||
| } else { | } else { | ||||
| this.$message.error("新增失败!") | |||||
| this.$message.error("保存失败!") | |||||
| } | } | ||||
| }) | }) | ||||
| .catch(err => { | .catch(err => { | ||||
| console.error(err); | console.error(err); | ||||
| this.$message.error("新增失败!") | |||||
| this.$message.error("保存失败!") | |||||
| }); | }); | ||||
| }, | }, | ||||
| getWidgets() { | |||||
| const url = baseUrl + "/print/printDatas?type=2" | |||||
| getWidgets(type) { | |||||
| const url = baseUrl + `/print/printDatas?type=${type}` | |||||
| this.$axios.get(url) | this.$axios.get(url) | ||||
| .then(res => { | .then(res => { | ||||
| console.log(res, 'res') | console.log(res, 'res') | ||||
| @@ -83,15 +84,33 @@ export default { | |||||
| .catch(err => { | .catch(err => { | ||||
| console.error(err); | console.error(err); | ||||
| }); | }); | ||||
| } | |||||
| }, | |||||
| getPrintData(tenantId, templateId) { | |||||
| const url = baseUrl + `/print/getTemplate?tenantId=${tenantId}&templateId=${templateId}` | |||||
| this.$axios.get(url) | |||||
| .then(res => { | |||||
| console.log(res, 'res') | |||||
| this.value = res.data.data.contentJson | |||||
| if (!this.value.tempItems || !this.value.tempItems.length) { | |||||
| this.value.tempItems = [] | |||||
| } | |||||
| this.getWidgets(this.value.type) | |||||
| }) | |||||
| .catch(err => { | |||||
| console.error(err); | |||||
| }); | |||||
| }, | |||||
| }, | }, | ||||
| created() { | created() { | ||||
| this.printData = this.$route.query.printData | |||||
| // this.printData = this.$route.query.printData | |||||
| this.tenantId = this.$route.query.tenantId | this.tenantId = this.$route.query.tenantId | ||||
| this.templateId = this.$route.query.templateId | |||||
| try { | try { | ||||
| this.value = this.printData | |||||
| this.getWidgets(this.value.type) | |||||
| // this.value = this.printData | |||||
| // this.getWidgets(this.value.type) | |||||
| this.getPrintData(this.tenantId, this.templateId) | |||||
| } catch (err) { | } catch (err) { | ||||
| console.error(err) | console.error(err) | ||||
| } | } | ||||