index.vue 1.3 KB

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