<!--
 * @Descripttion:
 * @version:
 * @Author: kBank
 * @Date: 2022-10-24 15:45:01
-->
<template>
  <div class="page">
    <topBar
      v-if="topList.length > 0"
      :topList="topList"
      :moren="moren"
    ></topBar>
    <div class="main">
      <div class="form_all">
        <el-form ref="select" :model="select" label-width="auto">
          <el-row :gutter="10">
            <el-col :span="4">
              <el-form-item label="开始编号">
                <el-input
                  clearable
                  v-model="select.sourceMemberCode"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="开始姓名">
                <el-input
                  clearable
                  v-model="select.sourceMemberName"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="接入编号">
                <el-input
                  clearable
                  v-model="select.targetMemberCode"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="接入姓名">
                <el-input
                  clearable
                  v-model="select.targetMemberName"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="会员编号">
                <el-input clearable v-model="select.memberCode"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="会员姓名">
                <el-input clearable v-model="select.memberName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item :label="$t('PER_DA_9')" prop="code">
                <el-date-picker
                  v-model="creationTime"
                  type="daterange"
                  @change="changeTime"
                  range-separator="——"
                  :start-placeholder="$t('CK_KS_3')"
                  :end-placeholder="$t('CK_KS_5')"
                  value-format="yyyy-MM-dd"
                  :unlink-panels="true"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-button type="primary" @click="getDataList">
                {{ $t("MN_T_2") }}</el-button
              >
              <el-button type="" @click="reset"> {{ $t("MN_T_3") }}</el-button>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div class="maintop">
        <div class="mainbtn">
          <el-button
            size="small"
            @click="openDig"
            v-hasButtons="['MissionAdd']"
            class="addBtn"
            >{{ $t("w_0328") }}</el-button
          >
          <el-button
            size="small"
            @click="fixedData"
            :disabled="selectData.length == 0"
            style="background-color: #ffad41"
            class="thebtn1"
          >
            修改</el-button
          >
          <el-button
            size="small"
            @click="deleteTable"
            style="background-color: #c8161d"
            class="thebtn1"
            :disabled="selectData.length == 0"
            >删除</el-button
          >
        </div>
      </div>
      <div class="maintable">
        <el-table
          :data="tableData"
          v-loading="loading"
          style="width: 100%"
          ref="multipleTable"
          :header-cell-style="{ background: '#EEEEEE' }"
          :row-class-name="tableRowClassName"
          @select-all="onSelectAll"
          @select="selected"
        >
          <el-table-column type="selection" width="55"> </el-table-column>
          <el-table-column
            align="center"
            prop="sourceMemberCode"
            label="开始编号"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="sourceMemberName"
            label="开始姓名"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="targetMemberCode"
            label="接入编号"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="targetMemberName"
            label="接入姓名"
          >
          </el-table-column>
          <el-table-column align="center" prop="memberCode" label="会员编号">
            <template slot-scope="scope">
              <div
                v-for="(item, index) in scope.row.cuMemberSwingNetDetailExtList"
                :key="index"
              >
                {{ item.memberCode }}
              </div>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="memberName" label="会员姓名">
            <template slot-scope="scope">
              <div
                v-for="(item, index) in scope.row.cuMemberSwingNetDetailExtList"
                :key="index"
              >
                {{ item.memberName }}
              </div>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="targetMemberName"
            label="接入部门"
          >
            <template slot-scope="scope">
              <div
                v-for="(item, index) in scope.row.cuMemberSwingNetDetailExtList"
                :key="index"
              >
                {{ item.placeDeptVal }}
              </div>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="firstAchieveRatio"
            label="首购上传比例"
          >
            <template slot-scope="scope">
              <div
                v-for="(item, index) in scope.row.cuMemberSwingNetDetailExtList"
                :key="index"
              >
                {{ item.firstAchieveRatio }}
              </div>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="firstReachPoint"
            label="首购奖金达标业绩"
          >
            <template slot-scope="scope">
              <div
                v-for="(item, index) in scope.row.cuMemberSwingNetDetailExtList"
                :key="index"
              >
                {{ item.firstReachPoint }}
              </div>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="repurchaseAchieveRatio"
            label="复购上传比例"
          >
            <template slot-scope="scope">
              <div
                v-for="(item, index) in scope.row.cuMemberSwingNetDetailExtList"
                :key="index"
              >
                {{ item.repurchaseAchieveRatio }}
              </div>
            </template>
          </el-table-column>

          <el-table-column
            align="center"
            prop="repurchaseReachPoint"
            label="复购奖金达标业绩"
          >
            <template slot-scope="scope">
              <div
                v-for="(item, index) in scope.row.cuMemberSwingNetDetailExtList"
                :key="index"
              >
                {{ item.repurchaseReachPoint }}
              </div>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="creationTime" label="创建时间">
          </el-table-column>
          <el-table-column align="center" prop="creationTime" label="操作">
            <template slot-scope="scope">
              <div
                style="color: #ffad41; cursor: pointer"
                @click="goodsDetails(scope.row)"
              >
                查看详情
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getDataList"
    />
    <el-dialog
      title="添加"
      :visible.sync="addCode"
      :close-on-click-modal="false"
      width="30%"
      center
      :before-close="handleCloseCode"
    >
      <el-form ref="form" :rules="rules" :model="form" label-width="auto">
        <el-row>
          <el-col :span="12">
            <el-form-item label="开始编号" prop="sourceMemberCode">
              <el-input clearable v-model="form.sourceMemberCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开始姓名">
              <el-input
                clearable
                disabled
                v-model="form.sourceMemberName"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="接入编号" prop="targetMemberCode">
              <el-input clearable v-model="form.targetMemberCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="接入姓名">
              <el-input
                clearable
                disabled
                v-model="form.targetMemberName"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleCloseCode">{{ $t("ENU_P_TYPE0") }}</el-button>
        <el-button type="primary" @click="sureCode">{{
          $t("ENU_P_TYPE4")
        }}</el-button>
      </span>
    </el-dialog>
    <!-- 选择会员 -->
    <el-dialog
      title="选择会员"
      :visible.sync="addList"
      :close-on-click-modal="false"
      width="30%"
      center
      :before-close="handleCloseList"
    >
      <div class="allTab">
        <el-table
          :data="digTable"
          style="width: 100%"
          :header-cell-style="{ background: '#EEEEEE' }"
          :row-class-name="tableRowClassName"
          @selection-change="handleSelectList"
        >
          <el-table-column type="selection" width="55"> </el-table-column>
          <el-table-column align="center" prop="memberCode" label="会员编号">
          </el-table-column>
          <el-table-column align="center" prop="memberName" label="会员姓名">
          </el-table-column>
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleCloseList">{{ $t("ENU_P_TYPE0") }}</el-button>
        <el-button type="primary" @click="sureList">{{
          $t("ENU_P_TYPE4")
        }}</el-button>
      </span>
    </el-dialog>
    <!-- 新增 -->
    <el-dialog
      title="确认"
      :visible.sync="addData"
      :close-on-click-modal="false"
      width="60%"
      center
      :before-close="handleCloseData"
    >
      <el-form ref="form" :rules="rules" :model="form" label-width="auto">
        <el-row>
          <el-col :span="12">
            <el-form-item label="开始编号" prop="sourceMemberCode">
              <el-input
                clearable
                disabled
                v-model="form.sourceMemberCode"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开始姓名">
              <el-input
                clearable
                disabled
                v-model="form.sourceMemberName"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="接入编号" prop="targetMemberCode">
              <el-input
                clearable
                disabled
                v-model="form.targetMemberCode"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="接入姓名">
              <el-input
                clearable
                disabled
                v-model="form.targetMemberName"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div class="disFlex">
        <el-button size="small" @click="toAddObj1" class="addBtn"
          >新增</el-button
        >
        <el-button size="small" @click="changeAllData" class="addBtn"
          >批量操作</el-button
        >
      </div>
      <el-table
        :data="selectRow"
        style="width: 100%"
        :header-cell-style="{ background: '#EEEEEE' }"
        :row-class-name="tableRowClassName"
        @selection-change="handleSelectionChange"
      >
        <el-table-column align="center" prop="memberCode" label="会员编号">
        </el-table-column>
        <el-table-column align="center" prop="memberName" label="会员姓名">
        </el-table-column>
        <el-table-column align="center" prop="placeDept" label="接入部门">
          <template slot="header" slot-scope="scope">
            <div>接入部门</div>
            <el-select v-model="changeData.placeDept" clearable placeholder="">
              <el-option
                v-for="item in deptList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </template>
          <template slot-scope="scope">
            <el-select v-model="scope.row.placeDept" clearable placeholder="">
              <el-option
                v-for="item in deptList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="firstAchieveRatio"
          label="首购上传比例"
        >
          <template slot="header" slot-scope="scope">
            <div>首购上传比例</div>
            <el-input
              clearable
              v-model="changeData.firstAchieveRatio"
            ></el-input>
          </template>
          <template slot-scope="scope">
            <el-input
              clearable
              v-model="scope.row.firstAchieveRatio"
            ></el-input>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="repurchaseAchieveRatio"
          label="复购上传比例"
        >
          <template slot="header" slot-scope="scope">
            <div>复购上传比例</div>
            <el-input
              clearable
              v-model="changeData.repurchaseAchieveRatio"
            ></el-input>
          </template>
          <template slot-scope="scope">
            <el-input
              clearable
              v-model="scope.row.repurchaseAchieveRatio"
            ></el-input>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="firstReachPoint"
          label="首购奖金达标业绩"
        >
          <template slot="header" slot-scope="scope">
            <div>首购奖金达标业绩</div>
            <!-- <el-select v-model="changeData.firstCalculate"
                       :placeholder="$t('CK_KS_38')">
              <el-option v-for="item in yesNo"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value">
              </el-option>
            </el-select> -->
            <el-input clearable v-model="changeData.firstReachPoint"></el-input>
          </template>
          <template slot-scope="scope">
            <el-input clearable v-model="scope.row.firstReachPoint"></el-input>
          </template>
          <!-- <template slot-scope="scope">
            <el-select v-model="scope.row.firstCalculate"
                       :placeholder="$t('CK_KS_38')">
              <el-option v-for="item in yesNo"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value">
              </el-option>
            </el-select>
          </template> -->
        </el-table-column>
        <el-table-column
          align="center"
          prop="repurchaseAchieveRatio"
          label="复购奖金达标业绩"
        >
          <template slot="header" slot-scope="scope">
            <div>复购奖金达标业绩</div>
            <!-- <el-select v-model="changeData.repurchaseAchieveRatio"
                       :placeholder="$t('CK_KS_38')">
              <el-option v-for="item in yesNo"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value">
              </el-option>
            </el-select> -->
            <el-input
              clearable
              v-model="changeData.repurchaseReachPoint"
            ></el-input>
          </template>
          <template slot-scope="scope">
            <el-input
              clearable
              v-model="scope.row.repurchaseReachPoint"
            ></el-input>
            <!-- <el-select v-model="scope.row.repurchaseCalculate"
                       :placeholder="$t('CK_KS_38')">
              <el-option v-for="item in yesNo"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value">
              </el-option>
            </el-select> -->
          </template>
        </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleCloseData">{{ $t("ENU_P_TYPE0") }}</el-button>
        <el-button type="primary" @click="sureData">{{
          $t("ENU_P_TYPE4")
        }}</el-button>
      </span>
    </el-dialog>
    <!-- 修改 -->
    <el-dialog
      title="修改"
      :visible.sync="addUp"
      :close-on-click-modal="false"
      width="60%"
      center
      :before-close="handleCloseUp"
    >
      <el-form ref="form" :rules="rules" :model="form" label-width="auto">
        <el-row>
          <el-col :span="12">
            <el-form-item label="开始编号" prop="sourceMemberCode">
              <el-input
                clearable
                disabled
                v-model="upDataObj.sourceMemberCode"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开始姓名">
              <el-input
                clearable
                disabled
                v-model="upDataObj.sourceMemberName"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="接入编号" prop="targetMemberCode">
              <el-input
                clearable
                disabled
                v-model="upDataObj.targetMemberCode"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="接入姓名">
              <el-input
                clearable
                disabled
                v-model="upDataObj.targetMemberName"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div class="disFlex">
        <el-button size="small" @click="toAddObj" class="addBtn"
          >新增</el-button
        >
        <el-button size="small" @click="changeAllData1" class="addBtn"
          >批量操作</el-button
        >
      </div>
      <el-table
        :data="upDataObj.cuMemberSwingNetDetailExtList"
        style="width: 100%"
        :header-cell-style="{ background: '#EEEEEE' }"
        :row-class-name="tableRowClassName"
        @selection-change="handleSelectionChange"
      >
        <el-table-column align="center" prop="memberCode" label="会员编号">
        </el-table-column>
        <el-table-column align="center" prop="memberName" label="会员姓名">
        </el-table-column>
        <el-table-column
          align="center"
          prop="firstAchieveRatio"
          label="接入部门"
        >
          <template slot="header" slot-scope="scope">
            <div>接入部门</div>
            <el-select v-model="changeData.placeDept" clearable placeholder="">
              <el-option
                v-for="item in deptList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </template>
          <template slot-scope="scope">
            <el-select v-model="scope.row.placeDept" clearable placeholder="">
              <el-option
                v-for="item in deptList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="firstAchieveRatio"
          label="首购上传比例"
        >
          <template slot="header" slot-scope="scope">
            <div>首购上传比例</div>
            <el-input
              clearable
              v-model="changeData.firstAchieveRatio"
            ></el-input>
          </template>
          <template slot-scope="scope">
            <el-input
              clearable
              v-model="scope.row.firstAchieveRatio"
            ></el-input>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="repurchaseAchieveRatio"
          label="复购上传比例"
        >
          <template slot="header" slot-scope="scope">
            <div>复购上传比例</div>
            <el-input
              clearable
              v-model="changeData.repurchaseAchieveRatio"
            ></el-input>
          </template>
          <template slot-scope="scope">
            <el-input
              clearable
              v-model="scope.row.repurchaseAchieveRatio"
            ></el-input>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="firstCalculate"
          label="首购奖金达标业绩"
        >
          <template slot="header" slot-scope="scope">
            <div>首购奖金达标业绩</div>
            <!-- <el-select v-model="changeData.firstCalculate"
                       :placeholder="$t('CK_KS_38')">
              <el-option v-for="item in yesNo"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value">
              </el-option>
            </el-select> -->
            <el-input clearable v-model="changeData.firstReachPoint"></el-input>
          </template>
          <template slot-scope="scope">
            <!-- <el-select v-model="scope.row.firstCalculate"
                       :placeholder="$t('CK_KS_38')">
              <el-option v-for="item in yesNo"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value">
              </el-option>
            </el-select> -->
            <el-input clearable v-model="scope.row.firstReachPoint"></el-input>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="repurchaseAchieveRatio"
          label="复购奖金达标业绩"
        >
          <template slot="header" slot-scope="scope">
            <div>复购奖金达标业绩</div>
            <!-- <el-select v-model="changeData.repurchaseAchieveRatio"
                       :placeholder="$t('CK_KS_38')">
              <el-option v-for="item in yesNo"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value">
              </el-option>
            </el-select> -->
            <el-input
              clearable
              v-model="changeData.repurchaseReachPoint"
            ></el-input>
          </template>
          <template slot-scope="scope">
            <!-- <el-select v-model="scope.row.repurchaseCalculate"
                       :placeholder="$t('CK_KS_38')">
              <el-option v-for="item in yesNo"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value">
              </el-option>
            </el-select> -->
            <el-input
              clearable
              v-model="scope.row.repurchaseReachPoint"
            ></el-input>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="repurchaseAchieveRatio"
          label="操作"
        >
          <template slot-scope="scope">
            <div
              style="color: #c8161d; font-size: 12px; cursor: pointer"
              @click="delRow(scope.$index)"
            >
              删除
            </div>
          </template>
        </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleCloseUp">{{ $t("ENU_P_TYPE0") }}</el-button>
        <el-button type="primary" @click="sureUp">{{
          $t("ENU_P_TYPE4")
        }}</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import topBar from "@/components/topBar";
import * as api from "@/api/specialBusiness.js";
export default {
  name: "Bzpz",
  components: {
    topBar,
  },
  data() {
    return {
      isAdd: false,
      changeData: {},
      addCode: false,
      addData: false,
      addList: false,
      addUp: false,
      selectRow: [],
      rules: {
        sourceMemberCode: [
          { required: true, validator: this.getName1, trigger: "blur" },
        ],
        targetMemberCode: [
          { required: true, validator: this.getName2, trigger: "blur" },
        ],
      },
      digTable: [],
      form: {},
      select: {},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 50,
      },
      addOrEdit: "",
      total: 0,
      dialogVisible: false,
      tableData: [],
      loading: false,
      yesNo: [],
      moren: "accessCode",
      topList: [
        {
          name: this.$t("ENU_APPROVE_B_190"),
          path: "emptyOrder",
          changed: false,
        },
        {
          name: this.$t("ENU_APPROVE_B_111"),
          path: "modifyDirectpush",
          changed: false,
        },
        {
          name: this.$t("MN_F_T_26"),
          path: "modifyPlacement",
          changed: false,
        },
        {
          name: this.$t("ENU_TRADE_T_816"),
          path: "waterPv",
          changed: false,
        },
        {
          name: this.$t("MN_F_T_28"),
          path: "modifyCode",
          changed: false,
        },
        {
          name: this.$t("MN_F_T_29"),
          path: "awardControl",
          changed: false,
        },
        {
          name: this.$t("MN_F_T_30"),
          path: "modifySettleCountry",
          changed: false,
        },
        {
          name: this.$t("MN_F_T_31"),
          path: "policyMoney",
          changed: false,
        },
        {
          name: this.$t("MN_F_T_208"),
          path: "bonusConfig",
          changed: false,
        },
        {
          name: "甩网配置",
          path: "accessCode",
          changed: false,
        },
      ],
      colSpanArr: [],
      rowIndexArr: [],
      selectData: "",
      upDataObj: {},
      deptList: [],
      creationTime: [],
    };
  },
  mounted() {
    // 获取列表
    this.getDataList();
    this.getData();
  },
  methods: {
    goodsDetails(row) {
      this.$router.push({
        path: "accessCodeDetails",
        query: {
          data: row.pkId,
        },
      });
    },
    changeAllData() {
      this.digTable.forEach((item) => {
        if (
          this.changeData.firstAchieveRatio ||
          this.changeData.firstAchieveRatio == 0
        ) {
          item.firstAchieveRatio = this.changeData.firstAchieveRatio;
        }
        if (
          this.changeData.repurchaseAchieveRatio ||
          this.changeData.repurchaseAchieveRatio == 0
        ) {
          item.repurchaseAchieveRatio = this.changeData.repurchaseAchieveRatio;
        }
        if (
          this.changeData.firstReachPoint ||
          this.changeData.firstReachPoint == 0
        ) {
          item.firstReachPoint = this.changeData.firstReachPoint;
        }
        if (
          this.changeData.repurchaseReachPoint ||
          this.changeData.repurchaseReachPoint == 0
        ) {
          item.repurchaseReachPoint = this.changeData.repurchaseReachPoint;
        }
        this.$set(item, "placeDept", this.changeData.placeDept);
      });
    },
    changeAllData1() {
      this.upDataObj.cuMemberSwingNetDetailExtList.forEach((item) => {
        if (
          this.changeData.firstAchieveRatio ||
          this.changeData.firstAchieveRatio == 0
        ) {
          item.firstAchieveRatio = this.changeData.firstAchieveRatio;
        }
        if (
          this.changeData.repurchaseAchieveRatio ||
          this.changeData.repurchaseAchieveRatio == 0
        ) {
          item.repurchaseAchieveRatio = this.changeData.repurchaseAchieveRatio;
        }
        if (
          this.changeData.firstReachPoint ||
          this.changeData.firstReachPoint == 0
        ) {
          item.firstReachPoint = this.changeData.firstReachPoint;
        }
        if (
          this.changeData.repurchaseReachPoint ||
          this.changeData.repurchaseReachPoint == 0
        ) {
          item.repurchaseReachPoint = this.changeData.repurchaseReachPoint;
        }
        this.$set(item, "placeDept", this.changeData.placeDept);
      });
    },
    toAddObj() {
      console.log(
        "toAddObj",
        this.upDataObj.targetMemberCode,
        this.form.targetMemberCode
      );
      api
        .queryMemberParent({
          memberCode: this.upDataObj.targetMemberCode,
        })
        .then((res) => {
          if (res.code == 200) {
            this.digTable = res.data;
          }
        });
      this.addList = true;
      // this.upDataObj.cuMemberSwingNetDetailExtList.push({
      //   firstAchieveRatio: '',
      //   firstCalculate: 0,
      //   memberCode: '',
      //   memberName: '',
      //   repurchaseAchieveRatio: '',
      //   repurchaseCalculate: 0,
      // })
    },
    toAddObj1() {
      console.log(123);
      api
        .queryMemberParent({
          memberCode: this.form.targetMemberCode,
        })
        .then((res) => {
          if (res.code == 200) {
            this.digTable = res.data;
          }
        });
      this.addList = true;
    },
    delRow(index) {
      this.upDataObj.cuMemberSwingNetDetailExtList.splice(index, 1);
    },
    getData() {
      api.getEYesNoList().then((res) => {
        this.yesNo = res.data;
      });
      api.getPlacedeptList().then((res) => {
        this.deptList = res.data;
      });
    },
    changeTime(val) {
      this.select.startCreationTime = val ? val[0] : "";
      this.select.endCreationTime = val ? val[1] : "";
    },
    getName1(rule, value, callback) {
      if (!value) {
        callback(new Error(this.$t("w_0278")));
      } else {
        api
          .queryMember({
            memberCode: value,
          })
          .then((res) => {
            if (res.code == 200) {
              this.$set(this.form, "sourceMemberName", res.data.memberName);
              this.$set(this.form, "pkSourceMember", res.data.pkId);
              callback();
            } else {
              callback(new Error(res.msg));
            }
          });
      }
    },
    getName2(rule, value, callback) {
      if (!value) {
        callback(new Error(this.$t("w_0278")));
      } else {
        api
          .queryMember({
            memberCode: value,
          })
          .then((res) => {
            if (res.code == 200) {
              this.$set(this.form, "targetMemberName", res.data.memberName);
              this.$set(this.form, "pkTargetMember", res.data.pkId);
              callback();
            } else {
              callback(new Error(res.msg));
            }
          });
      }
    },
    reset() {
      this.select = {};
      this.creationTime = [];
      this.getDataList();
    },
    // 点击修改
    toFixed(id) {
      this.$router.push({
        path: "missionDetails",
        query: {
          pkId: id,
        },
      });
    },
    // 删除
    handleDelete(id) {
      this.$confirm(this.$t("MN_F_T_303"), this.$t("w_0034"), {
        confirmButtonText: this.$t("w_0035"),
        cancelButtonText: this.$t("ENU_P_TYPE0"),
        type: "warning",
      }).then(() => {
        api.missionDel(id).then((res) => {
          this.getDataList();
        });
      });
    },
    handleClose() {
      this.dialogVisible = false;
      this.$refs["form"].clearValidate();
      this.$refs["form"].resetFields();
    },
    deleteTable() {
      let pkId = this.selectData.pkId;
      this.$confirm(this.$t("MN_F_T_303"), this.$t("w_0034"), {
        confirmButtonText: this.$t("w_0035"),
        cancelButtonText: this.$t("ENU_P_TYPE0"),
        type: "warning",
      }).then(() => {
        api.deleteNet(pkId).then((res) => {
          this.getDataList();
        });
      });
    },
    openDig() {
      this.isAdd = true;
      this.addCode = true;
    },

    handleCloseUp() {
      this.changeData = {};
      this.addUp = false;
    },
    handleCloseCode() {
      this.addCode = false;
    },
    handleCloseList() {
      this.addList = false;
    },
    handleCloseData() {
      this.changeData = {};
      this.addData = false;
    },
    handleSelectList(row) {
      this.selectRow = row;
    },
    // 选择会员确认
    sureList() {
      if (this.selectRow.length > 0) {
        if (this.isAdd) {
          this.addData = true;
          this.addList = false;
        } else {
          this.upDataObj.cuMemberSwingNetDetailExtList.forEach(
            (item, index) => {
              this.selectRow = this.selectRow.filter((ctem) => {
                return ctem.memberCode != item.memberCode;
              });
            }
          );
          this.selectRow.forEach((item) => {
            this.upDataObj.cuMemberSwingNetDetailExtList.push({
              firstAchieveRatio: 0,
              firstReachPoint: 0,
              pkMember: item.pkId,
              memberCode: item.memberCode,
              memberName: item.memberName,
              repurchaseAchieveRatio: 0,
              repurchaseReachPoint: 0,
              placeDept: 1,
            });
          });
          this.addList = false;
        }
      } else {
        this.$message({
          message: "请选择",
          type: "warning",
        });
      }
    },
    // 修改
    sureUp() {
      api.saveNet(this.upDataObj).then((res) => {
        if (res.code == 200) {
          this.$message({
            message: res.msg,
            type: "success",
          });
          this.addUp = false;
          this.getDataList();
        }
      });
    },
    // 提交确认
    sureData() {
      let arr = [];
      this.selectRow.forEach((item) => {
        arr.push({
          pkMember: item.pkId,
          firstAchieveRatio: item.firstAchieveRatio,
          repurchaseAchieveRatio: item.repurchaseAchieveRatio,
          firstReachPoint: item.firstReachPoint,
          repurchaseReachPoint: item.repurchaseReachPoint,
          placeDept: item.placeDept,
        });
      });
      api
        .saveNet(
          Object.assign({}, this.form, { cuMemberSwingNetDetailExtList: arr })
        )
        .then((res) => {
          if (res.code == 200) {
            this.$message({
              message: res.msg,
              type: "success",
            });
            this.addData = false;
            this.getDataList();
          }
        });
    },
    // 输入编号query
    sureCode() {
      api
        .queryMemberParent({
          memberCode: this.form.targetMemberCode,
        })
        .then((res) => {
          if (res.code == 200) {
            this.digTable = res.data;
          }
        });
      // this.addData = true
      this.addList = true;
      this.addCode = false;
    },
    // 修改弹框
    fixedData() {
      let pkId = this.selectData.pkId;
      api.queryNet({ pkId: pkId }).then((res) => {
        this.upDataObj = res.rows[0];
        this.addUp = true;
        this.isAdd = false;
      });
    },
    getDataList() {
      this.loading = true;
      api
        .queryNet(Object.assign({}, this.queryParams, this.select))
        .then((res) => {
          this.loading = false;
          this.tableData = res.rows;
          this.total = res.total;
        });
    },
    onSelectAll() {
      this.$refs.multipleTable.clearSelection();
    },
    selected(selection, row) {
      this.selectData = selection[0] || "";
      // 清除 所有勾选项
      this.$refs.multipleTable.clearSelection();
      if (selection.length == 0) return;
      this.$refs.multipleTable.toggleRowSelection(row, true);
    },
    handleSelectionChange(val) {},
    /** 导出按钮操作 */
    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(
          "/system/manage/ho-enterprise-mission/export",
          Object.assign({}, this.queryParams, this.select),
          `${this.$t("MN_F_T_193")}${new Date().getTime()}.xlsx`
        );
      });
    },
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 == 1) {
        return "warning-row";
      } else if (rowIndex % 2 == 0) {
        return "success-row";
      }
      return "";
    },
  },
};
</script>
<style scoped lang="scss">
::v-deep .el-table .warning-row {
  background: #f9f9f9;
}

::v-deep .el-table .success-row {
  background: #ffffff;
}
::v-deep .el-table thead {
  color: #000000;
}
::v-deep .el-select {
  width: 100%;
}
.uploadIcon ::v-deep .el-upload--picture-card {
  display: none !important; /* 上传按钮隐藏 */
}
.page {
  padding: 20px;
  background: #f9f9f9;
  font-size: 14px;
  .main {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);
    .form_all {
      padding: 0px 20px 0 20px;
      // margin-bottom: 20px;
      background: #fff;
      border-radius: 8px;
    }
    .maintop {
      display: flex;
      padding: 0px 0px;
      justify-content: space-between;
      align-items: center;

      background: #f8f8f8;
      .mainbtn {
        .thebtn1 {
          background: #3181e5;
          color: #ffffff;
        }
        .thebtn2 {
          background: #ffad41;
          color: #ffffff;
        }
      }
      .maintitle {
        font-size: 10px;
        font-family: MicrosoftYaHei;
        color: #999999;
      }
    }
  }
  .tem {
    display: flex;
    align-items: center;
    justify-content: center;
    img {
      width: 28px;
      height: 20px;
      margin-right: 3px;
    }
  }
  .isRed {
    color: #ed1d25;
  }
  .isGreen {
    color: #1ab62b;
  }
  .bgImg {
    width: 48px;
    height: 48px;
  }
}
.openClose {
  text-align: right;
  margin-right: 10px;
  color: #3181e5;
}
.dizhi {
  ::v-deep .el-cascader {
    width: 100%;
  }
}
::v-deep .el-date-editor.el-input,
.el-date-editor.el-input__inner {
  width: auto;
}
::v-deep .el-date-editor.el-input,
.el-date-editor.el-input__inner {
  width: auto;
}
.form_all ::v-deep .el-input__suffix {
  top: 0px !important;
}
.form_all ::v-deep .el-select .el-input .el-select__caret.is-reverse {
  transform: translateY(0px) !important;
}
::v-deep .el-input__suffix {
  top: -3px;
}
::v-deep .el-select .el-input__suffix {
  top: 5px;
}
::v-deep .el-select .el-input .el-select__caret.is-reverse {
  transform: translateY(-8px);
}
::v-deep .el-cascader .el-input__suffix {
  top: 0px;
}
::v-deep .el-input__clear {
  margin-bottom: 20px !important;
}
.disFlex {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.allTab {
  max-height: 600px;
  overflow-y: auto;
}
</style>
