<template>
  <!-- 【单证】 财务核对表 -->
  <div id="costAllocationTotal">
    <!-- 查询区域 -->
    <a-card :bordered="false">
      <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 placeholder="请输入计划号" v-model="queryParam.planNo"></a-input>
              </a-form-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-item label="日期" has-feedback>
                <a-input placeholder="请输入日期" v-model="queryParam.dverifyDate"></a-input>
              </a-form-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-item label="面损表单据状态">
                <a-input placeholder="请输入面损表单据状态" v-model="queryParam.customerShortame"></a-input>
              </a-form-item>
            </a-col>
            <template v-if="toggleSearchStatus">
              <a-col :md="6" :sm="8">
              <a-form-item label="分配表单据状态">
                <a-input placeholder="请输入分配表单据状态" v-model="queryParam.customerShortame"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-item label="部门">
                <a-input placeholder="请输入部门" v-model="queryParam.department"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-item label="业务员">
                <a-input placeholder="请输入业务员" v-model="queryParam.salesman"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-item label="计划师傅/制单人">
                <a-input placeholder="请输入" v-model="queryParam.maker"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-item label="对单人">
                <a-input placeholder="请输入" v-model="queryParam.customerShortame"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-item label="备注">
                <a-input placeholder="请输入" v-model="queryParam.customerShortame"></a-input>
              </a-form-item>
            </a-col>
            </template>

            <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>
    </a-card>

    <!-- table区域  -->
    <a-card :bordered="false" style=" marginTop:10px;">
      <a-table
        bordered
        rowKey="id"
        :columns="costAllocationColumns"
        :data-source="costAllocationData"
        :loading="loading"
        :pagination="pagination"
        :scroll="{ x: 1500 }"
        @change="handleTableChange"
      >
      </a-table>
    </a-card>

    <!-- 详情 大抽屉 -->
    <costDetail-drawer ref="costDetailDrawer" :fatherList="getCostList" @ok="modalFormOk"></costDetail-drawer>
  </div>
</template>

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

import costDetailDrawer from '@views/cost-allocation-total/costDetailDrawer.vue'

import { checkList } from '@api/document/inancialReconciliation.js'

export default {
  name: 'inancialReconciliation', // 成本分配汇总 单证
  mixins: [JeecgListMixin],
  components: { JEllipsis, moment, costDetailDrawer },

  data() {
    let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} />
    return {
      costAllocationColumns: [
        { title: '计划单号', width: 120, dataIndex: 'planNo', fixed: 'left', className: 'replacecolor' },
        { title: '日期', width: 120, dataIndex: 'dverifyDate', className: 'replacecolor' },
        { title: '部门', width: 120, dataIndex: 'department', className: 'replacecolor'},
        { title: '业务员', width: 120, dataIndex: 'salesman', className: 'replacecolor' },
        { title: '计划师傅/制单人', width: 150, dataIndex: 'maker', className: 'replacecolor' },
        { title: '对单人(手输人)', width: 220, dataIndex: 'processUnit', align: 'left', className: 'replacecolor' },
        //  {
        //   title: '创建时间',
        //   dataIndex: 'createTime',
        //   align: 'center',
        //   sorter: true,
        //   customRender: text => {
        //     return moment(text).format('YYYY-MM-DD')
        //   }
        // },
        {
          title: '交单日期',
          width: 120,
          dataIndex: 'outdat',
          customRender: text => {
            // return moment(text).format('YYYY-MM-DD')
          },
          className: 'replacecolor'
        },
        {
          title: '返单日期',
          width: 120,
          dataIndex: 'outdat',
          customRender: text => {
            // return moment(text).format('YYYY-MM-DD')
          },
          className: 'replacecolor'
        },
        {
          title: '审核结束日期',
          width: 120,
          dataIndex: 'outdat',
          customRender: text => {
            // return moment(text).format('YYYY-MM-DD')
          },
          className: 'replacecolor'
        },
        {
          title: '面纱结束日期',
          width: 120,
          dataIndex: 'outdat',
          customRender: text => {
            // return moment(text).format('YYYY-MM-DD')
          },
          className: 'replacecolor'
        },
        { title: '面损表单据状态', width: 90, dataIndex: 'actualShipquantity', className: 'replacecolor' },
        {
          title: '交单日期',
          width: 120,
          dataIndex: 'outdata',
          customRender: text => {
            // return moment(text).format('YYYY-MM-DD')
          },
          className: 'replacecolor'
        },
        {
          title: '返单日期',
          width: 120,
          dataIndex: 'outdat',
          customRender: text => {
            // return moment(text).format('YYYY-MM-DD')
          },
          className: 'replacecolor'
        },
        {
          title: '结束日期',
          width: 120,
          dataIndex: 'outdat',
          customRender: text => {
            // return moment(text).format('YYYY-MM-DD')
          },
          className: 'replacecolor'
        },
        { title: '分配表单据状态', width: 120, dataIndex: 'usdTotalexportprice', className: 'replacecolor' },
        {
          title: '备注',
          width: 180,
          dataIndex: 'remarks',
          customRender: t => ellipsis(t),
          className: 'replacecolor',
          scopedSlots: { customRender: 'remarks' }
        },

      ],
      costAllocationData: [],
      // 查询条件
      queryParam: {
        // index: '',
        // planNum: '',
        // customerShortame: '',
        pageNo: '' // 点击的页数
      },
      // 分页
      pagination: {
      },
      dateFormat: 'YYYY-MM-DD',
      loading: false // 表格加载
    }
  },
  created() {
    this.getCostList()
  },
  methods: {
   // 分页查询
   getCostList() {
      this.$nextTick(() => {
        checkList(this.queryParam).then(res => {
          if (res.success) {
            this.costAllocationData = res.result.records
            this.pagination = {
              total: res.result.total,
              current: res.result.current,
              pageSize: res.result.size
            }
          }
        })
      })
    },
    searchQuery() {
      this.getCostList()
    },
    searchReset() {
      this.queryParam.pageNo = ''
      this.queryParam = {}
      this.getCostList()
    },

    handleTableChange(pagination, filters, sorter) {
      this.queryParam.pageNo = pagination.current
      this.getCostList()
    },
  },
  computed: {},
  mounted() {}
}
</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>
