/*
 * @Author: howie
 * @Date: 2022-06-14 10:14:37
 * @LastEditors: howie
 * @LastEditTime: 2022-07-03 17:47:25
 * @FilePath: \supply-front\src\mixin\index.js
 * @Description:
 *
 * Copyright (c) 2022, All Rights Reserved.
 */
export default {
  data() {
    return {
      currentPage: 1, // 当前页码
      pageSize: 10, // 每页数量
      listTotal: 0, // 列表总数
      listLoading: false, // 加载
      screenForm: {}, // 筛选表单数据
      dataList: [], // 表格数据
      ids: [], // 多选数据id
      dialogVisible: false, // 弹框
      conditionList: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    // 提交筛选表单
    submitScreenForm() {
      this.currentPage = 1
      this.getList()
    },
    // 重置筛选表单
    resetScreenForm() {
        this.$refs.screenForm.resetFields()
      this.currentPage = 1
      this.getList()
    },
    hanlePagination(val) {
      // 更改每页数量
      this.handleSizeChange(val)
      // 更改当前页
      this.handleCurrentChange(val)
    },
    // 更改每页数量
    handleSizeChange(val) {
      this.pageSize = val
      this.currentPage = 1
      this.getList()
    },
    // 更改当前页
    handleCurrentChange(val) {
      this.currentPage = val
      this.getList()
    },

    // Windows全局打印
    hanlePrint() {
      window.print()
    },

    // 筛选全部数据
    hanleSelectAll(selection, index) {
      this.ids = selection.map(k => {
        return k.id || k.updPriceBillId
      })
      console.log(this.ids)
    },

    /**
     * @description  单条数据删除 或者 全部数据删除
     * @author zhou
     * @param {*} id 删除单条数据传
     * @return {*}  Promise.resolve(ids)
     */
    hanleDeleteAllPromise(id) {
      return new Promise((resolve, reject) => {
        const ids = id ? [id] : this.ids
        if (!ids.length) {
          this.$errorMsg('请选择删除内容')
          return
        }
        resolve(ids)
      })
    }
  }
}
