<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.ccqy" placeholder="请输入"></el-input>
        </el-form-item>
		<el-form-item label="状态:">
		  <el-select
		    v-model="formInline.ysZt"
		    class="inputWidth"
		    placeholder="请选择"
		  >
		    <el-option
		      v-for="i in ysZtOptions"
		      :key="i.value"
		      :label="i.label"
		      :value="i.value"
		    ></el-option>
		  </el-select>
		</el-form-item>
		<el-form-item label="轮换年度:">
          <el-date-picker
              v-model="formInline.lhnd"
              type="year"
              placeholder="选择轮换年度"
              format="yyyy"
              value-format="yyyy">
            </el-date-picker>
        </el-form-item>
		<el-form-item label="品种:">
		  <el-select
		    v-model="formInline.pzbm"
		    class="inputWidth"
		    placeholder="请选择"
		  >
		    <el-option
		      v-for="i in pzOptions"
		      :key="i.dictCode"
		      :label="i.dictName"
		      :value="i.dictCode"
		    ></el-option>
		  </el-select>
		</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>
      <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="ccqy"
		  label="申报单位"
		  show-overflow-tooltip
		>
		</el-table-column>
        <el-table-column
          align="center"
          prop="lhnd"
          label="轮换年度"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          align="center"
          prop="pzmc"
          label="品种"
          show-overflow-tooltip
        >
        </el-table-column>

        <el-table-column
          align="center"
          prop=""
          label="预算70%"
          show-overflow-tooltip
        >
		<el-table-column align="center"
		  prop="ysZtmc"
		  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,'ys','ck')"
		        type="primary"
		        size="small"
		        class="operate_show_btn iconfont iconchakan2"
		      ></el-button>
		    </el-tooltip>
			<el-tooltip
			  class="item"
			  effect="light"
			  content="接收"
			  placement="top"
			>
			  <el-button
			  v-if="scope.row.ysZt == '91000200'"
			  @click="addSubmit(scope.row,'ys','js')"
			    type="primary"
			    size="small"
				class="operate_edit_btn iconfont iconjieshou"
			  ></el-button>
			</el-tooltip>
			<el-tooltip
			 v-if="scope.row.ysZt == '91000201' && scope.row.ysbfzt == 0"
			   class="item"
			   effect="light"
			   content="撤销"
			   placement="top"
			 >
			   <el-button
			     @click="addSubmit(scope.row,'ys','gz')"
			     style="float: left"
			     type="primary"
			     size="small"
			     class="operate_edit_btn iconfont iconfanhui"
			   ></el-button>
			 </el-tooltip>
		  </template>
		</el-table-column>
        </el-table-column>
        <el-table-column
          align="center"
          prop=""
          label="清算30%"
          show-overflow-tooltip
        >
		    <el-table-column align="center"
		      prop="qsZtmc"
		      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
				  v-if="scope.row.ysZt == '91000201'"
		            @click="addSubmit(scope.row,'qs','ck')"
		            type="primary"
		            size="small"
		            class="operate_show_btn iconfont iconchakan2"
		          ></el-button>
		        </el-tooltip>
		    	<el-tooltip
		    	  class="item"
		    	  effect="light"
		    	  content="接收"
		    	  placement="top"
		    	>
		    	  <el-button
		    	  v-if="scope.row.qsZt == '91000200'"
		    	  @click="addSubmit(scope.row,'qs','js')"
		    	    type="primary"
		    	    size="small"
		    		class="operate_edit_btn iconfont iconjieshou"
		    	  ></el-button>
		    	</el-tooltip>
		    	<el-tooltip
		    	 v-if="scope.row.qsZt == '91000201' && scope.row.qsbfzt == 0"
		    	   class="item"
		    	   effect="light"
		    	   content="撤销"
		    	   placement="top"
		    	 >
		    	   <el-button
		    	     @click="addSubmit(scope.row,'qs','gz')"
		    	     style="float: left"
		    	     type="primary"
		    	     size="small"
		    	     class="operate_edit_btn iconfont iconfanhui"
		    	   ></el-button>
		    	 </el-tooltip>
		      </template>
		    </el-table-column>
        </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 {subsidyList,getPzOptions} from '@/api/bglhbt/index'
export default {
  data() {
    return {
		pzOptions:[],
		ysZtOptions:[
			{
			    label:'未上报',
			    value:'91000000'
			},
			{
			    label:'待提交',
			    value:'91000001'
			},
			{
			    label:'待盖章',
			    value:'91000100'
			},
			{
			    label:'待接收',
			    value:'91000200'
			},
			{
			    label:'已接收',
			    value:'91000201'
			},
			{
			    label:'已驳回',
			    value:'91000202'
			}
		],
      formInline: {
        lhnd:'',
		pzbm:'',
		ysZt:'',
		ccqy:'',
      },
      listLoading: false,
      tableData: [
        {
          lhnd:'2019'
        }
      ],
      pageForm: {
        pageNum: 1,
        pageSize: 10,
        total: 0,
      },
    };
  },
  created() {
    this.getList("start");
	getPzOptions().then((res) => {
	  this.pzOptions = res.data;
	});
  },
  methods: {
    ChangereportDate(val){
      console.log(val,'ppiu88=========')
      this.formInline.startDate=val[0]
      this.formInline.endDate=val[1]
    },
    doSearch() {
      this.pageForm.pageNum = 1;
      this.getList();
    },
    //获取列表
    getList(type) {
      this.listLoading=true
      if (type != "start") {
        //非初始化调用：查询、分页
        sessionStorage.setItem("searchData", JSON.stringify(this.formInline));
        sessionStorage.setItem("pageData", JSON.stringify(this.pageForm));
      } else {
        //初始化分两种情况，详情页等返回后的初始化，以及第一次进入此菜单的初始化
        if (JSON.parse(sessionStorage.getItem("searchData"))) {
          //详情页返回后，将对应查询条件和分页的字段赋值，页面回显参数
          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={
        ...this.pageForm,
       ...this.formInline
      }
      subsidyList(data).then((res) => {
        if(res.infoCode == 200){
         this.tableData = res.data.list;
         this.pageForm.total = res.data.total;
         this.listLoading=false
        }else{
          this.$message.error(res.msg);
		  this.listLoading=false
        }
      });

    },
    //新增
    addSubmit(row,jstype,type) {
      this.$router.push({
        name: "bglhbtDetail",
        query: {
          id:row ? row.id : undefined,
          jstype:jstype ? jstype :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>
