<template>
  <div class="ele-body" style="width: 100%">
    <el-card shadow="never" v-loading="loading" style="width: 100%">
      <div class="ele-border-lighter form-content" v-loading="loading">
        <search-table @search="reload"></search-table>

        <!-- 数据表格 -->
        <ele-pro-table
          ref="table"
          :columns="columns"
          :datasource="datasource"
          height="calc(100vh - 410px)"
          style="margin-bottom: 10px"
          full-height="calc(100vh - 116px)"
          tool-class="ele-toolbar-form"
          :selection.sync="selection"
          @columns-change="handleColumnChange"
          :cache-key="cacheKeyUrl"
          :page-size="20"
        >
          <template v-slot:orderNo="{ row }">
            <el-link
              type="primary"
              :underline="false"
              @click="openorderDetail(row, 'orderNo')"
            >
              {{ row.orderNo }}
            </el-link>
          </template>
          <!-- 表头工具栏 -->
          <template v-slot:action="{ row }">
            <el-button
              size="small"
              type="primary"
              class="ele-btn-icon"
              @click="openEdit(row)"
            >
              详情
            </el-button>
          </template>
        </ele-pro-table>
      </div>
    </el-card>

    <order-detail-dialog ref="orderDetailDialogRef"></order-detail-dialog>
    <detailDialog ref="detailDialog" @success="reload"></detailDialog>
  </div>
</template>

<script>
  import searchTable from './components/searchTable.vue';

  import orderDetailDialog from '@/views/saleManage/saleOrder/components/detailDialog.vue';
  import detailDialog from './components/detailDialog.vue';

  import dictMixins from '@/mixins/dictMixins';
  import { getTableList } from '@/api/saleManage/palletManagement';
  import tabMixins from '@/mixins/tableColumnsMixin';

  export default {
    mixins: [dictMixins,tabMixins],
    components: {
      searchTable,
      orderDetailDialog,
      detailDialog
    },

    data() {
      return {
        loading: false, // 加载状态
        cacheKeyUrl:'eos-3f2ac512-saleOrder-palletManagement',
        columns: [
          {
            columnKey: 'index',
            label: '序号',
            type: 'index',
            width: 55,
            align: 'center',
            showOverflowTooltip: true,
            fixed: 'left'
          },

          {
            prop: 'projectName',
            label: '项目名称',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 180
          },
          {
            prop: 'orderNo',
            label: '销售订单编码',
            align: 'center',
            sortable: true,
            slot: 'orderNo',
            showOverflowTooltip: true,
            minWidth: 200
          },
          {
            prop: 'productName',
            label: '托盘名称',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 140
          },
          {
            prop: 'totalCount',
            label: '托盘数量',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 140
          },

          {
            prop: 'resviceNum',
            label: '已回收数量',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 140
          },
          {
            prop: 'noResviceNum',
            label: '未回收数量',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 140
          },
          {
            columnKey: 'action',
            label: '操作',
            width: 160,
            align: 'center',
            resizable: false,
            slot: 'action',
            showOverflowTooltip: true,
            fixed: 'right'
          }
          // {
          //   prop: 'createUserName',
          //   label: '创建人',
          //   align: 'center',
          //   showOverflowTooltip: true,
          //   minWidth: 80
          // },
          // {
          //   prop: 'createTime',
          //   label: '创建时间',
          //   align: 'center',
          //   showOverflowTooltip: true,
          //   minWidth: 170
          // },
        ]
      };
    },
    computed: {},

    methods: {
      /* 表格数据源 */
      datasource({ page, limit, where, order }) {
        return getTableList({
          pageNum: page,
          size: limit,
          ...where
        });
      },

      /* 刷新表格 */
      reload(where) {
        this.$refs.table.reload({ page: 1, where });
      },
      openEdit(row) {
        this.$refs.detailDialog.open(row);
      },
      //查看详情
      openorderDetail(row, type) {
        if (type === 'docNo') {
          this.$refs.DetailDialogRef.open(row);
        }
        if (type === 'orderNo') {
          this.$refs.orderDetailDialogRef.open({ id: row.orderId });
        }
      }
    }
  };
</script>

<style lang="scss" scoped>
  .ele-body {
    padding-top: 0;
    padding-bottom: 0;
  }

  :deep .el-card__body {
    padding: 0;
  }

  :deep(.el-link--inner) {
    margin-left: 0px !important;
  }

  .sys-organization-list {
    height: calc(100vh - 264px);
    box-sizing: border-box;
    border-width: 1px;
    border-style: solid;
    overflow: auto;
  }

  .sys-organization-list :deep(.el-tree-node__content) {
    height: 40px;

    & > .el-tree-node__expand-icon {
      margin-left: 10px;
    }
  }

  .switch_left ul .active {
    border-top: 4px solid var(--color-primary);
    color: var(--color-primary-5);
  }

  .switch {
    padding-bottom: 20px;
  }

  .el-dropdown-link {
    cursor: pointer;
    color: var(--color-primary-5);
  }

  .el-icon-arrow-down {
    font-size: 12px;
  }
</style>
