<!--
  @description: 采购计划-计划结果执行确认-确认执行结果弹框
  @author: lxl
  @date： 2020-10-30 10:32
-->
<template>
  <el-dialog
    :visible.sync="dialogExecuteData.executeVisible"
    :before-close="handleClose"
    title="结果执行确认"
    width="700px"
    custom-class=""
  >
    <section style="margin:10px 0px">
      <el-table
        :data="tableData"
        class="tableLimit"
      >
        <el-table-column align="center" width="60" type="index" label="序号" />
        <el-table-column prop="purchaseNo" align="center" min-width="120" label="行项目编号" />
        <el-table-column prop="purchaseCode" min-width="150" align="center" label="物资编码" />
        <el-table-column prop="purchaseName" min-width="150" header-align="center" align="left" label="物资信息" />
        <el-table-column prop="resultExeNo" min-width="150" align="center" label="执行结果编号" />
      </el-table>
      <pagination :pagination-data="paginationData" />
    </section>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="ensure">
        确 定
      </el-button>
      <el-button @click="handleClose()">
        取 消
      </el-button>
    </div>
  </el-dialog>
</template>
<script>
/* api*/
import { purchasePlanDetailResultAffirm } from '@/api/procurement/purchasplan'
/* 公用组件*/
import { ListMixin } from '@/mixins/ListMixin' // 分页
import { paging } from '@/assets/js/utils/index.js' // 前端分页
import pagination from '@comp/common/pagination/pagination' // 分页组件
export default {
  name: 'ExecuteRestDialog',
  components: {
    pagination
  },
  mixins: [ListMixin],
  props: {
    dialogExecuteData: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      tableData: []
    }
  },
  watch: {
    'dialogExecuteData.executeVisible'(val) {
      if (val) {
        this.tableData = paging({}, this.dialogExecuteData.executeTableData, this.paginationData)
      }
    }
  },
  created() {
  },
  methods: {
    // 确定
    ensure() {
      const params = { planDetailIds: this.dialogExecuteData.planDetailId }
      purchasePlanDetailResultAffirm(params).then(response => {
        if (response.header.ret === '0') {
          this.$message.success(response.header.msg)
        } else {
          this.$message.warning(response.header.msg)
        }
        this.handleClose()
      })
        .catch(() => {
        })
    },
    // 弹框关闭
    handleClose() {
      this.$emit('close')
      this.dialogExecuteData.executeVisible = false
    }
  }
}
</script>
<style scoped>
</style>
