manualTable.vue 1.88 KB
<!-- 不传入接口名称,手动调用接口,并更新表格数据 -->
<template>
  <div>
    <el-form
      :inline="true"
      :model="searchForm"
    >
      <el-form-item label="name:">
        <el-input v-model="searchForm.name"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button
          size="small"
          type="primary"
          @click="handleSearch"
        >查询</el-button>
      </el-form-item>
    </el-form>
    <glsx-table
      ref="tableRef2"
      :tableData="tableData"
      :tableTotal="tableTotal"
      :tableParams="tableParams"
      @refreshTable="handleSearch"
    >
      <span
        slot="auth-button"
        slot-scope="scope"
        :data="scope.scope"
      >
        <el-button
          type="text"
          @click="handleAdd(scope.scope)"
        >新增</el-button>
      </span>
    </glsx-table>
  </div>
</template>

<script>
import { getListApi2 } from '../api/test'
export default {
  name: 'manualTable',
  data() {
    return {
      searchForm: {
        name: ''
      },
      // 表格参数
      tableData: [],
      tableTotal: 0,
      tableParams: {
        listName: 'list',
        tableOption: true,
        tableColumns: [{
          label: 'id',
          prop: 'id',
          width: '80px'
        }, {
          label: '姓名',
          prop: 'name'
        }]
      }
    }
  },

  mounted() {
    this.handleSearch()
  },

  methods: {
    handleAdd(row) {
      this.$notify({
        title: '提示',
        message: row
      })
    },
    handleSearch() {
      var params = {
        ...JSON.parse(JSON.stringify(this.searchForm)),
        pageSize: this.$refs.tableRef2.page.pageSize,
        pageNum: this.$refs.tableRef2.page.pageNum
      }
      getListApi2(params).then(res => {
        this.tableData = res.list
        this.tableTotal= res.total
      })
    }
  }
}

</script>
<style scoped>
</style>