<!--
  @description:订单查询列表-全部
  @Modifier: lxl
  @routerPath:
  @date: 2021-2-16-17:12
-->
<template>
  <div>
    <section>
      <el-table ref="smallTable" v-loading="loading" :data="tableData" @sort-change="sortChange">
        <el-table-column type="index" label="序号" align="center" width="60" />
        <!--订单编号  -->
        <el-table-column
          prop="orderCode"
          sortable="custom"
          label="订单编号"
          header-align="center"
          align="center"
          min-width="150"
        />
        <!-- 来源编号 -->
        <!-- <el-table-column
          prop="belongTenderNo"
          sortable="custom"
          label="来源编号"
          header-align="center"
          align="center"
          min-width="150"
        /> -->
        <!-- 采购单编号 -->
        <el-table-column
          label="采购单编号"
          prop="tenderNo"
          width="150"
          header-align="center"
          align="center"
        >
          <template slot-scope="scope">
            <el-link
              type="primary"
              @click.stop="procResult(scope.row)"
            >
              {{ scope.row.tenderNo }}
            </el-link>
          </template>
        </el-table-column>
        <!-- sap订单号 -->
        <!--        <el-table-column
          prop="sapOrderCode"
          sortable="custom"
          label="sap订单号"
          header-align="center"
          align="center"
          min-width="150"
        />-->
        <!--订单名称  -->
        <el-table-column
          prop="orderName"
          sortable="custom"
          label="订单名称"
          header-align="center"
          align="left"
          min-width="230"
        />
        <el-table-column
          prop="abolishReason"
          sortable="custom"
          label="订单作废原因"
          min-width="180"
          header-align="center"
          align="left"
        />
        <el-table-column
          prop="abolishTime"
          sortable="custom"
          label="订单作废时间"
          min-width="180"
          header-align="center"
          align="left"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.abolishTime && $Moment(scope.row.abolishTime).format(momentDateTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="activeTime"
          sortable="custom"
          label="订单生效时间"
          min-width="180"
          header-align="center"
          align="left"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.activeTime && $Moment(scope.row.activeTime).format(momentDateTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="releaseReason"
          sortable="custom"
          label="订单退回原因"
          min-width="180"
          header-align="center"
          align="left"
        />
        <el-table-column
          prop="releaseTime"
          sortable="custom"
          label="订单退回时间"
          min-width="180"
          header-align="center"
          align="left"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.releaseTime && $Moment(scope.row.releaseTime).format(momentDateTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="订单退回状态"
          prop="releaseStatus"
          sortable="custom"
          width="150"
          header-align="center"
          align="center"
        >
          <template slot-scope="scope">
            {{ scope.row.releaseStatus && filterDictText(procurementOrderReleaseStatusList,scope.row.releaseStatus) }}
          </template>
        </el-table-column>

        <!-- 状态 orderStatus 99 图推送sap订单状态-->
        <el-table-column
          prop="syncStatus"
          sortable="custom"
          label="状态"
          width="150"
          header-align="center"
          align="center"
        >
          <template slot-scope="scope">
            <span> {{ filterDictText(syncStatusList, scope.row.syncStatus) }}</span>
          </template>
        </el-table-column>
        <!--供应商名称  -->
        <el-table-column
          prop="winningDepartName"
          sortable="custom"
          label="供应商名称"
          min-width="180"
          header-align="center"
          align="left"
        />
        <!--采购单位  -->
        <el-table-column
          prop="purchaseDepartName"
          sortable="custom"
          label="采购单位"
          min-width="180"
          header-align="center"
          align="left"
        />
        <!--采购执行单位  -->
        <el-table-column
          prop="purchaseDepartExecuteName"
          sortable="custom"
          label="采购执行单位"
          min-width="200"
          header-align="center"
          align="left"
        />
        <!--生成方式  -->
        <el-table-column
          prop="tenderMethod"
          sortable="custom"
          label="生成方式"
          width="150"
          header-align="center"
          align="center"
        >
          <template slot-scope="scope">
            <span>{{ filterDictText(tender_methodList,scope.row.tenderMethod) }}</span>
          </template>
        </el-table-column>
        <!--订单总额(元)  -->
        <el-table-column
          label="订单总额(元)"
          prop="orderTotalMoney"
          sortable="custom"
          min-width="150"
          header-align="center"
          align="right"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.orderTotalMoney?moneyFormat(scope.row.orderTotalMoney.toFixed(2)):scope.row.orderTotalMoney }}</span>
          </template>
        </el-table-column>
        <!--创建日期  -->
        <el-table-column label="创建日期" align="center" sortable="custom" prop="createTime" width="180" header-align="center">
          <template slot-scope="scope">
            <span>{{ $Moment(scope.row.createTime).format(momentDateTime) }}</span>
          </template>
        </el-table-column>
        <!--订单状态  -->
        <el-table-column
          label="订单状态"
          prop="orderStatus"
          sortable="custom"
          width="150"
          header-align="center"
          align="center"
        >
          <template slot-scope="scope">
            <span> {{ filterDictText(procurementOrderOrderStatusList, scope.row.orderStatus) }}</span>
          </template>
        </el-table-column>
        <!-- 采购员 -->
        <el-table-column
          prop="purchaseUserRealName"
          sortable="custom"
          label="采购员"
          min-width="180"
          header-align="center"
          align="left"
        />

        <!--操作  -->
        <el-table-column
          header-align="center"
          label="操作"
          align="center"
          fixed="right"
          width="210"
        >
          <template slot-scope="scope">
            <slot :row="scope.row" :index="scope.index" />
          </template>
        </el-table-column>
      </el-table>
    </section>
  </div>
</template>

<script>
import { filterDictText, moneyFormat } from '@/assets/js/utils' // 深拷贝
import { procurementOrderGroupMixins } from '@/views/procurement/procurementOrder/mixins/procurementOrderGroupMixins.js'

/* 组件*/
export default {
  name: 'OrderAllTable',
  mixins: [procurementOrderGroupMixins],
  props: {
    // 表格数据
    tableData: {
      type: Array,
      default: function() {
        return []
      }
    },
    // 查看来源编号方法
    procResult: {
      type: Function,
      default: function(data) {}
    }
  },
  data() {
    return {
      loading: false
    }
  },
  created() {
  },
  methods: {
    moneyFormat, // 金额千分位
    filterDictText, // 字典翻译
    // 排序
    sortChange: function(column, prop, order) {
      let orderType = ''
      switch (column.order) {
        case 'ascending':
          orderType = 'ASC'
          break
        case 'descending':
          orderType = 'DESC'
          break
      }
      this.$emit('orderData', { column: column.prop, orderSort: orderType })
    }
  }
}
</script>

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