有关标准页面的组件方法

<template>
  <div>
    <el-row v-if="showSurvey">
      <el-col :span="24" style="margin-bottom: 10px;">
        <el-tag type="info" class="self__tag">
          概况
        </el-tag>
        <slot name="survey" />
      </el-col>
    </el-row>
    <el-row v-if="showOperate">
      <el-col :span="24" style="margin-bottom: 17px;">
        <el-tag type="info" class="self__tag">
          操作
        </el-tag>
        <slot name="operate" />
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24" style="display: flex;">
        <el-tag type="info" class="self__tag">
          查询
        </el-tag>
        <slot name="search" />
      </el-col>
    </el-row>
    <el-row v-if="showSelection">
      <el-col :span="24" style="margin-bottom: 10px;">
        <el-tag type="info" class="self__tag">
          快捷
        </el-tag>
        <slot name="fast" />
      </el-col>
    </el-row>
    <el-table
      :data="tableData"
      size="small"
      border
      :cell-style="cellStyle"
      :header-cell-style="headerStyle"
      class="table"
      :max-height="limitHeight?tableHeight:null"
      @selection-change="handleSelection"
    >
      <el-table-column v-if="showSelection" type="selection" />
      <el-table-column
        v-for="(item,index) in columnList"
        :key="index"
        :label="item.label"
        :prop="item.prop"
        :formatter="item.type?(getFormatter(item.type)):null"
        :width="item.width?item.width:null"
        :show-overflow-tooltip="item.show?true:null"
      />
      <slot name="else" />
      <slot v-if="showTableControl" name="tableControl" />
    </el-table>
    <div class="self__footer">
      <slot name="footer" />
      <page-nation :total="total" @pageChange="pageChange" />
    </div>
  </div>
</template>

<script>
import constants from '~/plugins/constants'
import dateUtil from '~/plugins/dateUtil'
import pageNation from '~/components/pageNation'
export default {
  name: 'NormPage',
  components: { pageNation },
  props: {
    //  显示操作行
    showOperate: {
      type: Boolean,
      default: false
    },
    // 表格数据
    tableData: {
      type: Array,
      default: () => []
    },
    //  显示表格多选
    showSelection: {
      type: Boolean,
      default: false
    },
    //  表格列数据
    columnList: {
      type: Array,
      default: () => []
    },
    showShop: {
      type: Boolean,
      default: false
    },
    //  是否限制表格的最大高度 true限制  false不限制
    limitHeight: {
      type: Boolean,
      default: true
    },
    showTableControl: {
      type: Boolean,
      default: false
    },
    total: {
      type: Number,
      default: 0
    },
    showSurvey: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      tableHeight: 0,
      formatterList: [
        { type: 'time', formatter: this.timeFormatter },
        { type: 'gid', formatter: this.gidFormatter },
        { type: 'uniacid', formatter: this.uniacidFormatter },
        { type: 'money', formatter: this.moneyFormatter },
        { type: 'inprice', formatter: this.inpriceFormatter },
        { type: 'tariff', formatter: this.tariffFormat },
        { type: 'endway', formatter: this.endwayFormat }
      ],
      comTypeList: [
        {
          typeName: '不限',
          value: 0
        },
        {
          typeName: '标准计时',
          value: 1
        },
        {
          typeName: '包时段',
          value: 2
        },
        {
          typeName: '包时长',
          value: 3
        }
      ]
    }
  },
  mounted () {
    this.$nextTick(() => {
      if (this.limitHeight) {
        this.tableHeight = constants.METHOD.setTableHeight()
      }
    })
  },
  methods: {
    cellStyle () {
      return constants.COMMON.cell_style
    },
    headerStyle () {
      return constants.COMMON.head_cell_style
    },
    handleSelection (val) {
      this.$emit('handleSelection', val)
    },
    timeFormatter (row, column, cellValue, index) {
      return dateUtil.parseTimeInYmdHms(cellValue)
    },
    getFormatter (type) {
      const obj = this.formatterList.find(item => item.type === type)
      return obj.formatter
    },
    //  上机类型判断
    tariffFormat (row, column, cellValue, index) {
      const obj = this.comTypeList.find(item => item.value === cellValue)
      return obj ? obj.typeName : ''
    },
    //  结账方式判断
    endwayFormat (row, column, cellValue, index) {
      // ZeroMoneyLogoff(1,"余额不足自动结账"),
      //  MemberLogoff(2,"会员自主结账"),
      //  UserLogoff(3,"吧员结账"),
      //  ChangePcLogoff(4,"换机结账"),
      //  PeriodEndLogoff(5,"包时段结束结账"),

      const arr = [
        '余额不足自动结账',
        '会员自主结账',
        '吧员结账',
        '换机结账',
        '包时段结束结账',
        '关机太久导致下机',
        '激活太久导致下机'
      ]
      return arr[cellValue - 1]
    },
    uniacidFormatter (row, column, cellValue, index) {
      return this.$store.getters['web/user/getCompanyNameByUniacid'](cellValue)
    },
    gidFormatter (row, column, cellValue, index) {
      if (cellValue === 0) {
        return '未上机'
      }
      return this.$store.getters['web/user/getNetbarName'](cellValue)
    },
    moneyFormatter (row, column, cellValue, index) {
      return cellValue / 100
    },
    inpriceFormatter (row, column, cellValue, index) {
      return cellValue / 1000
    },
    pageChange (val) {
      this.$emit('pageChange', val)
    }
  }
}
</script>

<style scoped lang="scss">
  .self__footer{
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }
</style>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值