<template>
  <!-- 面料 转入数量 成本分配统计表   -->
  <a-modal
    title="面料 - 转入数量"
    v-model="fabInQuaModVis"
    :confirmLoading="confirmLoading"
    width="86%"
    style="top:330px;left:100px;"
    :footer="null"
  >
    <!-- tabel  -->
    <a-spin :spinning="confirmLoading">
      <a-table :loading="loading" bordered :columns="columns" :data-source="data" :pagination="false"> </a-table>
      <!-- 导出 打印 返回  -->
      <a-row style="marginTop:20px;">
        <a-col :md="24" :sm="12">
          <span style="float: right;" class="table-operator">
            <a-button type="primary" icon="download" @click="handleExportXls('成本分配-面料-转入数量')">导出</a-button>
            <a-button type="primary" @click="print" icon="printer" style="margin:0 10px;">打印</a-button>
            <a-button type="primary" @click="cancel" icon="rollback">取消</a-button>
          </span>
        </a-col>
      </a-row>
    </a-spin>
  </a-modal>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JEllipsis from '@/components/jeecg/JEllipsis'
import moment from 'moment'

import { downFile } from '@/api/manage'

export default {
  name: 'FabInQuaModal', // 面料 转入数量 弹框
  mixins: [JeecgListMixin],
  components: { JEllipsis, moment },
  data() {
    return {
      // 面料 - 转入数量 表头
      columns: [
        {
          title: '存货名称',
          dataIndex: 'inventoryName',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '颜色',
          dataIndex: 'color',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '计划单号',
          dataIndex: 'planNum',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '转入数量',
          dataIndex: 'transferQuantity',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '单位成本',
          dataIndex: 'unitCost',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '总成本',
          dataIndex: 'totalCost',
          width: 120,
          className: 'replacecolor'
        }
      ],
      data: [],
      loading: false,
      confirmLoading: false,
      fabInQuaModVis: false
    }
  },
  // 接收父组件 方法
  props: {
    father: {
      type: Function,
      default: null
    }
  },

  methods: {
    // 导出
    handleExportXls(fileName) {
      console.log('需导出的fileName:', fileName)
      const params = this.dyeLossRateData
      console.log('导出参数', params)
      // downFile('/scas/dyeLoss/excel', params).then(data => {
      //   console.log('888')
      //   if (!data) {
      //     this.$message.warning('文件下载失败')
      //     return
      //   }
      //   if (typeof window.navigator.msSaveBlob !== 'undefined') {
      //     window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xls')
      //   } else {
      //     let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
      //     let link = document.createElement('a')
      //     link.style.display = 'none'
      //     link.href = url
      //     link.setAttribute('download', fileName + '.xls')
      //     document.body.appendChild(link)
      //     link.click()
      //     document.body.removeChild(link) // 下载完成移除元素
      //     window.URL.revokeObjectURL(url) // 释放掉blob对象
      //   }
      // })
    },
    // 打印
    print() {},

    cancel() {
      console.log('返回成本分配统计表')
      this.fabInQuaModVis = false
    }
  }
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
@import '~@assets/less/overwriter.less';
/deep/ .ant-table-thead > tr > th {
  text-align: center;
  // font-weight: 700;
}

/deep/ .ant-table-tbody {
  text-align: center;
}

// /deep/ th.replacecolor {
//   background-color: #ccc;
// }
</style>
