<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="厂家名称" prop="factoryName">
        <el-input
          v-model="queryParams.factoryName"
          placeholder="请输入厂家名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <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-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['biz:score:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['biz:score:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['biz:score:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          v-hasPermi="['biz:score:import']"
        >训练数据集导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['biz:score:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5" >
        <el-button type="primary" size="mini" @click="mytrain">训练</el-button>

      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="scoreList" @selection-change="handleSelectionChange" >
      <el-table-column type="selection" width="55" align="center" />

      <el-table-column label="厂家名称" align="center" prop="factoryName"  />
      <el-table-column label="生产线运行情况良好" align="center" prop="factor1" width="140"/>
      <el-table-column label="生产过程耗材稳定供应" align="center" prop="factor2" width="170"/>
      <el-table-column label="定期进行生产线维护保养" align="center" prop="factor3" width="180"/>
      <el-table-column label="质量体系完善且运行情况良好" align="center" prop="factor4" width="200"/>
      <el-table-column label="建立了与配套元器件生产相适应的生产管理系统且运行情况良好" align="center" prop="factor5" width="400"/>
      <el-table-column label="重要岗位人员定期进行专业培训" align="center" prop="factor6" width="210"/>
      <el-table-column label="产品批次管理有具体文件内容规定，是否有管理责任人" align="center" prop="factor7" width="380"/>
      <el-table-column label="未发生过因产品批次问题引起的交付问题" align="center" prop="factor8" width="300"/>
      <el-table-column label="产品全寿命周期可追溯，质量一致性高" align="center" prop="factor9" width="320" />
      <el-table-column label="生产工艺已完成定型，且有相关产品生产经历" align="center" prop="factor10" width="280"/>
      <el-table-column label="有明确生产过程控制技术手段" align="center" prop="factor11" width="270" />
      <el-table-column label="关键工序有明确的评价准则、严格的监控措施和完整记录" align="center" prop="factor12" width="370" />
      <el-table-column label="芯片的合格率水平满足要求" align="center" prop="factor13" width="240"/>
      <el-table-column label="封装的合格率水平满足要求" align="center" prop="factor14" width="240" />
      <el-table-column label="未发生过中重大失效问题" align="center" prop="factor15" width="230" />
      <el-table-column label="针对重大失效问题，建立有应急处理机制，且严格执行。" align="center" prop="factor16" width="350"/>
      <el-table-column label="针对不同的核心零部件，由相应的采购策略" align="center" prop="factor17" width="320" />
      <el-table-column label="具有稳定可靠的供货渠道" align="center" prop="factor18" width="250"/>
      <el-table-column label="核心零部件检验制度完善" align="center" prop="factor19" width="250"/>
      <el-table-column label="无重大质量问题发生" align="center" prop="factor20" width="230"/>
      <el-table-column label="生产产能充足" align="center" prop="factor21" width="210"/>
      <el-table-column label="产能调度分配机制成熟完善，能够满足要求" align="center" prop="factor22" width="320"/>
      <el-table-column label="根据产品自身和用户应用需求特点，建立合理的库存策略" align="center" prop="factor23" width="380"/>
      <el-table-column label="针对有供货风险的零部件有合理的进出库管理策略" align="center" prop="factor24" width="360"/>
      <el-table-column label="温湿度等存储环境条件满足要求" align="center" prop="factor25" width="260"/>
      <el-table-column label="有稳定的核心零部件、半成品/成品库存量" align="center" prop="factor26" width="340" />
      <el-table-column label="该产品符合技术发展趋势，为企业主攻主流产品" align="center" prop="factor27" width="360"/>
      <el-table-column label="产品用户市场需求量大，有长期生产、供货意愿和策略，有相关产品系列化发展策略" align="center" prop="factor28" width="508"/>
      <el-table-column label="制定有完善的元器件状态管控制度或措施，且有效执行" align="center" prop="factor29" width="340"/>
      <el-table-column label="器件状态清晰明确，且状态变更过程完全受控" align="center" prop="factor30" width="320"/>
      <el-table-column label="产品供货周期合理，能满足用户采购要求" align="center" prop="factor31" width="300"/>
      <el-table-column label="最小起订量设置合理" align="center" prop="factor32" width="200"/>
      <el-table-column label="制定有相应的供应商准入、选择、评价等制度，并严格执行" align="center" prop="factor33" width="370"/>
      <el-table-column label="有长期稳定合作的核心关键的外协单位" align="center" prop="factor34" width="320"/>
      <el-table-column label="能够及时为用户提供应用全过程的技术售后服务" align="center" prop="factor35" width="300"/>
      <el-table-column label="了解用户对于国产元器件的应用需求及其发展趋势，了解用户的配套供货需求" align="center" prop="factor36" width="480"/>
      <el-table-column label="制定了健全的稳定核心人员的措施，并有效执行" align="center" prop="factor37" width="320"/>
      <el-table-column label="成立有专门的军品管理部门和科研生产技术团队，核心团队稳定" align="center" prop="factor38" width="400"/>
      <el-table-column label="核心人员均具备相应的专业知识和技术能力" align="center" prop="factor39" width="300"/>
      <el-table-column label="建立了良好的成本管控措施" align="center" prop="factor40" width="240"/>
      <el-table-column label="能够承担产品生产、配套相关成本，能够持续盈利" align="center" prop="factor41" width="320"/>
      <el-table-column label="经济性好，企业能够持续获利" align="center" prop="factor42" width="250"/>
      <el-table-column label="和供应链各节点单位之间建立了良好的信息沟通机制，能有效沟通信息，协调解决问题" align="center" prop="factor43" width="514"/>
      <el-table-column label="产品推广应用情况良好，市场认可度高，客户满意度高" align="center" prop="factor44" width="340"/>
      <el-table-column label="最终等级" align="center" prop="finalGrade" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['biz:score:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['biz:score:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改厂家得分对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="500px">
        <el-form-item label="厂家名称" prop="factoryName">
          <el-input v-model="form.factoryName" placeholder="请输入厂家名称" />

        </el-form-item>
        <el-form-item label="生产线运行情况良好" prop="factor1">

          <el-select v-model="form.factor1" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="生产过程耗材稳定供应" prop="factor2">
<!--          <el-input v-model="form.factor2" placeholder="请输入生产过程耗材稳定供应" />-->
          <el-select v-model="form.factor2" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="定期进行生产线维护保养" prop="factor3">
<!--          <el-input v-model="form.factor3" placeholder="请输入定期进行生产线维护保养" />-->
          <el-select v-model="form.factor3" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="质量体系完善且运行情况良好" prop="factor4">
<!--          <el-input v-model="form.factor4" placeholder="请输入质量体系完善且运行情况良好" />-->
          <el-select v-model="form.factor4"  >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="建立了与配套元器件生产相适应的生产管理系统且运行情况良好" prop="factor5">
<!--          <el-input v-model="form.factor5" placeholder="请输入建立了与配套元器件生产相适应的生产管理系统且运行情况良好" />-->
          <el-select v-model="form.factor5" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="重要岗位人员定期进行专业培训" prop="factor6">
<!--          <el-input v-model="form.factor6" placeholder="请输入重要岗位人员定期进行专业培训" />-->
          <el-select v-model="form.factor6" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="产品批次管理有具体文件内容规定，是否有管理责任人" prop="factor7">
<!--          <el-input v-model="form.factor7" placeholder="请输入产品批次管理有具体文件内容规定，是否有管理责任人" />-->
          <el-select v-model="form.factor7" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="未发生过因产品批次问题引起的交付问题" prop="factor8">
<!--          <el-input v-model="form.factor8" placeholder="请输入未发生过因产品批次问题引起的交付问题" />-->
          <el-select v-model="form.factor8" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="产品全寿命周期可追溯，质量一致性高" prop="factor9">
<!--          <el-input v-model="form.factor9" placeholder="请输入产品全寿命周期可追溯，质量一致性高" />-->
          <el-select v-model="form.factor9" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="生产工艺已完成定型，且有相关产品生产经历" prop="factor10">
<!--          <el-input v-model="form.factor10" placeholder="请输入生产工艺已完成定型，且有相关产品生产经历" />-->
          <el-select v-model="form.factor10" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="有明确生产过程控制技术手段" prop="factor11">
<!--          <el-input v-model="form.factor11" placeholder="请输入有明确生产过程控制技术手段" />-->
          <el-select v-model="form.factor11" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="关键工序有明确的评价准则、严格的监控措施和完整记录" prop="factor12">
<!--          <el-input v-model="form.factor12" placeholder="请输入关键工序有明确的评价准则、严格的监控措施和完整记录" />-->
          <el-select v-model="form.factor12" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="芯片的合格率水平满足要求" prop="factor13">
<!--          <el-input v-model="form.factor13" placeholder="请输入芯片的合格率水平满足要求" />-->
          <el-select v-model="form.factor13" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="封装的合格率水平满足要求" prop="factor14">
<!--          <el-input v-model="form.factor14" placeholder="请输入封装的合格率水平满足要求" />-->
          <el-select v-model="form.factor14" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="未发生过中重大失效问题" prop="factor15">
<!--          <el-input v-model="form.factor15" placeholder="请输入未发生过中重大失效问题" />-->
          <el-select v-model="form.factor15" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="针对重大失效问题，建立有应急处理机制，且严格执行。" prop="factor16">
<!--          <el-input v-model="form.factor16" placeholder="请输入针对重大失效问题，建立有应急处理机制，且严格执行。" />-->
          <el-select v-model="form.factor16" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="针对不同的核心零部件，由相应的采购策略" prop="factor17">
<!--          <el-input v-model="form.factor17" placeholder="请输入针对不同的核心零部件，由相应的采购策略" />-->
          <el-select v-model="form.factor17" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="具有稳定可靠的供货渠道" prop="factor18">
<!--          <el-input v-model="form.factor18" placeholder="请输入具有稳定可靠的供货渠道" />-->
          <el-select v-model="form.factor18" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="核心零部件检验制度完善" prop="factor19">
<!--          <el-input v-model="form.factor19" placeholder="请输入核心零部件检验制度完善" />-->
          <el-select v-model="form.factor19" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="无重大质量问题发生" prop="factor20">
<!--          <el-input v-model="form.factor20" placeholder="请输入无重大质量问题发生" />-->
          <el-select v-model="form.factor20" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="生产产能充足" prop="factor21">
<!--          <el-input v-model="form.factor21" placeholder="请输入生产产能充足" />-->
          <el-select v-model="form.factor21" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="产能调度分配机制成熟完善，能够满足要求" prop="factor22">
<!--          <el-input v-model="form.factor22" placeholder="请输入产能调度分配机制成熟完善，能够满足要求" />-->
          <el-select v-model="form.factor22" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="根据产品自身和用户应用需求特点，建立合理的库存策略" prop="factor23">
<!--          <el-input v-model="form.factor23" placeholder="请输入根据产品自身和用户应用需求特点，建立合理的库存策略" />-->
          <el-select v-model="form.factor23" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="针对有供货风险的零部件有合理的进出库管理策略" prop="factor24">
<!--          <el-input v-model="form.factor24" placeholder="请输入针对有供货风险的零部件有合理的进出库管理策略" />-->
          <el-select v-model="form.factor24" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="温湿度等存储环境条件满足要求" prop="factor25">
<!--          <el-input v-model="form.factor25" placeholder="请输入温湿度等存储环境条件满足要求" />-->
          <el-select v-model="form.factor25" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="有稳定的核心零部件、半成品/成品库存量" prop="factor26">
<!--          <el-input v-model="form.factor26" placeholder="请输入有稳定的核心零部件、半成品/成品库存量" />-->
          <el-select v-model="form.factor26" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="该产品符合技术发展趋势，为企业主攻主流产品" prop="factor27">
<!--          <el-input v-model="form.factor27" placeholder="请输入该产品符合技术发展趋势，为企业主攻主流产品" />-->
          <el-select v-model="form.factor27" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="产品用户市场需求量大，有长期生产、供货意愿和策略，有相关产品系列化发展策略" prop="factor28">
<!--          <el-input v-model="form.factor28" placeholder="请输入产品用户市场需求量大，有长期生产、供货意愿和策略，有相关产品系列化发展策略" />-->
          <el-select v-model="form.factor28" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="制定有完善的元器件状态管控制度或措施，且有效执行" prop="factor29">
<!--          <el-input v-model="form.factor29" placeholder="请输入制定有完善的元器件状态管控制度或措施，且有效执行" />-->
          <el-select v-model="form.factor29" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="器件状态清晰明确，且状态变更过程完全受控" prop="factor30">
<!--          <el-input v-model="form.factor30" placeholder="请输入器件状态清晰明确，且状态变更过程完全受控" />-->
          <el-select v-model="form.factor30" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="产品供货周期合理，能满足用户采购要求" prop="factor31">
<!--          <el-input v-model="form.factor31" placeholder="请输入产品供货周期合理，能满足用户采购要求" />-->
          <el-select v-model="form.factor31" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="最小起订量设置合理" prop="factor32">
<!--          <el-input v-model="form.factor32" placeholder="请输入最小起订量设置合理" />-->
          <el-select v-model="form.factor32" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="制定有相应的供应商准入、选择、评价等制度，并严格执行" prop="factor33">
<!--          <el-input v-model="form.factor33" placeholder="请输入制定有相应的供应商准入、选择、评价等制度，并严格执行" />-->
          <el-select v-model="form.factor33" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="有长期稳定合作的核心关键的外协单位" prop="factor34">
<!--          <el-input v-model="form.factor34" placeholder="请输入有长期稳定合作的核心关键的外协单位" />-->
          <el-select v-model="form.factor34" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="能够及时为用户提供应用全过程的技术售后服务" prop="factor35">
<!--          <el-input v-model="form.factor35" placeholder="请输入能够及时为用户提供应用全过程的技术售后服务" />-->
          <el-select v-model="form.factor35" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="了解用户对于国产元器件的应用需求及其发展趋势，了解用户的配套供货需求" prop="factor36">
<!--          <el-input v-model="form.factor36" placeholder="请输入了解用户对于国产元器件的应用需求及其发展趋势，了解用户的配套供货需求" />-->
          <el-select v-model="form.factor36" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="制定了健全的稳定核心人员的措施，并有效执行" prop="factor37">
<!--          <el-input v-model="form.factor37" placeholder="请输入制定了健全的稳定核心人员的措施，并有效执行" />-->
          <el-select v-model="form.factor37" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="成立有专门的军品管理部门和科研生产技术团队，核心团队稳定" prop="factor38">
<!--          <el-input v-model="form.factor38" placeholder="请输入成立有专门的军品管理部门和科研生产技术团队，核心团队稳定" />-->
          <el-select v-model="form.factor38" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="核心人员均具备相应的专业知识和技术能力" prop="factor39">
<!--          <el-input v-model="form.factor39" placeholder="请输入核心人员均具备相应的专业知识和技术能力" />-->
          <el-select v-model="form.factor39" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="建立了良好的成本管控措施" prop="factor40">
<!--          <el-input v-model="form.factor40" placeholder="请输入建立了良好的成本管控措施" />-->
          <el-select v-model="form.factor40" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="能够承担产品生产、配套相关成本，能够持续盈利" prop="factor41">
<!--          <el-input v-model="form.factor41" placeholder="请输入能够承担产品生产、配套相关成本，能够持续盈利" />-->
          <el-select v-model="form.factor41" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="经济性好，企业能够持续获利" prop="factor42">
<!--          <el-input v-model="form.factor42" placeholder="请输入经济性好，企业能够持续获利" />-->
          <el-select v-model="form.factor42" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="和供应链各节点单位之间建立了良好的信息沟通机制，能有效沟通信息，协调解决问题" prop="factor43">
<!--          <el-input v-model="form.factor43" placeholder="请输入和供应链各节点单位之间建立了良好的信息沟通机制，能有效沟通信息，协调解决问题" />-->
          <el-select v-model="form.factor43" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="产品推广应用情况良好，市场认可度高，客户满意度高" prop="factor44">
<!--          <el-input v-model="form.factor44" placeholder="请输入产品推广应用情况良好，市场认可度高，客户满意度高" />-->
          <el-select v-model="form.factor44" >
            <el-option
              v-for="item in options"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="最终等级" prop="finalGrade">
          <el-input v-model="form.finalGrade" placeholder="请输入最终等级" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 训练数据导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px">
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
          <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的数据
          <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog
      title="训练"
      :visible.sync="dialogVisible"
      width="20%"
      style="top:225px"

    >
      <div  align="center">
        <el-progress
          type="circle"
          :percentage="Progress"
          width="80"
          :status="progressStatus"
        ></el-progress>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listScore, getScore, delScore, addScore, updateScore,train } from "@/api/biz/score";
import { getToken } from "@/utils/auth";
export default {
  name: "Score",
  data() {
    return {
      options:[{
        value: '是',
        label: '是'
      }, {
        value: '否',
        label: '否'
      }],
      dialogVisible:false,
      Progress:0,
      // 导入参数
      upload: {
        // 是否显示弹出层（导入）
        open: false,
        // 弹出层标题（导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/biz/score/importData"
      },
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 厂家得分表格数据
      scoreList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        factoryName: null,
        factor1: null,
        factor2: null,
        factor3: null,
        factor4: null,
        factor5: null,
        factor6: null,
        factor7: null,
        factor8: null,
        factor9: null,
        factor10: null,
        factor11: null,
        factor12: null,
        factor13: null,
        factor14: null,
        factor15: null,
        factor16: null,
        factor17: null,
        factor18: null,
        factor19: null,
        factor20: null,
        factor21: null,
        factor22: null,
        factor23: null,
        factor24: null,
        factor25: null,
        factor26: null,
        factor27: null,
        factor28: null,
        factor29: null,
        factor30: null,
        factor31: null,
        factor32: null,
        factor33: null,
        factor34: null,
        factor35: null,
        factor36: null,
        factor37: null,
        factor38: null,
        factor39: null,
        factor40: null,
        factor41: null,
        factor42: null,
        factor43: null,
        factor44: null,
        finalGrade: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  computed: {
    progressStatus() {
      return this.Progress === 100 ? 'success' : '';
    },
  },
  methods: {
    mytrain(){
      let result;
      train().then(res=>{
        result = res

      })
      // 模拟进度变化，每0.1秒更新一次，共更新100次
      this.dialogVisible = true
      const intervalId = setInterval(() => {

        this.Progress++;
        // 如果进度达到100%，清除定时器
        if (this.Progress >= 100) {
          this.Progress = 0
          clearInterval(intervalId);
          this.dialogVisible = false

          if(result.code===200)
            this.$modal.msgSuccess(result.msg);
          else {
            this.$modal.msgError(result.msg);
          }
        }
      }, 100);

    },
    /** 查询厂家得分列表 */
    getList() {
      this.loading = true;
      listScore(this.queryParams).then(response => {
        this.scoreList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        factoryName: null,
        factor1: null,
        factor2: null,
        factor3: null,
        factor4: null,
        factor5: null,
        factor6: null,
        factor7: null,
        factor8: null,
        factor9: null,
        factor10: null,
        factor11: null,
        factor12: null,
        factor13: null,
        factor14: null,
        factor15: null,
        factor16: null,
        factor17: null,
        factor18: null,
        factor19: null,
        factor20: null,
        factor21: null,
        factor22: null,
        factor23: null,
        factor24: null,
        factor25: null,
        factor26: null,
        factor27: null,
        factor28: null,
        factor29: null,
        factor30: null,
        factor31: null,
        factor32: null,
        factor33: null,
        factor34: null,
        factor35: null,
        factor36: null,
        factor37: null,
        factor38: null,
        factor39: null,
        factor40: null,
        factor41: null,
        factor42: null,
        factor43: null,
        factor44: null,
        finalGrade: 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.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加厂家得分";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getScore(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改厂家得分";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateScore(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addScore(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除厂家得分编号为"' + ids + '"的数据项？').then(function() {
        return delScore(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('biz/train/importTemplate', {
      }, `train_dataset_template_${new Date().getTime()}.xlsx`)
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('biz/score/export', {
        ...this.queryParams
      }, `score_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "训练数据集导入";
      this.upload.open = true;
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
// 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    }

  }
};
</script>
<style>

.el-checkbox__inner {
  border-color: #8492a6 !important;
}
.app-container {
  min-height: 100vh;
  background: radial-gradient(circle at 10% 20%, #3A71A8 0%, rgb(239, 249, 249) 90%);
}
</style>
