<template>
  <div class="content-main">
    <el-row class="search-bm-boder">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="填报单位:">
          <el-input clearable v-model="formInline.dwmc" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item label="填报期数:">
          <el-date-picker
                v-model="formInline.bbsj"
                type="month"
                placeholder="选择期数"
                format="yyyyMM"
                value-format="yyyyMM">
              </el-date-picker>
        </el-form-item>
        <el-form-item>
          <div class="search-button">
            <span class="search-line"></span>
            <el-button
              type="primary"
              size="small"
              class="iconfont iconchaxun"
              @click="getList"
              >查询</el-button
            >
            <el-button
              type="primary"
              @click="
               formInline = {};
                doSearch();
              "
              size="small"
              class="iconfont iconzhongzhi"
              >重置</el-button
            >
          </div>
        </el-form-item>
      </el-form>
    </el-row>
    <el-row></el-row>
   <!-- <el-row
      class="addBtnBg"
      style="
        background: rgb(237, 245, 253);
        line-height: 50px;
        margin-bottom: 10px;
      "
    >
      <el-button
        type="primary"
        class="iconfont iconxinzeng"
        size="small"
        @click="addSubmit(undefined,'add')"
        >新增</el-button
      >
    </el-row> -->
    <el-row>
      <el-table
        :data="tableData"
        stripe
        v-loading="listLoading"
        border
        fit
        highlight-current-row
        style="width: 100%"
      >
        <el-table-column align="center" label="序号" width="70">
          <template slot-scope="scope">
            <span>{{ scope.$index + 1 }}</span>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="dwmc"
          label="申报单位"
          show-overflow-tooltip
        >
          <template slot-scope="scope">{{ scope.row.dwmc }}</template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="bbsj"
          label="填报期数"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          align="center"
          prop="createDate"
          label="填报时间"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column align="center" label="操作" width="180px">
          <template slot-scope="scope">
            <el-tooltip
              class="item"
              effect="light"
              content="查看"
              placement="top"
            >
              <el-button
                @click="addSubmit(scope.row,'ck')"
                style="float: left"
                type="primary"
                size="small"
                class="operate_show_btn iconfont iconchakan2"
              ></el-button>
            </el-tooltip>
          <!--  <el-tooltip
            v-if="scope.row.status == '0'"
              class="item"
              effect="light"
              content="修改"
              placement="top"
            >
              <el-button
                @click="addSubmit(scope.row,'xg')"
                style="float: left"
                type="primary"
                size="small"
                class="operate_edit_btn iconfont iconxiugai1"
              ></el-button>
            </el-tooltip>
            <el-tooltip
             v-if="scope.row.status == '0'"
              class="item"
              effect="light"
              content="删除"
              placement="top"
            >
              <el-button
                @click="deleteSubmit(scope.row)"
                style="float: left"
                type="primary"
                size="small"
                class="operate_delete_btn iconfont iconshanchu"
              ></el-button>
            </el-tooltip> -->
          </template>
        </el-table-column>
      </el-table>
    </el-row>
    <el-row>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="pageForm.pageNum"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="pageForm.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="pageForm.total"
      ></el-pagination>
    </el-row>
  </div>
</template>

<script>
import {
  financeReportPage,financeReportDelete
} from "@/api/cwbb/index";

export default {
  data() {
    return {
      formInline: {
        dwmc:'',
        bbsj:'',
		bbm: "01",
      },
      listLoading: false,
      tableData: [],
      pageForm: {
        pageNum: 1,
        pageSize: 10,
        total: 0,
      },
    };
  },
  created() {
    this.getList("start");
  },
  methods: {
    doSearch() {
      this.pageForm.pageNum = 1;
      this.getList();
    },
    //获取列表
    getList(type) {
      if (type != "start") {
        //非初始化调用：查询、分页
        sessionStorage.setItem("searchData", JSON.stringify(this.formInline));
        sessionStorage.setItem("pageData", JSON.stringify(this.pageForm));
      } else {
		  // console.log(JSON.parse(sessionStorage.getItem("searchData")).bbm,'999922-------')
        //初始化分两种情况，详情页等返回后的初始化，以及第一次进入此菜单的初始化
        if (JSON.parse(sessionStorage.getItem("searchData")) && JSON.parse(sessionStorage.getItem("searchData")).bbm == '01') {
          //详情页返回后，将对应查询条件和分页的字段赋值，页面回显参数
          this.formInline = JSON.parse(sessionStorage.getItem("searchData"));
          this.pageForm = JSON.parse(sessionStorage.getItem("pageData"));
        } else {
          //第一次进去此菜单时，保存上方默认的data
          sessionStorage.setItem("searchData", JSON.stringify(this.formInline));
          sessionStorage.setItem("pageData", JSON.stringify(this.pageForm));
        }
      }
      var data={
        type:'asset',
		bbm: "01",
		status:'1',
        ...this.pageForm,
       ...this.formInline
      }
      financeReportPage(data).then((res) => {
        if(res.infoCode == 200){
         this.tableData = res.data.list;
         this.pageForm.total = res.data.total;
        }else{

        }
      });
    },
    //新增
    addSubmit(row,type) {
      this.$router.push({
        name: "balanceSheetDetail",
        query: {
          id:row ? row.id : undefined,
          type:type ? type : undefined
        },
      });
    },
    handleSizeChange(val) {
      this.pageForm.pageSize = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.pageForm.pageNum = val;
      this.getList();
    },
  },
};
</script>
<style scoped>
.h3 {
  text-align: center;
  font-size: 1em;
  line-height: 2.5;
  color: #fff;
  background-color: #49a2fa;
  margin-bottom: 20px;
}
</style>
