<template>
  <div class="collection pagePadding">
    <ex-table
      v-loading="loading"
      :table="table"
      :data="tableData"
      :columns="columns"
      :page="pageInfo"
      :size="size"
      :noPagination="true"
      @page-curr-change="handlePageChange"
      @page-size-change="handleSizeChange"
      @screen-reset="
        pageInfo.curr = 1;
        parmValue.page = 1;
        searchList();
      "
      @screen-submit="
        pageInfo.curr = 1;
        parmValue.page = 1;
        searchList();
      "
    >
      <template #table-header="{}">
        <div style="width: 100%">
          <el-row style="padding: 0 0 0 80px">
            <el-col :span="3" class="fr" style="width: 66px; padding: 0 0 0 10px">
              <el-button type="primary" :size="searchSize" @click="searchList">
                刷新
              </el-button>
            </el-col>
          </el-row>
         
        </div></template
      >


      <template #operation="{ scope }">
 
        <el-tooltip
          v-if="powers.some((i) => i == '005')"
          effect="dark"
          content="修改"
          placement="top"
        >
          <i
            class="el-icon-edit tb-icon"
            @click="openModal(scope.row, '005', scope.row.status)"
          ></i>
        </el-tooltip>
    
      </template>
    </ex-table>

    <!-- 弹窗 新增/修改 -->
    <add-edit
      :id="modelId"
      :show-model="showModel"
      :sitem="sitem"
      @refresh="searchList"
      @cancel="showModel = false"
    />
  </div>
</template>
<script>
import addEdit from "./addEdit";
import asyncRequest from "@/apis/service/serviceParam/collection";
import roleLevel from "@/assets/js/roleLevel";
import mixinPage from "@/mixins/elPaginationHandle";
import { mapGetters } from "vuex";
import resToken from "@/mixins/resToken";

export default {
  name: "collection",
  mixins: [mixinPage, resToken],
  components: {
    addEdit,
  },
  computed: {
    //组件SIZE设置
    ...mapGetters(["tablebtnSize", "searchSize", "size"]),
    powers() {
      const tran = this.$store.getters.btnList.find((i) => i.menu_route == "collection") || {};
      const { action } = tran ?? {};
      return action ?? [];
    },
  },
  data() {
    return {
      roleLevel: roleLevel,
      loading: true,
      showModel: false,
      modelId: "000",
      sitem: {},
      parmValue: {
        page: 1, // 页码
        size: 999, // 每页显示条数
        quick_search:"", //活动预算属性
        status:"", //状态属性
      },
 
      // 表格 - 数据
      tableData: [],
      // 表格 - 参数
      table: {
        stripe: true,
        border: true,
        // _defaultHeader_: ["setcol"]
      },
      // 表格 - 分页
      pageInfo: {
        size: 999,
        curr: 1,
        total: 0,
      },
      // 表格 - 列参数
      columns: [
        {
          prop: "bank_name",
          label: "银行名称",
        },
        {
          prop: "bank_account",
          label: "银行账号",
        },
        {
          prop: "create_time",
          label: "创建时间",
        },
        {
          prop: "",
          label: "操作",
          fixed: "right",
          _noset_: true,
          width:'80px',
          _slot_: "operation",
        },
      ],
    };
  },
  mounted() {
    this.searchList();
  },
  methods: {
    restSearch() {
      // 表格 - 分页
      this.pageInfo = {
        size: 999,
        curr: 1,
        total: 0,
      };
      this.parmValue = {
        page: 1, // 页码
        size: 999, // 每页显示条数
        status: "",
        quick_search: "",
      };
      this.searchList();
    },
    // 新建/编辑/详情
    openModal(row, type, status) {
      this.sitem = row;
      this.modelId = type;
      this.showModel = true;
    },
   
    // 刷新表格
    async searchList() {
      this.loading = true;
      const model={
        ...this.parmValue,
        limit:this.parmValue.size
      }
      const res = await asyncRequest.list(model);
      if (res && res.code === 1 && res.data) {
        this.tableData = res.data.list;
        this.pageInfo.total = Number(res.data.total);
      } else {
        this.tableData = [];
        this.pageInfo.total = 0;
      }
      this.loading = false;
    },
  },
};
</script>

<style lang="scss" scoped></style>
