富茂A端打印模板内嵌编辑器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 6 месеца
преди 6 месеца
преди 6 месеца
преди 6 месеца
преди 6 месеца
преди 6 месеца
преди 6 месеца
преди 6 месеца
преди 6 месеца
преди 6 месеца
преди 6 месеца
преди 6 месеца
преди 6 месеца
преди 6 месеца
преди 6 месеца
преди 6 месеца
преди 6 месеца
преди 6 месеца
преди 6 месеца
преди 6 месеца
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <kr-print-designer ref="printDesigner" :temp-value="value" :widget-options="widgets" @save="handleSave" />
  3. </template>
  4. <script>
  5. // import { OutStockOptions, InStockOptions } from '../data/options'
  6. const baseUrl = process.env.VUE_APP_BASE_API;
  7. export default {
  8. data() {
  9. return {
  10. tenantId: '',
  11. printData: [],
  12. value: {
  13. title: 'demo',
  14. width: 750,
  15. height: 550,
  16. pageWidth: 750,
  17. pageHeight: 550,
  18. tempItems: [],
  19. },
  20. widgets: [],
  21. }
  22. },
  23. methods: {
  24. handleSave(data) {
  25. const obj = {
  26. contentJsonUpdate: {
  27. id: data.id,
  28. type: data.type,
  29. title: data.title,
  30. width: data.width,
  31. height: data.height,
  32. pageWidth: data.pageWidth,
  33. pageHeight: data.pageHeight,
  34. tempItems: data.tempItems,
  35. },
  36. id: data.id,
  37. tenantId: this.tenantId,
  38. title: data.title,
  39. }
  40. console.log(obj, 'handleSave')
  41. this.addNewModel(obj)
  42. },
  43. // 手动初始话模板数据
  44. initTemp() {
  45. this.$refs.printDesigner.initTemp(this.value, this.widgets)
  46. },
  47. addNewModel(data) {
  48. this.$axios.post(baseUrl + "/print/updateTemplates", data)
  49. .then(res => {
  50. console.log(res, 'res')
  51. if (res.data.code == 200) {
  52. this.$message.success("新增成功!")
  53. this.$router.back()
  54. } else {
  55. this.$message.error("新增失败!")
  56. }
  57. })
  58. .catch(err => {
  59. console.error(err);
  60. this.$message.error("新增失败!")
  61. });
  62. },
  63. getWidgets() {
  64. const url = baseUrl + "/print/printDatas?type=2"
  65. this.$axios.get(url)
  66. .then(res => {
  67. console.log(res, 'res')
  68. const arr = []
  69. res.data.data.forEach(item => {
  70. delete item.printComponents.defaultValue
  71. arr.push(item.printComponents)
  72. });
  73. this.widgets = arr
  74. console.log(this.widgets, 'this.widgets ')
  75. //传入值变化后,需要手动初始化模板数据,否则不会同步
  76. this.initTemp()
  77. })
  78. .catch(err => {
  79. console.error(err);
  80. });
  81. }
  82. },
  83. created() {
  84. this.printData = this.$route.query.printData
  85. this.tenantId = this.$route.query.tenantId
  86. try {
  87. this.value = this.printData
  88. this.getWidgets(this.value.type)
  89. } catch (err) {
  90. console.error(err)
  91. }
  92. },
  93. }
  94. </script>