el-table表单的 二次封装

     <el-table
        ref="table"
        v-loading="loading"
        :data="tableData"
        style="width: 100%; margin-top: 10px; border: 1px solid #ebeef5"
        stripe
      >
        <el-table-column width="80" label="序号" align="center" type="index" />
        <template v-for="head in tableHeaders">
          <el-table-column
            v-if="head.show"
            :key="head.value"
            :prop="head.value"
            :label="head.label"
            :width="head.width"
            align="center"
          >
            <template slot-scope="scope">
            <!--过滤器 根据自己需要  见下文备注信息-->
              <span v-if="head.value === 'status'">
                {{ scope.row.status | filterHandleStatus(scope.row.status) }}
              </span>
              <!--过长时弹框展示-->
              <span v-else>{{ scope.row[head.value] }}</span>
            </template>
          </el-table-column>
        </template>
        <el-table-column width="200" label="操作" align="center" fixed="right">
          <template slot-scope="scope">
            <div class="center-evenly">
              <el-button
                type="text"
                @click="handleView(scope.row)"
              >
                审核
              </el-button>
              <el-button type="text" @click="checkView(scope.row)">
                查看
              </el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>

-------------------------------------------------------------------------

 data() {
    return {
      tableData: [],//调用自己查询列表信息的方法 进行赋值
      loading: '',
      tableHeaders: [
        { label: '申请人', width: 100, value: 'applyPersonName', show: true,width:100 },
        { label: '报销人', width: 100, value: 'reimburseName', show: true },

      ]
    }
  },
-----------------------------------------------------------------------
     调用方法
    async handleDataLis() {
      this.loading = true
      let params = {}
      params = {
        ...this.queryInfo,
        ...this.page
      }
      const res = await querySimpleReimburseInfo(params)
      if (res && res.code === 200) {
        this.tableData = res.data
        this.total = res.totalCount
      }
      this.loading = false
    },
--------------------------------------------------------------------------
/** 配置过滤方法  新建一个JS 文件  **/
import Vue from 'vue'
import {HANDLE_STATUS} from '@/config/index'

Vue.filter('filterHandleStatus', function (v) {
  const result = HANDLE_STATUS.find(item => item.value === v)
  if (result) {
    return result.label
  } else {
    return v

------------------------------------------------------------------------
在main.js配置过滤器
import * as filters from './filters/index'
  }
})

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值