<template>
  <!-- 齐套率报表 -->
  <div id="fullratetable">
    <!-- 查询 -->
    <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="开始年月">
                <!--  :disabled-date="disabledDate" 不可选择的日期 -->
                <a-month-picker
                  placeholder="请选择开始年月"
                  format="YYYY-MM"
                  style="width:100%;"
                  v-model="queryParam.startYearMonth"
                />
              </a-form-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-item label="结束年月">
                <a-month-picker
                  placeholder="请选择结束年月"
                  format="YYYY-MM"
                  style="width:100%;"
                  v-model="queryParam.endYearMonth"
                />
              </a-form-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-item label="区间(天)">
                <a-input placeholder="请输入区间" v-model="queryParam.sectionData"></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.department"></a-input>
                </a-form-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-item label="出库齐套">
                  <a-input placeholder="请输入出库齐套" v-model="queryParam.outboundSet"></a-input>
                </a-form-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-item label="来源订单号">
                  <a-input placeholder="请输入出库齐套" v-model="queryParam.sourceOrderNo"></a-input>
                </a-form-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-item label="销售订单数量">
                  <a-input placeholder="请输入出库齐套" v-model="queryParam.salesOrderQuantity"></a-input>
                </a-form-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-item label="订单编号">
                  <a-input placeholder="请输入订单编号" v-model="queryParam.orderNum"></a-input>
                </a-form-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-item label="订单数量">
                  <a-input placeholder="请输入订单数量" v-model="queryParam.orderQuantity"></a-input>
                </a-form-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-item label="颜色">
                  <a-input placeholder="请输入颜色" v-model="queryParam.color"></a-input>
                </a-form-item>
              </a-col>

              <a-col :md="6" :sm="8">
                <a-form-item label="交期">
                  <a-date-picker
                    placeholder="请选择交期"
                    @change="shipDateChange"
                    style="width: 100%"
                    v-model="queryParam.deliveryDate"
                  />
                </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>
            </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>

    <!-- 操作按钮区域 邮件 分析图-->
    <a-card :bordered="false" style="marginTop:10px;">
      <div class="table-operator">
        <a-button type="primary" icon="bell" @click="emailMsgMod">维护邮件发送通知</a-button>
        <a-button type="primary" @click="checkMonth" icon="line-chart">查看分析图-月份</a-button>
        <a-button type="primary" @click="checkdepartment" icon="bar-chart">查看分析图-部门</a-button>
      </div>

      <!-- table rowKey="id" -->
      <a-table
        bordered
        :columns="fullrateColumns"
        :data-source="fullrateData"
        :loading="loading"
        :row-key="record => record.id"
        :scroll="{ x: 1500 }"
      >
      </a-table>
    </a-card>
    <!-- 维护邮件发送通知 :father="cc"-->
    <emailMsg-modal ref="emailMsgModal"></emailMsg-modal>
    <monthChart-modal ref="monthChartModal"></monthChart-modal>
    <departmentChart-modal ref="departmentChartModal"></departmentChart-modal>
  </div>
</template>

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

import emailMsgModal from '@views/reportForms/full-rate-table/emailMsgModal.vue'
import monthChartModal from '@views/reportForms/full-rate-table/monthChartModal.vue'
import departmentChartModal from '@views/reportForms/full-rate-table/departmentChartModal.vue'

export default {
  name: 'Fullratetable', // 齐套率报表
  mixins: [JeecgListMixin],
  components: { JEllipsis, moment, emailMsgModal, monthChartModal, departmentChartModal },

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

    return {
      // 齐套率统计表 表头
      fullrateColumns: [
        {
          title: '出库齐套',
          dataIndex: 'outboundSet',
          width: 120,
          fixed: 'left',
          className: 'replacecolor'
        },
        {
          title: '来源订单号',
          dataIndex: 'sourceOrderNo',
          width: 160,
          fixed: 'left',
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },

        {
          title: '销售订单数量',
          dataIndex: 'salesOrderQuantity',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '订单编号',
          dataIndex: 'orderNum',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '订单数量',
          dataIndex: 'orderQuantity',
          width: 120,
          className: 'replacecolor'
        },

        {
          title: '颜色',
          dataIndex: 'color',
          width: 120,
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },
        {
          title: '门幅',
          dataIndex: 'larghezza',
          width: 120,
          className: 'replacecolor'
        },
        //  {
        //   title: '创建时间',
        //   dataIndex: 'createTime',
        //   align: 'center',
        //   sorter: true,
        //   customRender: text => {
        //     return moment(text).format('YYYY-MM-DD')
        //   }
        // },
        {
          title: '交期',
          dataIndex: 'deliveryDate',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '部门',
          dataIndex: 'department',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '业务员',
          dataIndex: 'salesman',
          width: 120,

          className: 'replacecolor'
        },
        {
          title: '存货名称',
          dataIndex: 'inventoryName',
          width: 120,
          customRender: t => ellipsis(t),
          className: 'replacecolor'
        },

        {
          title: '存货编码',
          dataIndex: 'cinvcode',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '子件用量',
          dataIndex: 'dosageSon',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '存货上游订单数量',
          dataIndex: 'upstreamOrdersInventoryNum',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '累计出库数量',
          dataIndex: 'outQuantityTotal',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '累计准时出库数量',
          dataIndex: 'outQuantityOnTime',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '累计延迟出库数量',
          dataIndex: 'outQuantityLate',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '未出库数量',
          dataIndex: 'notOutQuantity',
          width: 120,
          className: 'replacecolor'
        },
        //  {
        //   title: '创建时间',
        //   dataIndex: 'createTime',
        //   align: 'center',
        //   sorter: true,
        //   customRender: text => {
        //     return moment(text).format('YYYY-MM-DD')
        //   }
        // },
        {
          title: '预计发货日期',
          dataIndex: 'estimatedShipDate',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '最早出库日期',
          dataIndex: 'earliestOutdate',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '最晚出库日期',
          dataIndex: 'latestOutDate',
          width: 120,
          className: 'replacecolor'
        },
        {
          title: '出库率',
          dataIndex: 'outRate',
          width: 90,
          fixed: 'right',
          className: 'replacecolor'
        },
        {
          title: '区间出库率',
          dataIndex: 'sectionOutRate',
          width: 120,
          fixed: 'right',
          className: 'replacecolor'
        },
        {
          title: '齐套率',
          dataIndex: 'fullRate',
          width: 90,
          fixed: 'right',
          className: 'replacecolor'
        }
      ],
      fullrateData: [
        {
          sourceOrderNo: 'AW21-PRU-19081-CHARCOAL-PH2RPT',
          orderNum: 'SYM632',
          orderQuantity: '570',
          color: '80#麻灰 CHARCOAL',
          inventoryName: 'PRI D6 主标 PM3001A',
          cinvcode: '0600000054',
          estimatedShipDate: '2021/9/24',
          outRate: '100',
          outQuantityOnTime: '3,240.00',
          fullRate: '100.00'
        },
        {},
        {},
        {}
      ],
      loading: false, // 加载状态

      // 查询条件
      queryParam: {
        startYearMonth: '',
        endYearMonth: '',
        sectionData: '', // 区间
        department: '',
        outboundSet: '', // 出库齐套
        sourceOrderNo: '', // 来源订单号
        salesOrderQuantity: '', // 销售订单数量
        orderNum: '', // 订单编号
        orderQuantity: '', // 订单数量
        color: '',
        deliveryDate: '', // 交期
        salesman: '' // 业务员
      },

      url: {
        // syncUser: '/act/process/extActProcess/doSyncUser',
        list: '/sys/user/list',
        // delete: '/sys/user/delete',
        // deleteBatch: '/sys/user/deleteBatch',
        exportXlsUrl: '/sys/user/exportXls', // 导出
        importExcelUrl: 'sys/user/importExcel' // 导入
      }
    }
  },
  created() {
    // this.getAdPaListClothes()
  },
  // html渲染出来后，操作dom
  mounted() {
    this.loadingChart()
  },
  methods: {
    loadingChart() {
      setTimeout(() => {
        this.loading = false
      }, 500)
    },
    // 邮件通知
    emailMsgMod() {
      this.$refs.emailMsgModal.emailMsgModVis = true
    },
    // 分析图- 月份
    checkMonth() {
      console.log('打开齐套率月份统计图')
      this.$refs.monthChartModal.monthChartModVis = true
    },
    // 分析图- 部门
    checkdepartment() {
      console.log('打开部门齐套率统计图')
      this.$refs.departmentChartModal.departmentChartModVis = true
    },

    searchQuery() {
      // this.getAnnList() // 渲染公告
    },
    // 重置
    searchReset() {
      this.queryParam = {}
      // this.getAnnList()
    },

    // 选中行
    // onSelectChange(keys, rows) {
    //   this.selectedRowKeys = keys
    //   this.selectedRows = rows
    // },
    // 分页、排序、筛选变化时触发
    // handleTableChange(pagination, filters, sorter) {
    //   // console.log('当前页信息>>>>',pagination)
    //   this.queryParam.pageNo = pagination.current
    //   // this.getAnnList()
    // }

    aa() {}
  },
  computed: {
    // 选中项
    rowSelection() {
      return {
        onChange: (selectedRowKeys, selectedRows) => {
          console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows)
        },
        getCheckboxProps: record => ({
          props: {
            disabled: record.title === 'Disabled User',
            // Column configuration not to be checked
            title: record.title
          }
        })
      }
    }
  }
}
</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>
