<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="'商品名称'">
              <el-input v-model="queryParams.productName" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="'是否定价'">
              <el-select
                v-model="queryParams.confirmPrice"
                clearable
                :placeholder="'请选择'"
              >
                <el-option
                  v-for="item in yesnoList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'供应价起止'">
              <div class="qzprice">
                <el-input
                  clearable
                  v-model="queryParams.agreementPriceStart"
                  :placeholder="'请输入'"
                >
                  <!-- <i slot="suffix" class="neibu"
                    >{{ `${getUser.currency.symbol}` }}
                  </i> -->
                </el-input>
                <div class="xian">——</div>
                <el-input
                  clearable
                  v-model="queryParams.agreementPriceEnd"
                  :placeholder="'请输入'"
                >
                  <!-- <i slot="suffix" class="neibu"
                    >{{ `${getUser.currency.symbol}` }}
                  </i> -->
                </el-input>
              </div>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="6">
            <el-form-item label="品牌名称">
              <el-input v-model="queryParams.brandName" clearable />
            </el-form-item>
          </el-col> -->
          <!-- <el-col :span="4">
            <el-form-item :label="'平台'">
              <el-select
                v-model="queryParams.source"
                clearable
                :placeholder="'请选择'"
                @change="changeSource"
              >
                <el-option
                  v-for="item in sourceList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col> -->

          <!-- <el-col :span="4">
            <el-form-item :label="'商品分类'">
              <el-select
                v-model="queryParams.category"
                clearable
                :placeholder="'请选择'"
                @change="changeClaasify"
              >
                <el-option
                  v-for="item in optionList"
                  :key="item.tid"
                  :label="item.title"
                  :value="item.tid"
                />
              </el-select>
            </el-form-item>
          </el-col> -->
          <el-col :span="6">
            <el-form-item :label="'指导价起止'">
              <div class="qzprice">
                <el-input
                  clearable
                  v-model="queryParams.guidePriceStart"
                  :placeholder="'请输入'"
                >
                  <!-- <i slot="suffix" class="neibu">{{ `${getUser.currency.symbol}` }} </i> -->
                </el-input>
                <div class="xian">——</div>
                <el-input
                  clearable
                  v-model="queryParams.guidePriceEnd"
                  :placeholder="'请输入'"
                >
                  <!-- <i slot="suffix" class="neibu">{{ `${getUser.currency.symbol}` }} </i> -->
                </el-input>
              </div>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="4">
            <el-form-item label="是否显示">
              <el-select
                v-model="queryParams.showFlag"
                clearable
                :placeholder="'请选择'"
              >
                <el-option
                  v-for="item in yesnoList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col> -->

          <!-- <el-col :span="4">
            <el-form-item label="类目分类">
              <el-select
                v-model="queryParams.classify"
                clearable
                :placeholder="'请选择'"
              >
                <el-option
                  v-for="item in secondOptionList"
                  :key="item.tid"
                  :label="item.title"
                  :value="item.tid"
                />
              </el-select>
            </el-form-item>
          </el-col> -->

          <el-col :span="4">
            <div class="searchbox">
              <el-button
                class="my_search"
                @click="
                  () => {
                    getSearch();
                    getCzNum();
                  }
                "
                > {{ '搜索' }}</el-button
              >
              <el-button class="my_reset" @click="reChongzhi"> {{ '重置' }}</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="main">
      <div class="maintop">
        <div class="mainbtn">
          <el-button
            size="small"
            :disabled="multiple"
            class="thebtn1"
            @click="moreFixPrice"
            >{{ '定价' }}</el-button
          >
          <el-button
            size="small"
            :disabled="multiple"
            class="thebtn2"
            @click="plClearPrice"
            >{{ '清空定价' }}</el-button
          >
          <el-button
            size="small"
            :disabled="multiple"
            class="thebtn2"
            @click="deleteChoice"
            > {{ '删除' }}</el-button
          >
        </div>
      </div>
      <div class="maintable">
        <el-table
          :data="tableData"
          v-loading="loading"
          class="thetable"
          height="700px"
          style="width: 100%"
          :header-cell-style="{ background: '#EEEEEE' }"
          @selection-change="handleSelectionChange"
          :cell-class-name="cellClassName"
          ref="dataTable"
        >
          <el-table-column type="selection" width="55"> </el-table-column>
          <!-- type="index"  -->
          <el-table-column align="center" prop="pkId" :label="'直供序号'">
          </el-table-column>
          <el-table-column align="center" :label="'商品图片'">
            <template slot-scope="scope">
              <el-image
                style="
                  width: 48px;
                  height: 48px;
                  border-radius: 10px;
                  cursor: pointer;
                "
                :src="scope.row.cover"
                :preview-src-list="[scope.row.cover]"
              >
              </el-image>
            </template>
          </el-table-column>
          <el-table-column
            min-width="200"
            align="center"
            prop="title"
            :label="'商品名称'"
          >
          </el-table-column>
          <!-- <el-table-column
            align="center"
            min-width="120px"
            prop="category"
            :label="'商品分类'"
          >
          </el-table-column> -->
          <!-- <el-table-column
            align="center"
            min-width="120px"
            prop="classify"
            label="类目分类"
          >
          </el-table-column> -->
          <!-- <el-table-column
            align="center"
            min-width="120px"
            prop="thirdBrandName"
            label="品牌名称"
          >
          </el-table-column> -->
          <el-table-column
            align="center"
            prop="specValueNames"
            min-width="150px"
            :label="'商品规格'"
          >
          </el-table-column>
          <el-table-column align="center" prop="sourceVal" :label="'平台'">
          </el-table-column>
          <el-table-column
            align="center"
            prop="agreementPrice"
            :label="'供应价'+'(¥)'"
          >
          </el-table-column>
          <el-table-column
            align="center"
            min-width="150px"
            prop="guidePrice"
            :label="'指导价'+'(¥)'"
          >
          </el-table-column>

          <el-table-column
            align="center"
            min-width="120px"
            prop=""
            :label="'售价方式'"
          >
            <template slot="header">
              <div>{{ '售价方式' }}</div>
              <div>
                <el-select v-model="plForm.sjfs" clearable placeholder="">
                  <el-option
                    v-for="item in sjfsList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </div>
            </template>
            <template slot-scope="scope">
              <el-select
                @change="changeSingleSjfs(scope.row)"
                v-model="scope.row.sjfs"
                clearable
                placeholder=""
              >
                <el-option
                  v-for="item in sjfsList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </template>
          </el-table-column>
          <!-- <el-table-column
            align="center"
            min-width="100px"
            prop=""
            label="比例"
          >
            <template slot="header">
              <div>比例(%)</div>
              <div>
                <el-input
                  :disabled="plForm.sjfs == 1 ? false : true"
                  v-model="plForm.plbl"
                ></el-input>
              </div>
            </template>
            <template slot-scope="scope">
              <el-input
                @change="changePrice(scope.row, scope.$index)"
                :disabled="scope.row.sjfs == 1 ? false : true"
                v-model="scope.row.bl"
              ></el-input>
            </template>
          </el-table-column> -->
          <el-table-column
            align="center"
            min-width="130px"
            prop="price"
            :label="'售价'+'(¥)'"
          >
            <template slot="header">
              <div>{{ `${'售价'}(${getUser.currency.symbol})` }}</div>
              <div>
                <el-input
                  :disabled="plForm.sjfs == 1 ? true : false"
                  v-model="plForm.plsj"
                ></el-input>
              </div>
            </template>
            <template slot-scope="scope">
              <el-input
                :disabled="scope.row.sjfs == 1 ? true : false"
                :style="
                  Number(scope.row.price) > Number(scope.row.guidePrice)
                    ? 'border:1px solid red'
                    : ''
                "
                @change="checkGrossProfit(scope.row, scope.$index)"
                v-model="scope.row.price"
              ></el-input>
            </template>
          </el-table-column>

          <el-table-column
            align="center"
            min-width="100px"
            prop="yjfs"
            :label="'业绩方式'"
          >
            <template slot="header">
              <div>{{ '业绩方式' }}</div>
              <div>
                <el-select v-model="plForm.yjfs" clearable placeholder="">
                  <el-option
                    v-for="item in wayList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </div>
            </template>
            <template slot-scope="scope">
              <el-select
                @change="changeSingleYjfs(scope.row)"
                v-model="scope.row.yjfs"
                clearable
                placeholder=""
              >
                <el-option
                  v-for="item in wayList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            min-width="100px"
            prop=""
            :label="'比例'"
          >
            <template slot="header">
              <div>{{ '比例' }}(%)</div>
              <div>
                <el-input
                  v-model="plForm.plbl2"
                  :disabled="plForm.yjfs == 1 ? false : true"
                ></el-input>
              </div>
            </template>
            <template slot-scope="scope">
              <el-input
                @change="changeAchieve(scope.row, scope.$index)"
                :disabled="scope.row.yjfs == 1 ? false : true"
                v-model="scope.row.bl2"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            min-width="130px"
            prop="achievement"
            :label="'业绩' + `(${isLocals()})`"
          >
            <template slot="header">
              <div>{{ `${'业绩'}(${getUser.currency.symbol})` }}</div>
              <div>
                <el-input
                  :disabled="plForm.yjfs == 1 ? true : false"
                  v-model="plForm.plyj"
                ></el-input>
              </div>
            </template>
            <template slot-scope="scope">
              <el-input
                :disabled="scope.row.yjfs == 1 ? true : false"
                v-model="scope.row.achievement"
                @change="getNetProfit(scope.row, scope.$index)"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            min-width="130px"
            prop="netProfit"
            :label="'业绩'+'($)'"
          >
            <template slot-scope="scope">
              <el-input
                disabled
                v-model="scope.row.achievementDollar"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            min-width="130px"
            prop="grossProfit"
            :label="`${'毛利润'}(${getUser.currency.symbol})`"
          >
            <template slot-scope="scope">
              <el-input
                :style="scope.row.grossProfit < 0 ? 'border:1px solid red' : ''"
                disabled
                v-model="scope.row.grossProfit"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            min-width="130px"
            prop="netProfit"
            :label="`${'纯利润'}(${getUser.currency.symbol})`"
          >
            <template slot-scope="scope">
              <el-input
                :style="scope.row.netProfit < 0 ? 'border:1px solid red' : ''"
                disabled
                v-model="scope.row.netProfit"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="time"
            :label="'操作'"
            min-width="100px"
            fixed="right"
          >
            <template slot-scope="scope">
              <!-- 0已定价 1未定价 -->
              <!-- <el-button
                @click.native.prevent="deleteRow(0, scope.row)"
                type="text"
                size="small"
                class="button-s1"
                v-if="scope.row.showFlag == 1"
                style="color: #4eabc5"
              >
                显示
              </el-button> -->
              <el-button
                @click.native.prevent="deleteRow(1, scope.row)"
                type="text"
                size="small"
                class="button-s1"
                style="color: #c8161d"
                v-if="scope.row.showFlag == 0"
              >
                {{ '删除' }}
              </el-button>
              <el-button
                @click.native.prevent="fixPrice(scope.row)"
                type="text"
                size="small"
                class="button-s1"
                style="color: #009b58"
                :disabled="scope.row.confirmPrice == 0 ? true : false"
              >
                {{ '定价' }}
              </el-button>
              <el-button
                class="button-s1"
                type="text"
                size="small"
                style="color: #e41b1b"
                @click.native.prevent="clearPrice(scope.row)"
              >
                {{ '清空定价' }}
              </el-button>
              <!-- @click.native.prevent="deleteRow(scope.row)" -->
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getSearch"
      :pageSizes="pageSizes"
    />
  </div>
</template>

        <script>
import topBar from "@/components/topBar";
import * as three from "@/api/threegoods";
import { mapGetters } from "vuex";
import { isLocals } from "@/utils/numberToCurrency";

export default {
  name: "DirectGoods",
  components: {
    topBar,
  },
  data() {
    return {
      moren: "directGoods",
      topList: [
        {
          name: '直供商品',
          path: "directGoods",
        },
      ],
      loading:false,
      tableData: [],
      queryParams: {
        pageNum: 1,
        pageSize: 100,
        source: 0,
        confirmPrice: 1,
        showFlag: 0,
      },
      sourceList: [],
      yesnoList: [],
      optionList: [],
      secondOptionList: [],
      pageSizes: [100, 200, 500],
      sjfsList: [
        // { value: "1", label: "比例" },
        { value: "2", label: '比值' },
        { value: "3", label: '指导价' },
      ],
      wayList: [
        { value: "1", label: '比例' },
        { value: "2", label: '比值' },
      ],
      total: 0,
      multipleSelection: [],
      multiple: true,
      plForm: {
        //顶部批量
        sjfs: "", //售价方式
        plbl: "", //比例
        plsj: "", //售价
        yjfs: "", //业绩方式
        plbl2: "", //比例
        plyj: "", //业绩
      },
    };
  },
  computed: {
    ...mapGetters(["getUser"]),
  },
  watch: {
    "plForm.sjfs"(n, o) {
      this.changePlsjfs(n);
    },
    "plForm.plbl"(n, o) {
      this.changePlbl(n);
    },
    "plForm.plsj"(n, o) {
      this.changePlsj(n);
    },
    "plForm.yjfs"(n, o) {
      this.changePlyjfs(n);
    },
    "plForm.plbl2"(n, o) {
      this.changePlbl2(n);
    },
    "plForm.plyj"(n, o) {
      this.changePlyj(n);
    },
    // "plForm.fxhdfs"(n, o) {
    //   this.changePlfxhdfs(n);
    // },
    // "plForm.plbl3"(n, o) {
    //   this.changePlbl3(n);
    // },
    // "plForm.plfxhd"(n, o) {
    //   this.changeFxhd(n);
    // },
  },
  created() {
    this.getOthers();
    this.getSearch();
  },
  methods: {
    changeSingleYjfs(row) {
      this.tableData.forEach((ele, index) => {
        if (row.tid == ele.tid) {
          if (row.yjfs == 1) {
            this.$set(this.tableData[index], "achievement", "");
          } else if (row.yjfs == 2) {
            this.$set(this.tableData[index], "bl2", "");
          }
        }
      });
    },
    //单条售价方式修改
    changeSingleSjfs(row) {
      if (row.sjfs == 3) {
        this.tableData.forEach((ele, index) => {
          if (ele.tid == row.tid) {
            this.$set(
              this.tableData[index],
              "price",
              this.tableData[index].guidePrice
            );
            this.checkGrossProfit(this.tableData[index], index);
          }
        });
      }
    },
    //批量删除
    deleteChoice() {
      this.$confirm('是否确认操作?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: "warning",
      }).then((_) => {
        let thepkIds = [];
        thepkIds = this.multipleSelection.map((item) => item.pkId);
        three
          .threeGoodsShowHide({
            source: this.queryParams.source,
            showFlag: 1,
            idList: thepkIds,
          })
          .then((res) => {
            this.$message({
              message: res.msg,
              type: "success",
            });
            this.getSearch();
          });
      });
    },
    //单笔删除
    deleteRow(type, row) {
      this.$confirm('是否确认操作?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: "warning",
      }).then((_) => {
        three
          .threeGoodsShowHide({
            source: this.queryParams.source,
            showFlag: type,
            idList: [row.pkId],
          })
          .then((res) => {
            this.$message({
              message: res.msg,
              type: "success",
            });
            this.getSearch();
          });
      });
    },
    isLocals,
    cellClassName({ row, column, rowIndex, columnIndex }) {
      if (
        (column.property == "grossProfit" || column.property == "pack_sl") &&
        row[column.property] <= 0
      ) {
        return "zeroClass";
      }
    },
    //批量选择售价方式
    changePlsjfs(val) {
      this.tableData.forEach((ele, index) => {
        this.$set(this.tableData[index], "sjfs", val);
        if (val == 3) {
          this.plForm.plbl = "";
          this.plForm.plsj = "";
          this.$set(
            this.tableData[index],
            "price",
            this.tableData[index].guidePrice
          );
          this.checkGrossProfit(this.tableData[index], index);
        } else if (val == 2) {
          this.plForm.plbl = "";
          this.$set(this.tableData[index], "price", "0");
          this.$set(this.tableData[index], "grossProfit", "");
        } else {
          this.plForm.plsj = "";
          this.$set(this.tableData[index], "price", "");
          this.$set(this.tableData[index], "grossProfit", "");
        }
      });
    },
    //批量比例1
    changePlbl(val) {
      this.tableData.forEach((ele, index) => {
        this.$set(this.tableData[index], "bl", val);
        this.changePrice(ele, index);
      });
    },
    //批量售价
    changePlsj(val) {
      this.tableData.forEach((ele, index) => {
        this.$set(this.tableData[index], "price", val);
        this.changePrice(ele, index);
      });
    },
    //批量选择业绩方式
    changePlyjfs(val) {
      this.tableData.forEach((ele, index) => {
        this.$set(this.tableData[index], "yjfs", val);
        if (val != 1) {
          this.plForm.plbl2 = "";
          this.$set(this.tableData[index], "achievement", "");
          this.$set(this.tableData[index], "achievementDollar", "");
          this.$set(this.tableData[index], "netProfit", "");
        } else {
          this.plForm.plyj = "";
          this.$set(this.tableData[index], "achievement", "");
          this.$set(this.tableData[index], "achievementDollar", "");
          this.$set(this.tableData[index], "netProfit", "");
        }
      });
    },
    //批量比例2
    changePlbl2(val) {
      this.tableData.forEach((ele, index) => {
        this.$set(this.tableData[index], "bl2", val);
        this.changeAchieve(ele, index);
      });
    },
    //批量业绩
    changePlyj(val) {
      this.tableData.forEach((ele, index) => {
        this.$set(this.tableData[index], "achievement", val);
        this.$set(
          this.tableData[index],
          "achievementDollar",
          parseFloat(val / this.getUser.currency.inExchangeRate).toFixed(2)
        );
        this.changeAchieve(ele, index);
      });
    },

    //售价 售价 = 供应价（协议价） * 比率 / 设置比值
    changePrice(row, index) {
      if (row.sjfs == 1) {
        let theprice = parseFloat(row.agreementPrice * row.bl * 0.01).toFixed(
          2
        );
        this.$set(this.tableData[index], "price", theprice);
        this.checkGrossProfit(row, index);
      } else {
        this.checkGrossProfit(row, index);
      }
    },
    //毛利润   毛利润 = 售价 - 供应价
    checkGrossProfit(row, index) {
      let theprofit = parseFloat(row.price - row.agreementPrice).toFixed(2);
      this.$set(this.tableData[index], "grossProfit", theprofit);
      this.changeAchieve(row, index);
    },
    //业绩  PV = 售价 * 比率 / 设置比值
    changeAchieve(row, index) {
      if (!row.price) {
        // this.plForm.yjfs = "";
        // this.plForm.plbl2 = "";
        this.plForm.plyj = "";
        // row.yjfs = "";
        // row.bl2 = "";
        row.grossProfit = "";
        row.netProfit = "";
        this.getNetProfit(row, index);
        return;
      } else {
        if (row.yjfs == 1) {
          let thepv = parseFloat(row.price * row.bl2 * 0.01).toFixed(2);
          this.$set(this.tableData[index], "achievement", thepv);
          this.getNetProfit(row, index);
        } else if (row.yjfs == 2) {
          this.getNetProfit(row, index);
        }
      }
    },
    //纯利润 纯利润 = 毛利润 - PV
    getNetProfit(row, index) {
      let thedollar = parseFloat(
        row.achievement / this.getUser.currency.inExchangeRate
      );
      this.$set(this.tableData[index], "achievementDollar", thedollar);
      let thenetProfit = parseFloat(row.grossProfit - row.achievement).toFixed(
        2
      );

      this.$set(this.tableData[index], "netProfit", thenetProfit);
    },
    changeSource(val) {
      if (val) {
        this.queryParams.category = "";
        three
          .getOptionList({ source: this.queryParams.source, parentId: "0" })
          .then((res) => {
            this.optionList = res.data;
          });
      }
    },
    //商品分类
    changeClaasify(val) {
      if (val) {
        this.optionList.forEach((ele) => {
          if (val == ele.tid) {
            // let parentId = "";
            // parentId = ele.tid;
            three
              .getOptionList({
                source: this.queryParams.source,
                parentId: val,
              })
              .then((res) => {
                this.secondOptionList = res.data;
              });
          }
        });
      } else {
        this.queryParams.classify = "";
        this.secondOptionList = [];
      }
    },

    getOthers() {
      three.getJxhhSource().then((res) => {
        this.sourceList = res.data;
      });
      three.getDealerYesNo().then((res) => {
        this.yesnoList = res.data;
      });
      three
        .getOptionList({ source: this.queryParams.source, parentId: "0" })
        .then((res) => {
          this.optionList = res.data;
        });
    },
    //单笔定价
    fixPrice(row) {
      var therow = [row];
      this.$confirm('是否确认操作?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: "warning",
      }).then((_) => {
        three
          .fixPrice({ detailList: therow, source: this.queryParams.source })
          .then((res) => {
            if (res.code == 200) {
              this.$message({
                message: res.msg,
                type: "success",
              });
              this.getSearch();
              this.plForm = {};
            }
          });
      });
    },
    //单笔清空定价
    clearPrice(row) {
      this.$confirm('是否清空定价?').then((_) => {
        this.$set(row, "sjfs", "");
        this.$set(row, "bl", "");
        this.$set(row, "price", "");
        this.$set(row, "yjfs", "");
        this.$set(row, "plbl2", "");
        this.$set(row, "bl2", "");
        this.$set(row, "achievement", "");
        this.$set(row, "achievementDollar", "");
        this.$set(row, "grossProfit", "");
        this.$set(row, "netProfit", "");
      });
    },
    //批量清空定价
    plClearPrice() {
      this.$confirm('是否清空定价?').then((_) => {
        this.tableData.forEach((element) => {
          this.multipleSelection.forEach((ele) => {
            if (element.tid == ele.tid) {
              this.$set(element, "sjfs", "");
              this.$set(element, "bl", "");
              this.$set(element, "price", "");
              this.$set(element, "yjfs", "");
              this.$set(element, "plbl2", "");
              this.$set(element, "bl2", "");
              this.$set(element, "achievement", "");
              this.$set(element, "achievementDollar", "");
              this.$set(element, "grossProfit", "");
              this.$set(element, "netProfit", "");
            }
          });
        });
      });
    },
    //批量定价
    moreFixPrice() {
      this.$confirm('是否确认操作?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: "warning",
      }).then((_) => {
        three
          .fixPrice({
            detailList: this.multipleSelection,
            source: this.queryParams.source,
          })
          .then((res) => {
            if (res.code == 200) {
              this.$message({
                message: res.msg,
                type: "success",
              });
              this.getSearch();
              this.plForm = {};
            }
          });
      });
    },

    //删除
    // deleteRow(row) {
    //   this.$confirm('确认删除?', '提示', {
    //     confirmButtonText: '确定',
    //     cancelButtonText: '取消',
    //     type: "warning",
    //   }).then(() => {
    //     sys.delBdStorehouse(row.pkId).then((res) => {
    //       if (res.code == 200) {
    //         this.$message({
    //           message: res.msg,
    //           type: "success",
    //         });
    //       }
    //       this.getSearch();
    //     });
    //   });
    // },
    handleSelectionChange(val) {
      this.multipleSelection = val;
      this.multiple = !val.length;
    },
    reChongzhi() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 100,
        source: 0,
        confirmPrice: 1,
        showFlag: 0,
      };
      this.getSearch();
    },
    getSearch() {
      this.loading = true
      three.getDirectList(this.queryParams).then((res) => {
        this.plForm = {
          //顶部批量
          sjfs: "2", //售价方式
          plbl: "", //比例
          plsj: "", //售价
          yjfs: "1", //业绩方式
          plbl2: "10", //比例
          plyj: "", //业绩
        };
        res.rows.forEach((ele) => {
          ele.bl2 = '10'
          ele.sjfs = "2";
          ele.yjfs = "1";
        });
        this.tableData = res.rows;
        this.total = res.total;
        this.loading = false
        // 搜索条件带有商品名称，则搜索完后默认全选
        if (this.queryParams.productName) {
          this.$refs.dataTable.toggleAllSelection();
        }

      });
    },
    getCzNum() {
      this.queryParams.pageNum = 1;
    },
  },
};
</script>

 <style lang="scss" scoped>
::v-deep .button-s1 {
  margin-left: 0;
}
.qzprice {
  display: flex;
  align-items: center;
  .xian {
    color: #ccc8c8;
  }
}
.thetable ::v-deep .el-input__suffix {
  top: 5px;
}
::v-deep .el-image-viewer__close {
  right: 500px;
}
::v-deep .el-input.is-disabled .el-input__inner {
  color: #333;
}
.zeroClass {
  color: red;
  font-weight: bold;
}
::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 0px 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: #48b2fd;
          padding: 0 20px;
          border-radius: 4px 4px 4px 4px;
          height: 32px;
        }
        .thebtn2 {
          color: #ffffff;
          background: #c8161d;
          border-radius: 4px 4px 4px 4px;
          height: 32px;
        }
      }
    }
  }
}
</style>
