<!--
  @description: 采购人/代理机构-委托代理合同审核-列表
  @author: 肖文龙
  @routerPath:/consignContract/consignContractAuditList
  @date： 2019-11-28 16:18:17
-->
<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
          >
            <!--委托合同编码-->
            <el-form-item ref="contractNo" label="委托合同编码" prop="contractNo">
              <el-input v-model.trim="searchForm.contractNo" placeholder="委托合同编码" />
            </el-form-item>
            <!--委托合同名称-->
            <el-form-item ref="contractName" label="委托合同名称" prop="contractName">
              <el-input v-model.trim="searchForm.contractName" placeholder="委托合同名称" />
            </el-form-item>
            <!--委托人-->
            <el-form-item ref="consignorName" label="委托人" prop="consignorName">
              <el-input v-model.trim="searchForm.consignorName" placeholder="委托人" />
            </el-form-item>
            <!--提交日期-->
            <el-form-item label="提交日期">
              <el-date-picker
                v-model="date"
                type="daterange"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                style="width:230px"
                @change="handleCreateTime"
              />
            </el-form-item>
            <!--创建人-->
            <el-form-item ref="createUserName" label="创建人" prop="createUserName">
              <el-input v-model.trim="searchForm.createUserName" placeholder="创建人" />
            </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"
          :data="tableData"
        >
          <el-table-column type="index" label="序号" align="center" width="60" />
          <el-table-column
            prop="contractNo"
            label="委托合同编码"
            header-align="center"
            width="120"
            align="center"
          />
          <el-table-column
            prop="contractName"
            label="委托合同名称"
            header-align="center"
          />
          <el-table-column
            prop="consignorName"
            label="委托人"
            header-align="center"
          />
          <el-table-column
            label="委托合同状态"
            align="center"
            header-align="center"
            width="120"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.useStatus==='00'">已保存</span>
              <span v-if="scope.row.auditStatus==='00'">待审批</span>
              <span v-if="scope.row.auditStatus==='01' && scope.row.useStatus!=='02'">已生效</span>
              <span v-if="scope.row.auditStatus==='02'">审核驳回</span>
              <span v-if="scope.row.contractStatus==='01'">已失效</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="createUserName"
            label="创建人"
            align="center"
            width="120"
            header-align="center"
          />
          <el-table-column
            prop="submitAuditDate"
            label="提交时间"
            width="125"
            align="center"
            header-align="center"
          >
            <template slot-scope="scope">
              <span>{{ scope.row.submitAuditDate && $Moment(scope.row.submitAuditDate).format(momentDateTime) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" 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>
import { getContractByPage } from '@/api/purchasePlan/taskplan'
import { ListMixin } from '@/mixins/ListMixin'
import { consignContractMixin } from '../mixins/consignContractMixin'// 字典信息
import { filterObj } from '@/assets/js/utils'
import pagination from '@comp/common/pagination/pagination'
export default {
  name: 'ConsignContractAuditList',
  components: {
    pagination
  },
  mixins: [ListMixin, consignContractMixin],
  data() {
    return {
      date: '',
      searchForm: {
        contractNo: '', // 委托合同编码
        contractName: '', // 委托合同名称
        consignorName: '', // 委托人姓名
        submitAuditStartDate: '', // 创建开始时间
        submitAuditEndDate: '', // 创建结束时间
        createUserName: '' // 创建人
      },
      tableData: []
    }
  },
  created() {
    this.loadData()
  },
  methods: {
    // 获取数据
    loadData() {
      const params = this.getQueryParams()// 查询条件
      params.status = '01' // 审核状态
      getContractByPage(params).then(response => {
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {

      })
    },
    handleCreateTime(val) {
      this.searchForm.submitAuditStartDate = this.$Moment(val[0]).format(this.momentDate)// 创建开始时间
      this.searchForm.submitAuditEndDate = this.$Moment(val[1]).format(this.momentDate)// 创建结束时间
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 搜索
    onSearch() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.loadData()
    },
    // 重置
    resetForm() {
      Object.keys(this.searchForm).forEach(val => {
        this.searchForm[val] = ''
      })
      this.date = ''
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.loadData()
    },
    // 审核
    audit(id) {
      this.$router.push({
        path: '/consignContract/consignContractAuditDetail',
        name: 'ConsignContractAuditDetail',
        params: {
          detailType: '02', // 委托合同标题展示 00 查看委托合同 01 台账查看委托合同 02 审批委托合同
          id
        }
      })
    }
  }
}
</script>

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