index.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <a-modal
  3. title="预览"
  4. :visible="visible"
  5. @ok="handleGetData"
  6. @cancel="handleCancel"
  7. okText="获取数据"
  8. cancelText="关闭"
  9. style="top:10px;"
  10. :destroyOnClose="true"
  11. width="100%"
  12. >
  13. <!-- :width="`${previewWidth}px`" -->
  14. <k-form-build :value="jsonData" @submit="handleSubmit" ref="KFormBuild" />
  15. <jsonModel ref="jsonModel" />
  16. </a-modal>
  17. </template>
  18. <script>
  19. /*
  20. * author kcz
  21. * date 2019-11-20
  22. */
  23. import jsonModel from "../KFormDesign/module/jsonModal";
  24. export default {
  25. name: "KFormPreview",
  26. data() {
  27. return {
  28. visible: false,
  29. previewWidth: 850,
  30. jsonData: {}
  31. };
  32. },
  33. components: {
  34. jsonModel
  35. },
  36. methods: {
  37. handleSubmit(p) {
  38. p.then(res => {
  39. console.log(res, "获取数据成功");
  40. this.$refs.jsonModel.jsonData = res;
  41. this.$refs.jsonModel.visible = true;
  42. }).catch(err => {
  43. console.error(err, "获取数据失败");
  44. });
  45. },
  46. handleGetData() {
  47. this.$refs.KFormBuild.getData()
  48. .then(res => {
  49. console.log(res, "获取数据成功");
  50. this.$refs.jsonModel.jsonData = res;
  51. this.$refs.jsonModel.visible = true;
  52. })
  53. .catch(err => {
  54. console.log(err, "获取数据失败");
  55. });
  56. },
  57. handleCancel() {
  58. this.visible = false;
  59. }
  60. }
  61. };
  62. </script>