Newer
Older
smartKitchenFront / src / utils / myUtils / mixins / listPage.js
const listMixin = {
  data() {
    return {
      tableData: { rows: [] }, // 品牌表格数据
      limit: 10, // 当前的行数
      offset: 1, // 当前页
      queryInfo: {}, // 搜索的数据
      isFristPage: false
    }
  },
  mounted() {
    // 获取 表格列表
    this.refresh()
  },
  methods: {
    //  页面行数改变
    setLimit(crrentSize) {
      this.limit = crrentSize
    },
    setOffset(offset) {
      this.offset = offset
    },
    //  搜索
    selectData() {
      this.queryInfo = { ...this.selectInfo } // 加入搜索内容
      // 回到初始页
      if (this.offset == 1) {
        this.refresh()
        return
      }
      this.offset = 1
      // this.getListPage(this.limit,this.offset)
      this.isFristPage = true
      //  将分页组件 调到第一页
    },
    // 刷新
    refresh() {
      this.$nextTick(() => {
        this.getListPage(this.limit, this.offset)
      })
    }
  },
  computed: {
    total() {
      const index = this.tableData.total / this.limit
      return Math.ceil(index)
    }
  },
  //  监听当前页 和当前页总条数的改变
  watch: {
    limit(newVls) {
      this.getListPage(newVls, this.offset)
    },
    offset(newVls) {
      this.getListPage(this.limit, newVls)
    }
  }
}
// 详情弹框相关数据
const elDataDialog = {
  data() {
    return {
      rowInfo: null,
      isShowInfo: false
    }
  },
  methods: {
    // 关闭详情
    closeInfo() {
      this.isShowInfo = false
    },
    //  打开详情
    showInfo(row) {
      console.log(row)
      this.isShowInfo = true
      // 改变当前行的数据
      this.rowInfo = row
      if (this.$refs.detail) {
        this.$refs.detail.initDialog(row.id)
      }
    }
  }
}
export {
  listMixin, elDataDialog
}