12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <template>
- <a-modal
- title="预览"
- :visible="visible"
- @ok="handleGetData"
- @cancel="handleCancel"
- okText="获取数据"
- cancelText="关闭"
- style="top:20px;"
- :destroyOnClose="true"
- :width="`${previewWidth}px`"
- >
- <k-form-build :value="jsonData" @submit="handleSubmit" ref="KFormBuild" />
- <jsonModel ref="jsonModel" />
- </a-modal>
- </template>
- <script>
- import jsonModel from "../KFormDesign/module/jsonModal";
- export default {
- name: "KFormPreview",
- data() {
- return {
- visible: false,
- previewWidth: 850,
- jsonData: {}
- };
- },
- components: {
- jsonModel
- },
- methods: {
- handleSubmit(p) {
- p.then(res => {
- console.log(res, "获取数据成功");
- this.$refs.jsonModel.jsonData = res;
- this.$refs.jsonModel.visible = true;
- }).catch(err => {
- console.error(err, "获取数据失败");
- });
- },
- handleGetData() {
- this.$refs.KFormBuild.getData()
- .then(res => {
- console.log(res, "获取数据成功");
- this.$refs.jsonModel.jsonData = res;
- this.$refs.jsonModel.visible = true;
- })
- .catch(err => {
- console.log(err, "获取数据失败");
- });
- },
- handleCancel() {
- this.visible = false;
- }
- }
- };
- </script>
|