Browse Source

前后:hse成绩模块

wd 4 years ago
parent
commit
7b626272cc

+ 24 - 0
src/dashoo.cn/backend/api/business/oilsupplier/hsescore/hsescore.go

@@ -0,0 +1,24 @@
+package hsescore
+
+import (
+	"time"
+)
+
+type HSEScore struct {
+	Id             int       `xorm:"not null pk autoincr INT(11)"`
+	SupplierId     int       `xorm:" INT(11)"`
+	SupplierName   string    `xorm:"comment('企业名称') VARCHAR(50)"`
+	Name   		   string    `xorm:"comment('考试人员姓名') VARCHAR(50)"`
+	IdNumber       string    `xorm:"comment('身份证号') VARCHAR(50)"`
+	Score   	   int       `xorm:"comment('成绩') VARCHAR(50)"`
+	TestNumber     int       `xorm:"comment('考号') VARCHAR(50)"`
+	TrainTime      time.Time `xorm:"comment('培训时间') DATE"`
+	ApplyTime      time.Time `xorm:"comment('有效期') DATE"`
+	Remark   	   string    `xorm:"comment('备注') VARCHAR(50)"`
+	CreateOn       time.Time `xorm:"comment('创建时间') DATETIME"`
+	CreateUserId   int       `xorm:"comment('创建者编号') INT(11)"`
+	CreateBy       string    `xorm:"comment('创建者') VARCHAR(50)"`
+	ModifiedOn     time.Time `xorm:"comment('修改时间') DATETIME"`
+	ModifiedUserId int       `xorm:"comment('修改者编号') INT(11)"`
+	ModifiedBy     string    `xorm:"comment('修改者') VARCHAR(50)"`
+}

+ 103 - 0
src/dashoo.cn/backend/api/business/oilsupplier/hsescore/hsescoreService.go

@@ -0,0 +1,103 @@
+package hsescore
+
+import (
+	"dashoo.cn/utils"
+	"strconv"
+
+	. "dashoo.cn/backend/api/mydb"
+	. "dashoo.cn/utils/db"
+	"github.com/go-xorm/xorm"
+)
+
+type HSEScoreService struct {
+	MyServiceBase
+}
+
+func GetHSEScoreService(xormEngine *xorm.Engine) *HSEScoreService {
+	s := new(HSEScoreService)
+	s.DBE = xormEngine
+	return s
+}
+
+func (s *HSEScoreService) GetMyPagingEntitiesWithOrderBytbl(tableName string, pageIndex, itemsPerPage int64, order string, asc bool, entitiesPtr interface{}, where string) (total int64) {
+	var resultsSlice []map[string][]byte
+	//获取总记录数
+	sqlCount := ` select count(DISTINCT a.Id) from HSEScore a `
+	sqlCount += ` left join OilSupplier b on b.Id = a.SupplierId `
+	sqlCount += ` left join OilSupplierCert c on b.Id = c.SupplierId `
+	sqlCount += ` where ` + where
+
+	sql := ` select a.* from HSEScore a `
+	sql += ` left join OilSupplier b on b.Id = a.SupplierId `
+	sql += ` left join OilSupplierCert c on b.Id = c.SupplierId `
+	sql += ` where ` + where
+	sql += ` group by a.Id `
+
+	if asc {
+		sql += ` order by ` + order + ` ASC `
+	} else {
+		sql += ` order by ` + order + ` DESC `
+	}
+	if pageIndex != 0 && itemsPerPage != 0 {
+		sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
+	}
+
+	s.DBE.SQL(sql).Find(entitiesPtr)
+	resultsSlice, _ = s.DBE.Query(sqlCount)
+	if len(resultsSlice) > 0 {
+		results := resultsSlice[0]
+		for _, value := range results {
+			total, _ = strconv.ParseInt(string(value), 10, 64)
+			break
+		}
+	}
+	return total
+}
+func (s *HSEScoreService) GetSupplierList(entitiesPtr interface{}) {
+	sql := ` select * from OilSupplier `
+	s.DBE.SQL(sql).Find(entitiesPtr)
+}
+
+func (s *HSEScoreService) GetName(tableName string, where ...string) (total int64) {
+	var err error
+	var resultsSlice []map[string][]byte
+
+	sql := "SELECT COUNT(*) AS total FROM " + tableName + " where " + where[0]
+	resultsSlice, err = s.DBE.Query(sql)
+
+	//LogError(err)
+	if len(resultsSlice) > 0 {
+		results := resultsSlice[0]
+		for _, value := range results {
+			total, err = strconv.ParseInt(string(value), 10, 64)
+			LogError(err)
+			break
+		}
+	}
+	return total
+}
+
+func (s *HSEScoreService) GetCounts(where string) (total int64) {
+	var err error
+	var resultsSlice []map[string][]byte
+
+	sql := "select count(*) from HSEScore where(" + where + ")"
+	resultsSlice, err = s.DBE.Query(sql)
+
+	//LogError(err)
+	if len(resultsSlice) > 0 {
+		results := resultsSlice[0]
+		for _, value := range results {
+			total, err = strconv.ParseInt(string(value), 10, 64)
+			LogError(err)
+			break
+		}
+	}
+	return total
+}
+
+func (s *HSEScoreService) DeleteById(tableName string, id string) (err error) {
+	where := "Id=" + id
+	error := s.DeleteEntityBytbl(tableName, where) //删除表头表数据
+	return error
+}

+ 1 - 0
src/dashoo.cn/backend/api/controllers/base.go

@@ -300,6 +300,7 @@ var (
 	OilContractSumScoreName        string = "OilContractSumScore"        //年度汇总评分
 	OilContractSumScoreItemsName   string = "OilContractSumScoreItems"   //年度汇总评分明细
 	OilSupplierLogName             string = "OilSupplierLog"             //供方申请日志(快照)
+	HSEScoreName             	   string = "HSEScore"                   // hse成绩表
 )
 
 //分页信息及数据

+ 384 - 0
src/dashoo.cn/backend/api/controllers/oilsupplier/hsescore.go

@@ -0,0 +1,384 @@
+package oilsupplier
+
+import (
+	"dashoo.cn/backend/api/business/oilsupplier/hsescore"
+	"dashoo.cn/backend/api/business/oilsupplier/supplier"
+	"encoding/json"
+	"fmt"
+	"github.com/tealeg/xlsx"
+	"log"
+	"os"
+	"strconv"
+	"strings"
+	"time"
+
+	. "dashoo.cn/backend/api/controllers"
+	"dashoo.cn/business2/permission"
+	"dashoo.cn/utils"
+)
+
+type HSEScoreController struct {
+	BaseController
+}
+
+// @Title 获取列表
+// @Description GetList
+// @Success 200 {object}
+// @router /getHSEList [get]
+func (this *HSEScoreController) GetList() {
+	//获取分页信息
+	page := this.GetPageInfoForm() //包括当前页、每页书数量
+	ApplyTime := this.GetString("ApplyTime")
+	SupplierName := this.GetString("SupplierName")
+	CommercialNo := this.GetString("CommercialNo")
+	AccessCardNo := this.GetString("AccessCardNo")
+	Name := this.GetString("Name")
+	where := " 1=1"
+
+	if SupplierName != "" {
+		where = where + " and a.SupplierName like '%" + SupplierName + "%'"
+	}
+	if AccessCardNo != "" {
+		where = where + " and c.AccessCardNo like '%" + AccessCardNo + "%'"
+	}
+	if CommercialNo != "" {
+		where = where + " and b.CommercialNo like '%" + CommercialNo + "%'"
+	}
+	if ApplyTime != "" {
+		where = where + " and a.ApplyTime = '" + ApplyTime + "'"
+	}
+	if Name != "" {
+		where = where + " and a.Name like '%" + Name + "%'"
+	}
+	orderby := "Id"
+	asc := false
+	Order := this.GetString("Order")
+	Prop := this.GetString("Prop")
+	if Order != "" && Prop != "" {
+		orderby = Prop
+		if Prop == "SupplierName" {
+			orderby = "a.SupplierName"
+		}
+		if Prop == "ApplyTime" {
+			orderby = "a.ApplyTime"
+		}
+		if Prop == "Name" {
+			orderby = "a.Name"
+		}
+		if Order == "asc" {
+			asc = true
+		}
+	}
+
+	//企业用户必须加创建人条件
+	if this.User.IsCompanyUser == 1 {
+		where = where + " and a.SupplierName = '" + this.User.Realname + "'"
+	} else {
+		//超级管理员和有查看所有数据权限的用户不加条件
+		svcPerm := permission.GetPermissionService(utils.DBE)
+		isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
+		if !svcPerm.IsAdmin(this.User.Id) && !isauth {
+			where = where + " and a.SupplierName = '" + this.User.Realname + "'"
+		}
+	}
+
+	svc := hsescore.GetHSEScoreService(utils.DBE) //获得数据库引擎
+	var list []hsescore.HSEScore
+	total := svc.GetMyPagingEntitiesWithOrderBytbl("HSEScore", page.CurrentPage, page.Size, orderby, asc, &list, where)
+
+	var datainfo DataInfo
+	datainfo.Items = list
+	datainfo.CurrentItemCount = total
+	datainfo.PageIndex = page.CurrentPage
+	datainfo.ItemsPerPage = page.Size
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+
+}
+
+// @Title get 导入excel
+// @Description 导入excel
+// @Success 200 {object} controllers.Request
+// @router /importExcel [get]
+func (this *HSEScoreController) ImportExcel() {
+	url := this.GetString("ExcelUrl")
+	//var errLineNum string
+	var errinfo ErrorDataInfo
+
+	if url == "" {
+		errinfo.Message = "文件不能为空"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+	if this.User.IsCompanyUser == 1 {
+		errinfo.Message = "您无权导入"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+	_dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
+	filename := strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
+	//60.30.245.229 替换成23
+	url = strings.Replace(url, "60.30.245.229", "10.76.248.23", -1)
+	utils.DownloadFile(url, filename, _dir)
+	t := time.Now()
+	filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + filename
+	xlFile, err := xlsx.OpenFile(filePath)
+	if err != nil {
+		fmt.Printf("open failed: %s\n", err)
+	}
+	var sheet = xlFile.Sheets[0]
+	dateStr := ""
+	supplierNameStr := ""
+	supplierName := ""
+
+	svc := hsescore.GetHSEScoreService(utils.DBE) //获得数据库引擎
+	for i := 1; i < len(sheet.Rows); i++ {
+		if i == 2 || i == 3 {
+			continue
+		}
+		if i == 1 {
+			dateStr = sheet.Rows[i].Cells[0].String()
+			continue
+		}
+		fmt.Println(dateStr)
+		var hse hsescore.HSEScore
+		var hseUpdate hsescore.HSEScore
+		var supplier supplier.OilSupplier
+		supplierName1 := sheet.Rows[i].Cells[1].String()
+		if supplierName1 != "" {
+			supplierName = sheet.Rows[i].Cells[1].String()
+		} else {
+			supplierName1 = supplierName
+		}
+		svc.GetEntityByWhere(OilSupplierName, "SupplierName = '" + supplierName1 + "'", &supplier)
+		if supplier.Id == 0 {
+			if strings.Index(supplierNameStr, supplierName1) == -1 {
+				supplierNameStr += supplierName1 + ","
+			}
+			continue
+		}
+		if supplierName1 != "" {
+			svc.GetEntityByWhere(HSEScoreName, "SupplierName = '" + supplierName1 + "' and TestNumber = " + sheet.Rows[i].Cells[2].String(), &hseUpdate)
+			if hseUpdate.Id > 0 {
+				hseUpdate.SupplierId = supplier.Id
+				hseUpdate.Name = sheet.Rows[i].Cells[3].String()
+				hseUpdate.IdNumber = sheet.Rows[i].Cells[4].String()
+				hseUpdate.Score,_ = strconv.Atoi(sheet.Rows[i].Cells[5].String())
+				hseUpdate.ModifiedOn = time.Now()
+				hseUpdate.ModifiedBy = this.User.Realname
+				hseUpdate.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
+				svc.UpdateEntityById(hseUpdate.Id, &hseUpdate)
+				continue
+			}
+		}
+		hse.SupplierName = supplierName1
+		hse.SupplierId = supplier.Id
+		hse.TestNumber,_ = strconv.Atoi(sheet.Rows[i].Cells[2].String())
+		hse.SupplierId = supplier.Id
+		hse.Name = sheet.Rows[i].Cells[3].String()
+		hse.IdNumber = sheet.Rows[i].Cells[4].String()
+		hse.Score,_ = strconv.Atoi(sheet.Rows[i].Cells[5].String())
+		hse.CreateOn = time.Now()
+		hse.CreateBy = this.User.Realname
+		hse.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+		_, err = svc.InsertEntityBytbl(HSEScoreName, &hse)
+		if err != nil {
+			fmt.Println(err)
+		}
+	}
+	os.Remove(filePath)
+	elapsed := time.Since(t)
+	log.Println(elapsed)
+
+	errinfo.Code = 0
+	errinfo.Message = "导入成功,其中" + strings.TrimRight(supplierNameStr, ",") + "这些公司找不到对应,请手动新增!"
+	this.Data["json"] = &errinfo
+	this.ServeJSON()
+}
+
+// @Title 获取企业列表
+// @Description GetList
+// @Success 200 {object}
+// @router /getSupplierList [get]
+func (this *HSEScoreController) GetSupplierList() {
+	svc := hsescore.GetHSEScoreService(utils.DBE) //获得数据库引擎
+	var list []supplier.OilSupplier
+	svc.GetSupplierList(&list)
+
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 添加
+// @Description 新增
+// @Success	200	{object}
+// @router /addHSE [post]
+func (this *HSEScoreController) AddHSEScore() {
+	var model hsescore.HSEScore
+	var supplier supplier.OilSupplier
+	var jsonBlob = this.Ctx.Input.RequestBody
+	var errinfo ErrorDataInfo
+	json.Unmarshal(jsonBlob, &model)
+
+	var err error
+	svc := hsescore.GetHSEScoreService(utils.DBE)
+
+	if this.User.IsCompanyUser == 1 {
+		errinfo.Message = "您无权添加"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+	svc.GetEntityByWhere(OilSupplierName, "Id = " + strconv.Itoa(model.SupplierId), &supplier)
+	if supplier.SupplierName == "" {
+		errinfo.Message = "找不到该企业"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	where := "IdNumber = '" + model.IdNumber + "'"
+	num := svc.GetCounts(where)
+	if num >= 1 {
+		errinfo.Message = "身份证号不能重复"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	model.ApplyTime = model.ApplyTime.AddDate(3,0,0)
+	model.SupplierName = supplier.SupplierName
+	model.CreateOn = time.Now()
+	model.CreateBy = this.User.Realname
+	model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+
+	_, err = svc.InsertEntityBytbl("HSEScore", &model)
+	if err == nil {
+		errinfo.Message = "添加成功"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "添加失败"
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 修改
+// @Description 修改
+// @Success	200	{object}
+// @router /updateHSE/:id [post]
+func (this *HSEScoreController) UpdateHSEScore() {
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var model hsescore.HSEScore
+	var supplier supplier.OilSupplier
+	var jsonBlob = this.Ctx.Input.RequestBody
+	svc := hsescore.GetHSEScoreService(utils.DBE)
+	json.Unmarshal(jsonBlob, &model)
+
+	svc.GetEntityByWhere(OilSupplierName, "Id = " + strconv.Itoa(model.SupplierId), &supplier)
+	if supplier.SupplierName == "" {
+		errinfo.Message = "找不到该企业"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+	if this.User.IsCompanyUser == 1 {
+		errinfo.Message = "您无权修改"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+	where := "IdNumber = '" + model.IdNumber + "' and Id != " + id
+	num := svc.GetCounts(where)
+	if num >= 1 {
+		errinfo.Message = "身份证号不能重复"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+	model.SupplierName = supplier.SupplierName
+	model.ApplyTime = model.ApplyTime.AddDate(3,0,0)
+	model.ModifiedOn = time.Now()
+	model.ModifiedBy = this.User.Realname
+	model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
+
+	var err error
+	_, err = svc.UpdateEntityById(id, &model)
+	if err == nil {
+		errinfo.Message = "修改成功"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "修改失败"
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 删除单条信息
+// @Description
+// @Success 200 {object} ErrorInfo
+// @Failure 403 :id 为空
+// @router /deleteHSE/:Id [delete]
+func (this *HSEScoreController) DeleteHSEScore() {
+	Id := this.Ctx.Input.Param(":Id")
+	var errinfo ErrorInfo
+	if Id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	svc := hsescore.GetHSEScoreService(utils.DBE)
+
+	if this.User.IsCompanyUser == 1 {
+		errinfo.Message = "您无权删除"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+	err := svc.DeleteById("HSEScore", Id)
+	if err == nil {
+		errinfo.Message = "删除成功"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}

+ 6 - 0
src/dashoo.cn/backend/api/routers/router.go

@@ -534,6 +534,12 @@ func init() {
 				&oilsupplier.BlackListController{},
 			),
 		),
+		// HSE考试成绩
+		beego.NSNamespace("/hse",
+			beego.NSInclude(
+				&oilsupplier.HSEScoreController{},
+			),
+		),
 	)
 	beego.AddNamespace(ns)
 }

+ 49 - 0
src/dashoo.cn/frontend_web/src/api/hsescore/hsescore.js

@@ -0,0 +1,49 @@
+export default {
+  // 导入
+  importExcel (params, myAxios) {
+    return myAxios({
+      url: '/hse/importExcel',
+      method: 'get',
+      params: params
+    })
+  },
+  // 列表
+  getHSEList (params, myAxios) {
+    return myAxios({
+      url: '/hse/getHSEList',
+      method: 'GET',
+      params: params
+    })
+  },
+  // 企业列表
+  getSupplierList (myAxios) {
+    return myAxios({
+      url: '/hse/getSupplierList',
+      method: 'GET'
+    })
+  },
+  // 新增
+  addHSE (params, myAxios) {
+    return myAxios({
+      url: '/hse/addHSE',
+      method: 'post',
+      data: params
+    })
+  },
+  // 修改
+  updateHSE (id, params, myAxios) {
+    return myAxios({
+      url: '/hse/updateHSE/' + id,
+      method: 'post',
+      data: params
+    })
+  },
+  // 删除
+  deleteHSE (id, myAxios) {
+    return myAxios({
+      url: '/hse/deleteHSE/' + id,
+      method: 'delete'
+    })
+  }
+
+}

+ 590 - 0
src/dashoo.cn/frontend_web/src/pages/select/hsescore/index.vue

@@ -0,0 +1,590 @@
+<template>
+  <div>
+    <!--顶部显示-->
+    <el-breadcrumb class="heading">
+      <el-breadcrumb-item :to="{ path: '/' }">平台首页</el-breadcrumb-item>
+      <el-breadcrumb-item>HSE成绩</el-breadcrumb-item>
+    </el-breadcrumb>
+
+    <!--内框顶部显示-->
+    <el-card class="box-card" style="height: calc(100vh - 115px);position:relative">
+      <div slot="header">
+        <span>
+          <i class="icon icon-table2"></i>
+        </span>
+
+        <el-form :model="searchForm" ref="searchformRef" :inline="true" style="float: right;position:absolute;right:15px;top:10.5px">
+          <el-form-item label="准入证号">
+            <el-input size="mini"  style="width:110px" v-model="searchForm.AccessCardNo" clearable placeholder="准入证号"></el-input>
+          </el-form-item>
+          <el-form-item label="工商注册号">
+            <el-input size="mini"  style="width:122px" v-model="searchForm.CommercialNo" clearable placeholder="工商注册号"></el-input>
+          </el-form-item>
+          <el-form-item label="企业名称">
+            <el-input size="mini"  style="width:110px" v-model="searchForm.SupplierName" clearable placeholder="企业名称"></el-input>
+          </el-form-item>
+          <el-form-item label="有效期">
+            <el-date-picker
+              v-model="searchForm.ApplyTime"
+              size="mini"
+              type="date"
+              format="yyyy 年 MM 月 dd 日"
+              value-format="yyyy-MM-dd"
+              placeholder="选择有效期"
+              style="width: 100%"
+            ></el-date-picker>
+          </el-form-item>
+          <el-form-item label="姓名">
+            <el-input size="mini" style="width:100px" v-model="searchForm.Name" clearable placeholder="姓名"></el-input>
+          </el-form-item>
+
+          <el-form-item>
+            <el-dropdown
+              split-button
+              type="primary"
+              size="mini"
+              @click="initDatas($event)"
+              @command="searchCommand"
+            >
+              查询
+              <el-dropdown-menu slot="dropdown">
+                <el-dropdown-item command="clear">查询重置</el-dropdown-item>
+              </el-dropdown-menu>
+            </el-dropdown>
+          </el-form-item>
+          <el-form-item>
+            <el-button v-if="!disabled" type="primary" size="mini" @click="add">新增</el-button>
+            <el-button v-if="!disabled" type="primary" size="mini" @click="importExcel" :loading="importLoading">导入</el-button>
+          </el-form-item>
+        </el-form>
+      </div>
+
+      <!--内框表格显示-->
+      <el-table
+        id="rebateSetTable"
+        :data="entityList"
+        size="mini"
+        v-loading="tableLoading"
+        border
+        height="calc(100vh - 243px)"
+        style="width: 100%"
+        @sort-change="orderby"
+        @selection-change="onSelect"
+        highlight-current-row
+        stripe
+      >
+        <el-table-column label="操作" width="200px" align="center" fixed="right" show-overflow-tooltip>
+          <template slot-scope="scope">
+            <el-button :disabled="disabled" type="primary" plain title="修改" size="mini" @click="update(scope.row)">修改</el-button>
+            <el-button :disabled="disabled" type="danger" plain title="删除" size="mini" @click="deleteRow(scope.row.Id)">删除</el-button>
+          </template>
+        </el-table-column>
+        <!--内框表格剩余栏显示-->
+        <el-table-column align="center" width="70" label="序号">
+          <template slot-scope="scope">
+            <span>{{scope.$index+(currentPage - 1) * size + 1}} </span>
+          </template>
+        </el-table-column>
+        <el-table-column label="企业名称" min-width="300px" prop="SupplierName" sortable align="center"></el-table-column>
+        <el-table-column label="身份证号" width="200px" prop="IdNumber" sortable align="center"></el-table-column>
+        <el-table-column label="姓名" width="120px" prop="Name" sortable align="center"></el-table-column>
+        <el-table-column label="有效期" width="120px" prop="ApplyTime" sortable align="center">
+          <template slot-scope="scope">
+            {{ jstimehandle(scope.row.ApplyTime+'') }}
+          </template>
+        </el-table-column>
+        <el-table-column label="考试成绩" width="120px" prop="Score" sortable align="center"></el-table-column>
+        <el-table-column label="培训日期" width="120px" prop="TrainTime" sortable align="center">
+          <template slot-scope="scope">
+            {{ jstimehandle(scope.row.TrainTime+'') }}
+          </template>
+        </el-table-column>
+      </el-table>
+
+      <!-- 分页 -->
+      <el-pagination
+        style="float: right; margin-top: 10px; margin-bottom: 5px"
+        @size-change="handleSizeChange"
+        @current-change="handleCurrentChange"
+        :current-page="currentPage"
+        :page-sizes="[10, 50, 100, 200, 500]"
+        :page-size="size"
+        layout="total, sizes, prev, pager, next, jumper"
+        :total="currentItemCount"
+      ></el-pagination>
+    </el-card>
+
+    <!--add/update-->
+    <el-dialog :title="title" :close-on-click-modal="false" :visible.sync="addDialog" width="400px">
+      <el-form label-width="100px" :model="updateData" ref="EntityForm" :rules="rules">
+        <el-row>
+          <el-col :span="24">
+            <el-form-item label="企业名称" prop="SupplierId">
+              <el-select ref="SupplierSelect" v-model="updateData.SupplierId" filterable placeholder="请选择企业名称" style="width: 100%">
+                <el-option :label="item.SupplierName" :value="item.Id" v-for="(item,index) of supplierSelectList" :key="index"></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="24">
+            <el-form-item label="姓名" prop="Name">
+              <el-input style="width:100%" v-model="updateData.Name" placeholder="请填写姓名"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="24">
+            <el-form-item label="身份证号" prop="IdNumber">
+              <el-input style="width:100%" v-model="updateData.IdNumber" placeholder="请填写身份证号"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="24">
+            <el-form-item label="考试成绩" prop="Score">
+              <el-input-number type="number" :min="0" :max="100" style="width:100%" v-model="updateData.Score" placeholder="请填写考试成绩"></el-input-number>
+            </el-form-item>
+          </el-col>
+          <el-col :span="24">
+            <el-form-item label="培训日期" prop="TrainTime">
+              <el-date-picker
+                v-model="updateData.TrainTime"
+                type="date"
+                format="yyyy 年 MM 月 dd 日"
+                value-format="yyyy-MM-dd"
+                placeholder="选择培训日期"
+                style="width: 100%"
+              ></el-date-picker>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="addDialog = false">取 消</el-button>
+        <el-button type="primary" @click="addOrUpdate()" :loading="addLoading">确 定</el-button>
+      </span>
+    </el-dialog>
+    <el-dialog title="上传文件" :close-on-click-modal="false" width="600px" :visible.sync="uploadshow">
+      <el-form label-width="100px">
+        <el-row>
+          <el-col :span="24">
+            <el-upload :limit="1" style="margin-top: 10px;" action="" ref="refuploadattach"
+                       :http-request="uploadrequest" :before-remove="beforeRemove" :before-upload="beforeAvatarUpload">
+              <el-button size="mini" type="primary">点击上传</el-button>
+            </el-upload>
+          </el-col>
+          <el-col :span="24">
+            <el-button style="float: right;" size="mini" type="primary" @click="uploadExcel()">确定</el-button>
+          </el-col>
+        </el-row>
+      </el-form>
+    </el-dialog>
+
+  </div>
+</template>
+
+<script>
+import hseApi from '@/api/hsescore/hsescore'
+import uploadajax from '@/assets/js/uploadajax.js'
+import {mapGetters} from "vuex"
+import axios from "axios";
+
+export default {
+  computed: {
+    ...mapGetters({
+      authUser: 'authUser'
+    })
+  },
+  created () {
+    this.getSupplierList()
+    this.initDatas()
+    if (this.authUser.Profile.IsCompanyUser === 1) {
+      this.disabled = true
+    }
+  },
+  activated () {
+  },
+  data () {
+    const checkIdNumber = (rule, value, callback) => {
+      if (value === '') {
+        callback(new Error('请填写身份证号'))
+      } else {
+        let re1 = /(^\d{18}$)|(^\d{17}(\d|X|x)$)/
+        if (!re1.test(this.updateData.IdNumber)) {
+          callback(new Error('请输入正确格式的身份证号'))
+        } else {
+          callback()
+        }
+      }
+    }
+    const validDate = (rule, value, callback) => {
+      if (!value || !value[0] || !value[1]) {
+        callback(new Error('请选择培训日期'))
+      } else {
+        callback()
+      }
+    }
+    return {
+      title: '',
+      disabled: false,
+      uploadshow: false,
+      id: 0,
+      addDialog: false,
+      tableLoading: false,
+      addLoading: false,
+      status: false,
+      importLoading: false,
+      entityList: [],
+      supplierSelectList: [], // 企业名称列表
+      rules: {
+        SupplierId: [
+          {required: true, message: '请选择企业名称', trigger: 'blur'}
+        ],
+        Score: [
+          {required: true, message: '请填写考试成绩', trigger: 'blur'}
+        ],
+        Name: [
+          {required: true, message: '请填写姓名', trigger: 'blur'}
+        ],
+        TrainTime: [
+          {required: true, validator: validDate, trigger: 'blur'}
+        ],
+        IdNumber: [
+          {required: true, validator: checkIdNumber, trigger: 'change'}
+        ]
+      },
+      size: 10,
+      currentPage: 1,
+      currentItemCount: 0,
+      searchForm: {
+        AccessCardNo: '',
+        SupplierName: '',
+        CommercialNo: '',
+        ApplyTime: '',
+        IdNumber: '',
+        Name: '',
+      },
+      updateData: {
+        SupplierId: '',
+        Name: '',
+        IdNumber: '',
+        Score: 0,
+        TrainTime: '',
+        ApplyTime: ''
+      },
+      // 列表排序
+      Column: {
+        Order: '',
+        Prop: ''
+      }
+    }
+  },
+  methods: {
+    jstimehandle (val) {
+      if (val === '' || val === '0001-01-01T08:00:00+08:00' || val === '0001-01-01T00:00:00Z') {
+        return '----'
+      }else if (val === '5000-01-01T23:59:59+08:00') {
+        return '永久'
+      } else {
+        val = val.replace('T', ' ')
+        return val.substring(0, 10)
+      }
+    },
+    // 确定
+    addOrUpdate() {
+      this.$refs['EntityForm'].validate((valid) => {
+        if (valid) {
+          console.log(this.updateData, 'this.updateData----')
+          if (this.updateData.TrainTime.length === 10) {
+            this.updateData.TrainTime += 'T00:00:00+08:00'
+          }
+          const timeArr = this.updateData.TrainTime.split('T')
+          const timeArr1 = timeArr[0].split('-')
+          this.updateData.ApplyTime = timeArr1[0] + '-12-31T' + timeArr[1]
+          this.addLoading = true
+          if (this.status) {
+            hseApi.updateHSE(this.id, this.updateData, this.$axios).then(res => {
+                if (res.data.code === 0) {
+                  // 刷新列表
+                  this.initDatas()
+                  this.$message({
+                    duration: 10000,
+                    type: 'success',
+                    message: res.data.message
+                  })
+                  this.addDialog = false
+                } else {
+                  this.$message({
+                    duration: 10000,
+                    type: 'warning',
+                    message: res.data.message
+                  })
+                }
+                this.addLoading = false
+              }).catch(err => {
+                console.error(err)
+              })
+          } else {
+            hseApi.addHSE(this.updateData, this.$axios)
+              .then(res => {
+                if (res.data.code === 0) {
+                  // 刷新列表
+                  this.initDatas()
+                  this.$message({
+                    duration: 10000,
+                    type: 'success',
+                    message: res.data.message
+                  })
+                  this.addDialog = false
+                } else {
+                  this.$message({
+                    duration: 10000,
+                    type: 'warning',
+                    message: res.data.message
+                  })
+                }
+                this.addLoading = false
+              })
+              .catch(err => {
+                console.error(err)
+              })
+          }
+        } else {
+          return false
+        }
+      })
+    },
+    importExcel() {
+      this.uploadshow = true
+    },
+    // 导入
+    uploadExcel () {
+      this.importLoading = true
+      this.uploadshow = false
+      let params = {
+        ExcelUrl: this.Excelurl
+      }
+      hseApi.importExcel(params, this.$axios).then(res => {
+        this.importLoading = false
+        this.initDatas()
+        this.$message({
+          duration: 10000,
+          type: 'success',
+          message: res.data.message
+        })
+      })
+    },
+    add() {
+      this.title = '新增'
+      this.addDialog = true
+      this.status = false
+      this.updateData.IdNumber = ''
+      this.updateData.Name = ''
+      this.updateData.Score = 0
+      this.updateData.SupplierId = ''
+      this.updateData.TrainTime = ''
+    },
+    update(row) {
+      this.title = '修改'
+      this.addDialog = true
+      this.status = true
+      this.updateData.TrainTime = row.TrainTime
+      this.updateData.SupplierId = row.SupplierId
+      this.updateData.Score = row.Score
+      this.updateData.IdNumber = row.IdNumber
+      this.updateData.Name = row.Name
+      this.id = row.Id
+    },
+    deleteRow(id) {
+      this.$confirm('确定删除?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+          hseApi.deleteHSE(id, this.$axios).then(res => {
+              if (res.data.code === 0) {
+                // 刷新列表
+                this.initDatas()
+                this.$message({
+                  duration: 10000,
+                  type: 'success',
+                  message: res.data.message
+                })
+              } else {
+                this.$message({
+                  duration: 10000,
+                  type: 'warning',
+                  message: res.data.message
+                })
+              }
+            }).catch(err => {
+              console.error(err)
+            })
+        }).catch(err => {
+          console.error(err)
+        })
+    },
+    openCompanyInfo (row) {
+      if (!row.CertId) {
+        this.$message({
+                    duration: 10000,
+                    type: 'warning',
+          message: '企业未准入,无法显示详细信息'
+        })
+        return false
+      }
+      if (row.SupplierTypeCode === '01') { // 物资类
+        this.$router.push('/oilsupplier/supplier/' + row.Id + '/goodsedit?certid=' + row.CertId + '&showcy=true')
+      } else if (row.SupplierTypeCode === '02') { // 基建类
+        this.$router.push('/oilsupplier/supplier/' + row.Id + '/basisedit?certid=' + row.CertId + '&showcy=true')
+      } else if (row.SupplierTypeCode === '03') { // 服务类
+        this.$router.push('/oilsupplier/supplier/' + row.Id + '/techedit?certid=' + row.CertId + '&showcy=true')
+      }
+    },
+    onSelect (e) {
+      var list = []
+      e.map((item, index) => {
+        list.push(item.CertId)
+      })
+      this.selectedCertIdList = String(list)
+    },
+    // 列表排序功能
+    orderby (column) {
+      if (column.order === 'ascending') {
+        this.Column.Order = 'asc'
+      } else if (column.order === 'descending') {
+        this.Column.Order = 'desc'
+      }
+      this.Column.Prop = column.prop
+      this.initDatas()
+    },
+    // 初始化列表方法
+    initDatas (event) {
+      if (event != null) {
+        this.currentPage = 1
+      }
+      let params = {
+        size: this.size,
+        currentPage: this.currentPage,
+        Order: this.Column.Order,
+        Prop: this.Column.Prop
+      }
+      // 查询条件
+      Object.assign(params, this.searchForm)
+      this.tableLoading = true
+      console.log(params, 'params----')
+      hseApi.getHSEList(params, this.$axios).then(res => {
+          this.entityList = res.data.items
+          this.currentItemCount = res.data.currentItemCount
+          this.tableLoading = false
+        }).catch(err => {
+          console.error(err)
+          this.tableLoading = false
+        })
+    },
+    getSupplierList() {
+      hseApi.getSupplierList(this.$axios).then(res => {
+          this.supplierSelectList = res.data.items
+        }).catch(err => {
+          console.error(err)
+        })
+    },
+    // 分页方法
+    handleCurrentChange (value) {
+      this.currentPage = value
+      this.initDatas()
+    },
+    handleSizeChange (value) {
+      this.size = value
+      this.currentPage = 1
+      this.initDatas()
+    },
+    searchCommand (command) {
+      if (command === 'search') {
+        this.dialogVisible = true
+      } else if (command === 'clear') {
+        this.clearSearch()
+      }
+    },
+    clearSearch () {
+      Object.assign(this.searchForm, this.searchFormReset)
+      if (process.client) {
+        window.localStorage.setItem('companySearchParams', '')
+      }
+      this.CityAry = []
+      this.SetupTime = ''
+      this.auditorg = ''
+      this.selectDept = ''
+      this.OperType = ''
+      this.hidden = true
+      this.Grade = ''
+      this.LinkCityAry = []
+      this.currentPage = 1
+      this.initDatas()
+    },
+    beforeRemove () {
+      this.Excelurl = ''
+      return true
+    },
+    beforeAvatarUpload (file) {
+      if (file.name.indexOf('.xlsx') < 0) {
+        this.$message.error({
+          duration: 10000,
+          message: '文件格式必须为.xlsx'
+        })
+        return false
+      }
+      return true
+    },
+    uploadrequest (option) {
+      let _this = this
+      if (process.client) {
+        const myDomain = window.location.host
+        axios.post(process.env.upfilehost, {}).then(function (res) {
+            if (res.data && res.data.fid && res.data.fid !== '') {
+              if (res.data.publicUrl.indexOf('/upfile') === 0) {
+                option.action = `http://${myDomain}/${res.data.publicUrl}/${res.data.fid}`
+              } else {
+                option.action = `http://${res.data.publicUrl}/${res.data.fid}`
+              }
+              console.log(option)
+              uploadajax(option)
+              _this.Excelurl = option.action
+            } else {
+              _this.$message({
+                duration: 10000,
+                type: 'warning',
+                message: '未上传成功!请刷新界面重新上传!'
+              })
+            }
+          }).catch(res => {
+            console.log(res, 'error')
+            _this.$message({
+              duration: 10000,
+              type: 'warning',
+              message: '未上传成功!请重新上传!'
+            })
+          })
+      }
+    },
+    formatDateTime (date) {
+      var y = date.getFullYear()
+      var m = date.getMonth() + 1
+      m = m < 10 ? ('0' + m) : m
+      var d = date.getDate()
+      d = d < 10 ? ('0' + d) : d
+      var h = date.getHours()
+      var minute = date.getMinutes()
+      minute = minute < 10 ? ('0' + minute) : minute
+      return y + '-' + m + '-' + d + ' ' + h + ':' + minute
+    }
+  }
+}
+</script>
+
+<style>
+.eldialog .el-input__inner {
+  border: none;
+}
+.eldialog .el-textarea__inner {
+  border: none;
+  resize: none;
+  height: 70px;
+}
+</style>
+