<template>
  <div class="order-manage-wrapper">
    <bread-crumb :curmbFirst="curmbFirst"></bread-crumb>
    <div class="order-manage-content screenSet" id="screenSet">
      <div class="header-title">订单管理</div>
      <el-form ref="searchForm" :model="searchForm" label-width="80px" label-suffix=":" :inline="true">
        <el-row :gutter="30" type="flex" style="margin-top: 10px">
          <el-col :span="18">
            <el-form-item label="商品名称">
              <el-input v-model="searchForm.name" size="small" placeholder="请输入商品名称"></el-input>
            </el-form-item>
            <el-form-item label="订单号">
              <el-input v-model="searchForm.id" size="small" placeholder="请输入订单号"></el-input>
            </el-form-item>
            <el-form-item label="买家名称">
              <el-input v-model="searchForm.name" size="small" placeholder="请输入买家名称"></el-input>
            </el-form-item>
            <el-form-item label="下单时间">
              <el-date-picker
                  v-model="searchForm.orderTime"
                  type="datetime"
                  size="small"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  placeholder="请选择下单时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6" style="text-align: right">
            <el-button type="primary" size="small" @click="searchList">查询</el-button>
            <el-button type="default" size="small" @click="resetForm" style="margin-left:0;">重置</el-button>
          </el-col>
        </el-row>
      </el-form>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="全部" name="all"></el-tab-pane>
        <el-tab-pane label="等待买家付款" name="first"></el-tab-pane>
        <el-tab-pane label="等待发货" name="second"></el-tab-pane>
        <el-tab-pane label="已发货" name="third"></el-tab-pane>
        <el-tab-pane label="交易成功" name="fourth"></el-tab-pane>
        <el-tab-pane label="关闭交易" name="five"></el-tab-pane>
      </el-tabs>
      <el-table :data="tableData" border  max-height="1000" class="item-table" style="width: 100%;margin-top: 10px;">
        <el-table-column prop="id" label="订单号" min-width="100" align="center"></el-table-column>
        <el-table-column prop="name" label="商品名称" min-width="100" align="center"></el-table-column>
        <el-table-column prop="status" label="交易状态" min-width="100" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.status | rangeStatus }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="name" label="实收款" min-width="100" align="center"></el-table-column>
        <el-table-column prop="name" label="买家" min-width="100" align="center"></el-table-column>
        <el-table-column prop="name" label="数量" min-width="100" align="center"></el-table-column>
        <el-table-column prop="name" label="规格" min-width="100" align="center"></el-table-column>
        <el-table-column prop="name" label="单价" min-width="100" align="center"></el-table-column>
        <el-table-column prop="createdTime" label="下单时间" min-width="100" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.createdTime | liveDateFilter }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="name" label="备注" min-width="100" align="center"></el-table-column>
        <el-table-column label="操作" min-width="370" align="center" fixed="right">
          <template slot-scope="scope">
            <div>
              <el-button @click="shopManage(scope.row)" type="text" size="small">查看详情</el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination">
        <el-pagination
            background
            @size-change="handleSizeChange"
            @current-change="handleNumChange"
            :current-page="searchForm.pageNo"
            :page-sizes="[10, 30, 50, 100]"
            :page-size="searchForm.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalRows"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>
<script>
  // import { openLoading, closeLoading } from "../../utils/utils";
  import BreadCrumb from "@/components/breadcrumb.vue";
  export default {
    components: {
      BreadCrumb
    },
    data(){
      return{
        curmbFirst: '订单管理',
        activeName: 'all',
        showAllFlag: false,
        showNewFlag: false,
        searchForm: {
          name: '',
          id: '',
          orderTime: '',
          pageNo: 1,
          pageSize: 10,
        },
        totalRows: 0,
        tableData: [
          //   {
          //   id: '',
          //   name: '',
          //   type: null,
          //   status: '',
          //   num: null,
          //   createdTime: '',
          // }
        ],
        typeList: [{
          label: '供货商',
          value: '1',
        }, {
          label: '医生小店',
          value: '2',
        }, {
          label: '小药房',
          value: '3',
        }]
      }
    },
    created() {

    },
    methods: {
      searchList(){

      },
      resetForm() {
        this.searchForm = {
          name: '',
          id: '',
          orderTime: ''
        };
        this.searchList();
      },
      //上线
      publishRange(row) {
        this.$confirm(`确定上线“${row.name}”吗？`, '', {
          confirmButtonText: '上线',
          cancelButtonText: '取消',
          type: 'warning',
          customClass: 'range-make-box',
        }).then(() => {
          //  confirm
          this.updateStatus(row.id, "30");
        }).catch(() => {
          //  cancel
          // this.$message.error("上线失败");
        });
      },
      //下线
      unPublishRange(row) {
        this.$confirm(`确定下线“${row.name}”吗？`, '', {
          confirmButtonText: '下线',
          cancelButtonText: '取消',
          type: 'warning',
          customClass: 'range-make-box',
        }).then(() => {
          this.updateStatus(row.id, "40");
          //  confirm
        }).catch(() => {
          //  cancel

        });
      },
      //编辑
      editShop(row) {
        this.$router.push({
          path: `/create-shop?enterType`,
          query:{
            storeId:row.storeId,
          }
        })
      },
      handleSizeChange(val) {
        this.searchForm.pageSize = val;
        this.searchForm.pageNo = 1;
        this.searchList();
      },
      handleNumChange(val) {
        this.searchForm.pageNo = val;
        this.searchList();
      },
      handleClick(tab, event) {},
    },
  }
</script>
<style lang="scss">
  .order-manage-wrapper{
    .order-manage-content{
      background: #fff;
      padding: 10px;
      .header-title{
        padding: 10px 12px;
        font-size: 13px;
        color: #449284;
        border-bottom: 1px solid #efefef;
      }
    }
    .el-button--text{
      color: #449284;
      font-size: 14px;
      &::after{
        content: '';
        position: relative;
        height: 14px;
        /*border-right: 1px solid #EBEEF5;*/
        border-right: 1px solid #aaaaaa;
        padding-right: 10px;
      }
      &:last-of-type{
        &::after{
          content: '';
          position: relative;
          width: 1px;
          height: 14px;
          border-right: none;
        }
      }
    }
  }
  .el-tabs__item.is-active{
    color: #449284;
  }
  .el-tabs__active-bar{
    background-color: #449284;
  }
  .el-tabs__item:hover{
    color: #449284;
  }
</style>
