vue table数据展示以及确认框

1、el-table 数据展示

(1)第一种

            <el-table-column label="状态"  width="180px" align="center">
              <template slot-scope="scope">
                <span v-if="scope.row.userState==0" >正常</span>
                <span v-if="scope.row.userState==1" style="color: red">冻结</span>
                <span v-if="scope.row.userState==2" style="color: green">异常</span>
              </template>
            </el-table-column>

(2)第二种

    <el-table-column label="支付状态" :formatter="state"  width="80px" align="center">
      </el-table-column>


      state(row, column) {
        if (row.state === 0) {
          return '未支付'
        } else if (row.state === 1) {
          return '已支付'
        }
      },

2、控制el-table大小显示

    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="载入中"
      border
      fit
      stripe
      highlight-current-row
      :height="tableHeight" //控制高度
      width="100%"
    >
    </el-table>

 tableHeight: null,

 mounted:function(){
      this.listLoading = false
      this.tableHeight = window.innerHeight - 300
    },

3、确认弹框

    <el-card class="box-card" style="margin-bottom: 20px;height: 80px">
      <el-form ref="ruleForm" :model="info" :rules="rules" label-position="right" label-width="20px" style="width: 100%; margin-left:0px; height: 30px">
        <el-row>

          <el-form-item label="" prop="userId">
            <el-input style="width: 30%" v-model="info.userId" placeholder="批量删除"/>
            <el-button style="width: 100px" type="primary" @click="submitForm('ruleForm')">
             删除
            </el-button>
          </el-form-item>

        </el-row>
      </el-form>
    </el-card>

    methods: {
      onJsonChange(value) {
        console.log('value:', value)
      },
      frozenUsers() {
        this.$confirm('确定要删除吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          var url = this.HOST + '/xx/xxx'
          var qs = require('qs');
          this.$axios.post(url, qs.stringify(this.info), {
            headers: {
              'Content-Type': 'application/x-www-form-urlencoded',
            },
          })
            .then(res => {
              if (res.data.needReLogin === 1) {
                this.$store.dispatch('LogOut').then(() => {
                  location.reload()
                })
              }
              if (res.data.state==true){
                this.$notify({
                  title: '成功',
                  message: res.msg,
                  type: 'success',
                  duration: 2000
                })
              }else {
                this.$notify.error({
                  title: '失败',
                  message: res.msg,
                  duration: 2000
                })
              }
            })
            .catch(error => {
              console.log(error)
            })

        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消操作'
          })
        })



      },
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {  //开启校验
          if (valid) {   // 如果校验通过,请求接口,允许提交表单
            this.frozenUsers()
          } else {   //校验不通过
            return false;
          }
        });
      }

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值