<template>
  <view class="content">
    <view class="header">
      <view class="headernei" @click="isTop = true">
        <img src="@/assets/images/search.png" alt="" />
      </view>
    </view>
    <view class="kuang" v-for="(item, index) in tableData" :key="index">
      <table class="tftable" border="1">
        <tr>
          <td align="right">{{ '产品主图' }}</td>
          <td align="left">
            <view>
              <img
                style="width: 56rpx; height: 56rpx;border-radius:8rpx;"
                :src="item.cover1"
                alt=""
            /></view>
          </td>
        </tr>
        <tr>
          <td align="right">{{ '产品编号' }}</td>
          <td align="left">{{ item.waresCode }}</td>
        </tr>
        <tr>
          <td align="right">{{ '产品名称' }}</td>
          <td align="left">{{ item.waresName }}</td>
        </tr>
        <tr>
          <td align="right">{{ '产品规格' }}</td>
          <td align="left">{{ item.specsName }}</td>
        </tr>
        <tr>
          <td align="right">{{ '重量' }}KG</td>
          <td align="left">{{ item.weight }}</td>
        </tr>
        <tr>
          <td align="right">{{ '产品单价' + `(${isLocalSymbol()})` }}</td>
          <td align="left">
            {{ item.productPrice | toThousandthAndKeepDecimal }}
          </td>
        </tr>
        <tr>
          <td align="right">{{ '产品数量' }}</td>
          <td align="left">{{ item.quantity }}</td>
        </tr>
        <tr>
          <td align="right">
            {{ '产品总价' + `(${isLocalSymbol()})` }}
          </td>
          <td align="left">
            {{ item.productPriceTotal | toThousandthAndKeepDecimal }}
          </td>
        </tr>
        <tr>
          <td align="right">{{ '商品编号' }}</td>
          <td align="left">{{ item.commodityCode }}</td>
        </tr>
        <tr>
          <td align="right">{{ '商品名称' }}</td>
          <td align="left">{{ item.commodityName }}</td>
        </tr>
        <tr>
          <td align="right">{{ '商品数量' }}</td>
          <td align="left">{{ item.waresQuantity }}</td>
        </tr>
        <tr>
          <td align="right">{{ '订单编号' }}</td>
          <td align="left">{{ item.orderCode }}</td>
        </tr>
        <tr>
          <td align="right">{{ '订单类型' }}</td>
          <td align="left">{{ item.orderTypeStr }}</td>
        </tr>
        <tr>
          <td align="right">{{ '会员编号' }}</td>
          <td align="left">{{ item.memberCode }}</td>
        </tr>
        <tr>
          <td align="right">{{ '会员姓名' }}</td>
          <td align="left">{{ item.memberName }}</td>
        </tr>
        <tr>
          <td align="right">{{ '联系方式' }}</td>
          <td align="left">{{ item.phone }}</td>
        </tr>
        <tr>
          <td align="right">{{ '发货类型' }}</td>
          <td align="left">{{ item.shippingChannelStr }}</td>
        </tr>
        <tr>
          <td align="right">{{ '收货人' }}</td>
          <td align="left">{{ item.recName }}</td>
        </tr>
        <tr>
          <td align="right">{{ '收货电话' }}</td>
          <td align="left">{{ item.recPhone }}</td>
        </tr>
        <tr>
          <td align="right">
            {{ `${'购买人' + '编号'}` }}
          </td>
          <td align="left">{{ item.buyMemberCode }}</td>
        </tr>
        <tr>
          <td align="right">{{ `${'购买人' + '姓名'}` }}</td>
          <td align="left">{{ item.buyMemberName }}</td>
        </tr>

        <tr>
          <td align="right">{{ '省' }}</td>
          <td align="left">{{ item.recProvinceName }}</td>
        </tr>
        <tr>
          <td align="right">{{ '市' }}</td>
          <td align="left">{{ item.recCityName }}</td>
        </tr>
        <tr>
          <td align="right">{{ '区/县' }}</td>
          <td align="left">{{ item.recCountryName }}</td>
        </tr>
        <tr>
          <td align="right">{{ '详细地址' }}</td>
          <td align="left">{{ item.recAddress }}</td>
        </tr>
        <tr>
          <td align="right">{{ '订单金额' }}</td>
          <td align="left">{{ item.orderAmount| toThousandthAndKeepDecimal }}</td>
        </tr>
        <tr>
          <td align="right">{{ '商品订单' + "BV" }}</td>
          <td align="left">
            {{ item.orderAssAchieve | toThousandthAndKeepDecimal }}
          </td>
        </tr>
        <tr>
          <td align="right">{{ '订单邮费' }}</td>
          <td align="left">{{ item.postage| toThousandthAndKeepDecimal }}</td>
        </tr>
        <tr>
          <td align="right">{{ '订单业绩' }}</td>
          <td align="left">{{ item.orderAchieve }}</td>
        </tr>
        <tr>
          <td align="right">{{ '发货方式' }}</td>
          <td align="left">{{ item.deliveryWayStr }}</td>
        </tr>
        <tr>
          <td align="right">{{ '供应方式' }}</td>
          <td align="left">{{ item.operateScope }}</td>
        </tr>
        <tr>
          <td align="right">{{ '运输方式' }}</td>
          <td align="left">{{ item.tranTypeStr }}</td>
        </tr>
        <tr>
          <td align="right">{{ '预售状态' }}</td>
          <td align="left">{{ item.preSaleStatusStr }}</td>
        </tr>
        <tr>
          <td align="right">{{ '订单状态' }}</td>
          <td align="left">{{ item.orderStatusStr }}</td>
        </tr>
        <tr>
          <td align="right">{{ '支付方式' }}</td>
          <td align="left">{{ item.payTypeStr }}</td>
        </tr>
        <tr>
          <td align="right">{{ '物流公司' }}</td>
          <td align="left">{{ item.logisticsCompany }}</td>
        </tr>
        <tr>
          <td align="right">{{ '快递单号' }}</td>
          <td align="left">{{ item.logisticsCode }}</td>
        </tr>
        <tr>
          <td align="right">{{ '备注' }}</td>
          <td align="left">{{ item.remark }}</td>
        </tr>
        <tr>
          <td align="right">{{ '创建日期' }}</td>
          <td align="left">{{ item.creationTime }}</td>
        </tr>
        <tr>
          <td align="right">{{ '支付日期' }}</td>
          <td align="left">{{ item.payTime }}</td>
        </tr>
      </table>
    </view>

    <!-- 顶部搜索 -->
    <u-popup :show="isTop" mode="top" @close="isTop = false">
      <view class="tt">
        <u--form
          labelPosition="left"
          labelWidth="auto"
          :model="select"
          ref="uForm"
        >
        <u-row gutter="10">
            <u-col span="6">
              <u-form-item :label="'产品编号'">
                <u--input fontSize="12" v-model="select.waresCode"></u--input>
              </u-form-item>
            </u-col>
            <u-col span="6">
              <u-form-item :label="'产品名称'">
                <u--input fontSize="12" v-model="select.waresName"></u--input>
              </u-form-item>
            </u-col>
          </u-row>
          <u-row gutter="10">
            <u-col span="6">
              <u-form-item :label="'订单类型'">
                <picker
                  :range="typeList"
                  range-key="label"
                  @change="bindPickerChange1"
                >
                  <u--input
                    disabled
                    fontSize="12"
                    disabledColor="#ffffff"
                    v-model="select.typeVal"
                    suffixIcon="arrow-down"
                    suffixIconStyle="font-size: 12px;"
                  ></u--input>
                </picker>
              </u-form-item>
            </u-col>
            <u-col span="6">
              <u-form-item :label="'订单编号'">
                <u--input fontSize="12" v-model="select.orderCode"></u--input>
              </u-form-item>
            </u-col>
           
          </u-row>

          <u-row gutter="10">
            <u-col span="6">
              <u-form-item :label="'会员编号'">
                <u--input fontSize="12" v-model="select.memberCode"></u--input>
              </u-form-item>
            </u-col>
            <u-col span="6">
              <u-form-item :label="'会员姓名'">
                <u--input fontSize="12" v-model="select.memberName"></u--input>
              </u-form-item>
            </u-col>
          
          </u-row>

          <u-row>
            <u-col span="6">
              <u-form-item :label="'联系方式'">
                <u--input fontSize="12" v-model="select.phone"></u--input>
              </u-form-item>
            </u-col>
            <u-col span="6">
              <u-form-item :label="`${'购买人'+'编号'}`">
                <u--input fontSize="12" v-model="select.buyMemberCode"></u--input>
              </u-form-item>
            </u-col>
          </u-row>
          <u-row gutter="10">
           
           <u-col span="6">
             <u-form-item :label="`${'购买人'+'姓名'}`">
               <u--input fontSize="12" v-model="select.buyMemberName"></u--input>
             </u-form-item>
           </u-col>
           <u-col span="6">
              <u-form-item :label="'收货人'">
                <u--input fontSize="12" v-model="select.recName"></u--input>
              </u-form-item>
            </u-col>
         </u-row>
          <u-row gutter="10">
            <u-col span="6">
              <u-form-item :label="'发货类型'">
                <picker
                  :range="fhTypeList"
                  range-key="label"
                  @change="bindPickerChange2"
                >
                  <u--input
                    disabled
                    fontSize="12"
                    disabledColor="#ffffff"
                    v-model="select.deliveryVal"
                    suffixIcon="arrow-down"
                    suffixIconStyle="font-size: 12px;"
                  ></u--input>
                </picker>
              </u-form-item>
            </u-col>
            <u-col span="6">
              <u-form-item :label="'支付方式'">
                <picker
                  :range="paywayList"
                  range-key="label"
                  @change="bindPickerChange3"
                >
                  <u--input
                    disabled
                    fontSize="12"
                    disabledColor="#ffffff"
                    v-model="select.payTypeVal"
                    suffixIcon="arrow-down"
                    suffixIconStyle="font-size: 12px;"
                  ></u--input>
                </picker>
              </u-form-item>
            </u-col>
           
          </u-row>
          <u-row gutter="10">
           
           <u-col span="6">
             <u-form-item :label="'商品编号'">
               <u--input fontSize="12" v-model="select.commodityCode"></u--input>
             </u-form-item>
           </u-col>
           <u-col span="6">
              <u-form-item :label="'商品名称'">
                <u--input fontSize="12" v-model="select.commodityName"></u--input>
              </u-form-item>
            </u-col>
         </u-row>
         
          
          <u-row gutter="10">
           
            <u-col span="12">
              <u-form-item :label="'快递单号'">
                <u--input fontSize="12" v-model="select.logisticsCode"></u--input>
              </u-form-item>
            </u-col>
          </u-row>
          <u-row gutter="10">
            <u-col span="12">
              <u-form-item
                :label="'创建日期'"
                @click="(isData = true), (setTime = 0)"
              >
                <u--input
                  disabled
                  fontSize="12"
                  disabledColor="#ffffff"
                  v-model="select.creationTimeVal"
                  suffixIcon="arrow-down"
                  suffixIconStyle="font-size: 12px;"
                ></u--input>
              </u-form-item>
            </u-col>
          </u-row>
          <u-row gutter="10">
            <u-col span="12">
              <u-form-item
                :label="'支付日期'"
                @click="(isData = true), (setTime = 1)"
              >
                <u--input
                  disabled
                  fontSize="12"
                  disabledColor="#ffffff"
                  v-model="select.payVal"
                  suffixIcon="arrow-down"
                  suffixIconStyle="font-size: 12px;"
                ></u--input>
              </u-form-item>
            </u-col>
          </u-row>
        </u--form>
        <view class="footer">
          <u-button
            @click="getList1"
            color="#C8161D"
            text="搜索"
            class="btnn"
          ></u-button>
          <u-button @click="reset" text="重置"></u-button>
        </view>
      </view>
    </u-popup>
    <u-calendar
      @close="isData = false"
      :closeOnClickOverlay="true"
      :show="isData"
      mode="range"
      :allowSameDay="true"
      :maxDate="calendar.maxDate"
      :minDate="calendar.minDate"
      :monthNum="calendar.monthNum"
      @confirm="confirm"
    ></u-calendar>
    <!-- 悬浮球 -->
    <drag-button />
    <export-ball ref="exportBall" @handleExport="handleExport" />
  </view>
</template>
      
<script>
import * as api from "@/api/logistics";
import { isLocals, isLocalSymbol } from "@/util/numberToCurrency";
export default {
  data() {
    return {
      select: {},
      isTop: false,
      isData: false,
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 20,
      },
      tableData: [],
      typeList: [], //订单类型
      fhTypeList: [], //发货类型
      paywayList:[],//支付方式
      userCountry: {},
      calendar: {
        minDate: '',
        maxDate: '',
        monthNum: 25,
      },
    };
  },
  onLoad(options) {
    this.select.orderCode = options.orderCode;
    this.getSearch();
    // 获取下拉
      this.getData();
      this.chooseTimed()
  },
  methods: {
    isLocalSymbol,
    isLocals,
     // 设置默认日期，最大值为今天，最小值为去年今天
     chooseTimed() {
      let date = new Date()
      let year = date.getFullYear()
      let month = date.getMonth() + 1
      let day = date.getDate()
      if (month <= 9) {
        month = '0' + month
      }
      if (day <= 9) {
        day = '0' + day
      }
      let minyear = year - 1
      let maxyear = year + 1
      this.calendar.minDate = minyear + '-' + month + '-' + day
      this.calendar.maxDate = maxyear + '-' + month + '-' + day
    },
    getData() {
      api.getOrderType().then((res) => {
        this.typeList = res.data;
      });
      api.getShippingChannelList().then((res) => {
        this.fhTypeList = res.data;
      });
      api.getOrderPayType().then((res) => {
        this.paywayList = res.data;
      });
    },

    onReachBottom() {
      this.queryParams.pageNum++;
      this.getSearch();
    },
    getSearch() {
      api
        .getFindOrderList(Object.assign({}, this.queryParams, this.select))
        .then((res) => {
          this.total = res.total;
          this.tableData = this.tableData.concat(res.rows);
        });
    },
    getList1() {
      this.tableData = [];
      this.queryParams.pageNum = 1;
      this.isTop = false;
      this.getSearch();
    },
    reset() {
      this.select = {};
      this.getSearch();
    },
    handleExport() {
      let url = "/sale/manage/order/get-order-info-export";
      let obj = Object.assign({}, this.select, this.queryParams);
      this.$refs.exportBall.handleExport(url, obj, '查看商品订单');
    },
    bindPickerChange2(e) {
      this.$set(
        this.select,
        "deliveryVal",
        this.fhTypeList[e.detail.value].label
      );
      this.$set(
        this.select,
        "shippingChannel",
        this.fhTypeList[e.detail.value].value
      );
    },
    bindPickerChange3(e) {
      this.$set(
        this.select,
        "payTypeVal",
        this.paywayList[e.detail.value].label
      );
      this.$set(
        this.select,
        "payType",
        this.paywayList[e.detail.value].value
      );
    },
    bindPickerChange1(e) {
      this.$set(this.select, "typeVal", this.typeList[e.detail.value].label);
      this.$set(this.select, "orderType", this.typeList[e.detail.value].value);
    },
   

    confirm(e) {
      if (this.setTime == 0) {
        this.$set(this.select, "startCreateDate", e[0]);
        this.$set(this.select, "endCreateDate", e[e.length - 1]);
        this.$set(
          this.select,
          "creationTimeVal",
          e[0] + " 至 " + e[e.length - 1]
        );
      } else {
        this.$set(this.select, "startPayDate", e[0]);
        this.$set(this.select, "endPayDate", e[e.length - 1]);
        this.$set(this.select, "payVal", e[0] + " 至 " + e[e.length - 1]);
      }

      this.isData = false;
    },
  },
};
</script>
      
      <style lang="scss" scoped>
.content {
  background: #f9f9f9;
  padding: 20rpx 24rpx;
}
.header {
  background: #ffffff;
  box-shadow: 0px 2px 10px 0px rgba(204, 204, 204, 0.4);
  border-radius: 20rpx;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20rpx;
  .headernei {
    background: rgba(216, 216, 216, 0);
    border-radius: 64rpx;
    opacity: 1;
    border: 2rpx solid #259dfe;
    width: 100%;
    padding: 22rpx 20rpx;
    img {
      width: 24rpx;
      height: 24rpx;
    }
  }
}
.kuang {
  background: #ffffff;
  box-shadow: 0rpx 4rpx 20rpx 0rpx rgba(204, 204, 204, 0.4);
  border-radius: 20rpx;
  margin-bottom: 20rpx;
}
.tftable {
  border-collapse: collapse;
  width: 100%;
  background: #fff;
  border: 1px solid #f9f9f9;
  margin-top: 20rpx;
  td {
    font-size: 24rpx;
    font-family: PingFang SC-Medium, PingFang SC;
    font-weight: 500;
    color: #999;
    padding: 20rpx 40rpx;
    width: 50%;
  }
  tr :nth-child(2) {
    color: #333333;
    font-size: 26rpx;
  }
  .theflex {
    display: flex;
    align-items: center;
  }
}
.che {
  padding: 20rpx 40rpx;
}
.tt {
  padding: 20rpx;
  margin-top: 20px;
  font-size: 24rpx;
}
::v-deep .u-transition {
  z-index: 998 !important;
}
.footer {
  display: flex;
  align-items: center;
  padding: 20rpx 60rpx;
  font-size: 24rpx;
  .btnn {
    margin-right: 40rpx;
  }
}
::v-deep .u-input {
  padding: 0 9px !important;
}
::v-deep .u-form-item__body__left__content__label {
  font-size: 12px;
}
::v-deep .u-form-item__body {
  padding: 5px 0;
}
</style>