
<template>
  <div class="shopAudit app-container">
    <div class="search">
        <el-input
          v-model="query.shopName"
          size="small"
          placeholder="请输入门店名称"
          class="item-width-200 "
        ></el-input>
         <el-select
          v-model="query.state"
          size="small"
          clearable
          class="item-width-200 ml10"
          placeholder="请选择"
        >
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
    </div>

    <el-table
      :data="tableData"
      tooltip-effect="dark"
      border
      v-loading="loading"
      style="width: 100%"
    >
      <el-table-column
        align="center"
        label="店铺名称"
        prop="shopName"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="shopMenuId"
        align="center"
        label="店铺经营类型"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="mainName"
        align="center"
        label="所属主体"
        show-overflow-tooltip
      >
      </el-table-column>
     
      <el-table-column
        prop="checkState"
        align="center"
        label="审核内容"
        show-overflow-tooltip
      >
       <template slot-scope="scope">
              {{scope.row.checkType == 1?'新店入驻':'店铺修改'}}
        </template>
      </el-table-column>
      <el-table-column
        prop="mainName"
        align="center"
        label="审核状态"
        show-overflow-tooltip
      >
       <template slot-scope="scope">
        <span :class="[scope.row.checkState == 2?'green':'']">{{scope.row.checkState | filterState}}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="commitTime"
        align="center"
        label="申请时间"
        show-overflow-tooltip
      >
      </el-table-column>
   
      <el-table-column prop="address" align="center" label="操作">
        <template slot-scope="scope">
         
          <el-button type="text" size="small" @click="handleAudit(scope.row.shopId,scope.row.checkState)"
            >{{scope.row.checkState == 2?'查看':'审核'}}</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <div class="page-box">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        background
        :current-page="query.currentPage"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="query.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>
  
  <script>
  import {debounce} from '@/utils/index';
  import {checkList} from '@/api/shop'
export default {
  name: "shopAudit",
  data() {
    return {
      options: [
        {
          value: null,
          label: "全部状态",
        },
        {
          value: "1",
          label: "待审核",
        },
        {
          value: "2",
          label: "成功",
        },
         {
          value: "3",
          label: "被驳回",
        },
      ],
      tableData: [],
      loading: false,
      query: {
        state: null,
        shopName: "",
        currentPage: 1,
        pageSize: 10,
      },
      title: "",
      total: 0,
    };
  },
 watch: {
    query: {
      handler: debounce(function(val) {
        
   this.checkList()
      }),
      deep:true
    }
  },
  filters: {
    filterState: function(val) {
      if(val == 1){
        return '待审核'
      }else if(val == 2){
        return '审核通过'
      }else if(val == 3){
        return '被驳回'
      }else{
        return '被删除'

      }
    }
  },
  methods: {
    handleAudit(id,checkState) {
      if(checkState == 2){
        this.$router.push({
          path:"/operationManage/shopAudit/audit",
          query:{
            id,
            title:'审核详情',
            mode:'detail'
          }
        });
      }else{

        this.$router.push({
          path:"/operationManage/shopAudit/audit",
          query:{
            id
          }
        });
      }

    },
    handleSizeChange(val) {
      this.query.currentPage = 1;
      this.query.pageSize = val;
   this.checkList()
    },
    handleCurrentChange(val) {
      this.query.currentPage = val;
   this.checkList()
    },

    checkList() {
      this.loading = true;
      checkList(this.query).then((res) => {
        this.loading = false;
        if (res.state == "Success") {
          this.tableData = res.content.records;
          this.total = res.content.total;
        }
      });
    },
  },
  created() {
   this.checkList()
  },
};
</script>
  
<style lang="scss" >
.shopAudit {
  
}

</style>
  