好久没写博客了🤣_0928


2021-09-28 18:22:45 星期二

1.设计问卷时后台查询数据报错
2.新增问卷时数据无法第一时间展示问题

问题1

idea报错:
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@62a78bf0] was not registered for synchronization because synchronization is not active
original SQL: SELECT id,template_id,field_name,field_type,field_scale,remark,created_by,created_time,updated_by,updated_time FROM fs_template_detail ORDER BY create_time DESC

代码是自动生成的 不仔细看 根本看不出来 这个错误 数据库的表字段 创建时间是created_time 上面sql语句 ORDER BY create_time 所以👀是个好东西。

问题2

image

设计一个问卷完成后,问卷数据不能第一时间展示出来,解决方法刷新,但是整个刷新体验不好,所以要写一个路由刷新

在App.vue上

<router-view v-if="isRouterAlive"></router-view>

export default {
provide () {
      return {
        reload: this.reload
      }
    },
	
data () {
      return {
        locale: zhCN,
        isRouterAlive: true
      }
    },
	
methods: {
      reload () {
        this.isRouterAlive = false
        this.$nextTick(function() {
          this.isRouterAlive = true
        })
      }
    }

全部代码

<template>
  <a-config-provider :locale="locale">
    <div id="app">
      <router-view v-if="isRouterAlive"/>
    </div>
  </a-config-provider>
</template>
<script>
  import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
  import enquireScreen from '@/utils/device'

  export default {
    provide () {
      return {
        reload: this.reload
      }
    },
    data () {
      return {
        locale: zhCN,
        isRouterAlive: true
      }
    },
    created () {
      let that = this
      enquireScreen(deviceType => {
        // tablet
        if (deviceType === 0) {
          that.$store.commit('TOGGLE_DEVICE', 'mobile')
          that.$store.dispatch('setSidebar', false)
        }
        // mobile
        else if (deviceType === 1) {
          that.$store.commit('TOGGLE_DEVICE', 'mobile')
          that.$store.dispatch('setSidebar', false)
        }
        else {
          that.$store.commit('TOGGLE_DEVICE', 'desktop')
          that.$store.dispatch('setSidebar', true)
        }

      })
    },
    methods: {
      reload () {
        this.isRouterAlive = false
        this.$nextTick(function() {
          this.isRouterAlive = true
        })
      }
    }
  }
</script>
<style>
  #app {
    height: 100%;
  }
</style>

https://blog.csdn.net/bamboozjy/article/details/99742812
https://www.cnblogs.com/maibao666/p/11175839.html

在你想刷新的页面

export default {
    inject: ['reload'],

// 刷新页面
      reflesh(){
        this.reload();
      },


<template>
  
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handle" type="primary" icon="plus">设计</a-button>
        <el-dialog 
        title="问卷设计" 
        @close="closeDialog" 
        :visible.sync="homeVisible" 
        center 
        :append-to-body='true' 
        :lock-scroll="false" 
        :close-on-press-escape="false"
        width="90%"
        top="3%">
          <home></home>
          <!-- <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取消</el-button>
            <el-button type="primary" @click="dialogVisible = false">确定</el-button>
          </span> -->
        </el-dialog>
      <!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button> -->
      <a-button type="primary" icon="download" @click="handleExportXls('fs_template')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <fs-template-modal ref="modalForm" @ok="modalFormOk"></fs-template-modal>
    <!-- <home ref="home" v-if="homeVisible"></home> -->
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import FsTemplateModal from './modules/FsTemplateModal'
  import Home from './Home.vue'

  export default {
    inject: ['reload'],
    name: 'FsTemplateList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      FsTemplateModal,
      Home
    },
    data () {
      return {
        description: 'fs_template管理页面',
        homeVisible: false,
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'问卷名称',
            align:"center",
            dataIndex: 'name'
          },
          {
            title:'问卷脚本',
            align:"center",
            dataIndex: 'templateScript'
          },
          {
            title:'问卷地址',
            align:"center",
            dataIndex: 'templateUrl'
          },
          {
            title:'状态',
            align:"center",
            dataIndex: 'status'
          },
          // {
          //   title:'创建人',
          //   align:"center",
          //   dataIndex: 'createBy'
          // },
          // {
          //   title:'创建时间',
          //   align:"center",
          //   dataIndex: 'createTime',
          //   customRender:function (text) {
          //     return !text?"":(text.length>10?text.substr(0,10):text)
          //   }
          // },
          // {
          //   title:'更新人',
          //   align:"center",
          //   dataIndex: 'updateBy'
          // },
          // {
          //   title:'更新时间',
          //   align:"center",
          //   dataIndex: 'updateTime',
          //   customRender:function (text) {
          //     return !text?"":(text.length>10?text.substr(0,10):text)
          //   }
          // },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/fstemplate/fsTemplate/list",
          delete: "/fstemplate/fsTemplate/delete",
          deleteBatch: "/fstemplate/fsTemplate/deleteBatch",
          exportXlsUrl: "/fstemplate/fsTemplate/exportXls",
          importExcelUrl: "fstemplate/fsTemplate/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      //获取自组建传过来的值--关闭编辑生态区的弹框 
      // closeMoule(e){
      //     alert(e)
      // },
      closeDialog(){
        // debugger
        // //清空数据
        // this.superFieldList = '';
        this.homeVisible = false;
        this.reflesh();
      },
      // 刷新页面
      reflesh(){
        this.reload();
      },
      handle(){
        this.homeVisible = true;
      },
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'name',text:'问卷名称'})
        fieldList.push({type:'string',value:'templateScript',text:'问卷脚本'})
        fieldList.push({type:'string',value:'templateUrl',text:'问卷地址'})
        fieldList.push({type:'string',value:'status',text:'状态'})
        // fieldList.push({type:'string',value:'createBy',text:'创建人'})
        // fieldList.push({type:'date',value:'createTime',text:'创建时间'})
        // fieldList.push({type:'string',value:'updateBy',text:'更新人'})
        // fieldList.push({type:'date',value:'updateTime',text:'更新时间'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
posted @ 2021-09-28 18:41  Drsyq  阅读(111)  评论(0)    收藏  举报