<template>
  <!-- 成本分配 主表 人民币费用支出 弹框 -->
  <a-modal
    title="人民币费用支出"
    v-model="mainTableExpenseCNYModVis"
    :confirmLoading="confirmLoading"
    width="86%"
    style="top:330px;left:100px;"
    :footer="null"
  >
    <!-- tabel 加载 -->
    <a-spin :spinning="confirmLoading">
      <!-- 查询  -->
      <div class="table-page-search-wrapper">
        <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="queryParam.setNo"></a-input>
              </a-form-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-item label="供应商" >
                <a-input v-model="queryParam.supplier"></a-input>
              </a-form-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
                <a @click="handleToggleSearch" style="margin-left: 8px">
                  {{ toggleSearchStatus ? '收起' : '展开' }}
                  <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
                </a>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>

      <!-- table -->
      <div>
        <a-table
          bordered
          :loading="loading"
          :columns="mainTableExpenseCNYColumns"
          :data-source="mainTableExpenseCNYData"
           :scroll="{ y: 500 }"
          :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" @click="backCostAllocationTable" icon="rollback">返回</a-button>
            </span>
          </a-col>
        </a-row>
      </div>
    </a-spin>
  </a-modal>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JEllipsis from '@/components/jeecg/JEllipsis'
export default {
  name: 'MainTableExpenseCNYModVis', //  成本分配统计 主表 人民币费用支出
  mixins: [JeecgListMixin],
  components: { JEllipsis },
  data() {
    return {
      loading: false, // 表格加载
      // orderDataform: this.$form.createForm(this),
      confirmLoading: false,
      mainTableExpenseCNYModVis: false,
      // 人民币费用支出 表头
      mainTableExpenseCNYColumns: [
        {
          title: '账套号',
          dataIndex: 'setNo',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '项目',
          dataIndex: 'expenseItem',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '金额',
          dataIndex: 'disbursedLocalmoney',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '供应商',
          dataIndex: 'processUnit',
          width: 120,
          className: 'replacecolor'
        }
      ],
      mainTableExpenseCNYData: [],
      fixedData:[],

      // 查询条件
      queryParam: {
        setNo: '', // 账套号
        supplier: '' // 供应商
      }
    }
  },
  // 接收父组件 方法
  props: {
    father: {
      type: Function,
      default: null
    }
  },
  created() {},
  methods: {
    // 返回
    backCostAllocationTable() {
      console.log('返回成本分配统计表')
      // this.$router.push('fabricLoss-table')
      // this.invoiceNumModVis = false
      this.close()
    },
    // 弹框查询按钮
    searchQuery() {
      var data = []
      this.fixedData.map(item =>{
        if(item.setNo.includes(this.queryParam.setNo) && item.processUnit.includes(this.queryParam.supplier)){
          data.push(item)
        }
      })
      this.mainTableExpenseCNYData = data
    },
    // 重置
    searchReset() {
      // console.log('人民币重置查询条件')
      // this.queryParam = {}
      this.queryParam.setNo = ''
      this.queryParam.supplier = ''
      this.mainTableExpenseCNYData = this.fixedData
      // this.getShipmentList()
    },
    close() {
      this.$emit('close')
      this.mainTableExpenseCNYModVis = 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>
