<!--
  @description: 建设项目审核-列表
  @author: 肖文龙
  @routerPath:/buildingProject/buildingProjectAuditList
  @date： 2019-12-4 18:42:19
-->
<template>
  <div>
    <!--标题-->
    <div class="title title_border p0-16">
      <i class="el-icon-s-home" />建设项目审核列表
    </div>
    <section class="p0-16">
      <!--查询条件-->
      <div class="crud_menu_title clearfix">
        <span class="icon-line fl">查询条件</span>
        <span class="fr pointer" @click="handleToggleSearch">
          <el-link
            :underline="false"
            :class="toggleSearchStatus?'arrow-is-active':''"
            type="primary"
            class="toggleSearchStatus icon el-icon-arrow-down"
          />
          {{ toggleSearchStatus?'收起高级查询' :'展开高级查询' }}
        </span>
      </div>
      <section :class="{'SearchContent_show':toggleSearchStatus}" class="clearfix SearchContent">
        <div class="SearchContent_leftInput fl">
          <el-form
            ref="searchForm"
            :model="searchForm"
            inline
            label-width="85px"
            label-position="left"
          >
            <!--批准文号-->
            <el-form-item ref="approvalNo" label="批准文号" prop="approvalNo">
              <el-input v-model.trim="searchForm.approvalNo" placeholder="批准文号" style="width:220px" />
            </el-form-item>
            <!--建设项目编码-->
            <el-form-item ref="projectNo" label="建设项目编码" prop="projectNo">
              <el-input v-model.trim="searchForm.projectNo" placeholder="建设项目编码" style="width:220px" />
            </el-form-item>
            <!--建设项目名称-->
            <el-form-item ref="projectName" label="建设项目名称" prop="projectName">
              <el-input v-model.trim="searchForm.projectName" placeholder="建设项目名称" style="width:220px" />
            </el-form-item>
            <!--创建人-->
            <el-form-item ref="createUser" label="创建人" prop="createUser">
              <el-input v-model.trim="searchForm.createUser" placeholder="创建人" style="width:220px" />
            </el-form-item>
            <!--提交日期-->
            <el-form-item ref="createTime" label="提交时间" prop="createTime">
              <el-date-picker
                v-model="searchForm.createTime"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                style="width:220px"
                value-format="yyyy-MM-dd"
                @change="handleCreateTime"
              />
            </el-form-item>
          </el-form>
        </div>
        <div class="fr">
          <el-button type="primary" @click="onSearch">
            搜 索
          </el-button>
          <el-button plain type="info" @click="resetForm('searchForm')">
            重 置
          </el-button>
        </div>
      </section>
      <!--查询结果-->
      <div class="crud_menu_title">
        <span class="icon-line">查询结果</span>
      </div>
      <section>
        <el-table
          ref="smallTable"
          v-loading="loading"
          :data="tableData"
        >
          <el-table-column type="index" label="序号" align="center" width="60" />
          <el-table-column
            prop="approvalNo"
            label="批准文号"
            header-align="center"
            align="left"
          />
          <el-table-column
            prop="projectNo"
            label="建设项目编码"
            min-width="120"
            header-align="center"
            align="center"
          />
          <el-table-column
            prop="projectName"
            label="建设项目名称"
            align="left"
            min-width="150"
            header-align="center"
          />
          <el-table-column
            prop="createUser"
            label="创建人"
            width="125"
            header-align="center"
            align="center"
          />
          <el-table-column
            prop="createTime"
            label="提交时间"
            header-align="center"
            align="center"
            width="150"
          >
            <template slot-scope="scope">
              {{ scope.row.createTime && $Moment(scope.row.createTime).format(momentDateTime) }}
            </template>
          </el-table-column>
          <el-table-column label="操作" header-align="center" align="center" width="80">
            <template slot-scope="scope">
              <el-link type="primary" @click.stop="audit(scope.row.id)">
                [审批]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
        <!--分页组件-->
        <pagination :pagination-data="paginationData" @change="loadData" />
      </section>
    </section>
  </div>
</template>

<script>
/* api接口*/
import { getConstructionProjectByPage } from '@/api/purchasePlan/taskplan'
/* 公共方法 */
import { ListMixin } from '@/mixins/ListMixin'
import { filterObj } from '@/assets/js/utils'
/* 分页组件*/
import pagination from '@comp/common/pagination/pagination'
export default {
  name: 'BuildingProjectAuditList',
  components: {
    pagination
  },
  mixins: [ListMixin],
  data() {
    return {
      loading: true,
      searchForm: {
        createTime: '', // 创建时间
        auditStatus: '00', // 审核状态
        approvalNo: '', // 批准文号
        projectNo: '', // 建设项目编码
        projectName: '', // 建设项目名称
        createUser: '', // 创建人
        createTimeStart: '',
        createTimeEnd: ''
      },
      tableData: []
    }
  },
  created() {
    this.loadData()
  },
  methods: {
    // 获取数据
    loadData() {
      const params = this.getQueryParams()// 查询条件
      params.auditStatus = '00'// 待审批
      getConstructionProjectByPage(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {
        this.loading = false
      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.page = this.paginationData.page
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 搜索
    onSearch() {
      this.paginationData.page = 1
      this.paginationData.pageSize = 10
      this.loadData()
    },
    // 重置
    resetForm(formName) {
      Object.keys(this.searchForm).forEach(val => {
        this.searchForm[val] = ''
      })
      this.$refs[formName].resetFields()
      this.searchForm.pageNo = 1
      this.searchForm.pageSize = 10
      this.loadData()
    },
    // 审核
    audit(id) {
      this.$router.push({
        path: '/buildingProject/buildingProjectAuditDetail',
        name: 'BuildingProjectAuditDetail',
        params: {
          detailType: '02', // 委托合同标题展示 00 查看建设项目 01 台账查看建设项目 02 审批建设项目
          id
        }
      })
    },
    // 创建时间
    handleCreateTime(val) {
      this.searchForm.createTimeStart = this.$Moment(val[0]).format(this.momentDate) // 创建开始时间
      this.searchForm.createTimeEnd = this.$Moment(val[1]).format(this.momentDate) // 创建结束时间
    }
  }
}
</script>

<style lang="less" scoped>
</style>
