<template>
  <ContainerQuery>
    <div v-if="$accessCheck($Access.PublishGoodsSearch)" slot="more">
      <el-form :inline="true" size="small">
        <el-form-item>
          <el-input
            v-model="keyword"
            style="width: 220px"
            placeholder="商品名称/编码/条码"
            clearable
            @keyup.enter.native="pageChange(1)"
            @clear="pageChange(1)"
          >
            <el-button slot="append" @click="pageChange(1)">
              <i class="el-icon-search"></i>
            </el-button>
          </el-input>
        </el-form-item>
        <el-form-item>
          <GoodsCategory
            v-model="form.categoryPath"
            :width="160"
            check-strictly
            clearable
            size="small"
            @change="goodsChane"
          />
        </el-form-item>
        <el-form-item>
          <el-input
            v-model="form.brand"
            style="width: 140px"
            placeholder="商品品牌"
            clearable
            @clear="delBrand"
          >
            <i
              slot="suffix"
              class="el-input__icon el-icon-search"
              @click="sel_brand = true"
            ></i>
          </el-input>
        </el-form-item>

        <el-form-item>
          <el-select
            v-model="enableStatus"
            placeholder="销售状态"
            style="width: 100px"
            clearable
            @change="pageChange(1)"
          >
            <el-option label="上架" :value="5"></el-option>
            <el-option label="下架" :value="4"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
    </div>
    <div v-if="!merchantId" slot="left">
      <el-dropdown split-button type="primary" @click="openAddGoods">
        发布商品
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>
            <div class="dropdown-div" @click="getAllGoodsList(1)">导出</div>
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
    <!-- <el-tabs v-model="activeName" type="card" @tab-click="tabChange">
      <el-tab-pane label="商品列表" name="all"></el-tab-pane>
      <el-tab-pane label="自选商品" name="selfGoods"></el-tab-pane>
      <el-tab-pane label="待审核商品" name="auditGoods"></el-tab-pane>
    </el-tabs>-->
    <el-table
      ref="goodsTable"
      :data="goods_data"
      @expand-change="showSpec"
      @selection-change="selectionChange"
    >
      <el-table-column
        type="selection"
        width="50"
        fixed="left"
      ></el-table-column>
      <el-table-column
        prop="id"
        label="ID"
        fixed="left"
        min-width="70"
      ></el-table-column>
      <el-table-column
        prop="materialName"
        label="商品"
        fixed="left"
        min-width="220"
      >
        <template slot-scope="scope">
          <div class="clearfix">
            <div class="float_left">
              <el-image fit="cover" :src="scope.row.images[0]"></el-image>
            </div>
            <div class="float_left goods-name-view" style="margin-left: 10px">
              <div class="goods-title">
                {{ scope.row.title }}
              </div>
              <div class="goods-no">
                {{ scope.row.code }}
              </div>
            </div>
          </div>
        </template>
      </el-table-column>
      <el-table-column
        prop="categoryName"
        label="商品分类"
        min-width="120"
      ></el-table-column>
      <el-table-column label="规格" width="100">
        <template slot-scope="scope">
          <div class="sku-btn" @click="toggleRowExpansion(scope.row)">
            {{ scope.row.specTotal }}种规格
          </div>
        </template>
      </el-table-column>
      <el-table-column label="" width="40" type="expand">
        <template slot-scope="scope">
          <ul class="sku-ul">
            <li
              v-for="(item, index) in scope.row.goods_sku_list"
              :key="index"
              class="sku-li"
            >
              <div class="clearfix">
                <div class="float_left">
                  <img
                    class="sku-img"
                    :src="item.specImage || scope.row.images[0]"
                    alt=""
                  />
                </div>
                <div class="sku-info float_left">
                  <p>
                    <span class="label">规格:</span>
                    {{ item.unitName }};{{ item.specValueName }}
                  </p>
                  <p>
                    <span class="label">库存:</span>
                    {{ $_common.formatNub(item.inventory) }}；
                    <span class="label">销量:</span>
                    {{ $_common.formatNub(item.salesNum) }}
                  </p>
                  <p>
                    <span class="label">起订量:</span>
                    {{ $_common.formatNub(item.setNum) }}；
                    <span class="label">市场价:</span>
                    {{ $_common.formattedNumber(item.marketPrice) }}
                  </p>
                  <p>
                    <span class="label">阶梯价:</span>
                    {{ item.enabledLadder === 1 ? "是" : "否" }}；
                    <span v-if="!item.enabledLadder">
                      <span class="label">销售价:</span>
                      {{ $_common.formattedNumber(item.salePrice) }}
                    </span>
                  </p>
                </div>
              </div>
              <div v-if="item.enabledLadder" class="clearfix">
                <div class="float_left" style="width: 50px; margin-right: 10px">
                  销售价:
                </div>
                <div class="float_left">
                  <p v-for="(price, indexP) in item.ladderPrice" :key="indexP">
                    <span>
                      数量:
                      <span style="color: #ff4040">
                        {{ price.from }}-{{
                          indexP === item.ladderPrice.length - 1
                            ? "∞"
                            : price.to
                        }}
                      </span>
                      ,
                    </span>
                    <span>
                      价格:
                      <span style="color: #ff4040">
                        {{ $_common.formattedNumber(price.price) }}
                      </span>
                      ;
                    </span>
                  </p>
                </div>
              </div>
            </li>
          </ul>
        </template>
      </el-table-column>
      <el-table-column
        prop="unitNameMaster"
        label="基本单位"
        min-width="80"
      ></el-table-column>
      <el-table-column prop="masterInventory" label="总库存" min-width="100">
        <template slot-scope="scope">
          {{ scope.row.inventorTotal - 0 }}
        </template>
      </el-table-column>
      <!--<el-table-column prop="virtualSalesNum" label="虚拟销量" min-width="100">
        <template slot-scope="scope">
          <el-input-number
            v-if="scope.row.sale_false_visible"
            v-model="virtual_sales_num"
            style="width: 100%"
            :controls="false"
            size="small"
            @keyup.enter.native="setSalesNum(scope.$index)"
            @blur="setSalesNum(scope.$index)"
          ></el-input-number>
          <div v-else class="click-div" @click="showSetSaleNum(scope.$index)">
            {{ scope.row.virtualSalesNum }}
            <el-button
              v-if="$accessCheck($Access.PublishGoodssetSalesNum)"
              type="text"
              icon="el-icon-edit"
            ></el-button>
          </div>
        </template>
      </el-table-column>-->
      <el-table-column
        prop="salesNum"
        label="真实销量"
        min-width="100"
      ></el-table-column>
      <el-table-column prop="enableStatus" label="商品状态" min-width="100">
        <template slot-scope="scope">
          <span v-if="scope.row.auditStatus === 1" class="warning-status">
            待审核
          </span>
          <div v-else>
            <span v-if="scope.row.enableStatus === 5" class="success-status">
              上架
            </span>
            <span v-else class="info-status">下架</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column
        prop="shopName"
        label="销售店铺"
        show-overflow-tooltip
        min-width="100"
      ></el-table-column>
      <el-table-column prop="createTime" label="创建时间" width="160">
        <template slot-scope="scope">
          {{ $_common.formatDate(scope.row.createTime) }}
        </template>
      </el-table-column>
      <el-table-column label="操作" fixed="right" min-width="100">
        <template slot-scope="scope">
          <el-button
            v-if="
              $accessCheck($Access.PublishGoodsUpdateEnableStatus) &&
              scope.row.auditStatus === 2
            "
            type="text"
            @click="changeGoodsStatus(scope.row)"
          >
            {{ scope.row.enableStatus === 5 ? "下架" : "上架" }}
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-drawer
      class="edit-drawer"
      :title="goods_name"
      :visible.sync="is_price"
      direction="rtl"
      size="50%"
    >
      <EditGoods
        v-if="is_price"
        :goods-id="price_goods_detail.id"
        @subData="editsubData"
      />
    </el-drawer>
    <FooterPage
      :page-size="pageSize"
      :total-page.sync="total"
      :current-page.sync="page"
      @pageChange="pageChange"
      @sizeChange="sizeChange"
    >
      <div slot="btn-div" class="foot-btn-div">
        <el-checkbox
          v-model="checkedAll"
          @change="checkAllChange"
        ></el-checkbox>
        <el-dropdown
          v-if="$accessCheck($Access.PublishGoodsUpdateEnableStatus)"
        >
          <el-button size="mini">
            批量上下架
            <i class="el-icon-caret-top"></i>
          </el-button>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>
              <div class="dropdown-div" @click="BatchUnloading(5)">
                批量上架
              </div>
            </el-dropdown-item>
            <el-dropdown-item>
              <div class="dropdown-div" @click="BatchUnloading(4)">
                批量下架
              </div>
            </el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </FooterPage>
    <BrandSelModel
      v-if="sel_brand"
      :is-check="false"
      :dialog-visible="sel_brand"
      @close="sel_brand = false"
      @confirm="brandConfirm"
    />
    <el-dialog
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      :title="set_tit"
      :visible.sync="is_set"
      width="30%"
    >
      <el-form ref="set_form" :model="set_form" label-width="100px">
        <el-form-item v-if="set_tit === '虚拟销量'" label="销量区间：">
          <el-input-number
            v-model="sale_num_form.minVal"
            :controls="false"
          ></el-input-number>
          -
          <el-input-number
            v-model="sale_num_form.maxVal"
            :controls="false"
          ></el-input-number>
          <p class="form-tip">虚拟总销量等于销量区间内产生的随机数</p>
        </el-form-item>
        <el-form-item v-if="set_tit === '转移分类'" label="转移分类：">
          <GoodsCategory v-model="set_form.category" check-strictly />
        </el-form-item>
        <el-form-item v-if="set_tit === '设置品牌'" label="设置品牌：">
          <el-input
            v-model="set_form.brandName"
            readonly
            style="width: 240px"
            placeholder="请选择品牌"
          >
            <i
              slot="suffix"
              class="el-input__icon el-icon-search"
              @click="sel_brand = true"
            ></i>
          </el-input>
        </el-form-item>
        <div v-if="set_tit === '物流设置'">
          <el-form-item v-if="false" label="物流支持：" prop="deliverySupIds">
            <el-checkbox-group v-model="set_form.deliverySupIds">
              <el-checkbox label="1">快递</el-checkbox>
              <el-checkbox label="2">自提</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
          <br />
          <el-form-item label="快递运费：">
            <el-radio-group v-model="set_form.expressType">
              <el-radio :label="1">包邮</el-radio>
              <el-radio :label="2">运费模版</el-radio>
              <el-radio :label="3">统一运费</el-radio>
            </el-radio-group>
          </el-form-item>
          <br />
          <div v-if="set_form.expressType === 2">
            <el-form-item label="运费模板：" prop="ruleId">
              <el-select v-model="set_form.ruleId" placeholder="请选择">
                <el-option
                  v-for="(item, index) in express_list"
                  :key="index"
                  :label="item.title"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </div>
          <div v-if="set_form.expressType === 3">
            <el-form-item label="统一运费：" prop="expressFee">
              <el-input-number
                v-model="set_form.expressFee"
                :controls="false"
              ></el-input-number>
              <span>元</span>
            </el-form-item>
          </div>
          <el-form-item v-if="false" label="是否展示快递：">
            <el-radio-group v-model="set_form.showExpress">
              <el-radio :label="4">不展示</el-radio>
              <el-radio :label="5">展示</el-radio>
            </el-radio-group>
          </el-form-item>
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="is_set = false">取 消</el-button>
        <el-button :loading="more_sub_btn" type="primary" @click="moreSubData">
          确 定
        </el-button>
      </span>
    </el-dialog>
  </ContainerQuery>
</template>

<script>
  import { getShopByStaff } from "@/api/Shop";
  import GoodsCategory from "@/component/common/GoodsCategory.vue";
  import BrandSelModel from "@/component/goods/BrandSelModel.vue";
  import EditGoods from "@/views/goods/sale/AddGoods";
  import {
    setSalesNum,
    getGoodsInfo,
    BatchUnloading,
    getAllGoods,
    exportGetAllGoods,
    searchGood,
    exportSearchGood,
    delGoods,
    setTop,
    GoodsUpdateEnableStatus,
    batchGoodsExpress,
    setSalesNumBatch,
    setBrand,
    auditGoods,
    getAllGoodsList,
    exportGetAllGoodsList,
  } from "@/api/goods";
  import { getAllExpressRule } from "@/api/System";
  import { mapGetters } from "vuex";
  export default {
    name: "MerchantsGoods",
    components: {
      GoodsCategory,
      EditGoods,
      BrandSelModel,
    },
    data() {
      return {
        merchantId: "",
        ifMerchant: 5,
        virtual_sales_num: 0,
        set_goods_id: 0,
        // 虚拟销量区间
        sale_num_form: {
          ids: [],
          minVal: "",
          maxVal: "",
        },
        activeName: "all",
        goods_sku_list: [],
        checkedAll: false, // 商品列表全选
        is_price: false, // 编辑商品
        goods_name: "",
        keyword: "",
        brandId: "",
        categoryId: "",
        enableStatus: "",
        sel_brand: false,
        total: 0,
        page: 1,
        pageSize: 10,
        goods_data: [], // table 数据
        choose_data: [],
        form: {
          categoryPath: [],
          search_key: "",
          brand: "",
          shop: "",
          enableStatus: "",
        },
        price_goods_detail: {},
        spec_loading: false,
        set_form: {
          masterUnitId: "",
          shopName: "",
          brandName: "",
          category: [],
          branchUnit: [],
          deliverySupIds: ["1", "2"], // 物流支持 固定值 1 快递 2 自提 传参格式：1,2
          expressType: 1, // 快递运费 1 包邮 2 运费模版 3 固定费用
          expressFee: "", // 固定费用
          showExpress: 5, // 是否展示快递 5展示 4不展示
          ruleId: "", // 运费模版id
        },
        express_list: [],
        more_sub_btn: false, // 批量设置运费loading
        is_set: false,
        set_tit: "",
        auditStatus: 2, // 审核状态
        isOption: "", // 是否是自选商品
      };
    },
    computed: {
      ...mapGetters({ storeData: "MUser/storeData" }),
    },
    created() {
      if (this.systemType === 3) {
        this.merchantId = this.storeData.merchantData.id;
      }
      // this.getAllGoods();
      this.getAllGoodsList();
      this.getAllExpressRule();
    },
    activated() {
      if (this.$_isInit()) return;
      this.getAllGoodsList();
    },
    methods: {
      async getShopByStaff() {
        const res = await getShopByStaff({
          page: this.page,
          pageSize: this.pageSize,
        });
        this.merchantId = res.data[0].merchantId;
        console.log(this.merchantId);
      },
      // 获取运费模版
      async getAllExpressRule() {
        const { data } = await getAllExpressRule();
        this.express_list = data;
      },
      async setSalesNum(index) {
        if (this.virtual_sales_num <= 0) {
          this.$message.warning("请输入大于0的值");
          return;
        }
        const data = await setSalesNum({
          id: this.goods_data[index].id,
          val: this.virtual_sales_num,
        });

        this.goods_data[index].sale_false_visible = false;
        await this.getAllGoodsList();
      },
      showSetSaleNum(index) {
        this.virtual_sales_num = this.goods_data[index].virtualSalesNum;
        this.goods_data[index].sale_false_visible = true;
      },
      openAddGoods() {
        this.$router.push("/goods/sale/AddGoodsOneStore");
      },
      tabChange() {
        switch (this.activeName) {
          case "all":
            this.auditStatus = 2;
            this.isOption = "";
            break;
          case "selfGoods":
            this.auditStatus = 2;
            this.isOption = 5;
            break;
          case "auditGoods":
            this.isOption = "";
            this.auditStatus = 1;
            break;
        }
        this.pageChange(1);
      },
      // 用于可展开表格与树形表格，切换某一行的展开状态，如果使用了第二个参数，则是设置这一行展开与否（expanded 为 true 则展开）
      toggleRowExpansion(row) {
        this.$refs.goodsTable.toggleRowExpansion(row);
        this.showSpec(row);
      },
      async showSpec(row) {
        const index = this.goods_data.findIndex((item) => item.id === row.id);
        if (!this.goods_data[index].goods_sku_list.length) {
          const { data } = await getGoodsInfo(row.id);
          if (data.specType === 2) {
            this.$nextTick(() => {
              this.goods_data[index].goods_sku_list = data.specMultiple.map(
                (item) => {
                  const specValueName = item.specGroup
                    .map((itemS) => {
                      return itemS.specValueName;
                    })
                    .join(";");
                  return {
                    ...item,
                    specValueName: specValueName,
                  };
                }
              );
            });
          } else if (data.specType === 1) {
            this.$nextTick(() => {
              this.goods_data[index].goods_sku_list = data.specMultiple.map(
                (item) => {
                  return {
                    ...item,
                    specValueName: "",
                  };
                }
              );
            });
          }
        }
        // this.goods_data = target
      },
      // 品牌搜索清空
      delBrand() {
        this.form.brand = "";
        this.brandId = "";
        this.pageChange(1);
      },
      // 批量选择
      selectionChange(val) {
        this.checkedAll = val.length === this.goods_data.length;
        this.choose_data = val;
      },
      // 编辑完成回调
      editsubData() {
        this.getAllGoodsList();
      },
      // 调整价格 编辑查看
      openPriceModel(row) {
        this.$router.push(`/goods/sale/EditGoodsOneStore/${row.id}`);
      },

      //  批量上下架
      async BatchUnloading(enableStatus) {
        let title =
          enableStatus === 4
            ? "确定要批量下架这些商品吗？"
            : "确定要批量上架这些商品吗？";
        if (!this.choose_data.length) {
          this.$message.warning("请选择要操作的商品");
          return;
        }
        this.$confirm(title, "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(async () => {
          if (!this.choose_data.length) {
            this.$message.warning("请选择要操作的商品");
            return;
          }
          const idData = this.choose_data.map((item) => {
            return item.id;
          });
          const data = await BatchUnloading({
            id: idData,
            enableStatus: enableStatus,
          });
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          await this.getAllGoodsList();
        });
      },
      // 获取列表
      async getAllGoods(exports) {
        let params = {
          page: this.page,
          pageSize: this.pageSize,
          auditStatus: this.auditStatus,
          ifMerchant: this.ifMerchant,
        };
        if (this.isOption) {
          params.isOption = this.isOption;
        }
        if (this.merchantId) {
          params.merchantId = this.merchantId;
        }
        if (exports) {
          const data = await exportGetAllGoods({
            ...params,
            export: 1,
          });
        } else {
          const data = await getAllGoods(params);
          this.goods_data = data.data.map((item) => {
            return {
              ...item,
              sale_false_visible: false,
              goods_sku_list: [],
            };
          });
          this.total = data.pageTotal;
        }
      },
      // 获取列表（优化）
      async getAllGoodsList(exports) {
        let params = {
          page: this.page,
          pageSize: this.pageSize,
          keyword: this.keyword,
          categoryPath: this.form.categoryPath.join(","),
          brandId: this.brandId,
          enableStatus: this.enableStatus,
        };
        if (this.merchantId) {
          params.merchantId = this.merchantId;
        }
        if (exports) {
          const data = await exportGetAllGoodsList({
            ...params,
            export: 1,
          });
        } else {
          const data = await getAllGoodsList(params);
          this.goods_data = data.data.map((item) => {
            return {
              ...item,
              sale_false_visible: false,
              goods_sku_list: [],
            };
          });
          this.total = data.pageTotal;
        }
      },
      //  搜索商品 searchGood
      // async searchGood(exports) {
      //   let params = {
      //     keyword: this.keyword,
      //     brandId: this.brandId,
      //     categoryPath: this.form.categoryPath.join(","),
      //     enableStatus: this.enableStatus,
      //     page: this.page,
      //     pageSize: this.pageSize,
      //     auditStatus: this.auditStatus,
      //     ifMerchant: 5,
      //   };
      //   if (this.isOption) {
      //     params.isOption = this.isOption;
      //   }
      //   if (this.merchantId) {
      //     params.merchantId = this.merchantId;
      //   }
      //   if (exports) {
      //     const data = await exportSearchGood({
      //       ...params,
      //       export: 1,
      //     });
      //   } else {
      //     const data = await searchGood(params);
      //
      //     this.goods_data = data.data.map((item) => {
      //       return {
      //         ...item,
      //         sale_false_visible: false,
      //         goods_sku_list: [],
      //       };
      //     });
      //     this.total = data.pageTotal;
      //   }
      // },
      // 判断当前使用方法为列表接口还是搜索引擎接口 获取列表数据
      // getData(exports) {
      //   // 搜索参数规整
      //   const obj = {
      //     keyword: this.keyword,
      //     brandId: this.brandId,
      //     categoryPath: this.form.categoryPath.join(","),
      //     enableStatus: this.enableStatus,
      //   };
      //   const isKey = this.$_common.isSerch(obj);
      //   if (isKey) {
      //     this.searchGood(exports);
      //   } else {
      //     this.getAllGoods(exports);
      //   }
      // },
      // 分类搜索
      goodsChane(val) {
        this.pageChange(1);
      },
      // 品牌搜索
      brandConfirm(row) {
        this.form.brand = row[0].title;
        this.brandId = row[0].id;
        this.pageChange(1);
      },
      // 商品上下架
      changeGoodsStatus(row) {
        const tit =
          row.enableStatus === 5
            ? "是否要下架该商品？"
            : "是否要将该商品上架？";
        this.$confirm(tit, "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(async () => {
          const data = await GoodsUpdateEnableStatus({
            id: row.id,
            enableStatus: row.enableStatus === 4 ? 5 : 4,
          });

          this.$message({
            type: "success",
            message: "操作成功!",
          });
          this.getAllGoodsList();
        });
      },
      // 切页
      pageChange(val) {
        this.page = val;
        this.getAllGoodsList();
      },
      // 每页数据大小改变
      sizeChange(val) {
        this.pageSize = val;
        this.pageChange(1);
      },
      checkAllChange() {
        this.$refs.goodsTable.toggleAllSelection();
      },
      // 打开批量设置弹窗
      openSet(tit) {
        this.is_set = true;
        this.set_tit = tit;
      },
      // 批量提交
      moreSubData() {
        if (this.set_tit === "设置品牌") {
          this.setBrand();
        }
        if (this.set_tit === "虚拟销量") {
          this.setSalesNumBatch();
        }
        if (this.set_tit === "物流设置") {
          this.batchGoodsExpress();
        }
      },
      // 批量设置运费
      async batchGoodsExpress() {
        if (!this.choose_data.length) {
          this.$message.warning("请选择要操作的商品");
          return;
        }
        const idData = this.choose_data.map((item) => {
          return item.id;
        });
        this.more_sub_btn = true;
        const data = await batchGoodsExpress({
          expressType: this.set_form.expressType,
          ruleId: this.set_form.ruleId,
          expressFee: this.set_form.expressFee,
          ids: idData,
        });
        this.more_sub_btn = false;

        this.is_set = false;
        this.$message.success("操作成功");
        this.getAllGoodsList();
      },
      // 设置虚拟销量
      async setSalesNumBatch() {
        if (!this.choose_data.length) {
          this.$message.warning("请选择要操作的商品");
          return;
        }
        if (!this.sale_num_form.minVal) {
          this.$message.warning("虚拟销量区间最小值不能为0");
          return;
        }
        if (!this.sale_num_form.maxVal) {
          this.$message.warning("虚拟销量区间最大值不能为0");
          return;
        }
        if (this.sale_num_form.maxVal <= this.sale_num_form.minVal) {
          this.$message.warning("虚拟销量区间最大值必须大于最小值");
          return;
        }
        const idData = this.choose_data.map((item) => {
          return item.id;
        });
        this.more_sub_btn = true;
        const data = await setSalesNumBatch({
          ...this.sale_num_form,
          ids: idData,
        });
        this.more_sub_btn = false;

        this.is_set = false;
        this.$message.success("操作成功");
        this.getAllGoodsList();
      },
      //  设置品牌
      async setBrand() {
        if (!this.choose_data.length) {
          this.$message.warning("请选择要操作的商品");
          return;
        }
        if (!this.brandId) {
          this.$message.warning("请选择要操作的品牌");
          return;
        }
        const idData = this.choose_data.map((item) => {
          return item.basicGoodsId;
        });
        this.more_sub_btn = true;
        const data = await setBrand({
          id: idData,
          brandId: this.brandId,
        });
        this.more_sub_btn = false;

        this.is_set = false;
        this.$message.success("操作成功");
        this.getAllGoodsList();
      },

      // 审核商品
      async auditGoods(id) {
        this.$confirm("确定要审核通过该商品吗?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(async () => {
          const data = await auditGoods(id);
          this.$message.success("操作成功");
          await this.getAllGoodsList();
        });
      },
    },
  };
</script>
<style scoped lang="scss">
  .sku-btn {
    width: 71px;
    height: 22px;
    line-height: 22px;
    background: #f5f5f5;
    border-radius: 4px;
    border: 1px solid #cad0d7;
    text-align: center;
    font-size: 12px;
    cursor: pointer;
  }
  .goods-name-view {
    width: calc(100% - 76px);
  }
  .goods-title {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .sku-ul {
    .sku-li {
      display: inline-block;
      margin-right: 10px;
      border: 1px solid #ebeef5;
      padding: 10px;
      width: 294px;
      vertical-align: middle;
      .sku-img {
        width: 50px;
        margin-right: 8px;
      }
      .sku-info {
        line-height: 23px;
        color: #111111;
        .label {
          display: inline-block;
          width: 50px;
          color: #666666;
          text-align: right;
        }
      }
    }
  }
</style>
