<template>
  <!--成本分配汇总  -->
  <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.index"></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.planNum"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <a-form-item label="客户简称">
              <a-input placeholder="请输入客户简称" v-model="queryParam.customerShortName"></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
        rowKey="id"
        :columns="costAllocationColumns"
        :data-source="costAllocationData"
        :loading="loading"
        :pagination="ipagination"
        :scroll="{ x: 1500 }"
        @change="handleTableChange"
      >
        <!-- 状态 -->
        <!-- slot-scope="text, record" -->
        <span slot="state">
          <!-- v-if="record.isRelease == '0'" -->
          <a-tag color="#f50">审核通过</a-tag>
          <!-- <a-tag color="#87d068" v-else>已发布</a-tag> -->
        </span>

        <!-- 操作 -->
        <span slot="operationSlot" slot-scope="text, record">
          <a href="javascript:void(0);" @click="detail(record)">详情</a>
          <a-divider type="vertical" />
          <a href="javascript:void(0);" @click="check(record)" style="color:green">审核</a>
        </span>
      </a-table>
    </div>

    <!-- 详情 大抽屉 -->
    <costAllocation-drawer ref="costAllocationDrawer" :father="aa" @ok="modalFormOk"></costAllocation-drawer>
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JEllipsis from '@/components/jeecg/JEllipsis'
import moment from 'moment'
import costAllocationDrawer from '@views/reportForms/cost-allocation-table/costAllocationDrawer.vue'

export default {
  name: 'CostAllocationTable', // 成本分配汇总
  mixins: [JeecgListMixin],
  components: { JEllipsis, moment, costAllocationDrawer },

  data() {
    let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} /> // 省略

    return {
      description: '成本分配汇总页面',

      // 查询条件
      queryParam: {
        index: '',
        planNum: '',
        customerShortName: ''
      },
      // 成本分配汇总 表头
      costAllocationColumns: [
        {
          title: '序号',
          width: 90,
          dataIndex: 'index',
          customRender: (text, record, index) => `${index + 1}`,
          fixed: 'left',
          className: 'replacecolor'
        },
        { title: '计划单号', width: 120, dataIndex: 'planNum', fixed: 'left', className: 'replacecolor' },
        { title: '款号', width: 120, dataIndex: 'styleNum', className: 'replacecolor' },
        { title: '业务员', width: 120, dataIndex: 'salesman', className: 'replacecolor' },
        {
          title: '部门',
          width: 120,
          dataIndex: 'department',
          className: 'replacecolor'
        },
        { title: '客户简称', width: 150, dataIndex: 'customerShortName', className: 'replacecolor' },
        { title: '加工单位', width: 120, dataIndex: 'processUnit', className: 'replacecolor' },
        //  {
        //   title: '创建时间',
        //   dataIndex: 'createTime',
        //   align: 'center',
        //   sorter: true,
        //   customRender: text => {
        //     return moment(text).format('YYYY-MM-DD')
        //   }
        // },
        { title: '出运日期', width: 120, dataIndex: 'outData', className: 'replacecolor' },
        { title: '成衣件数', width: 90, dataIndex: 'clothesQuantity', className: 'replacecolor' },
        { title: '销售美元', width: 120, dataIndex: 'SalesUSD', className: 'replacecolor' },
        { title: '销售人民币', width: 120, dataIndex: 'SalesCNY', className: 'replacecolor' },
        { title: '面料(不含税)', width: 120, dataIndex: 'FabricExcludedTax', className: 'replacecolor' },
        { title: '辅料(不含税)', width: 120, dataIndex: 'ingredientsExcludedTax', className: 'replacecolor' },
        { title: '加工费(CNY)', width: 120, dataIndex: 'processCostCNY', className: 'replacecolor' },
        { title: '加工费(USD)', width: 120, dataIndex: 'processCostUSD', className: 'replacecolor' },
        { title: '费用支出(汇总CNY)', width: 160, dataIndex: 'costPayTotalCNY', className: 'replacecolor' },
        { title: '费用支出(汇总USD)', width: 160, dataIndex: 'costPayTotalUSD', className: 'replacecolor' },
        { title: '事故单人民币金额', width: 160, dataIndex: 'accidentCNYAmount', className: 'replacecolor' },
        {
          title: '备注',
          width: 180,
          dataIndex: 'note',
          customRender: t => ellipsis(t),
          className: 'replacecolor',
          scopedSlots: { customRender: 'note' }
        },
        {
          title: '状态',
          width: 120,
          dataIndex: 'state',
          className: 'replacecolor',
          scopedSlots: { customRender: 'state' }
        },
        {
          title: '操作',
          dataIndex: 'operation',
          scopedSlots: { customRender: 'operationSlot' },
          fixed: 'right',
          width: 160,
          className: 'replacecolor'
        }
      ],
      costAllocationData: [
        {
          orderNum: 'AA002200001',
          note: '跟Jeecg-Boot官网统一,单元格内容较多时，多出内容以“……”替代,鼠标移入显示全部内容（此处原型图上是弹框，）'
        }
      ],
      loading: false // 表格加载
    }
  },
  created() {
    // 渲染订单销售列表
  },
  methods: {
    // 同步 synchronization() {},

    // 查询按钮
    searchQuery() {
      // 渲染成本分配统计表
    },
    searchReset() {
      // console.log('>>>>重置')
      this.queryParam = {}
      // 重新成本分配统计表
    },

    // 操作 详情
    detail(record) {
      // 点击了详情
      this.$refs.costAllocationDrawer.visible = true
    },
    // 操作 审核
    check() {},

    // father 抽屉方法
    aa() {}

    // 分页、排序、筛选变化时触发
    // handleTableChange(pagination, filters, sorter) {
    //   // console.log('当前页信息>>>>',pagination)
    //   this.queryParam.pageNo = pagination.current
    //   // this.getOrderList()
    // }
  },
  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>
