<!--
  @description: 信用库管理
  @Modifier: haofengxian
  @routerPath:/supperManagement/creditLibraryManageList
  @date: 2022-02-23-18:06
-->
<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="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="qualificationsType" label="来源" prop="qualificationsType">
              <el-select v-model="searchForm.qualificationsType" placeholder="请选择" style="width:220px;">
                <el-option
                  v-for="item in supplierQualificationsTypeGroup"
                  :key="item.typecode"
                  :label="item.typename"
                  :value="item.typecode"
                />
              </el-select>
            </el-form-item>
            <el-form-item ref="regcapitalBegin" label="注册资金(万元)" prop="regcapitalBegin">
              <p style="display:flex;width:220px;">
                <el-input v-model="searchForm.regcapitalBegin" placeholder="请输入" width="88px" />~
                <el-input v-model="searchForm.regcapitalEnd" placeholder="请输入" width="88px" />
              </p>
            </el-form-item>
            <el-form-item ref="supplierType" label="类别" prop="supplierType">
              <el-select v-model="searchForm.supplierType" placeholder="请选择" style="width:220px;">
                <el-option
                  v-for="item in supplierTypeCodeGroup"
                  :key="item.typecode"
                  :label="item.typename"
                  :value="item.typecode"
                />
              </el-select>
            </el-form-item>
            <el-form-item ref="supplyScopeId" label="供货范围" prop="supplyScopeId">
              <el-input v-model.trim="searchForm.supplyScope" style="width: 220px" @focus="dialogData.dialog=true" />
            </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="date" label="注册日期" prop="date">
              <el-date-picker
                v-model="searchForm.createTime"
                :value-format="elValueSaveFormat"
                type="daterange"
                range-separator="-"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                style="width:220px"
              />
            </el-form-item>
            <el-form-item ref="areaValue" label="所属地区" prop="areaValue">
              <el-input v-model="searchForm.areaValue" placeholder="所属地区" 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"
          v-loading="loading"
          :data="tableData"
        >
          <el-table-column
            type="index"
            label="序号"
            width="60px"
            fixed="left"
            align="center"
          />
          <el-table-column

            fixed="left"
            header-align="center"
            prop="supplierName"
            label="供应商名称"
            min-width="200"
          >
            <template slot-scope="scope">
              <el-link
                :underline="false"
                type="primary"
                @click="examineSupplierInfo(scope.row)"
              >
                {{ scope.row.supplierName }}
              </el-link>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="linkerName"
            label="经办人"
            min-width="110"
          />
          <el-table-column
            align="center"
            prop="linkerTel"
            label="联系电话"
            width="110"
          />
          <el-table-column

            align="center"
            label="类别"
            prop="supplierType"
            min-width="160"
          >
            <template slot-scope="scope">
              {{ filterDictText(supplierTypeCodeGroup,scope.row.supplierType ) }}
            </template>
          </el-table-column>
          <el-table-column

            header-align="center"
            label="供货范围"
            prop="supplyScope"
            min-width="200"
          />
          <el-table-column

            label="申报单位"
            prop="departNames"
            header-align="center"
            min-width="200"
          />
          <el-table-column
            label="来源"
            prop="qualificationsType"
            align="center"
            width="110"
          >
            <template slot-scope="scope">
              {{ filterDictText(supplierQualificationsTypeGroup,scope.row.qualificationsType ) }}
            </template>
          </el-table-column>
          <el-table-column
            header-align="center"
            label="注册资金(万元)"
            prop="regcapital"
            align="right"
            width="120"
          />
          <el-table-column

            label="所属地区"
            prop="areaValue"
            min-width="200"
          />
          <el-table-column

            label="营业执照代码"
            prop="businesslicence"
            align="center"
            min-width="160"
          />
          <el-table-column
            label="注册日期"
            prop="createTime"
            align="center"
            width="130"
          >
            <template slot-scope="scope">
              <span>
                {{ scope.row.createTime && $Moment(scope.row.createTime).format(momentDateTime) }}
              </span>
            </template>
          </el-table-column>
          <!--<el-table-column
            fixed="right"
            header-align="center"
            label="操作"
            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="loadData" />
      </section>
    </section>
    <!-- 供货范围 -->
    <category-tree-dialog :dialog-data="dialogData" @categoryTreeInfo="categoryTreeInfo" />
    <!-- 供应商信息查看-弹框 -->
    <editorDeclarationDetailDialong ref="supplierInfo" />
  </div>
</template>
<script>
/* 接口*/
import { listSupplierRepositoryPagesByAll } from '@/api/supplier/declaraTionrecord'
/* 公用方法*/
import { filterObj, filterDictText, restoreInitialValue } from '@/assets/js/utils'// 常用方法
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
import { supplierGroupMixin } from '../mixins/supplierGroupMixin'
import { declareHegSupperGroupMixin } from '../editorDeclaration/mixins/declareHegSupperGroupMixin'

/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
import categoryTreeDialog from '@/views/common/tools/categoryTree-dialog'// 供货范围
import editorDeclarationDetailDialong from '@/views/supplier/editorDeclaration/editorDeclarationContent/editorDeclarationDetail-dialog'// 供应商信息查看

export default {
  name: 'ProjectManagerTenderList',
  components: {
    categoryTreeDialog, // 供货范围
    pagination, // 分页
    editorDeclarationDetailDialong // 供应商信息查看-弹框
  },
  mixins: [ListMixin, supplierGroupMixin, declareHegSupperGroupMixin],
  data() {
    return {
      loading: true,
      // ----------------------------------------
      // 弹窗-展示/隐藏状态 true 展示/false 隐藏
      dialogData: {
        title: '供货范围',
        dialog: false, // 产品分类
        selectCodes: [] // 当前选中的供货范围Code
      },
      // 搜索
      searchForm: {
        supplierName: '', // 供应商名称
        linkerName: '', // 经办人
        qualificationsType: '', // 来源
        regcapitalBegin: '', // 注册资金开始
        regcapitalEnd: '', // 注册资金结束
        supplierType: '', // 类别
        supplyScope: '', // 供货范围名称
        supplyScopeId: '', // 供货范围id
        businesslicence: '', // 营业执照代码
        createTime: [], // 注册时间
        createTimeBegin: '', // 注册开始时间
        createTimeEnd: '', // 注册结束时间
        areaValue: '' // 所属地区
      },
      tableData: []
    }
  },
  created() {
    // 查询字典
    this.getDeclarationDictionariesGroup()
    // 获取列表信息
    this.loadData()
  },
  methods: {
    filterDictText,
    // 获取数据
    loadData() {
      const params = this.getQueryParams()// 查询条件
      listSupplierRepositoryPagesByAll(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.tableData.forEach(item => {
          // 金额保留两位小数
          item.regcapital = item.regcapital ? Number(item.regcapital).toFixed(2) : '0.00'
        })
        this.paginationData.total = response.data.total
      }).catch(() => {

      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.createTimeBegin = param.createTime[0] // 查询注册开始间
      param.createTimeEnd = param.createTime[1]// 查询结束开始间
      // 删除不需要的参数
      delete param.createTime
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 查看
    intoProject(row) {
      this.$router.push({
        path: '/supperManagement/supplierOrganizationInfoDetail',
        query: {
          departId: row.supplierId
        }
      })
    },
    // 供货范围选择/清空
    categoryTreeInfo(data) {
      this.searchForm.supplyScope = data.labels
      this.searchForm.supplyScopeId = data.keys
      this.dialogData.selectCodes = data.keys.split(',')
    },
    // 搜索
    onSearch() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      // 获取列表信息
      this.loadData()
    },
    // 重置
    resetForm() {
      // 初始化参数
      restoreInitialValue(this.searchForm)
      // 获取列表信息
      this.onSearch()
    },
    // 供应商信息-弹框
    examineSupplierInfo(row) {
      this.$refs.supplierInfo.open(row.id)// 供应商主键id
    }
  }
}
</script>
<style lang="less" scoped>
</style>
