<template>
  <div class="fxOrderProfitLossList">
    <div class="el-card__header">
      <span>{{$t('objFill.v101.FinancialModule.shunyihs')}}</span>
      <div style="display: flex; flex-direction: row; align-items: center">
        <!---->
        <el-button type="primary" class="el-button--small" @click="Export"
          >{{$t('objFill.v101.FinancialModule.daochuqb')}}</el-button
        >
      </div>
    </div>

    <div class="content">
      <div style="display: flex; flex-direction: row; align-items: center">
        <span>{{$t('hotel.hotel_Supplier')}}</span>
        <el-select
          class="w150"
          style="margin-left: 10px"
          v-model="msg.SupplierId"
          filterable
          size="small"
          :placeholder="$t('pub.pleaseSel')"
          @change="(msg.pageIndex = 1), getTotalOrderProfitLoss()"
        >
          <el-option :key="0" :value="0" :label="$t('advmanager.v_all')"></el-option>
          <el-option
            v-for="item in options"
            :key="item.ID"
            :label="item.Name"
            :value="item.ID"
          >
          </el-option>
        </el-select>
        <div class="block" style="margin-left: 10px">
          <!-- <el-date-picker
            style="padding: 3px 10px; width: 380px; height: 32px"
            v-model="value"
            type="daterange"
            :range-separator="$t('OrderList.zhi')"
            :start-placeholder="$t('OrderList.star')"
            :end-placeholder="$t('OrderList.end')"
            value-format="yyyy-MM-dd"
            @change="change"
            align="right"
          >
          </el-date-picker> -->
          <StartDateLimit :clearable="false" :dateTime="value" @change="(startDate,endDate)=>{value=[startDate,endDate],change(value)}"></StartDateLimit>
        </div>
        <span style="margin: 0 10px">{{$t('hotel.order_Number')}}</span>
        <el-input
          v-model="msg.OrderNo"
          :placeholder="$t('objFill.qingsrddid')"
          style="width: 200px"
          @keyup.enter.native="(msg.pageIndex = 1), getTotalOrderProfitLoss()"
          clearable
          @clear="(msg.pageIndex = 1), getTotalOrderProfitLoss()"
        ></el-input>
        <!-- ------------ -->
        <span style="margin: 0 10px">{{$t('fnc.danjia')}}</span>
        <el-input
          v-model.number="msg.Unit_Price"
          :placeholder="$t('objFill.v101.FinancialModule.qingshurdj')"
          style="width: 100px"
          type="number"
          :step="0.01"
          @keyup.enter.native="(msg.pageIndex = 1), getTotalOrderProfitLoss()"
          @clear="(msg.pageIndex = 1), getTotalOrderProfitLoss()"
        ></el-input
        >-
        <el-input
          v-model.number="msg.EndUnit_Price"
          :placeholder="$t('objFill.v101.FinancialModule.qingshurdj')"
          style="width: 100px"
          type="number"
          :step="0.01"
          @keyup.enter.native="(msg.pageIndex = 1), getTotalOrderProfitLoss()"
          @clear="(msg.pageIndex = 1), getTotalOrderProfitLoss()"
        ></el-input>
        <span style="margin: 0 10px">{{$t('MarketingActi.commName')}}</span>
        <el-autocomplete
          style="width: 350px"
          v-model="GoodsIDs"
          :fetch-suggestions="remoteMethod"
          :placeholder="$t('pub.pleaseImport')"
          @select="forceUpdate"
          @blur="spget()"
          :trigger-on-focus="false"
        ></el-autocomplete>
      </div>
      <div style="margin: 10px 0">
        <span style="margin: 0 10px">{{$t('objFill.v101.FinancialModule.daili')}}</span>
        <el-autocomplete
          v-model="OneUserId"
          :fetch-suggestions="querySearchAsync"
          :placeholder="$t('pub.pleaseImport')"
          @select="handleSelect"
          @blur="dlget()"
          :trigger-on-focus="false"
        ></el-autocomplete>
        <span>{{$t('admin.admin_company')}}</span>
        <el-select
          size="small"
          v-model="msg.CompanyId"
          :filter-method="ChangeListName"
          filterable
          :placeholder="$t('pub.pleaseSel')"
          @change="(msg.pageIndex = 1), getTotalOrderProfitLoss()"
        >
          <el-option :label="$t('pub.unlimitedSel')" :value="0"></el-option>
          <el-option
            v-for="item in companyData"
            :key="item.Id"
            :label="item.Name"
            :value="item.Id"
          >
          </el-option>
        </el-select>
        <div style="float: right">
          <span style="margin: 0 10px">{{$t('objFill.v101.FinancialModule.pingjunml')}}:</span>
          <span style="color: #f00">{{ OrderProfitLoss.AvgGrossProfit }}</span>
        </div>
      </div>
    </div>
    <div style="padding: 10px 20px; background: #fff; margin-top: 10px">
      <!--      <div class="Subtotal">-->

      <!--        <div class="Subtotal_item" style="margin:15px">-->
      <!--          <div style='width:100%;border-bottom:1px solid #f2f2f2'>-->
      <!--            <i class="iconfont icon-qian groupTourOrder_count_green" style="font-size:12px"></i>-->
      <!--            <span class='Subtotal_t'>{{$t('objFill.v101.FinancialModule.yinyeshour')}}</span>-->
      <!--          </div>-->
      <!--          <div><span class='Subtotal_t'>{{$t('objFill.v101.FinancialModule.jiesuank')}}:</span>¥{{OrderProfitLoss.TotalFinal_Price}}</div>-->
      <!--          <div><span class='Subtotal_t'>运费收入:</span>¥{{OrderProfitLoss.TotalFreightMoney }}</div>-->
      <!--          <div><span class='Subtotal_t'>{{$t('objFill.v101.FinancialModule.yishou')}}:</span>¥{{OrderProfitLoss.TotalAllPrice}}</div>-->
      <!--          <div><span class='Subtotal_t'>{{$t('Operation.Op_weiShou')}}:</span>¥{{OrderProfitLoss.TotalNoAllPrice }}</div>-->
      <!--          <div><span class='Subtotal_t'>{{$t('objFill.v101.FinancialModule.hejishu')}}:</span>¥{{OrderProfitLoss.TotalPay}}</div>-->
      <!--        </div>-->
      <!--        <div class="Subtotal_item" style="margin:15px">-->
      <!--          <div style='width:100%;border-bottom:1px solid #f2f2f2'>-->
      <!--            <i class="iconfont icon-qian groupTourOrder_count_green" style="font-size:12px"></i>-->
      <!--            <span class='Subtotal_t'>{{$t('objFill.v101.FinancialModule.yinyecb')}}</span>-->
      <!--          </div>-->
      <!--          <div class="ProfitLoss">-->
      <!--            <div class="ProfitLoss_xbox">-->
      <!--              <div><span class='Subtotal_t'>{{$t('objFill.v101.FinancialModule.caigoucb')}}:</span>¥{{OrderProfitLoss.TotalCostMoney }}</div>-->
      <!--&lt;!&ndash;              <div><span class='Subtotal_t'>{{$t('objFill.v101.FinancialModule.baozftx')}}:</span>¥{{OrderProfitLoss.TotalPackingMoney }}</div>&ndash;&gt;-->
      <!--              <div><span class='Subtotal_t'>运费支出:</span>¥{{OrderProfitLoss.TotalGoodsFreight }}</div>-->
      <!--&lt;!&ndash;              <div><span class='Subtotal_t'>{{$t('objFill.v101.FinancialModule.shanpyftx')}}:</span>¥{{OrderProfitLoss.TotalGoodsFreight }}</div>&ndash;&gt;-->
      <!--             <div><span class='Subtotal_t'>{{$t('active.cl_qita')}}:</span>¥{{OrderProfitLoss.TotalOneOtherPrice }}</div>-->
      <!--            </div>-->
      <!--            <div class="ProfitLoss_xbox" style="margin-left:60px">-->
      <!--              <div><span class='Subtotal_t'>{{$t('fnc.a_heji')}}:</span>¥{{OrderProfitLoss.TotalALLCommission }}</div>-->
      <!--              <div><span class='Subtotal_t'>{{$t('objFill.v101.FinancialModule.yifu')}}:</span>¥{{OrderProfitLoss.TotalPaid }}</div>-->
      <!--              <div><span class='Subtotal_t'>{{$t('objFill.v101.FinancialModule.weifu')}}:</span>¥{{OrderProfitLoss.TotalNoPaid }}</div>-->
      <!--              <div><span class='Subtotal_t'>{{$t('objFill.maoli')}}:</span>¥{{OrderProfitLoss.TotalGrossProfit }}</div>-->
      <!--              <div><span class='Subtotal_t'>总返佣:</span>¥{{OrderProfitLoss.TotalFXCommission }}</div>-->
      <!--            </div>-->
      <!--             <div class="ProfitLoss_xbox" style="margin-left:60px">-->
      <!--              <div><span class='Subtotal_t'>已返佣金额:</span>¥{{OrderProfitLoss.TotalRemitFXCommission }}</div>-->
      <!--              <div><span class='Subtotal_t'>已付成本:</span>¥{{OrderProfitLoss.TotalPaidCostMoney }}</div>-->
      <!--              <div><span class='Subtotal_t'>其他实收:</span>¥{{OrderProfitLoss.TotalRealMoney }}</div>-->
      <!--              <div><span class='Subtotal_t'>其他实付:</span>¥{{OrderProfitLoss.TotalPayMoney }}</div>-->
      <!--              <div><span class='Subtotal_t'>{{$t('sm.youhuijine')}}:</span>¥{{OrderProfitLoss.TotalCouponMoney }}</div>-->

      <!--            </div>-->
      <!--            <div class="ProfitLoss_xbox" style="margin-left:60px">-->

      <!--&lt;!&ndash;              <div><span class='Subtotal_t'>公司结算金额:</span>¥{{OrderProfitLoss.TotalCompanyProfit }}</div>&ndash;&gt;-->

      <!--            </div>-->
      <!--          </div>-->
      <!--        </div>-->

      <!--      </div>-->
    </div>
    <el-table
      :data="tableData"
      v-loading="loading"
      header-cell-class-name="headClass"
      style="width: 100%"
      border
    >
      <el-table-column :label="$t('objFill.v101.FinancialModule.shangpixx')" align="center">
        <el-table-column
          :label="$t('hotel.order_Number')"
          prop="OrderNo"
          width="200"
          :show-overflow-tooltip="true"
        >
          <template slot-scope="scope">
            {{ scope.row.OrderNo }}
            <el-tooltip
              class="item"
              effect="dark"
              :content="$t('hotel.hotel_HasBeenCancelled')"
              placement="top"
              v-if="scope.row.OrderStatus == 7"
              style=""
            >
              <i class="el-tooltip el-icon-info" style="color: #ff4048"></i>
            </el-tooltip>
          </template>
        </el-table-column>
        <el-table-column :label="$t('objFill.v101.FinancialModule.guge')" width="200" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            {{ scope.row.GoodsName }}{{ scope.row.Specification }}
            <!--<p v-for="(item,index) in scope.row.Specification " :key="index">{{item}}</p>-->
          </template>
        </el-table-column>
        <el-table-column :label="$t('fnc.danjia')" prop="Unit_Price"></el-table-column>
        <el-table-column :label="$t('restaurant.res_Number')" prop="Number"></el-table-column>
        <el-table-column
          :label="$t('hotel.hotel_Supplier')"
          prop="SupplierName"
          width="120"
          :show-overflow-tooltip="true"
        ></el-table-column>
      </el-table-column>

      <el-table-column :label="$t('objFill.v101.FinancialModule.yinyeshour')" align="center">
        <el-table-column :label="$t('objFill.v101.FinancialModule.jiesuank')" prop="Final_Price"></el-table-column>
        <el-table-column :label="$t('objFill.v101.FinancialModule.yunfeisr')" prop="FreightMoney"></el-table-column>
        <el-table-column
          :label="$t('objFill.v101.FinancialModule.baoxiansr')"
          prop="InsuranceMoney"
        ></el-table-column>
        <el-table-column :label="$t('objFill.v101.FinancialModule.yishou')" prop="AllPrice"></el-table-column>
        <!--结算款-已收-->
        <!--暂时写为0-->
        <!--<p>{{scope.row.Final_Price - scope.row.FreightMoney}}</p>-->
        <!-- <el-table-column :label="$t('Operation.Op_weiShou')" >
          <template slot-scope="scope">
            <p>0</p>
          </template>
        </el-table-column> -->
        <el-table-column
          :label="$t('objFill.qitashouru')"
          prop="YSMoney"
          width="80"
        ></el-table-column>
        <el-table-column :label="$t('objFill.v101.FinancialModule.hejishour')">
          <template slot-scope="scope">
            {{ scope.row.AllPrice + scope.row.YSMoney }}
          </template>
        </el-table-column>
      </el-table-column>

      <el-table-column :label="$t('objFill.v101.FinancialModule.yinyecb')" align="center">
        <el-table-column :label="$t('fnc.shouxufei')" prop="ServiceCharge" width="80">
          <template slot-scope="scope">
            <span v-if="scope.row.OrderNo == '小计'"
              >{{
                (
                  scope.row.ServiceCharge - scope.row.ReturnServiceCharge
                ).toFixed(2)
              }}
            </span>
            <span v-else
              >{{ scope.row.ServiceCharge
              }}<span
                style="color: #ff4544"
                v-if="scope.row.ReturnServiceCharge > 0"
                >-{{ scope.row.ReturnServiceCharge }}</span
              >
            </span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('objFill.v101.FinancialModule.caigoucb')" prop="CostMoney"></el-table-column>

        <el-table-column :label="$t('objFill.v101.FinancialModule.yunfeizhic')" prop="GoodsFreight"></el-table-column>
        <el-table-column
          :label="$t('objFill.v101.FinancialModule.baoxianzc')"
          prop="InsuranceCostMoney"
        ></el-table-column>
        <!-- <el-table-column label="已付成本" prop="PaidCostMoney" ></el-table-column> -->
        <el-table-column :label="$t('objFill.v101.FinancialModule.zongfanyo')" prop="FXCommission">
          <template slot-scope="scope">
            <span
              v-if="scope.row.OrderNo == '小计' || scope.row.OrderStatus == 7"
              >{{ scope.row.FXCommission }}</span
            >
            <span
              v-else
              @click="showFXCommission(scope.row)"
              style="color: #409eff; cursor: pointer"
              >{{ scope.row.FXCommission }}</span
            >
          </template>
        </el-table-column>
        <el-table-column
          :label="$t('objFill.v101.FinancialModule.yifangyo')"
          prop="RemitFXCommission"
          width="70"
        ></el-table-column>
        <el-table-column
          :label="$t('objFill.v101.FinancialModule.dindyhje')"
          prop="CouponMoney"
          width="70"
        ></el-table-column>
        <el-table-column
          :label="$t('fnc.tkjine')"
          prop="RefundActual"
          width="80"
        ></el-table-column>
        <el-table-column
          :label="$t('objFill.qitazhichu')"
          prop="YFMoney"
          width="80"
        ></el-table-column>
        <!-- <el-table-column :label="$t('active.cl_qita')" prop="OtherPrice" width="70"></el-table-column>
        <el-table-column :label="$t('fnc.a_heji')" prop="ALLCommission" width="70"></el-table-column> -->
        <el-table-column prop="NoPaid" :label="$t('fnc.yingfu')"></el-table-column>
        <el-table-column prop="Paid" :label="$t('objFill.v101.FinancialModule.yifu')"></el-table-column>
      </el-table-column>
      <!-- <el-table-column :label="$t('active.cl_qita')" align="center">
        <el-table-column :label="$t('objFill.qitashouru')" prop="YSMoney" width="70"></el-table-column>
        <el-table-column :label="$t('fnc.shishou')" prop="RealMoney" width="70"></el-table-column>
        <el-table-column :label="$t('objFill.qitazhichu')" prop="YFMoney" width="70"></el-table-column>
        <el-table-column :label="$t('fnc.shifu')" prop="PayMoney" width="70"></el-table-column>
      </el-table-column> -->

      <el-table-column
        prop="TotalDepositMoney"
        :label="$t('objFill.v101.FinancialModule.chuzhikdk')"
      ></el-table-column>
      <el-table-column
        prop="CompanyName"
        :label="$t('admin.admin_company')"
        width="120"
      ></el-table-column>

      <el-table-column prop="GrossProfit" :label="$t('objFill.maoli')"></el-table-column>
      <!--      <el-table-column label="分公司结算" >-->
      <!--        <template slot-scope="scope">-->
      <!--          <span >{{((scope.row.GrossProfit *scope.row.CompanyProfitRate)/100).toFixed(2)}}</span>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <el-table-column prop="GrossProfitRate" :label="$t('objFill.maolilv')" width="100">
        <template slot-scope="scope">
          {{ scope.row.GrossProfitRate }}%
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      style="text-align: right"
      background
      @current-change="handleCurrentChange"
      :page-size="msg.pageSize"
      :current-page.sync="msg.pageIndex"
      layout="prev, pager, next"
      :total="count"
    >
    </el-pagination>
    <el-dialog :title="$t('objFill.v101.FinancialModule.chakanfay')" :visible.sync="czjfDig" width="900px">
      <div class="diaBox" style="">
        <div v-if="itemData.LiveCommission > 0">
          <span>{{$t('objFill.v101.FinancialModule.zhibozrs')}}:{{ itemData.LivePeopleNum }}{{$t('hotel.hotel_people')}}</span>
          <span style="margin-left: 30px"
            >{{$t('objFill.v101.FinancialModule.zhibozyj')}}:{{ itemData.LiveCommission }}{{$t('hotel.hotel_yuan')}}</span
          >
        </div>
        <div class="diaBox" style="margin-top: 15px">
          <el-table border :data="CommissionList" style="width: 800px">
            <el-table-column prop="Commission" :label="$t('objFill.v101.FinancialModule.fanyolx')">
              <template slot-scope="scope">
                <span v-if="scope.row.CommissionType == 1"
                  >{{$t('objFill.v101.FinancialModule.dindanfay')}}:{{ scope.row.Commission }}</span
                >
                <span v-if="scope.row.CommissionType == 2"
                  >{{$t('objFill.v101.FinancialModule.gongysfayo')}}:{{ scope.row.Commission }}</span
                >
                <span v-if="scope.row.CommissionType == 3"
                  >{{$t('objFill.v101.FinancialModule.weidiafayo')}}:{{ scope.row.Commission }}</span
                >
                <span v-if="scope.row.CommissionType == 4"
                  >{{$t('objFill.v101.FinancialModule.vipgoumfyo')}}:{{ scope.row.Commission }}</span
                >
              </template>
            </el-table-column>
            <el-table-column prop="UserName" :label="$t('objFill.v101.FinancialModule.nicheng')"> </el-table-column>
            <el-table-column prop="Name" :label="$t('system.query_airName')"> </el-table-column>
          </el-table>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" size="small" @click="czjfDig = false"
          >{{$t('objFill.v101.header.wozhidl')}}</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
  import StartDateLimit from '../../public/StartDateLimit.vue';
export default {
  name: "fxOrderProfitLossList",
  components: {StartDateLimit},
  data() {
    return {
      value: [],
      msg: {
        pageIndex: 1,
        pageSize: 15,
        SupplierId: 0,
        StartDate: "",
        EndDate: "",
        OrderNo: "", //订单号
        GoodsID: 0,
        OneUserId: 0,
        IsFxCommission: 1,
        CompanyId: 0,
        Unit_Price: 0, //单价
        EndUnit_Price: 0, //单价
      },
      CommissionList: [],
      czjfDig: false,
      options: [],
      tableData: [],
      searchList: [],
      companyData: [], //公司列表
      count: 0,
      loading: false,
      GoodsIDs: "", //商品id
      OneUserId: "", //代理
      OrderProfitLoss: {}, //小计
      itemData: {},
    };
  },
  created() {
    this.GetSupperOrderEditAuth()
    if (this.$route.query.year && this.$route.query.month) {
      this.msg.StartDate =
        this.$route.query.year + "-" + this.$route.query.month + "-01";
      var d1 = new Date(this.msg.StartDate);
      var d2 = new Date(d1);
      d2.setMonth(d2.getMonth() + 1);
      d2.setDate(d2.getDate() - 1);
      var month = d2.getMonth() + 1;
      var day = d2.getDate();
      this.msg.EndDate = d2.getFullYear() + "-" + month + "-" + day;
      this.value[0] = this.msg.StartDate;
      this.value[1] = this.msg.EndDate;
    }
    this.getTotalOrderProfitLoss();
    this.getSupplierList();
    this.getCompanyUserList("");
  },
  methods: {
    GetSupperOrderEditAuth() {
          var actionCode = this.$AuthCode.isQueryHistoryData;
          this.CheckUserAuth(actionCode, res => {
            if (res.data.resultCode == 1 && res.data.data == 1) {

            }else{
              let StartDate = this.getBeforeDate(186, new Date().Format("yyyy-MM-dd"))
              let EndDate = this.getBeforeDate(-1, new Date().Format("yyyy-MM-dd"))
              this.value = [StartDate, EndDate]
              this.msg.StartDate = this.value[0];
              this.msg.EndDate = this.value[1];
            }
          });

      },
    getDateList() {
      if (this.value != "" && this.value != null) {
        this.msg.StartDate = this.value[0];
        this.msg.EndDate = this.value[1];
      }
      if (!this.msg.Unit_Price || this.msg.Unit_Price == "") {
        this.msg.Unit_Price = 0;
      }
      if (!this.msg.EndUnit_Price || this.msg.EndUnit_Price == "") {
        this.msg.EndUnit_Price = 0;
      }
      this.loading = true;
      this.mallapipost(
        "/api/LiveHouse/GetOrderProfitLossList",
        this.msg,
        (res) => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            if (res.data.data.pageData.length > 0) {
              res.data.data.pageData.push(this.OrderProfitLoss);
            }
            this.tableData = res.data.data.pageData;
            this.count = res.data.data.count;
          } else {
            this.Info(res.data.message);
          }
        }
      );
    },
    getSupplierList() {
      //获取供应商接口
      this.mallapipost("/api/LiveHouse/GetSupplierAllList", {}, (res) => {
        this.loading = false;
        if (res.data.resultCode == 1) {
          this.options = res.data.data;
        }
      });
    },
    showFXCommission(row) {
      this.itemData = row;
      this.mallapipost(
        "/api/LiveHouse/GetOrderCommissionList",
        { TenantId: 1, MallBaseId: 1, OrderDetailId: row.Id },
        (res) => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            this.CommissionList = res.data.data;
          }
        }
      );
      this.czjfDig = true;
    },
    getTotalOrderProfitLoss() {
      if (this.value != "" && this.value != null) {
        this.msg.StartDate = this.value[0];
        this.msg.EndDate = this.value[1];
      }
      if (!this.msg.Unit_Price || this.msg.Unit_Price == "") {
        this.msg.Unit_Price = 0;
      }
      if (!this.msg.EndUnit_Price || this.msg.EndUnit_Price == "") {
        this.msg.EndUnit_Price = 0;
      }
      // this.mallapipost("/api/LiveHouse/GetTotalOrderProfitLoss", this.msg, res => {
      this.mallapipost(
        "/api/LiveHouse/GetTotalOrderProfitLoss_V2",
        this.msg,
        (res) => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            this.OrderProfitLoss = res.data.data;
            this.OrderProfitLoss.OrderNo = "小计";
            this.getDateList();
          }
        }
      );
    },
    getCompanyUserList(Name) {
      this.mallapipost(
        "/api/LiveHouse/GetCompanyUserList",
        { Name: Name },
        (res) => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            this.companyData = res.data.data;
          }
        }
      );
    },
    Export() {
      let msg = this.msg;
      msg = JSON.parse(JSON.stringify(msg));
      this.GetMallLocalFile(
        "/api/LiveHouse/GetFXOrderProfitLossExcel",
        msg,
        this.$t('objFill.v101.FinancialModule.fenxsyhs')+".xls"
      );
    },
    remoteMethod(query, cb) {
      let results = [];
      if (query !== "" && query.length >= 2) {
        this.mallapipost(
          "/api/LiveHouse/GetGoodsList",
          {
            Name: query,
          },
          (res) => {
            if (res.data.resultCode == 1) {
              res.data.data.forEach((x) => {
                let obj = {
                  value: x.Name,
                  Id: x.Id,
                };
                results.push(obj);
              });
            }
          },
          (err) => {}
        );
      } else {
        this.msg.GoodsID = 0;
        this.msg.pageIndex = 1;
        this.getTotalOrderProfitLoss();
      }
      cb(results);
    },
    forceUpdate(item) {
      if (item) {
        this.msg.GoodsID = item.Id;
      } else {
        this.msg.GoodsID = 0;
      }
      this.msg.pageIndex = 1;
      this.getTotalOrderProfitLoss();
    },
    spget() {
      if (this.GoodsIDs == "") {
        this.msg.GoodsID = 0;
        this.msg.pageIndex = 1;
        this.getTotalOrderProfitLoss();
      }
    },
    querySearchAsync(queryString, cb) {
      let results = [];
      if (queryString !== "" && queryString.length >= 1) {
        this.mallapipost(
          "/api/LiveHouse/GetDistributorInfoList",
          {
            Name: queryString,
          },
          (res) => {
            if (res.data.resultCode == 1) {
              res.data.data.forEach((x) => {
                let obj = {
                  value: x.Name,
                  UserId: x.UserId,
                };
                results.push(obj);
              });
            }
          },
          (err) => {}
        );
      } else {
        this.msg.OneUserId = 0;
        this.msg.pageIndex = 1;
        this.getTotalOrderProfitLoss();
      }
      cb(results);
    },
    handleSelect(item) {
      if (item) {
        this.msg.OneUserId = item.UserId;
      } else {
        this.msg.OneUserId = 0;
      }
      this.msg.pageIndex = 1;
      this.getTotalOrderProfitLoss();
    },
    dlget() {
      if (this.OneUserId == "") {
        this.msg.OneUserId = 0;
        this.msg.pageIndex = 1;
        this.getTotalOrderProfitLoss();
      }
    },
    handleCurrentChange(val) {
      this.msg.pageIndex = val;
      this.getDateList();
    },
    change(val) {
      if (val == null) {
        this.value = "";
        this.msg.StartDate = "";
        this.msg.EndDate = "";
      }
      this.msg.pageIndex = 1;
      this.getTotalOrderProfitLoss();
    },
    ChangeListName(val) {
      this.getCompanyUserList(val);
    },
  },
};
</script>

<style>
.fxOrderProfitLossList .el-card__header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  padding: 18px 20px;
}

.fxOrderProfitLossList .el-button--small {
  padding: 9px 15px;
}

.fxOrderProfitLossList .content .searchInput {
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  margin-left: 20px;
}

.fxOrderProfitLossList .content .searchInput .el-input__inner {
  border: none;
  outline: none;
  height: 30px;
  line-height: 30px;
}

.fxOrderProfitLossList .content .searchInput {
  line-height: normal;
  display: inline-table;
  border-collapse: separate;
  border-spacing: 0;
  width: 250px;
  margin-right: 20px;
}

.fxOrderProfitLossList .content {
  background: #fff;
  margin-top: 10px;
  padding: 15px;
  box-sizing: border-box;
}

.fxOrderProfitLossList .el-icon-date {
  line-height: 24px;
}

.fxOrderProfitLossList .el-range-separator {
  line-height: 24px;
}

.fxOrderProfitLossList .just {
  color: rgb(104, 207, 61);
}

.fxOrderProfitLossList .negative {
  color: red;
}

.fxOrderProfitLossList .el-input__icon {
  line-height: 24px;
}

.fxOrderProfitLossList .el-table td,
.el-table th {
  padding: 3px 0;
}

.fxOrderProfitLossList .el-table {
  font-size: 13px;
}

.fxOrderProfitLossList .el-select__tags-text {
  display: inline-block;
  width: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fxOrderProfitLossList .el-select__tags {
  max-width: 400px;
}

.fxOrderProfitLossList .Subtotal {
  width: 100%;
  margin: 10px 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  background: #f2f2f2;
  font-size: 12px;
}

.fxOrderProfitLossList .Subtotal_item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-left: 50px;
  background: #fff;
  padding: 20px;
}

.fxOrderProfitLossList .Subtotal_item .Subtotal_t {
  margin: 3px 0;
  font-size: 12px;
  width: 90px;
  display: inline-block;
}

.fxOrderProfitLossList .ProfitLoss {
  display: flex;
  flex-direction: row;
  align-items: center;
  background: #fff;
}

.fxOrderProfitLossList .ProfitLoss_xbox {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  background: #fff;
}
.fxOrderProfitLossList .diaBox {
  display: flex;
  flex-direction: column;
  align-items: center;
}
</style>