<!--
  @description: 供应商查询-供应商资源库列表-合格供应商库-需要申报不含下级机构
  @author: qink/郝凤仙
  @routerPath:
  @date:  2020/4/9 16:04
-->
<template>
  <div>
    <div class="main">
      <!--查询条件-->
      <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="supplierName" label="供应商名称" prop="supplierName">
              <el-input v-model="searchForm.supplierName" placeholder="请输入" style="width:220px" />
            </el-form-item>
            <el-form-item ref="linkerName" label="经办人" prop="linkerName">
              <el-input v-model="searchForm.linkerName" placeholder="请输入" style="width:220px" />
            </el-form-item>
            <el-form-item ref="linkerTel" label="联系电话" prop="linkerTel">
              <el-input v-model="searchForm.linkerTel" placeholder="请输入" style="width:220px" />
            </el-form-item>
            <el-form-item ref="businesslicence" label="营业执照代码" prop="businesslicence">
              <el-input v-model="searchForm.businesslicence" 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"
                @change="handleCreateTime"
              />
            </el-form-item>
            <el-form-item ref="tenderRedss" label="申报单位" prop="tenderRedss">
              <el-input v-model="searchForm.tenderRedss" style="width:220px" />
            </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"
          width="100%"
        >
          <el-table-column
            type="index"
            label="序号"
            fixed
            width="60px"
            align="center"
          />
          <el-table-column

            prop="supplierName"
            fixed
            label="供应商名称"
            min-width="260"
          />
          <el-table-column
            header-align="center"
            prop="linkerName"
            label="经办人"
            min-width="75"
          />
          <el-table-column
            header-align="center"
            label="联系电话"
            prop="linkerTel"
            min-width="110"
          />
          <el-table-column

            label="供货范围"
            prop="supplyScope"
            min-width="110"
          />
          <el-table-column

            label="申报单位"
            prop="departNames"
            min-width="110"
          />
          <el-table-column
            label="来源"
            prop="qualificationsType"
            align="center"
            width="110"
          >
            <template slot-scope="scope">
              <span
                v-for="(item) in supplierQualificationsTypeGroup"
                v-if="scope.row.qualificationsType === item.typecode"
                :key="item.typecode"
              >{{ item.typename }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="营业执照代码"
            prop="businesslicence"
            min-width="110"
          />
          <el-table-column
            label="注册日期"
            prop="createTime"
            align="center"
            width="130"
          >
            <template slot-scope="scope">
              {{ scope.row.createTime && $Moment(scope.row.createTime).format(momentDateTime) }}
            </template>
          </el-table-column>
          <el-table-column
            header-align="center"
            label="操作"
            fixed="right"
            align="center"
            width="80"
          >
            <template slot-scope="scope">
              <el-link
                type="primary"
                @click="intoProject(scope.row)"
              >
                [查看]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
        <!--分页组件-->
        <pagination :pagination-data="paginationData" @change="getSupplyEnquiry" />
      </section>
    </div>
  </div>
</template>
<script>
import { listSupplierRepositoryPagesBySupply } from '@api/supplier/declaraTionrecord'
import pagination from '@comp/common/pagination/pagination'// 分页
import { ListMixin } from '@/mixins/ListMixin'// 分页
import { filterObj, restoreInitialValue } from '@/assets/js/utils'// 常用方法
import { supplierGroupMixin } from '../mixins/supplierGroupMixin'

export default {
  name: 'SupplyEnquiryChildrenList',
  components: {
    pagination // 分页
  },
  mixins: [ListMixin, supplierGroupMixin],
  data() {
    return {
      // 搜索
      searchForm: {
        supplierName: '', // 供应商名称
        linkerName: '', // 经办人
        linkerTel: '', // 联系电话
        supplyScopeId: '', // 供货范围id
        businesslicence: '', // 营业执照代码
        createTime: [], // 注册时间
        createTimeBegin: '', // 注册开始时间
        createTimeEnd: '', // 注册结束时间
        areaValue: '' // 所属地区
      },
      tableData: []
    }
  },
  created() {
    // 获取字典-申报记录部分
    this.getDeclarationDictionariesGroup()
  },
  methods: {
    // 查看
    intoProject() {
      this.$router.push('/supperManagement/wareHousingAuditeds')
    },
    // 组装搜索数据
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      // 删除不需要的参数
      delete param.createTime
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 获取数据
    getSupplyEnquiry(id) {
      this.searchForm.supplyScopeId = id || this.searchForm.supplyScopeId
      const params = this.getQueryParams()// 查询条件
      listSupplierRepositoryPagesBySupply(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {
        this.loading = false
      })
    },
    // 处理搜索时间格式
    handleCreateTime(val) {
      if (val) {
        this.searchForm.createTimeBegin = this.$Moment(val[0]).format(this.momentSaveFormat)// 创建开始时间
        this.searchForm.createTimeEnd = this.$Moment(val[1]).format(this.momentSaveFormat)// 创建结束时间
      }
    },
    // 搜索
    onSearch() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.getSupplyEnquiry()
    },
    // 重置
    resetForm(formName) {
      const id = this.searchForm.supplyScopeId
      restoreInitialValue(this.searchForm)
      this.searchForm.supplyScopeId = id
      this.onSearch()
    }
  }
}
</script>
<style lang="less" scoped>
.no_wrap {
  white-space: nowrap;
  text-overflow: ellipsis;
}
.left-tree {
  float: left;
  // margin-right: 10px;
  width: 15%;

  .tree-container {
    overflow: auto;
    height: 75vh;
  }

  .tree {
    width: 5000px;
  }
}

.scrollbar {
  height: 80vh;
}

.filter-container {
  margin: 30px 20px !important;
}
.wrap_i {
  display: flex;
  width: 100%;
  justify-content: space-between;
}
</style>
