<template>
  <div class="app-container">
    <el-form class="secbox" :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="88px">
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="项目编号" prop="noticeTitle">
            <el-input
              v-model="queryParams.noticeTitle"
              placeholder="输入项目编号"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="创建日期" prop="noticeTitle">
            <el-date-picker
                  v-model="queryParams.value1"
                  type="date"
                  placeholder="年 / 月 / 日">
                </el-date-picker>
          </el-form-item>
        </el-col>
        
        <!-- <el-col :span="8">
          <el-form-item label="逾期程度" prop="createBy">
            <el-select v-model="value" placeholder="选择建设内容">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
          </el-form-item>
        </el-col> -->
        <el-col :span="8">
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <!-- 列表 -->
    <!-- 标签页 -->
    <div class="tabs">
        <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane name="first">
              <div slot="label" class="tab flexc">
                <img class="tabimg" v-if="activeName=='first'" src="@/assets/images/project/taba_.png"/>
                <img class="tabimg" v-else src="@/assets/images/project/taba.png"/>
                <span>签约环节(6)
                </span>
              </div>
              <!-- 列表数据 -->
            </el-tab-pane>
            <el-tab-pane  name="second">
              <div slot="label" class="tab flexc">
                <img class="tabimg" v-if="activeName=='second'" src="@/assets/images/project/tabb_.png"/>
                <img class="tabimg" v-else src="@/assets/images/project/tabb.png"/>
                <span>开工环节(2)
                </span>
              </div>
            </el-tab-pane>
            <el-tab-pane  name="third">
              <div slot="label" class="tab flexc">
                <img class="tabcimg" v-if="activeName=='third'" src="@/assets/images/project/tabc_.png"/>
                <img class="tabcimg" v-else src="@/assets/images/project/tabc.png"/>
                <span>建设环节(5)
                </span>
              </div>
              </el-tab-pane>
            <el-tab-pane  name="fourth">
              <div slot="label" class="tab flexc">
                <img class="tabdimg" v-if="activeName=='fourth'" src="@/assets/images/project/tabd_.png"/>
                <img class="tabdimg" v-else src="@/assets/images/project/tabd.png"/>
                <span>投产环节(2)
                </span>
              </div>
              </el-tab-pane>
          </el-tabs>

          <div class="btns flexcc">
            <!-- <div class="btna coa flexc">
              <img  src="@/assets/images/project/yqicoa.png"/>一般逾期
            </div>
            <div class="btna cob flexc">
              <img  src="@/assets/images/project/yqicob.png"/>严重逾期
            </div> -->
            <div style="width: 25px;"></div>
            <!-- <el-button type="success"  class="cbbtn"  size="small">一键催办</el-button> -->
            <el-button type="primary" plain   size="small" @click="hadeadd">创建</el-button>
            <el-button type="success"  class="cbbtn" size="small" @click="handleExport">导出</el-button>
          </div>
		  <div class="blist" >
		    <boxlist v-if="isgse" type="xmgl" :datalist="liesse"></boxlist>
		  </div>
		  
          <Pagination
            v-show="total>0"
            :total="total"
            background
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
    </div>

  </div>
</template>

<script>
// import { listNotice, getNotice, delNotice, addNotice, updateNotice } from "@/api/system/notice"
import { listQyxx, getQyxx, delQyxx, addQyxx, updateQyxx } from "@/api/zhaoshang/qyxx" 
import firstInfoForm from "./firstInfoForm"
import boxlist from "./boxlist.vue"
export default {
  name: "Notice",
  dicts: ['sys_notice_status', 'sys_notice_type'],
  components:{
    boxlist
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
	  ishsouetan:false,
      // 总条数
      total: 0,
	  liesse:{},
      // 公告表格数据
      noticeList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
       pageNum: 1,
               pageSize: 10,
               xmId: null,
               xmbh: null,
               xmmc: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        noticeTitle: [
          { required: true, message: "公告标题不能为空", trigger: "blur" }
        ],
        noticeType: [
          { required: true, message: "公告类型不能为空", trigger: "change" }
        ]
      },
	  tableMaxHeight:380,
	  num:5,
    value:'',
    options: [{
              value: '选项1',
              label: '黄金糕'
            }, {
              value: '选项2',
              label: '双皮奶'
            }],
       activeName:'first',
       info:{},
	   isgse:false
    }
  },
  created() {
    this.getList()
  },
  computed: {
    dynamicStyle() {
      return {
        overflow:'auto',
        height:  this.tableMaxHeight + 'px',
      }
    }
    },
  methods: {
    /** 查询公告列表 */
	
    getList() {
      this.loading = true
	  this.isgse = false
      listQyxx(this.queryParams).then(response => {
        this.noticeList = response.rows
		this.liesse.noticeList = response.rows
		console.log(this.liesse)
        this.total = response.total
		this.isgse = true
        this.loading = false
      })
    },
    handleClick(){
	 if(this.activeName == 'first'){
		 this.queryParams.progress = 1
		 this.getList()
	 }else if(this.activeName == 'second'){
		 this.queryParams.progress = 2
		 this.getList()
	 }else if(this.activeName == 'third'){
		 this.queryParams.progress = 3
		 this.getList()
	 }else if(this.activeName == 'fourth'){
		 this.queryParams.progress = 4
		 this.getList()
	 }
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
              jsxxId: null,
              xmId: null,
              xmbh: null,
              xmmc: null,
              beginTime: null,
              endTime: null,
              jgTime: null,
              rtTime: null,
              createBy: null,
              createTime: null,
              updateBy: null,
              updateTime: null,
              remark: null
            }
      this.resetForm("form")
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm")
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.qyxxId)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },
	hadeadd(){
		this.$router.push({
		  path: '/zhaoshang/add',
		  query: {
		  	'id':-1,
		  }
		})
	},
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = "添加公告"
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const qyxxId = row.qyxxId || this.ids
      getNotice(qyxxId).then(response => {
        this.form = response.data
        this.open = true
        this.title = "修改公告"
      })
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.qyxxId != undefined) {
            updateQyxx(this.form).then(response => {
              this.$modal.msgSuccess("修改成功")
              this.open = false
              this.getList()
            })
          } else {
            addQyxx(this.form).then(response => {
              this.$modal.msgSuccess("新增成功")
              this.open = false
              this.getList()
            })
          }
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const qyxxIds = row.qyxxId || this.ids
	  delQyxx(qyxxIds).then(response => {
	    this.$modal.msgSuccess("删除成功")
	    this.getList()
	  })
    },
	handleExport() {
	      this.download('zhaoshangV3/qyxx/export', {
	        ...this.queryParams
	      }, `qyxx_${new Date().getTime()}.xlsx`)
	    }
  }
}
</script>
<style scoped lang="scss">
::v-deep{
  .secbox{
    .el-button{padding: 9px 15px;}
    .el-form-item__label{line-height: 40px;}
    // .el-input__inner{height: 40px;line-height: 40px;}
    // .el-form-item{min-width: 25%;}
  }
  .tabs{
    .el-tabs__item{padding-right: 0;color: #666666;line-height: 45px;height: 45px;padding-left: 0;}
    .is-active{color: #2777D0;font-weight: bold;}
  }
  .pagination-container{margin-top: 8px;}
}
.secbox{background: #FFFFFF;
border-radius: 4px;padding: 25px 16px 7px;margin-bottom: 15px;}
.tabs{position: relative;background: #FFFFFF;padding-bottom: 25px;
  .tab{padding: 0 21px;}
  .tabimg{width: 14px;height: 14px;margin-right: 8px;}
  .tabcimg{width: 13px;height: 13px;margin-right: 9px;}
  .tabdimg{width: 14px;height: 15px;margin-right: 8px;}
  .btns{height: 45px;box-sizing: border-box;position: absolute;right: 0;top: 0;
    .btna{margin-left: 28px;font-weight: bold;
font-size: 14px;
    &.coa{color: #FE960E;}
    &.cob{color: #FF6969;}
      img{width: 12px;height: 14px;margin-right: 7px;}
    }
  }
  .cbbtn{padding: 0 12px;height: 32px;line-height: 32px;border-radius: 4px;font-weight: bold;
font-size: 14px;
color: #FFFFFF;}
.blist{padding: 10px 16px 0;}
}
</style>
