<template>
  <div class="aacontainer">
    <el-tabs type="card" v-model="actName" @tab-click="handleClickX">
      <el-tab-pane label="全部订单" name="10"></el-tab-pane>
      <el-tab-pane v-for="(item,index) in orderOptions" :label="item.dictLabel" :name="item.dictValue"></el-tab-pane>
    </el-tabs>
    <el-table v-loading="loading" :data="storeOrderList">
      <el-table-column label="订单号" align="center" prop="orderCode" width="180px"/>
<!--      <el-table-column label="所属店铺" align="center" prop="storeName" width="180px"/>-->
      <el-table-column label="所属公司" align="center" prop="companyName" width="180px"/>
      <el-table-column label="所属员工" align="center" prop="companyUserNickName" width="180px"/>
      <el-table-column label="用户昵称" align="center" prop="userPhone" show-overflow-tooltip width="100px"/>
      <el-table-column label="收件人" align="center" prop="realName" />
      <el-table-column label="订单总价" align="center" prop="totalPrice" />
<!--      <el-table-column label="商品分类" align="center" prop="totalPrice" />-->
      <el-table-column label="实付金额" align="center" prop="payPrice" />
      <el-table-column label="代收金额" align="center" prop="payDelivery" />
      <el-table-column label="订单状态" align="center" prop="status" >
        <template slot-scope="scope">
              <dict-tag :options="orderOptions" :value="scope.row.status"/>
         </template>
      </el-table-column>
      <el-table-column label="下单时间" align="center" prop="createTime" width="180" />
<!--      <el-table-column label="支付状态 " align="center" prop="isPay" >-->
<!--        <template slot-scope="scope">-->
<!--              <dict-tag :options="payStatusOptions" :value="scope.row.isPay"/>-->
<!--            </template>-->
<!--      </el-table-column>-->
      <el-table-column label="支付时间" align="center" prop="payTime" width="180" />
      <el-table-column label="支付方式" align="center" prop="payType" >
        <template slot-scope="scope">
              <dict-tag :options="PayOptions" :value="scope.row.payType"/>
         </template>
      </el-table-column>
      <el-table-column label="发货时间" align="center" prop="deliverySendTime" width="180" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { getToken } from "@/utils/auth";
import {listStoreOrder} from "@/api/hisStore/storeOrder";
export default {
  name: "userInquir",
  props:["data"],
  data() {
    return {
      actName:"10",
      show:{
              title:"订单详情",
              open:false,
            },
      upload: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        // url: process.env.VUE_APP_BASE_API + "/his/order/importData"
      },
      // 遮罩层
      loading: true,
      // // 导出遮罩层
      // exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 订单表格数据
      storeOrderList: [],
      // 弹出层标题
      title: "",
      createTime:null,
      payTime:null,
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        storeId: null,
        orderCode: null,
        userId: null,
        userName: null,
        userPhone: null,
        userAddress: null,
        cartId: null,
        totalNum: null,
        totalPrice: null,
        payPrice: null,
        payMoney: null,
        isPay: null,
        payTime: null,
        payType: null,
        status: null,
        refundStatus: null,
        refundImg: null,
        refundExplain: null,
        refundTime: null,
        refundReason: null,
        refundMoney: null,
        deliveryCode: null,
        deliveryName: null,
        deliverySn: null,
        isDel: null,
        costPrice: null,
        verifyCode: null,
        shippingType: null,
        isChannel: null,
        isPrescribe: null,
        prescribeId: null,
        finishTime: null,
        patientName: null,
        doctorName: null,
        sTime:null,
        eTime:null,
        paysTime:null,
        payeTime:null,
        deliveryTime: null,
        tuiMoney: null,
        tuiMoneyStatus: null,
        tuiUserId: null,
        orderCreateType: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
       PayOptions:[],
       orderOptions:[],
       payStatusOptions:[],
       refundOptions:[],
       channelOptions:[],
       orderTypeOptions:[],
       tuiOptions:[],
       orOptions:[],
       storeOPtions:[],
    };
  },
  created() {
    this.getDicts("store_pay_type").then(response => {
        this.PayOptions = response.data;
      });
    this.getDicts("store_order_type").then(response => {
        this.orderTypeOptions = response.data;
      });
    this.getDicts("store_order_status").then(response => {
        this.orderOptions = response.data;
      });

    this.getDicts("sys_store_payment_status").then(response => {
        this.payStatusOptions = response.data;
      });
    this.getDicts("sys_refund_status").then(response => {
        this.refundOptions = response.data;
      });
    this.getDicts("sys_channel").then(response => {
        this.channelOptions = response.data;
      });
  },
  methods: {
    getUserOrderDetails(id){
      this.queryParams.userId=id
      this.getList();
    },

    /** 查询订单列表 */
    getList() {
      this.loading = true;
      listStoreOrder(this.queryParams).then(response => {
        this.storeOrderList = response.rows;
        this.total = response.total;
        this.loading = false;
      });

    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        orderId: null,
        storeId: null,
        orderCode: null,
        userId: null,
        userName: null,
        userPhone: null,
        userAddress: null,
        cartId: null,
        totalNum: null,
        totalPrice: null,
        payPrice: null,
        payMoney: null,
        isPay: null,
        payTime: null,
        payType: null,
        createTime: null,
        updateTime: null,
        status: null,
        refundStatus: "0",
        refundImg: null,
        refundExplain: null,
        refundTime: null,
        refundReason: null,
        refundMoney: null,
        deliveryCode: null,
        deliveryName: null,
        deliverySn: null,
        remark: null,
        isDel: null,
        costPrice: null,
        verifyCode: null,
        shippingType: null,
        isChannel: null,
        isPrescribe: null,
        prescribeId: null,
        finishTime: null,
        deliveryTime: null,
        tuiMoney: null,
        tuiMoneyStatus: 0,
        tuiUserId: null,
        orderCreateType: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
   handleClickX(tab, event) {
    if(tab.name=="10"){
      this.queryParams.status=null;
    }else{
      this.queryParams.status=tab.name;
    }
     this.handleQuery();
   },
  changeTime(){
        if(this.createTime!=null){
          this.queryParams.sTime=this.createTime[0];
          this.queryParams.eTime=this.createTime[1];
        }else{
          this.queryParams.sTime=null;
          this.queryParams.eTime=null;
        }
      },
  }
};
</script>
