<template>
  <div class="financialBox">
    <el-form ref="form" :model="form" label-width="80px" class="line-bottom" inline>
      <el-form-item label="主管部门:">
        <el-input v-model="form.projectName" clearable placeholder="主管部门"  style="width:180px"></el-input>
      </el-form-item>
      <el-form-item label="状态:">
        <el-select v-model="form.findingsAudit" clearable placeholder="请选择"  style="width:180px">
          <el-option
            v-for="(item,index) in findingsAuditObj"
            :key="index"
            :label="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
        <div class="searchBox">
            <div class="search-line"></div>
            <el-button
                    class="iconfont iconchaxun"
                    size="mini"
                    type="primary"
                    style="margin-top:3px;margin-left:10px;"
                    @click="searchInfo"
            > 查询
            </el-button>
            <el-button
                    class="iconfont iconzhongzhi"
                    size="mini"
                    style="margin-top:3px;margin-left:10px;"
                    @click="clearInfo"
                    type="primary"
            > 重置
            </el-button>
        </div>
    </el-form>
    <el-table :data="tableData" v-loading="tableLoading" stripe border style="width: 100%;margin-top:10px;">
      <el-table-column type="index" label="序号" width="60" align="center"></el-table-column>
      <el-table-column :show-overflow-tooltip="true" prop="projectName" label="主管部门" align="center"></el-table-column>
      <el-table-column :show-overflow-tooltip="true" prop="projectContent" label="资金总额"  align="center"></el-table-column>
      <el-table-column :show-overflow-tooltip="true" prop="expenditureProgress" label="财政拨款" align="center">
        <template slot-scope="scope">
          <span>{{scope.row.expenditureProgress=='null'?'':scope.row.expenditureProgress}}</span>
        </template>
      </el-table-column>
      <el-table-column :show-overflow-tooltip="true"  label="填写日期" align="center">
        <template slot-scope="scope">
          <span>{{scope.row.fillDate?scope.row.fillDate.split('T')[0]:"-"}}</span>
        </template>
      </el-table-column>
      <el-table-column :show-overflow-tooltip="true" prop="findingsAudit" label="状态"  align="center"></el-table-column>
      <el-table-column label="操作" width="85" align="center">
        <template slot-scope="scope">
            <el-tooltip class="item" effect="light" content="查看" placement="top">
                <el-button
                        type="primary"
                        class="button operate_show_btn"
                        @click.stop="modifyShow(scope.row,'show')"
                        style="float:left;"
                >
                    <i class="iconfont iconchakan2" style="font-size: 13px"></i>
                </el-button>
            </el-tooltip>
          <el-tooltip
                  class="item"
                  effect="light"
                  content="审核"
                  placement="top"
                  v-show="scope.row.sfxssh.sfxssh == 1"
          >
            <el-button
              type="primary"
              class="button operate_edit_btn"
              @click.stop="modify(scope.row,'update')"
              style="float:left;"
            >
                <i class="iconfont iconshenhe" style="font-size: 13px"></i>
            </el-button>
          </el-tooltip>
        </template>
      </el-table-column>
    </el-table>
    <div class="pag-right clearFix">
      <el-pagination
        class="right"
        style="text-align:right;margin-right: 20px;"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="formPage.page"
        :page-sizes="[10,20,30,40]"
        :page-size="formPage.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="formPage.total"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
import {
  budgetPerformanceManagementByPage,
  budgetPerformanceManagementDelete,
  budgetPerformanceManagementSubmission,
  budgetPerformanceManagementByPageOfAudit
} from "@/api/budgetPerformanceManagement/index";

export default {
  data() {
    return {
      form: {},
      formPage: {
        page: 1,
        size: 10,
        total: 0
      },
      //状态
      findingsAuditObj: [
        {
          value: "处室处长审核",
          code: "1"
        },
        {
          value: "办公室财务人员审核",
          code: "2"
        },
        {
          value: "办公室财务处长审核",
          code: "3"
        },
        {
          value: "规划财务处人员审核",
          code: "4"
        },
        {
          value: "规划财务处处长审核",
          code: "5"
        },
        {
          value: "审核通过",
          code: "6"
        },
        {
          value: "驳回",
          code: "0"
        },
      ],
      //列表数据
      tableData: [],
      //列表loading控制
      tableLoading: false
    };
  },
  methods: {
    // 审核
    modify(row, state) {
      this.$router.push({
        path: "examineAdd",
        query: {
          id: row.id,
          state: state,
          row: JSON.stringify(row),
          fundSo: row.fundSources,
          bolF: "fundSources"
        }
      });
    },
    // 查看
    modifyShow(row, state) {
      let params = row
      if(params.expenditureProgress == 'null' || !params.expenditureProgress){
        delete params.expenditureProgress
      }
      this.$router.push({
        path: "examineShow",
        query: {
          id: row.id,
          state: state,
          row: JSON.stringify(params),
          fundSo: row.fundSources,
          bolF: "fundSources"
        }
      });
    },
    //清空
    clearInfo() {
      this.form = {};
      this.initTableData();
    },
    //查询
    searchInfo() {
      this.initTableData();
    },
    //分页大小
    handleSizeChange(val) {
      this.formPage.size = val;
      this.initTableData();
    },
    //分页页数
    handleCurrentChange(val) {
      this.formPage.page = val;
      this.initTableData();
    },
    //初始化列表数据
    initTableData() {
      this.tableLoading = true;
      this.form.auditor = "审批"
      budgetPerformanceManagementByPage(this.form, this.formPage, 1).then(
        response => {
          if (response.infoCode === 200) {
            this.tableData = response.data.list;
            this.formPage.total = response.data.total;
          } else {
            this.$message({
              type: "error",
              message: response.msg
            });
          }
          this.tableLoading = false;
        }
      );
    }
  },
  created() {
    this.initTableData();
  }
};
</script>
<style scoped>
    .financialBox{
        overflow-y: auto;
        margin: 10px;
        border: 1px solid #f4f5f8;
        padding: 10px;
        min-width: 960px;
    }
    .textRed{
        color:#F56C6C ;
    }
    .dashboard-container{
        overflow: auto;
    }
    .searchBox{
        position: relative;
        display: inline-block;
    }
    .line-bottom{
        border-bottom:1px dashed #006bd5;
    }
    .search-line {
        cursor: pointer;
        border-right: 1px dashed #737bf1;
        height: 38px;
        display: inline-block;
        margin:0 10px 0 20px;
        vertical-align: middle;
    }
</style>
