<template>
  <a-modal
    title="多发少发"
    v-model="pilosityFewerModVis"
    :confirmLoading="confirmLoading"
    width="86%"
    style="top:330px;left:100px;minHeight:700px"
    :footer="null"
  >
    <!-- tabel 加载 -->
    <a-spin :spinning="confirmLoading">
      <!-- 回显信息  -->
      <div class="table-page-search-wrapper" style="marginTop:20px;">
        <!-- <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :md="6" :sm="8">
              <a-form-item label="存货名称">
                <a-input v-model="pilosityFewerList.goodsName"></a-input>
              </a-form-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-item label="色号">
                <a-input v-model="pilosityFewerList.color"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-item label="计划数量">
                <a-input v-model="pilosityFewerList.planQuantity"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-item label="购入数量">
                <a-input v-model="pilosityFewerList.purchaseQuantity"></a-input>
              </a-form-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-item label="多发少发">
                <a-input v-model="pilosityFewerList.pilosityFewer"></a-input>
              </a-form-item>
            </a-col> -->
            <!-- <a-col :md="6" :sm="8">
              <a-form-item label="备注">
                <a-input v-model="pilosityFewerList.styleNumber"></a-input>
              </a-form-item>
            </a-col> -->

            <!-- <a-col :md="24" :sm="24">
              <a-form-item label="备注" class="noteBg">
                <a-input type="textarea" v-model="pilosityFewerList.remarks" style="minHeight:100px;"></a-input> -->
                <a-table
                     bordered
                    :loading="loading"
                    :columns="pilosityFewerColumns"
                     :data-source="pilosityFewerList"
                     :pagination="false"
                    :scroll="{ y: 500 }"
                   >
                   <span slot="color" slot-scope="text,record">
                     <a-input placeholder="请输入" v-model="record.color" />
                    </span>
                    <span slot="remarks" slot-scope="text,record">
                     <a-input placeholder="请输入" v-model="record.remarks" />
                    </span>
                </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="backFabricLossTable" icon="rollback">返回</a-button>
                    </span>
                  </a-col>
                </a-row>
            <!-- </a-col>
          </a-row>
        </a-form> -->
      </div>
    </a-spin>
  </a-modal>
</template>

<script>
import { downFile,downFile1 } from '@/api/manage'
export default {
  name: 'pilosityFewerListModal', // 事故单 弹框
  components: {},
  data() {
    return {
      loading: false,
      confirmLoading: false,
      pilosityFewerModVis: false,
       planNum:'',
      pilosityFewerList: [],
      pilosityFewerColumns:[
        {
          title: '存货名称',
          dataIndex: 'goodsName',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '色号',
          dataIndex: 'color',
          width: 120,
          className: 'replacecolor',
          scopedSlots: { customRender: 'color' },
        },
        {
          title: '计划数量',
          dataIndex: 'planQuantity',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '购入数量',
          dataIndex: 'purchaseQuantity',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '多发少发',
          dataIndex: 'pilosityFewer',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '备注',
          dataIndex: 'remarks',
          width: 120,
          className: 'replacecolor',
          scopedSlots: { customRender: 'remarks' },
        },
      ]
    }
  },
  // 接收父组件 方法
  props: {
    father: {
      type: Function,
      default: null
    },
    planNum:{
      type: String,
      default: null
    }
  },
  created() {},
  methods: {
    //  导出
    handleExportXls(fileName) {
      console.log('需导出的fileName:', fileName)
      const params = {
        planNum:this.planNum,
        syPilosityFewer :this.pilosityFewerList,
        sheetName:'多发少发'
      }
      console.log('导出参数', params)
      downFile1('/cost/syCostAllocation/exportXlsSyCostAllocation', 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' }), this.planNum+'-'+fileName + '.xlsx')
        } 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 + '.xlsx')
          document.body.appendChild(link)
          link.click()
          document.body.removeChild(link) // 下载完成移除元素
          window.URL.revokeObjectURL(url) // 释放掉blob对象
        }
      })
    },
    // 打印
    print() {},
    // 返回
    backFabricLossTable() {
      console.log('返回到面料损耗表')
      this.pilosityFewerModVis = 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>
