<template>
  <div class="page">
    <topBar
      v-if="topList.length > 0"
      :topList="topList"
      :moren="moren"
    ></topBar>
    <div class="thetopbox">
      <el-form label-width="100px">
        <el-row>
         
          <el-col :span="4">
            <el-form-item :label="$t('MN_F_40')">
              <el-input clearable v-model="queryParams.productCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="$t('MN_F_39')">
              <el-input clearable v-model="queryParams.productName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="商品编号">
              <el-input clearable v-model="queryParams.waresCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="商品名称">
              <el-input clearable v-model="queryParams.waresName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="$t('MN_T_1')">
              <el-input clearable v-model="queryParams.memberCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="$t('CK_KS_14')">
              <el-input clearable v-model="queryParams.memberName"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="4">
            <el-form-item :label="$t('MN_F_T_829')">
              <el-select
                clearable
                :placeholder="$t('CK_KS_38')"
                v-model="queryParams.pkVertex"
              >
                <el-option
                  v-for="item in vertexList"
                  :key="item.pkId"
                  :label="item.vertexName"
                  :value="item.pkId"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="$t('MN_F_T_122')">
              <el-select
                clearable
                :placeholder="$t('CK_KS_38')"
                v-model="queryParams.pkTeamCode"
              >
                <el-option
                  v-for="item in memberTeamList"
                  :key="item.pkId"
                  :label="item.teamName"
                  :value="item.pkId"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="$t('MY_ORD_2')" >
              <el-select
                clearable
                :placeholder="$t('CK_KS_38')"
                v-model="queryParams.orderType"
              >
                <el-option
                  v-for="item in orderTypeList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item :label="$t('CK_KS_123')">
              <el-date-picker
                v-model="queryParams.thetimes"
                @change="changeTime"
                value-format="yyyy-MM-dd"
                type="daterange"
                :clearable="false"
                :range-separator="$t('w_0139')"
                :start-placeholder="$t('CK_KS_4')"
                :end-placeholder="$t('CK_KS_5')"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <div class="searchbox">
              <el-button
                class="my_search"
                @click="
                  () => {
                    getSearch();
                    getCzNum();
                  }
                "
              >
                {{ $t("MN_T_2") }}</el-button
              >
              <el-button class="my_reset" @click="reChongzhi">
                {{ $t("MN_T_3") }}</el-button
              >
            </div>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="main">
      <div class="maintop">
        <div class="mainbtn">
          <el-button size="small" class="thebtn1" @click="handleExport">
            {{ $t("MN_T_8") }}</el-button
          >
        </div>
      </div>
      <div class="maintable">
        <el-table
          :data="tableData"
          v-loading="loading"
          height="680px"
          style="width: 100%"
          :header-cell-style="{ background: '#EEEEEE' }"
          @selection-change="handleSelectionChange"
        >
          <el-table-column prop="colsele" type="selection" width="55">
          </el-table-column>
          <el-table-column
            align="center"
            prop="orderCode"
            :label="$t('MY_ORD_1')"
            min-width="180px"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="productCode"
            :label="$t('MN_F_40')"
            min-width="100px"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="orderTypeVal"
            :label="$t('MY_ORD_2')"
          >
          </el-table-column>
           <el-table-column
            align="center"
            prop="productName"
            :label="$t('MN_F_39')"
            min-width="200px"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="waresCode"
            label="商品编号"
            min-width="150px"
          />
          <el-table-column
            align="center"
            prop="waresName"
            label="商品名称"
            min-width="150px"
          />
          <el-table-column
            align="center"
            prop="price"
            min-width="120px"
            :label="$t('MN_F_T_238')+`(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="quantity"
            :label="$t('MN_F_43')"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="priceTotal"
            min-width="120px"
            :label="$t('MN_F_T_1176')+`(${isLocalSymbol()})`"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="memberCode"
            :label="$t('MN_T_1')"
            min-width="120px"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="memberName"
            :label="$t('CK_KS_14')"
            min-width="120px"
          >
          </el-table-column>

          <el-table-column
            align="center"
            prop="phone"
            :label="$t('w_0052')"
            min-width="120px"
          >
          </el-table-column>

          <el-table-column
            align="center"
            prop="vertexName"
            min-width="120px"
            :label="$t('MN_F_T_829')"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="teamCodeName"
            min-width="120px"
            :label="$t('MN_F_T_122')"
          >
          </el-table-column>

          <el-table-column
            align="center"
            prop="recName"
            :label="$t('MY_ORD_10')"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="recPhone"
            min-width="120px"
            :label="$t('MN_F_45')"
          >
          </el-table-column>
          <el-table-column
            align="center"
            min-width="140px"
            prop="purchaseCode"
            :label="`${$t('ENU_GIFT_T_2') + $t('MN_F_T_228')}`"
          />
          <el-table-column
            align="center"
            min-width="120px"
            prop="purchaseName"
            :label="`${$t('ENU_GIFT_T_2') + $t('PER_DA_14')}`"
          />
          <el-table-column
            align="center"
            prop="recProvinceVal"
            :label="$t('MY_ORD_11')"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="recCityVal"
            :label="$t('MY_ORD_12')"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="recCountyVal"
            :label="$t('MY_ORD_13')"
          >
          </el-table-column>
          <el-table-column
            min-width="200px"
            align="center"
            prop="recAddress"
            :label="$t('S_C_27')"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="orderAmount"
            :label="$t('MY_ORD_6')"
            min-width="120px"
          >
            <template slot-scope="scope">
              <span>{{ scope.row.orderAmount | numFilter }}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="postage"
            :label="$t('MN_F_T_237')"
          >
            <template slot-scope="scope">
              <span>{{ scope.row.postage | numFilter }}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="orderAchieve"
            min-width="120px"
            :label="$t('MY_ORD_16') + `(PV)`"
          >
            <template slot-scope="scope">
              <span>{{ scope.row.orderAchieve | numFilter }}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="deliveryWayVal"
            :label="$t('w_0061')"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="payTypeStr"
            :label="$t('w_0215')"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="remark"
            min-width="120px"
            :label="$t('MY_WAL_22')"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="createTime"
            min-width="120px"
            :label="$t('PER_DA_9')"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="payTime"
            min-width="120px"
            :label="$t('MN_F_T_914')"
          >
          </el-table-column>
        </el-table>
      </div>
    </div>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getSearch"
    />
  </div>
</template>
      
<script>
import topBar from "@/components/topBar";
import * as sta from "@/api/statistics";
import * as log from "@/api/logistics";
import { getAwardsListChiose } from "@/api/level";
import { getcountryAllList } from "@/api/exchangerate";
import { getvertexValue, getmemberTeamList } from "@/api/financialCase";
import { isLocals, isLocalSymbol } from "@/utils/numberToCurrency";
export default {
  name: "ProductDetailQuery",
  components: {
    topBar,
  },
  filters: {
    numFilter(value) {
      // 截取当前数据到小数点后两位
      let realVal = parseFloat(value).toFixed(2);
      return realVal;
    },
  },
  data() {
    return {
      moren: "productDetailQuery",
      topList: [
        {
          name: this.$t("CK_KS_132"),
          path: "productDetailQuery",
        },
      ],
      tableData: [],
      loading:false,
      queryParams: {
        pageNum: 1,
        pageSize: 50,
        thetimes: [],
      },
      total: 0,
      multipleSelection: [],
      awardsList: [],
      memberTeamList: [],
      vertexList: [],
      countryList: [],
      orderTypeList: [],
    };
  },
  created() {
    this.getSearch();
    this.getOthers();
  },
  methods: {
    isLocalSymbol,
    isLocals,
    changeTime(val) {
      this.queryParams.startPayTime = val[0];
      this.queryParams.endPayTime = val[1];
    },
    getOthers() {
      getAwardsListChiose().then((res) => {
        this.awardsList = res.rows;
      });
      getmemberTeamList().then((res) => {
        this.memberTeamList = res.rows;
      });
      getvertexValue().then((res) => {
        this.vertexList = res.data;
      });
      getcountryAllList().then((res) => {
        this.countryList = res.data;
      });
      // 获取订单类型
      log.getOrderTypeRepurchaseAll().then((res) => {
        this.orderTypeList = res.data;
      });
    },
    //导出
    handleExport() {
      this.$confirm(this.$t("MN_F_T_407"), this.$t("MN_F_T_304"), {
        confirmButtonText: this.$t("w_0035"),
        cancelButtonText: this.$t("ENU_P_TYPE0"),
        type: "warning",
      }).then((_) => {
        this.download(
          "/report/manager/member-report/product-detail-query-list-export",
          { ...this.queryParams },
          `${this.$t("CK_KS_132")}${new Date().getTime()}.xlsx`
        );
      });
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    reChongzhi() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 50,
        thetimes: [],
      };
      this.getSearch();
    },
    getSearch() {
      this.loading = true
      sta.getProductDetailQueryList(this.queryParams).then((res) => {
        this.loading = false
        if (res.code == 200) {
          this.tableData = res.rows;
          this.total = res.total;
          
        }
      });
    },
    getCzNum() {
      this.queryParams.pageNum = 1;
    },
  },
};
</script>
      
      <style lang="scss" scoped>
::v-deep .el-image-viewer__close {
  right: 500px;
}
::v-deep .dizhi .el-cascader {
  width: 100%;
}
::v-deep .el-range-editor.el-input__inner {
  width: 100%;
}
::v-deep .el-table thead {
  color: #000000;
}
::v-deep .el-table .warning-row {
  background: #f9f9f9;
}
.page {
  padding: 10px 20px;
  background: #f9f9f9;
  font-size: 14px;
  .thetopbox {
    padding: 15px 20px 15px 0;
    background: #ffffff;
    border-radius: 8px;
    .searchbox {
      display: flex;
      align-items: center;
      margin-left: 40px;
    }
    .searchtitle {
      margin-right: 10px;
    }
    .searchbtn {
      background: #08143f;
      color: #ffffff;
    }
  }
  .main {
    //margin-top: 20px;
    background: #f9f9f9;
    //border-radius: 8px;
    //box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);

    .maintop {
      display: flex;
      // padding: 10px 0;
      justify-content: space-between;
      align-items: center;
      .mainbtn {
        .thebtn1 {
          color: #ffffff;
          background: #ffad41;
          width: 68px;
          height: 32px;
        }
        .thebtn2 {
          color: #ffffff;
          background: #009b58;
          width: 68px;
          height: 32px;
        }
        .thebtn3 {
          color: #ffffff;
          background: #c8161d;
          width: 68px;
          height: 32px;
        }
      }
    }
  }
}
</style>
      