<style scoped lang="scss">
::v-deep a {
  color: #409eff;
  display: block;
}
p {
  text-align: left;
  margin: 0;
}
</style>
<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="100px"
    >
      <el-form-item label="商品名称" prop="itemTitle">
        <el-input
          v-model="queryParams.itemTitle"
          placeholder="请输入商品名称"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="商品Id" prop="itemId">
        <el-input
          v-model.number="queryParams.itemId"
          placeholder="请输入商品Id"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="选择日期">
        <el-date-picker
          v-model="uploadDate"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-table
      v-loading="loading"
      :data="typeList"
      @selection-change="handleSelectionChange"
      ref="multipleTable"
    >
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <!-- <el-table-column
        label="商品图片"
        align="center"
        prop="imageUrl"
        width="150"
      >
        <template slot-scope="scope">
          <img
            :src="scope.row.imageUrl"
            alt=""
            style="width: 100px; height: auto"
          />
        </template>
      </el-table-column>
      <el-table-column label="商品名称" align="center" prop="itemTitle">
      </el-table-column> -->
      <el-table-column
        label="商品名称"
        align="center"
        prop="itemTitle"
        width="300"
      >
        <template slot-scope="scope">
          <div style="display: flex; width: 100%">
            <div style="width: 40%">
              <img
                :src="scope.row.imageUrl"
                alt=""
                style="width: 70px; height: auto"
              />
            </div>
            <div style="width: 60%">
              <a
                style="
                  text-overflow: ellipsis;
                  white-space: nowrap;
                  overflow: hidden;
                  width: 100%;
                "
                :title="scope.row.itemTitle"
              >
                {{ scope.row.itemTitle }}
              </a>
              <p>商品Id： {{ scope.row.itemId }}</p>
              <p>
                佣金率：
                {{
                  scope.row.itemCommissionRate
                    ? scope.row.itemCommissionRate / 10 + "%"
                    : "-"
                }}
              </p>
            </div>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="认领人" align="center" prop="userName" />
      <el-table-column label="订单数" align="center" prop="orderNum">
      </el-table-column>
      <el-table-column label="有效订单数" align="center" prop="validOrderNUm" />
      <el-table-column
        label="失效订单数"
        align="center"
        prop="invalidOrderNUm"
      />
      <el-table-column label="有效率" align="center" prop="validRadio">
        <template slot-scope="scope">
          {{
            scope.row.validRadio
              ? (scope.row.validRadio * 100).toFixed(2) + "%"
              : "-"
          }}
        </template>
      </el-table-column>
      <el-table-column label="发货数" align="center" prop="deliveryNum">
      </el-table-column>
      <el-table-column label="发货率" align="center" prop="deliveryRadio">
        <template slot-scope="scope">
          {{
            scope.row.deliveryRadio
              ? (scope.row.deliveryRadio * 100).toFixed(2) + "%"
              : "-"
          }}
        </template>
      </el-table-column>
      <el-table-column label="未发货数" align="center" prop="notDeliveryNum">
      </el-table-column>
      <el-table-column
        label="服务费率"
        align="center"
        prop="regimentalPromotionRate"
      >
        <template slot-scope="scope">
          {{
            scope.row.regimentalPromotionRate
              ? scope.row.regimentalPromotionRate / 10 + "%"
              : "-"
          }}
        </template>
      </el-table-column>
      <el-table-column label="实付金额" align="center" prop="payAmount">
        <template slot-scope="scope">
          {{
            scope.row.payAmount ? (scope.row.payAmount / 100).toFixed(2) : "-"
          }}
        </template>
      </el-table-column>
      <el-table-column
        label="预估服务费收入"
        align="center"
        prop="regimentalPromotionAmount"
      >
        <template slot-scope="scope">
          {{
            scope.row.regimentalPromotionAmount
              ? (scope.row.regimentalPromotionAmount / 100).toFixed(2)
              : "-"
          }}
        </template>
      </el-table-column>
      <el-table-column
        label="结算服务费收入"
        align="center"
        prop="totalRegimentalSettleAmount"
      >
        <template slot-scope="scope">
          {{
            scope.row.totalRegimentalSettleAmount
              ? (scope.row.totalRegimentalSettleAmount / 100).toFixed(2)
              : "-"
          }}
        </template>
      </el-table-column>
    </el-table>

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

<script>
import {
  listType,
  getType,
  delType,
  addType,
  updateType,
  refreshCache,
} from "@/api/system/dict/type";
import { getUserItemDetail } from "@/api/supplyChain/supplyChain";
export default {
  name: "ClaimOk",
  dicts: ["sys_normal_disable"],
  data() {
    return {
      dialogTableVisible: false,
      logPage: {
        pageNum: 1,
        pageSize: 10,
      },
      logData: [],
      logTotal: 0,
      logLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 字典表格数据
      typeList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 分配销售
      openAllocation: false,
      // 选择的销售id
      saleId: undefined,
      // 获取用户id
      userId: undefined,
      // 销售列表
      saleList: [],
      // 分配销售确定loading
      confirmLoadingSale: false,
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        itemId: undefined,
        itemTitle: undefined,
        orderStartDate: undefined,
        orderEndDate: undefined,
      },
      uploadDate: [new Date(), new Date()],
      //查询参数所用下拉数据
      queryParamsList: {},
    };
  },
  created() {
    this.userId = this.$store.getters.userId;
    let date = new Date();
    let y = date.getFullYear();
    let MM = date.getMonth() + 1;
    MM = MM < 10 ? "0" + MM : MM;
    let dd = date.getDate();
    dd = dd < 10 ? "0" + dd : dd;
    this.uploadDate = [`${y}-${MM}-${dd}`, `${y}-${MM}-${dd}`];
  },
  mounted() {
    this.$nextTick(() => {
      this.getList();
    });
  },
  methods: {
    toDetail(item) {
      this.$router.replace({
        path: "/supplyChain/kuaishou/indexDetails",
        query: {
          id: item.promoterId,
          name: item.promoterNickName,
          orderStartDate: this.uploadDate[0],
          orderEndDate: this.uploadDate[1],
        },
      });
    },
    toIndexDetail(item) {
      this.$router.replace({
        path: "/supplyChain/kuaihsou/goodsDetails",
        query: {
          id: item.itemId,
          name: item.itemTitle,
          orderStartDate: this.uploadDate[0],
          orderEndDate: this.uploadDate[1],
        },
      });
    },
    /** 查询字典类型列表 */
    getList() {
      this.loading = true;
      getUserItemDetail(
        this.addDateRange(
          {
            ...this.queryParams,
            userId: this.$store.getters.remark == "管理员" ? null : this.userId,
          },
          this.uploadDate,
          "orderStartDate",
          "orderEndDate"
        )
      ).then((response) => {
        this.typeList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.confirmLoading = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {};
      this.dateFile = null;
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      let date = new Date();
      let y = date.getFullYear();
      let MM = date.getMonth() + 1;
      MM = MM < 10 ? "0" + MM : MM;
      let dd = date.getDate();
      dd = dd < 10 ? "0" + dd : dd;
      this.uploadDate = [`${y}-${MM}-${dd}`, `${y}-${MM}-${dd}`];
      this.resetForm("queryForm");
      this.queryParams.pageNum = 1;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
    },
  },
};
</script>
