avue-crud组件

vue

<template>

  <div class="mod-prod">

    <avue-crud ref="crud"

               :page="page"

               :data="dataList"

               :table-loading="dataListLoading"

               :update-before="dataListLoading"

               :permission="permission"

               :option="tableOption"

               @row-save="addHandle"

               @row-update="updateHandle"

               @row-del="deleteHandle"

               @search-change="searchChange"

               @selection-change="selectionChange"

               @on-load="getDataList">

      <template slot="menuLeft">

        <el-button type="danger"

                   @click="deleteHandle()"

                   size="small"

                   :disabled="dataListSelections.length <= 0">批量删除</el-button>

      </template>

    </avue-crud>

  </div>

</template>

<script>

import { tableOption } from '@/crud/sys/pay-integral-manager'

export default {

  data () {

    return {

      dataForm: {

        prodName: ''

      },

      permission: {

        delBtn: this.isAuth('prod:prod:delete')

      },

      dataList: [],

      page: {

        total: 0, // 总页数

        currentPage: 1, // 当前页数

        pageSize: 10 // 每页显示多少条

      },

      dataListSelections: [],

      dataListLoading: false,

      tableOption: tableOption,

      resourcesUrl: window.SITE_CONFIG.resourcesUrl

    }

  },

  methods: {

    // 获取数据列表

    getDataList (page, params) {

      this.dataListLoading = true

      this.$http({

        url: this.$http.adornUrl('/integral/payIntegral/page'),

        method: 'get',

        params: this.$http.adornParams(

          Object.assign(

            {

              current: page == null ? this.page.currentPage : page.currentPage,

              size: page == null ? this.page.pageSize : page.pageSize

            },

            params

          )

        )

      }).then(({ data }) => {

        this.dataList = data.records

        this.page.total = data.total

        this.dataListLoading = false

      })

    },

    // 新增

    addHandle(row,done){

        console.log(row)

        this.$http({

            url: this.$http.adornUrl(`/integral/payIntegral/save`),

            method: 'post',

            data: this.$http.adornData(row,false)

          }).then(({ data }) => {

            this.$message({

              message: '操作成功',

              type: 'success',

              duration: 1500,

              onClose: () => {

                this.getDataList(this.page)

              }

            })

            done();

          })

    },

    // 编辑

    updateHandle(row,done){

        this.$http({

            url: this.$http.adornUrl(`/integral/payIntegral/put`),

            method: 'put',

            data: this.$http.adornData(row,false)

          }).then(({ data }) => {

            this.$message({

              message: '操作成功',

              type: 'success',

              duration: 1500,

              onClose: () => {

                this.getDataList(this.page)

              }

            })

            done();

          })

    },

    // 删除

    deleteHandle (row) {

        console.log("ddd")

        var ids = this.dataListSelections.length <= 0 ? [row.id] : this.dataListSelections.map(item => {

        return item.id

      })

      this.$confirm(`确定进行[${this.dataListSelections.length <= 0 ? '删除' : '批量删除'}]操作?`, '提示', {

        confirmButtonText: '确定',

        cancelButtonText: '取消',

        type: 'warning'

      })

        .then(() => {

          this.$http({

            url: this.$http.adornUrl(`/integral/payIntegral/delete`),

            method: 'delete',

            data: this.$http.adornData(ids, false)

          }).then(({ data }) => {

            this.$message({

              message: '操作成功',

              type: 'success',

              duration: 1500,

              onClose: () => {

                this.getDataList(this.page)

              }

            })

          })

        })

        .catch(() => { })

    },

    // 条件查询

    searchChange (params) {

      this.getDataList(this.page, params)

    },

    // 多选变化

    selectionChange (val) {

        console.log(val)

      this.dataListSelections = val

    }

  }

}

</script>

js

export const tableOption = {

    border: true,

    selection: true,

    index: false,

    indexLabel: '序号',

    stripe: true,

    menuAlign: 'center',

    menuWidth: 350,

    align: 'center',

    refreshBtn: true,

    searchSize: 'mini',

    addBtn: true,

    editBtn: true,

    delBtn: true,

    viewBtn: true,

    props: {

      label: 'label',

      value: 'value'

    },

    column: [{

      label: '积分兑换id',

      prop: 'id',

      width: 100,

      editDisplay:false,

      addDisplay:false,

    }, {

      label: '兑换名',

      prop: 'payName',

      search: true,

      width: 150,

    }, {

      label: '兑换地址',

      prop: 'payUrl',

      width: 480,

    }, {

      label: '积分查询',

      prop: 'queryUrl',

      width: 260,

    }]

  }

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小贞-10086

世纪的浪漫,最不过——雨落星辰

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值