<!--
  @description:全流程时间节点表
  @Modifier: zhangyawen
  @routerPath: /statisticalManagement/wholeProcessTimeNode-list
  @date: 2021-5-21-15:00
-->
<template>
  <table-crud
    :menu="true"
    :search-form="searchForm"
    search-label-width="auto"
    @on-load="loadData"
  >
    <template v-slot:header>
      全流程时间节点表
    </template>
    <template v-slot:search="search">
      <el-form-item label="计划上报时间" prop="timeDate">
        <el-date-picker
          v-model="searchForm.timeDate"
          type="daterange"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          @change="(val) => {handleCreateTime(val, 'statisticsTimeStart', 'statisticsTimeEnd');}"
        />
      </el-form-item>
      <el-form-item label="订单生成时间" prop="orderCreateDate">
        <el-date-picker
          v-model="searchForm.orderCreateDate"
          type="daterange"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          @change="(val) => {handleCreateTime(val, 'orderCreateTimeStart', 'orderCreateTimeEnd');}"
        />
      </el-form-item>
      <el-form-item label="订单生效时间" prop="activeDate">
        <el-date-picker
          v-model="searchForm.activeDate"
          type="daterange"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          @change="(val) => {handleCreateTime(val, 'activeTimeStart', 'activeTimeEnd');}"
        />
      </el-form-item>
      <el-form-item label="板块查询" prop="belongBk">
        <el-select v-model="searchForm.belongBk" placeholder="所属板块">
          <el-option
            v-for="item in belong_bkList"
            :key="item.typecode"
            :label="item.typename"
            :value="item.typecode"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="行项目编号" prop="purchaseNo">
        <el-input
          v-model.trim="searchForm.purchaseNo"
          placeholder="行项目编号"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item label="物资编号" prop="purchaseCode">
        <el-input
          v-model.trim="searchForm.purchaseCode"
          placeholder="物资编号"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item label="采购单号" prop="tenderNo">
        <el-input
          v-model.trim="searchForm.tenderNo"
          placeholder="采购单号"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item label="订单编号" prop="orderCode">
        <el-input
          v-model.trim="searchForm.orderCode"
          placeholder="订单编号"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item label="sap订单编号" prop="ebeln">
        <el-input
          v-model.trim="searchForm.ebeln"
          placeholder="sap订单编号"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
    </template>
    <template slot="menuLeft">
      <div class="mb10">
        <el-button type="primary" @click="exportAll">
          导出
        </el-button>
      </div>
    </template>
    <template v-slot:GXTable>
      <el-table ref="smallTable" v-loading="loading" :data="tableData">
        <el-table-column
          type="index"
          label="序号"
          width="60px"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop="purchaseNo"
          label="行项目编号"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="purchaseCode"
          label="物资编号"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="purchaseName"
          label="物资名称"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="purchaseDepartName"
          label="采购单位"
          min-width="170"
        />
        <el-table-column
          :formatter="formatterBelongBk"
          header-align="center"
          prop="belongBk"
          label="所属板块"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="tenderNo"
          label="采购单编号"
          min-width="170"
        />
        <el-table-column
          :formatter="formatterOrderStatus"
          header-align="center"
          prop="orderStatus"
          label="订单状态"
          min-width="170"
        />
        <el-table-column
          label="订单编号"
          prop="orderCode"
          width="170"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop="ebeln"
          label="sap订单编号"
          width="170"
          align="center"
        />
        <el-table-column
          :formatter="formatterDataStatus"
          header-align="center"
          prop="dataStatus"
          label="行项目状态"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="orderConfirmUserName"
          label="采购业务员"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="planCreateTime"
          label="计划创建时间"
          align="center"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="packReportAuditTime"
          label="计划上报审批时间"
          align="center"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="packSubmitTime"
          label="打包提交时间"
          align="center"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="packAuditPassTime"
          label="打包完成时间"
          align="center"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="planToSubmitDurationDate"
          label="打包完成时间（天）"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="packAssignTime"
          label="采购单分配时间"
          align="center"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="projectSubmitTime"
          label="公告提交时间"
          align="center"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="publishTime"
          label="公告审批完成时间"
          align="center"
          width="170"
        />
        <!--        <el-table-column
          header-align="center"
          prop="publishTime"
          label="公告发布时间"
          align="center"
          width="170"
        />-->
        <el-table-column
          header-align="center"
          prop="pack_pass_projectauditpass_date"
          label="公告审批结束时间（天）- 计划打包审批时间"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="quoteEndTime"
          label="报价截止时间"
          align="center"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="winningSubmitDate"
          label="中选结果提交时间"
          align="center"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="winningPassTime"
          label="中选审批完成时间"
          align="center"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="orderCreateDurationDate"
          label="成单天数（天）"
          min-width="120"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="orderCreateTime"
          label="订单生成时间"
          align="center"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="activeTime"
          label="订单生效时间"
          align="center"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="order_create_active_date"
          label="订单生效时间-订单生成时间（天）"
          min-width="120"
          align="right"
        />
        <!--     <el-table-column
          header-align="center"
          prop=""
          label="合同签订日期"
          align="center"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="供应商供货日期"
          align="center"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="验收日期"
          align="center"
          width="170"
        />-->
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* api */
import { getProcurementFullProcessTimeNodeStatisticsList, downProcurementFullProcessTimeNodeStatisticsList } from '@/api/procurement/statisticalManagement'
import { statisticalMixins } from './../mixins/statisticalMixins'// 字典信息
// /* 公用方法*/
import { download } from '@/assets/js/utils'// 常用方法
export default {
  name: 'WholeProcessTimeNodeList',
  mixins: [statisticalMixins],
  data() {
    return {
      loading: true,
      // 搜索
      searchForm: {
        orderCreateDate: [], // 订单生成时间
        orderCreateTimeStart: '', // 订单生成时间-开始
        orderCreateTimeEnd: '', // 订单生成时间-结束
        activeDate: [], // 订单生效时间
        activeTimeStart: '', // 订单生效时间-开始
        activeTimeEnd: '', // 订单生效时间-结束
        belongBk: '', // 板块查询
        ebeln: '', // sap订单号
        orderCode: '', // 订单编号
        purchaseCode: '', // 物料号
        purchaseNo: '', // 行项目号
        timeDate: [],
        statisticsTimeEnd: '', // 计划上报时间
        statisticsTimeStart: '', // 计划上报时间
        tenderNo: '' // 采购单号
      },
      tableData: [],
      searchParams: {} // 参数
    }
  },
  methods: {
    // 导出
    exportAll() {
      downProcurementFullProcessTimeNodeStatisticsList(this.searchParams).then(res => {
        download(res, '全流程时间节点表.xls')
      })
    },
    // 获取数据
    loadData(params, callback) {
      this.searchParams = params
      delete this.searchParams.timeDate
      delete this.searchParams.orderCreateDate
      delete this.searchParams.activeDate
      getProcurementFullProcessTimeNodeStatisticsList(this.searchParams).then(response => {
        this.loading = false
        this.tableData = response.data.records
        callback(response.data.total)
      }).catch(() => {
        this.loading = false
      })
    },
    // 处理搜索时间格式
    handleCreateTime(val, start, end) {
      if (val) {
        this.searchForm[start] = this.$Moment(val[0]).format(this.momentDate) // 开始时间
        this.searchForm[end] = this.$Moment(val[1]).format(this.momentDate) // 结束时间
      }
    }
  }
}
</script>

<style  lang="less" scoped>
</style>

