<template>
  <el-dialog
    append-to-body
    title="历史明细"
    class="el-dialogDeep"
    :visible.sync="historyVisible"
    width="70%"
    :close-on-click-modal="false"
    :destroy-on-close="true"
    :close-on-press-escape="false"
    v-dialog-drag
    :before-close="closeDialog"
  >
    <avue-crud
      ref="historyCrud"
      :data="historyData"
      :option="historyOption"
    ></avue-crud>
    <span slot="footer" class="dialog-footer">
        <el-button @click="closeDialog">关 闭</el-button>
      </span>
  </el-dialog>
</template>

<script>
import {historyPrice} from "@/api/dealer/sales";

export default {
  name: "history",
  props: {
    params: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {
      historyVisible: false,
      historyData: [],
      historyOption: {
        stripe: true,
        border: true,
        index: true,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        addBtn: false,
        menu: false,
        align: "center",
        menuWidth: "180",
        selection: false,
        tip: false,
        column: [
          {
            label: "价格",
            prop: "price",
            index: 1,
            overHidden: true
          },
          {
            label: "日期",
            prop: "businesDate",
            index: 2,
            overHidden: true
          },
          {
            label: "备注",
            prop: "remarks",
            index: 3,
            overHidden: true
          },
        ]
      },
    }
  },
  methods: {
    init() {
      this.historyVisible = true;
      historyPrice(this.params).then(res => {
        this.historyData = res.data.data? res.data.data: [];
        this.$set(this.historyOption, 'height', window.innerHeight - 240)
      })
    },
    // 关闭弹窗
    closeDialog() {
      this.historyVisible = false;
      this.historyData = [];
      this.$emit("closeDialog")
    },
  },
}
</script>

<style scoped>

</style>
