<template>
  <div class="mall-section-container">
    <div class="mall-content-section">
      <div class="mall-content-title">
        <el-breadcrumb separator="/">
          <el-breadcrumb-item :to="{ path: '' }">
            <a href="/report/#/memberSummary">首页</a>
          </el-breadcrumb-item>
          <el-breadcrumb-item>积分商城</el-breadcrumb-item>
          <el-breadcrumb-item>商品</el-breadcrumb-item>
          <el-breadcrumb-item>优惠券</el-breadcrumb-item>
        </el-breadcrumb>
        <h3>
          <span>优惠券</span>
        </h3>
      </div>
      <div class="section">
        <div class="operate-top">
          <div class="fl">
            <div class="search-item">
              <el-input v-model.trim="searchValue" placeholder="请输入优惠券名称进行搜索" prefix-icon="el-icon-search" clearable class="w-280" @keyup.enter.native="getSearchList" @clear="getSearchList"></el-input>
            </div>
            <div class="search-item">
              <el-select v-model="shelf" placeholder="上下架状态" clearable class="w-140" @change="getListCurr">
                <el-option label="已上架" :value="2"></el-option>
                <el-option label="已下架" :value="1"></el-option>
              </el-select>
            </div>
            <div class="search-item">
              <el-checkbox v-model="showSelfStatus" label="仅看本人" border @change="getListCurr" v-if="showFlag"></el-checkbox>
            </div>
          </div>
          <div class="fr">
            <div class="search-item">
              <el-select v-model="goodsType" placeholder="请选择批量操作" clearable @change="handleData">
                <el-option label="批量上架" :value="0"></el-option>
                <el-option label="批量下架" :value="1"></el-option>
                <el-option label="批量删除" :value="2"></el-option>
              </el-select>
            </div>
            <el-button type="primary" @click="addCoupon">新增优惠券</el-button>
          </div>
        </div>
        <div v-loading="loading">
          <el-table ref="multipleTable" :data="tableDate" style="width: 100%" @sort-change="sortChange" @selection-change="handleSelectAll">
            <el-table-column type="selection" width="50" :selectable="selectInit"></el-table-column>
            <el-table-column label="礼品信息" min-width="260px">
              <template slot-scope="scope">
                <div class="gift-info">
                  <!-- <p v-if="scope.row.cardType === 2" style="display:inline-block">
                    <img v-if="scope.row.mainImageUrl" :src="scope.row.mainImageUrl" alt="" />
                    <img v-else src="../../../../static/img/quan02.png" alt="" />
                  </p>
                  <p style="display:inline-block"  v-if="scope.row.cardType === 0">
                    <img v-if="scope.row.mainImageUrl" :src="scope.row.mainImageUrl" alt="" />
                    <img v-else src="../../../../static/img/quan01.png" alt="" />
                  </p>-->
                  <img v-if="scope.row.mainImageUrl" :src="scope.row.mainImageUrl" alt />
                  <img v-if="scope.row.cardType === 2 && !scope.row.mainImageUrl" src="../../../../static/img/quan02.png" alt />
                  <img v-if="scope.row.cardType === 0 && !scope.row.mainImageUrl" src="../../../../static/img/quan01.png" alt />
                  <img v-if="scope.row.cardType === 1 && !scope.row.mainImageUrl" src="../../../../static/img/quan03.png" alt />
                  <div class="info-name">
                    <div>
                      <el-tooltip :content="'优惠券id：' + scope.row.integralMallProId" effect="dark" placement="top-start">
                        <p class="pro-ellipsis" :class="[!scope.row.hasActivity ? 'pro-ellipsis' : scope.row.proReferId.split(',').length > 1 ? 'pro-ellipsis2' : 'pro-ellipsis3']" style="display:inline-block">{{ scope.row.proTitle }}</p>
                      </el-tooltip>
                      <el-tooltip v-if="scope.row.cardErrorMessage && scope.row.cardErrorMessage !== ''" class="tips-content" popper-class="store-tips" effect="light" :content="scope.row.cardErrorMessage && scope.row.cardErrorMessage !== '' ? '卡券存在异常，请进入详情查看' : ''" placement="top-start">
                        <i class="iconfont icon-xinxixianshi" style="colorfs:#f5222d;display:inline-block"></i>
                      </el-tooltip>
                    </div>
                    <p class="category-ellipsis">{{ scope.row.proSubTitle }}</p>
                    <p class="category-ellipsis">{{ scope.row.remarks }}</p>
                    <div v-if="scope.row.hasActivity" style="font-size:12px;background-color:#f56c6c;color:#fff;line-height:16px;width:32px;text-align:center">秒杀</div>
                    <!-- <div style="font-size:14px;background-color:#f56c6c;color:#fff;line-height:20px;width:35px;text-align:center">秒杀</div> -->
                  </div>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="integralCost" label="积分费用" sortable="custom" min-width="110px">
              <template slot-scope="scope">
                <!-- <editInfo :popoverType='1' :popoverNum="scope.row.integralCost"><editInfo> -->
                <p class="intergral-edit">
                  {{ scope.row.integralCost }}积分
                  <i class="el-icon-edit" @click="updataCash(scope.row)" v-if="scope.row.canEdit"></i>
                </p>
              </template>
            </el-table-column>
            <el-table-column prop="cashCost" label="现金费用" sortable="custom" min-width="110px">
              <template slot-scope="scope">
                <p class="intergral-edit">
                  {{ scope.row.cashCost }}元
                  <i class="el-icon-edit" @click="updataCash(scope.row)" v-if="scope.row.canEdit"></i>
                </p>
              </template>
            </el-table-column>
            <el-table-column prop="sortCost" label="库存" sortable="custom">
              <template v-slot:header>
                库存
                <el-popover trigger="hover" width="250" placement="top" content="该礼品在积分商城所有的库存，包括活动库存，库存分布请点击数字查看">
                  <i class="iconfont icon-xinxixianshi" v-show="specialOrder" style="margin-left:-2px" slot="reference"></i>
                </el-popover>
              </template>
              <template slot-scope="scope">
                <p class="intergral-edit">
                  <el-button v-if="specialOrder" type="text" @click="checkStockDistribute(scope.row)">{{ scope.row.virtualStock }}</el-button>
                  <span v-else>{{ scope.row.virtualStock }}</span>
                  <i class="el-icon-edit" @click="handleTable(scope.row, 3)" v-if="scope.row.canEdit"></i>
                </p>
              </template>
            </el-table-column>
            <el-table-column prop="sortTimes" label="兑换次数" sortable="custom" min-width="110px">
              <template slot-scope="scope">
                <el-button type="text" @click="goRecord(scope.row)">{{ scope.row.allExchangeNumber }}</el-button>
                <!-- <p>{{ scope.row.allExchangeNumber }}</p> -->
              </template>
            </el-table-column>
            <el-table-column prop="createTime" label="创建时间" sortable="custom" min-width="110px">
              <template slot-scope="scope">
                <p>{{ getTime(scope.row.createTime) }}</p>
                <p>{{ getSeconds(scope.row.createTime) }}</p>
              </template>
            </el-table-column>
            <el-table-column prop="creatorName" label="创建人" min-width="110px" v-if="openFlag">
              <template slot-scope="scope">{{ scope.row.creatorName ? scope.row.creatorName : '--' }}</template>
            </el-table-column>
            <el-table-column prop="sort" label="序号" sortable="custom" min-width="140px" :render-header="renderHeader">
              <template slot-scope="scope">
                <p v-if="!scope.row.editStatus" class="edit-number intergral-edit">
                  {{ scope.row.sort }}
                  <i class="el-icon-edit" @click="editNumber(scope.row)" v-if="scope.row.canEdit"></i>
                </p>
                <div v-if="scope.row.editStatus">
                  <el-input v-if="scope.row.editStatus" v-model="scope.row.sort" placeholder size="mini" class="w-180" @blur="value => limitSort(value, scope.row)" style="width:60px"></el-input>
                  <span class="operate-span" @click="editNumSubmit(scope.row)">确定</span>
                  <span class="operate-span" @click="editNumCancel(scope.row)">取消</span>
                </div>
                <span style="display:none">{{ refash }}</span>
              </template>
            </el-table-column>
            <el-table-column label="操作" min-width="180px">
              <template slot-scope="scope">
                <div>
                  <el-button type="text" @click="getLink(scope.row)" v-if="scope.row.canEdit">推广</el-button>
                  <el-button type="text" v-if="scope.row.status === 2 && scope.row.canEdit && scope.row.releaseType === 1" @click="deleteList(scope.row, 1)">下架</el-button>
                  <!-- <el-button type="text" @click="ladderList(scope.row)" v-if="scope.row.isDifferentialPricing">阶梯价</el-button> -->
                  <el-button type="text" v-if="scope.row.status === 2 && scope.row.canEdit && scope.row.releaseType === 2 && scope.row.isShelves === 1" @click="deleteList(scope.row, 2)">上架</el-button>
                  <el-button type="text" v-if="scope.row.status === 2 && scope.row.canEdit && scope.row.releaseType === 2 && scope.row.isShelves === 0" @click="deleteList(scope.row, 1)">下架</el-button>
                  <el-button type="text" v-if="scope.row.status === 1 && scope.row.canEdit" @click="deleteList(scope.row, 2)">上架</el-button>
                  <el-button type="text" @click="goAdd(scope.row)">编辑</el-button>
                  <!-- <dm-delete @confirm="deleteList(scope.row, 0, scope.$index)" tips="确定删除该商品吗?">
                    <el-button type="text" v-if="scope.row.canEdit">删除</el-button>
                  </dm-delete> -->
                  <el-dropdown style="margin-left:20px;" @command="command => handleCommand(command, scope.row, scope.$index)" placement="bottom-start">
                    <span class="el-dropdown-link" style="color:#1890ff;cursor: pointer;"> <i class="el-icon-more"></i> </span>
                    <el-dropdown-menu slot="dropdown" style="width:110px;">
                      <!-- <el-dropdown-item command="1" v-if="scope.row.changeType === '5' && scope.row.canEdit">券码</el-dropdown-item> -->
                      <el-dropdown-item command="2" v-if="scope.row.isDifferentialPricing">阶梯价</el-dropdown-item>
                      <el-dropdown-item command="3" v-if="scope.row.canEdit">删除</el-dropdown-item>
                    </el-dropdown-menu>
                  </el-dropdown>
                  <!-- <el-popover placement="top" width="160" v-model="scope.row.visible2" style="margin-left:8px">
                    <p style="line-height:1.5;padding: 10px 10px 20px;">确定删除该商品吗？</p>
                    <div style="text-align: right; margin: 0">
                      <el-button size="mini" type="text" @click="scope.row.visible2 = false">取消</el-button>
                      <el-button type="primary" size="mini" @click="deleteList(scope.row, 0, scope.$index)">确定</el-button>
                    </div>
                    <el-button slot="reference" type="text" v-if="scope.row.canEdit">删除</el-button>
                  </el-popover>-->
                </div>
              </template>
            </el-table-column>
            <template slot="empty">
              <div class="no-data-wrap">
                <div class="no-data-icon">
                  <img src="../../../../static/img/no-data_icon.png" />
                </div>
                <p>暂无数据</p>
              </div>
            </template>
          </el-table>
          <div class="pagination-conteiner" v-show="tableDate.length > 0">
            <div class="pagination">
              <dm-pagination v-if="total != 0" background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="pageSizes" :page-size="pageSize" layout="total, sizes, prev, pager, next" :total="total"></dm-pagination>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 上架失败提示 -->
    <el-dialog title="提示" :visible.sync="outerVisible" class="dialogStyle" :before-close="outerViewClose">
      <div class="dialog-body">
        <i class="el-icon-warning"></i>
        <!-- <span>共{{ sum }}条申请，退款成功{{ successNum }}个，退款失败{{ failNum }}个，</span> -->
        <span>{{ errorMessage }}</span>
        <el-button type="primary" class="viewReason" @click="innerVisible = true">查看失败原因</el-button>
      </div>
      <el-dialog class="dialogStyle" width="30%" title="查看失败原因" :visible.sync="innerVisible" append-to-body>
        <div class="dialog-body failReason" v-for="(item, index) in errorList" :key="index">
          <span>{{ item }}</span>
          <!-- <span class="marginLeft">{{ item.message }}</span> -->
        </div>
        <div slot="footer" class="dialog-footer borderNone contentCenter">
          <el-button type="primary" @click="innerViewClose">关闭</el-button>
        </div>
      </el-dialog>
      <div slot="footer" class="dialog-footer borderNone">
        <el-button type="primary" @click="outerViewClose">确定</el-button>
      </div>
    </el-dialog>
    <!-- 推广 -->
    <eqCode :modalData="modalData" :integralMallProId="integralMallProId" :saleType="saleType"></eqCode>
    <!-- 调整积分费用 -->
    <editInfo :editInfoModal="editInfoModal" @getList="getList"></editInfo>
    <!-- <stockModal :intergralModal="intergralModal" @getList="getList"></stockModal> -->
    <updateCash v-if="packageDialog" :packageData="packageData" @getList="getList" @closePackage="closePackage"></updateCash>
    <!-- 阶梯价 -->
    <coupon-ladder-price :ladderPriceData="ladderPriceData" @closeUpdateLadder="closeUpdateLadder" v-if="ladderDialogVisible" @getList="getList"></coupon-ladder-price>
    <!-- 查看库存分布 -->
    <check-stock-distirbute :integralMallProId="integralMallProId" @closeStockDistirbute="closeStockDistirbute" v-if="stockDialog" @getList="getList"></check-stock-distirbute>
  </div>
</template>

<script>
import qs from 'qs';
import request from '../../../service/request.js';
import getInputVal from '../../../utils/common.js';
// import copy from '../../../utils/clone.js';
import eqCode from '../../../components/eqCode';
import selectType from '../../../components/selectGoodsType';
import editInfo from '../../../components/editCouponInfo';
import updateCash from '../../../components/updataCash';
import couponLadderPrice from '../../../components/couponLadderPrice';
import checkStockDistirbute from '../../../components/checkStockDistirbute';
// import stockModal from '../../../components/getSkuList';
export default {
  data() {
    return {
      getTime: getInputVal.getTime,
      getSeconds: getInputVal.getSeconds,
      searchValue: '',
      shelf: '', //上下架状态
      goodsType: '', //批量操作
      tableDate: [],
      showSelfStatus: false,
      showFlag: false,
      openFlag: true,
      currentPage: 1,
      pageSizes: [20, 40, 60, 80],
      pageSize: 20,
      total: 0,
      refash: false,
      modalData: {
        //推广数据
        show: false,
        imgUrl: '',
        loading: false
      },
      selectArr: [], //选中的数据
      addModalData: {
        dialogVisible: false
      },
      // 列表编辑组件传参
      editInfoModal: {
        dialogVisible: false,
        num: '',
        mallProId: '',
        type: '',
        costValue: ''
      },
      couponListObj: {},
      // 券包积分现金更新
      packageDialog: false,
      packageData: {
        integralMallProId: ''
      },
      integralMallProId: '',
      saleType: '',
      errorMessage: '',
      errorList: '',
      outerVisible: false,
      innerVisible: false,
      ladderPriceData: {
        data: [],
        id: ''
        // show: false
      },
      ladderDialogVisible: false,
      stockDialog: false,
      enterpriseId: '',
      specialOrder: false
    };
  },
  created() {
    if (localStorage.getItem('couponListObj')) {
      this.couponListObj = JSON.parse(localStorage.getItem('couponListObj'));
      this.currentPage = this.couponListObj.currentPage;
      this.pageSize = this.couponListObj.pageSize;
      this.total = this.couponListObj.total;
      this.shelf = this.couponListObj.shelf;
      this.searchValue = this.couponListObj.searchValue;
      this.sortType = this.couponListObj.sortType;
      this.sortColumn = this.couponListObj.sortColumn;
      localStorage.removeItem('couponListObj'); //使用完就清除缓存
    }
    this.getStatus();
    this.getList();
    this.getUserId();
  },
  methods: {
    // 阶梯价定制，判断达摩测试环境与地素环境
    // 达摩测试 ff8080815dacd3a2015dacd3ef5c0000
    // 达摩生产 ff8080816a36326c016a53380d8b5f52
    // 地素 ff80808163218c030163429b47110635
    // 地素测试 ff8080816f12b5c0016f1d5896820147
    getUserId() {
      request.get('/api-auth/get-login-user-info').then(res => {
        if (res.data.errorCode === 0) {
          this.enterpriseId = res.data.result.enterpriseId;
          let id1 = 'ff8080815dacd3a2015dacd3ef5c0000';
          let id2 = 'ff80808163218c030163429b47110635';
          let id3 = 'ff8080816f12b5c0016f1d5896820147';
          let id4 = 'ff8080816a36326c016a53380d8b5f52';
          if (this.enterpriseId === id1 || this.enterpriseId === id2 || this.enterpriseId === id3 || this.enterpriseId === id4) {
            this.specialOrder = true;
          } else {
            this.specialOrder = false;
          }
        } else {
          this.$message.error(res.data.message);
        }
      });
    },
    renderHeader(h, { column, $index }, index) {
      return h('span', {}, [h('span', {}, '序号'), h('el-popover', { props: { placement: 'top-start', width: '200', trigger: 'hover', content: '礼品在小程序端的展示排序，序号越大，排序越靠前。' } }, [h('i', { slot: 'reference', class: 'iconfont icon-xinxixianshi' }, '')])]);
    },
    renderHeader2(h, { column, $index }, index) {
      return h('span', {}, [h('span', {}, '库存'), h('el-popover', { props: { placement: 'top-start', width: '250', trigger: 'hover', content: '该礼品在积分商城所有的库存，包括活动库存，库存分布请点击数字查看' } }, [h('i', { slot: 'reference', class: 'iconfont icon-xinxixianshi' }, '')])]);
    },
    // 查看库存分布
    checkStockDistribute(item) {
      this.stockDialog = true;
      this.integralMallProId = item.integralMallProId;
    },
    closeStockDistirbute() {
      this.stockDialog = false;
    },
    getStatus() {
      request.post('/api-integral-mall/is-show-self ').then(res => {
        if (res.data.errorCode === 0) {
          this.showFlag = res.data.result.showFlag;
          this.openFlag = res.data.result.openFlag;
        } else {
          this.$message.error(res.data.message);
        }
      });
    },
    handleCommand(command, item, index) {
      if (command == 2) {
        this.ladderList(item);
      } else if (command == 3) {
        this.$confirm('<div>确认删除该商品吗?</div>', '提示', {
          closeOnClickModal: false,
          showClose: false,
          type: 'warning',
          customClass: 'show-title',
          dangerouslyUseHTMLString: true,
          confirmButtonText: '确认'
        })
          .then(() => {
            this.deleteList(item, 0, index);
          })
          .catch(() => {
            return;
          });
      }
    },
    //跳转到兑换记录
    goRecord(item) {
      this.$router.push({ name: 'couponExchange', query: { integralMallProId: item.integralMallProId } });
    },
    // 获取列表
    getList() {
      let params = {
        currentPage: this.currentPage,
        pageSize: this.pageSize,
        sortType: this.sortType,
        sortColumn: this.sortColumn,
        giftName: this.searchValue,
        shelf: this.shelf ? this.shelf : -1, //上架状态
        showSelfFlag: this.showSelfStatus ? 1 : 0
      };
      this.loading = true;
      request.post('/api-integral-mall/page-cards', qs.stringify(params)).then(res => {
        if (res.data.errorCode === 0) {
          if (res.data.result.rows) {
            this.tableDate = res.data.result.rows;
            this.total = res.data.result.total;
          } else {
            this.tableDate = [];
            this.total = 0;
          }
          this.loading = false;
        } else {
          this.$message.error(res.data.message);
          this.loading = false;
        }
      });
    },
    //分页设置每页的数量
    handleSizeChange(size) {
      this.pageSize = size;
      this.getList();
    },
    // 分页设置跳转到第几页
    handleCurrentChange(page) {
      this.currentPage = page;
      this.getList();
    },
    // 搜索
    getSearchList() {
      this.currentPage = 1;
      this.getList();
    },
    getListCurr() {
      this.currentPage = 1;
      this.getList();
    },
    // 排序
    sortChange(value) {
      this.sortColumn = value.prop;
      if (value.order == 'ascending') {
        this.sortType = 'asc';
      } else if (value.order == 'descending') {
        this.sortType = 'desc';
      }
      this.getList();
    },
    ladderList(item) {
      // this.ladderPriceData.show = true;
      this.ladderPriceData.id = item.integralMallProId;
      this.ladderDialogVisible = true;
      console.log(this.ladderPriceData);
    },
    closeUpdateLadder() {
      console.log(111);
      this.ladderDialogVisible = false;
      this.getList();
    },
    // 商品链接
    getLink(item) {
      this.modalData.loading = true;
      this.integralMallProId = item.integralMallProId;
      this.saleType = 'card';
      let params = {
        integralMallProId: item.integralMallProId,
        type: 'card'
      };
      this.modalData.show = true;
      request.get('/api-integral-mall/get-qRCode', { params }).then(res => {
        if (res.data.errorCode === 0) {
          this.modalData.show = true;
          this.modalData.pageUrl = res.data.result.page;
          this.modalData.imgUrl = res.data.result.url;
          this.modalData.loading = false;
        } else {
          this.$message.error(res.data.message);
        }
      });
    },
    // 删除操作
    deleteList(item, type, index) {
      let params = {
        proId: item.integralMallProId,
        type: Number(type)
      };
      request.post('/api-integral-mall/delete-pro', qs.stringify(params)).then(res => {
        if (res.data.errorCode === 0) {
          let text = Number(type) === 0 ? '删除成功' : Number(type) === 1 ? '下架成功' : '上架成功';
          this.$message.success(text);
          if (Number(type) === 0) {
            this.tableDate.splice(index, 1);
            if (this.tableDate.length === 0) {
              if (this.currentPage > 1) {
                this.currentPage = this.currentPage - 1;
              }
            }
          }
          this.getList(); //拉取列表
        } else {
          this.$message.error(res.data.message);
        }
      });
    },
    // 全选操作
    handleSelectAll(val) {
      this.selectArr = val;
    },
    // 批量操作
    handleData() {
      if (this.selectArr.length === 0) {
        this.$message.error('请先选择要批量操作的数据');
        this.goodsType = '';
        return false;
      }
      let shelfArr = []; //上架的礼品id
      let soldOutArr = []; //下架的礼品id
      let deleteArr = []; //删除的礼品id
      let type = '';
      let proId = '';
      for (let item of this.selectArr) {
        if (item.status === 1) {
          //下架状态（进行上架操作）
          soldOutArr.push(item.integralMallProId);
        } else if (item.status === 2) {
          //上架状态（进行下架操作）
          shelfArr.push(item.integralMallProId);
        }
        deleteArr.push(item.integralMallProId);
      }
      if (this.goodsType === 0) {
        type = 2;
        //批量上架
        if (soldOutArr.length === 0) {
          this.$message.error('请先选择要上架的数据');
          return false;
        } else {
          proId = soldOutArr.join(',');
        }
      } else if (this.goodsType === 1) {
        //批量下架
        type = 1;
        if (shelfArr.length === 0) {
          this.$message.error('请先选择要下架的数据');
          return false;
        } else {
          proId = shelfArr.join(',');
        }
      } else if (this.goodsType === 2) {
        type = 0;
        //批量删除
        if (deleteArr.length === 0) {
          this.$message.error('请先选择要删除的数据');
          return false;
        } else {
          proId = deleteArr.join(',');
        }
      }
      let params = {
        proId: proId,
        type: type
      };
      request.post('/api-integral-mall/delete-pro', qs.stringify(params)).then(res => {
        if (res.data.errorCode === 0) {
          let text = Number(type) === 0 ? '删除成功' : Number(type) === 1 ? '下架成功' : '上架成功';
          this.$message.success(text);
          this.currentPage = 1;
          this.getList(); //拉取列表
          this.goodsType = '';
        } else if (res.data.errorCode === 1) {
          this.errorMessage = res.data.message;
          this.errorList = res.data.result;
          if (this.errorList && this.errorList.length > 0) {
            this.outerVisible = true;
          }
        } else {
          this.$message({
            dangerouslyUseHTMLString: true,
            message: `<div>${res.data.message}</div>`,
            type: 'error'
          });
          this.goodsType = '';
        }
      });
    },
    innerViewClose() {
      this.innerVisible = false;
    },
    outerViewClose() {
      this.outerVisible = false;
      this.getList();
      this.goodsType = '';
    },
    // 新增礼品
    addCoupon() {
      this.$router.push({ name: 'couponInfo', query: { giftId: '-1', coupCardId: '-1', canEdit: true } });
    },
    // 编辑
    goAdd(item) {
      this.couponListObj = {
        currentPage: this.currentPage,
        pageSize: this.pageSize,
        total: this.total,
        shelf: this.shelf,
        searchValue: this.searchValue,
        sortType: this.sortType,
        sortColumn: this.sortColumn
      };
      window.localStorage.setItem('couponListObj', JSON.stringify(this.couponListObj));
      this.$router.push({ name: 'couponInfo', query: { giftId: item.integralMallProId, coupCardId: item.proReferId, canEdit: item.canEdit } });
    },
    //编辑序号
    editNumber(item) {
      item.editStatus = true;
      this.refash = !this.refash;
    },
    limitSort(value, item) {
      var reg = /^([1-9]\d*|[0]{1,1})$/; //含0正整数
      if (!reg.test(item.sort)) {
        this.$message.error('序号必须是正整数');
        this.$nextTick(() => {
          item.sort = 0;
        });
        return false;
      }
    },
    // 确定编辑序号
    editNumSubmit(item) {
      let params = {
        integralMallProId: item.integralMallProId,
        sort: item.sort
      };
      request.post('/api-integral-mall/update-integral-sort', qs.stringify(params)).then(res => {
        if (res.data.errorCode === 0) {
          this.$message.success('更新成功');
          item.editStatus = false;
          this.refash = !this.refash;
          this.getList(); //拉取列表
        } else {
          this.$message.error(res.data.message);
        }
      });
    },
    // 取消编辑序号
    editNumCancel(item) {
      item.editStatus = false;
      this.refash = !this.refash;
    },
    handleTable(item, type) {
      if (type === 1) {
        this.editInfoModal.num = item.integralCost;
        this.editInfoModal.type = '积分费用';
      } else if (type === 2) {
        this.editInfoModal.num = item.cashCost;
        this.editInfoModal.type = '现金费用';
        this.editInfoModal.costValue = item.costValue;
      } else if (type === 3) {
        this.editInfoModal.num = item.virtualStock;
        this.editInfoModal.type = '库存';
      }

      this.editInfoModal.mallProId = item.integralMallProId;
      this.editInfoModal.dialogVisible = true;
    },
    //更新积分现金
    updataCash(item) {
      this.packageData.integralMallProId = item.integralMallProId;
      this.packageDialog = true;
    },
    closePackage() {
      this.packageDialog = false;
    },
    selectInit(row, index) {
      return row.canEdit;
    }
  },
  components: {
    eqCode,
    selectType,
    editInfo,
    updateCash,
    couponLadderPrice,
    checkStockDistirbute
    // stockModal
  }
};
</script>
<style scoped>
.section {
  background: #fff;
  margin: 24px;
  padding: 24px;
}
.w-280 {
  width: 280px;
}
.w-140 {
  width: 140px;
}
.gift-info img {
  width: 75px;
  height: 75px;
  border-radius: 4px;
  padding: 4px;
  border: 1px solid #dcdfe6;
  vertical-align: middle;
}
.info-name {
  display: inline-block;
  vertical-align: top;
  width: 58%;
}
.pro-ellipsis {
  color: #303133;
  height: 35px;
  line-height: 18px;
  /* width: 230px; */
  font-size: 14px;
}
.pro-ellipsis2 {
  color: #303133;
  height: 60px;
  line-height: 18px;
  /* width: 230px; */
  font-size: 14px;
}
.pro-ellipsis3 {
  color: #303133;
  height: 21px;
  line-height: 18px;
  /* width: 230px; */
  font-size: 14px;
}
.category-ellipsis {
  color: #909399;
  font-size: 13px;
}
.el-icon-edit {
  margin-left: 5px;
  cursor: pointer;
}
.operate-span {
  font-size: 13px;
  cursor: pointer;
}
.intergral-edit .el-icon-edit {
  display: none;
}
.intergral-edit:hover .el-icon-edit {
  display: inline-block;
}
</style>
<style>
.dialogStyle .el-dialog__footer {
  border-top: none;
}
.dialogStyle .el-dialog {
  width: 450px;
}
.dialogStyle .viewReason {
  background-color: #fff !important;
  color: #1890ff !important;
  border: none !important;
  padding-left: 0 !important;
  text-decoration: underline !important;
  text-decoration-color: #1890ff !important;
}
.dialogStyle .marginLeft {
  margin-left: 15px;
}
.dialogStyle .contentCenter {
  text-align: center;
  margin-top: 120px;
}
.dialogStyle .failReason {
  margin-bottom: 10px;
}
.dialogStyle .dialog-body .el-icon-warning {
  color: #faad14;
  font-size: 20px;
  margin-right: 10px;
}
</style>
