123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <template>
- <a-modal
- title="请选择表单关联的数据表"
- :visible="visible"
- @ok="handleImportJson"
- @cancel="handleCancel"
- cancelText="关闭"
- :destroyOnClose="true"
- wrapClassName="code-modal-9136076486841527"
- style="top:20px;"
- width="850px"
- >
- <div class="copy-btn-box-9136076486841527">
- 数据库表名:
- <a-input placeholder="请输入表名" style="width:20%;" v-model="businessTable" />
- </div>
- </a-modal>
- </template>
- <script>
- import { getFormByBusinessTable } from '../../api/api';
- export default {
- name: "selectModal",
- data() {
- return {
- visible: false,
- jsonData: {},
- handleSetSelectItem: null,
- text:"",
- businessTable:""
- ,formData:{}
- };
- },
- methods: {
- handleCancel() {
- this.visible = false;
- },
- beforeUpload(e) {
-
- const _this = this;
- const reader = new FileReader();
- reader.readAsText(e);
- reader.onload = function() {
- _this.jsonFormat = this.result;
- _this.handleImportJson();
- };
- return false;
- },
- handleImportJson() {
-
- try {
-
- if(!this.businessTable){
- this.$message.error("请输入数据库表明");
- return;
- }
-
- getFormByBusinessTable(this.businessTable).then(res=>{
- if(res.data.success){
-
- const editorJsonData = res.data.result.jsonContent;
-
- this.jsonData.list = editorJsonData.list;
- this.jsonData.config = editorJsonData.config;
- this.jsonData.config.layout = editorJsonData.config.layout;
-
- this.formData.businessTable=this.businessTable;
- this.formData.text=res.data.result.text;
- this.businessTable="";
- this.handleCancel();
- this.$message.success("查询成功");
- }else{
- this.$message.error(res.data.message);
- }
- })
-
-
-
-
-
-
-
-
- } catch (error) {
- console.error(error);
- this.$message.error("导入失败,数据格式不对");
- }
- }
- }
- };
- </script>
- <style lang="less" scoped>
- .hint-box {
- background: #e9e9e9;
- margin: 0;
- border-bottom: 2px solid #fff;
- }
- </style>
|