<template>
  <!-- 仓储设备投资建设上报 -->
  <div class="content-main">
    <el-form :inline="true" :model="formInline" ref="formInline" class="demo-form-inline">
      <el-form-item label="年份:">
        <el-date-picker v-model="formInline.sbnf" value-format="yyyy" type="year" @change="changeYear"
            placeholder="请选择年份"></el-date-picker>
      </el-form-item>
	  <el-form-item v-show="!hzDisable && orgCode=='LS001'" label="区域:" prop="ssqymc">
	    <el-input
	      clearable
	      class="inputCompatible"          
	      v-model="formInline.ssqymc"
	      placeholder="区域"
	    ></el-input>
	  </el-form-item>
	  <el-form-item v-show="!hzDisable && orgCode=='LS001'" label="库点名称:" prop="sskdmc">
	    <el-input
	      clearable
	      class="inputCompatible"        
	      v-model="formInline.sskdmc"
	      placeholder="库点名称"
	    ></el-input>
	  </el-form-item>
      <el-form-item style="border-left:1px dashed #006bd5;padding-left:15px">
        <el-button type="primary" size="small" class="iconfont iconchaxun" @click="GetList">查询</el-button>
        <el-button
          type="primary"
          size="small"
          class="iconfont iconzhongzhi"
          @click="resetFun('formInline')"
        >重置</el-button>
      </el-form-item>
    </el-form>
    <el-row style="background: rgb(237, 245, 253); line-height: 50px;margin-bottom: 10px;">
      <el-button
        type="primary"
        class="iconfont"
        size="small"
        @click="GetHzbList('add')"
      >汇总表</el-button>
      <el-button
        type="primary"
        class="iconfont"
        size="small"
        @click="GetSbMxList('add')"
      >设备投资明细表</el-button>
      <el-button
        type="primary"
        class="iconfont icondaochu11"
        size="small"
        @click="exportXls('add')"
      >导出</el-button>
    </el-row>
    <ccsstzjchzbCompont
    v-show="hzDisable"
      ref="ccsstzjchzbCompont"
    ></ccsstzjchzbCompont>
    <ccsstzmxCompont v-show="!hzDisable" ref="ccssComponenMx"></ccsstzmxCompont>
  </div>
</template>

<script>
	import ccsstzjchzbCompont from "./ccsstzjchzbCompont.vue";
  import ccsstzmxCompont from "./ccsstzmxCompont.vue"
  export default {
	  components: { ccsstzjchzbCompont,ccsstzmxCompont },
    data() {
      return {
        hzDisable:true,
		orgCode:sessionStorage.getItem('orgCode'),
        formInline:{
          sbnf:new Date().getFullYear().toString(),
		  sskdmc:'',
		  ssqymc:'',
        },
      }
    },
    created() {
      // this.getTableData();
    },
	mounted() {
    this.GetHzbList()
	  // this.$refs.ccssComponentS.getList();
	},
    methods: {
      exportXls(){
        if(this.hzDisable){
        	var data={
        	 orgCode:sessionStorage.getItem('orgCode'),
        	 sbnf:this.formInline.sbnf
        	}
        	this.$refs.ccsstzjchzbCompont.exportExcel(data);
        }else{
        	var data={
        	   orgCode:sessionStorage.getItem('orgCode'),
        			 ...this.formInline
        	}
        	this.$refs.ccssComponenMx.exportExcel(data);
        }
      },
      //查询
      GetList(){
        if(this.hzDisable){
          this.GetHzbList()
        }else{
          this.GetSbMxList()
        }
      },
      //重置
      resetFun(formName){
		   this.$refs[formName].resetFields();
        this.formInline.sbnf=new Date().getFullYear().toString()
        if(this.hzDisable){
          this.GetHzbList()
        }else{
          this.GetSbMxList()
        }
      },
		GetHzbList() {
      this.hzDisable=true
      var data={
             orgCode:sessionStorage.getItem('orgCode'),
             sbnf:this.formInline.sbnf
          }
      this.$refs.ccsstzjchzbCompont.init(data,'ck');
		},
    GetSbMxList(){
      this.hzDisable=false
      var data={
             orgCode:sessionStorage.getItem('orgCode'),
             // sbnf:this.formInline.sbnf,
			 ...this.formInline
          }
      this.$refs.ccssComponenMx.init(data,'qu');
    },
      // 选中事件
      changeYear() {
        console.log("changeYear:", this.nf);
      },
      confirmReporting() {
        this.$confirm("是否确认上报数据?", "提示", {
          closeOnClickModal: false,
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.$message.success("上报成功");
        }).catch((err) => {
          this.$message.error(err);
        });
      }
    }
  }
</script>

<style scoped>
  .spanStyle {
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .spanStyleRight {
    display: flex;
    justify-content: right;
    align-items: right;
  }
</style>
