<!--
  @description:集采采购单明细表
  @Modifier: haoFx
  @routerPath: /statisticalManagement/collectivePurchase-list
  @date: 2021-05-24-20:14
-->
<template>
  <table-crud
    :menu="true"
    :search-form="searchForm"
    search-label-width="auto"
    @on-load="loadData"
  >
    <template v-slot:header>
      集采采购单明细表
    </template>
    <template v-slot: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="tenderMethod">
        <el-select v-model="searchForm.tenderMethod" placeholder="采购方式">
          <el-option
            v-for="item in tender_methodList"
            :key="item.typecode"
            :label="item.typename"
            :value="item.typecode"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否框架" prop="planType">
        <el-select v-model="searchForm.planType" placeholder="是否框架">
          <el-option
            v-for="item in isFramePlanList"
            :key="item.typecode"
            :label="item.typename"
            :value="item.typecode"
          />
        </el-select>
      </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="isFinishProject">
        <el-select v-model="searchForm.isFinishProject" placeholder="是否已完成采购单">
          <el-option
            v-for="item in isFinishProjectList"
            :key="item.typecode"
            :label="item.typename"
            :value="item.typecode"
          />
        </el-select>
      </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="tenderNo"
          label="采购单编号"
          align="center"
          width="170"
        />
        <el-table-column
          :formatter="formatterTenderMethod"
          header-align="center"
          prop="tenderMethod"
          label="采购方式"
          min-width="170"
        />
        <el-table-column
          :formatter="formatterTenderType"
          header-align="center"
          prop="tenderType"
          label="公开/邀请"
          min-width="120"
        />
        <el-table-column
          header-align="center"
          prop="supplierCategory"
          label="供应商分类"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="supplierAttribute"
          label="供应商属性"
          width="170"
        />
        <el-table-column
          :formatter="formatterReviewMethod"
          header-align="center"
          prop="reviewMethod"
          label="评审办法"
          width="120"
        />
        <el-table-column
          header-align="center"
          prop="sourcingUserRealName"
          label="采购员"
          width="120"
        />
        <el-table-column
          header-align="center"
          prop="quoteEndTime"
          label="报价截止时间"
          align="center"
          width="170"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.quoteEndTime&&
              $Moment(scope.row.quoteEndTime).format(momentDateTime)
            }}</span>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="quoteValidity"
          label="报价有效期"
          align="center"
          width="170"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.quoteValidity&&
              $Moment(scope.row.quoteValidity).format(momentDateTime)
            }}</span>
          </template>
        </el-table-column>
        <el-table-column
          :formatter="formatterIsUploadReplyFile"
          header-align="center"
          prop="isUploadReplyFile"
          label="强制上传应答文件"
          width="170"
        />
        <el-table-column
          :formatter="formatterPayType"
          header-align="center"
          prop="payType"
          label="付款方式"
          width="170"
        />
        <el-table-column
          :formatter="formatterQuoteType"
          header-align="center"
          prop="quoteType"
          label="报价要求"
          width="170"
        />
        <el-table-column
          :formatter="formatterQuoteMethod"
          header-align="center"
          prop="quoteMethod"
          label="询价方式"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="remark2"
          label="公告备注"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="packAssignTime"
          label="采购单分配时间"
          align="center"
          width="170"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.packAssignTime&&
              $Moment(scope.row.packAssignTime).format(momentDateTime)
            }}</span>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="projectSubmitTime"
          label="公告提交时间"
          align="center"
          width="170"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.projectSubmitTime&&
              $Moment(scope.row.projectSubmitTime).format(momentDateTime)
            }}</span>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="publishTime"
          label="公告审批完成时间"
          align="center"
          width="170"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.publishTime&&
              $Moment(scope.row.publishTime).format(momentDateTime)
            }}</span>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="suppliersName"
          label="中选供应商"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="partnerNo"
          label="供应商sap编码"
          align="center"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="transactionBudget"
          label="报价净单价(元)"
          align="right"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="distributionTotalMoney"
          label="报价净总价(元)"
          align="right"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="offerRemarks"
          label="品牌/生产厂商"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="distributionTotalTaxMoney"
          label="中选行项目含税总价(元)"
          align="right"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="negRecordCode"
          label="报价单号"
          align="center"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="winningSubmitDate"
          label="中选结果提交时间"
          align="center"
          width="170"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.winningSubmitDate&&
              $Moment(scope.row.winningSubmitDate).format(momentDateTime)
            }}</span>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="winningPassTime"
          label="中选审批完成时间"
          align="center"
          width="170"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.winningPassTime&&
              $Moment(scope.row.winningPassTime).format(momentDateTime)
            }}</span>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="orderCode"
          label="订单编号"
          align="center"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="ebeln"
          label="sap订单编号"
          align="center"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="orderName"
          label="订单名称"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="orderTotalMoney"
          label="订单净总额(元)"
          align="right"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="orderCreateTime"
          label="订单生成时间"
          align="center"
          width="170"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.orderCreateTime&&
              $Moment(scope.row.orderCreateTime).format(momentDateTime)
            }}</span>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="activeTime"
          label="订单生效时间"
          align="center"
          width="170"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.activeTime&&
              $Moment(scope.row.activeTime).format(momentDateTime)
            }}</span>
          </template>
        </el-table-column>
        <el-table-column
          :formatter="formatterOrderStatus"
          header-align="center"
          prop="orderStatus"
          label="订单状态"
          width="170"
        />
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* 接口*/
import { queryPlanPurchaseProjectStatisticsPageList, downPlanPurchaseProjectStatisticsList } from '@api/procurement/statisticalManagement'
import { statisticalMixins } from '../../mixins/statisticalMixins'// 字典信息
// /* 公用方法*/
import { download } from '@/assets/js/utils'// 常用方法
export default {
  name: 'CollectivePurchaseList',
  mixins: [statisticalMixins],
  data() {
    return {
      loading: true,
      // 搜索
      searchForm: {
        timeDate: [], // 统计时间
        belongBk: '', // 板块查询
        isFinishProject: '', // 是否已完成采购
        planType: '', // 是否框架
        statisticsTimeEnd: '', // 采购单审批时间
        statisticsTimeStart: '', // 采购单审批时间
        tenderMethod: '' // 采购方式
      },
      tableData: [],
      searchParams: {} // 入参
    }
  },
  created() {
  },
  methods: {
    // 导出
    exportAll() {
      downPlanPurchaseProjectStatisticsList(this.searchParams).then(res => {
        download(res, '集采采购单明细报表.xls')
      })
    },
    // 获取数据
    loadData(params, callback) {
      delete params.timeDate
      this.searchParams = params
      queryPlanPurchaseProjectStatisticsPageList(params).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) // 结束时间
      }
    },
    getSum(param) {
      const { columns } = param
      const sums = []
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '合计'
          return
        }
        /*     switch(column.property) {
                      case "money":
                        sums[index] = (this.footer.moneySum / 100).toFixed(2) + '元’; //值取自后台
                        break;
                      case "profit":
                        sums[index] = this.footer.profitSum / 100 + '元’; //值取自后台
                        break;
                      default:
                        break;
                    }*/
      })
      return sums
    }
  }
}
</script>

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

