123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <template>
- <a-modal
- title="查询"
- :visible="visible"
- @ok="handleImportJson"
- @cancel="handleCancel"
- cancelText="关闭"
- :destroyOnClose="true"
- wrapClassName="code-modal-9136076486841527"
- style="top:20px;"
- width="850px"
- >
- <a-row :gutter="24">
- <a-col :md="4" :sm="24">
-
- 数据库表名:
-
-
-
- </a-col>
- <a-col :md="18" :sm="24">
- <a-select v-model="businessTable" style="width: 30%" placeholder="请选择数据库表名" allowClear show-search >
- <a-select-option v-for="(item) in tableList" :key="item.tableName" :value="item.tableName">{{item.tableName}}{{item.tableComment}}</a-select-option>
- </a-select>
- </a-col>
- </a-row>
- <a-row :gutter="24" v-if="dataSource.length>0">
- <a-col :md="24" :sm="24">
- <a-alert message="目前该数据库表关联的表单存在多个,请选择其中一个!" type="info" banner/><br>
- <a-table
- bordered
- :data-source="dataSource"
- :columns="columns"
- :rowKey="record=>record.id"
- :pagination="false"
- style="margin-top:5px"
- >
- <template slot="operation" slot-scope="text, record">
- <a href="javascript:;" @click="textClick(record)">确定</a>
- </template>
- </a-table>
- </a-col>
- </a-row>
- </a-modal>
- </template>
- <script>
- import { getFormByBusinessTable,getTableList } from "../../api/api";
- export default {
- name: "queryModal",
- data() {
- return {
- tableList:[],
- dataSource:[],
- columns:[
- {
- title: '表单名称',
- dataIndex: 'text',
- scopedSlots: { customRender: 'text' },
- },
- {
- title: '数据库表名',
- dataIndex: 'businessTable',
- },
- {
- title: '表单描述',
- dataIndex: 'stepMemo',
- },
- {
- title: '操作',
- dataIndex: 'operation',
- scopedSlots: { customRender: 'operation' },
- }
- ],
- visible: false,
- jsonData: {},
- handleSetSelectItem: null,
- text: "",
- businessTable: "",
- formData: {}
- };
- },
- created(){
-
- getTableList().then(res=>{
- if(res.data.success){
- this.tableList=res.data.result;
- }
- });
- },
- 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;
- },
- textClick(data){
- console.log(data)
-
- this.jsonData.list = data.jsonContent.list;
- this.jsonData.config = data.jsonContent.config;
- this.jsonData.config.layout = data.jsonContent.config.layout;
-
- this.formData.businessTable=data.businessTable;
- this.formData.text=data.text;
- this.formData.stepMemo=data.stepMemo;
- this.handleCancel();
- },
- handleImportJson() {
-
- try {
-
- if (!this.businessTable) {
- this.$message.error("请输入数据库表明");
- return;
- }
-
- getFormByBusinessTable(this.businessTable).then(res => {
- if (res.data.success) {
- if(res.data.result.tbTableInfoList!=null&&res.data.result.tbTableInfoList.length>1){
- this.dataSource=res.data.result.tbTableInfoList;
- }else{
-
- 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.formData.stepMemo=res.data.result.stepMemo;
- this.businessTable = "";
- this.dataSource=[];
- 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>
|