瀏覽代碼

前后:黑名单模块

dubch 4 年之前
父節點
當前提交
f2c261d658

+ 23 - 0
src/dashoo.cn/backend/api/business/oilsupplier/blacklist/blacklist.go

@@ -0,0 +1,23 @@
+package BlackList
+
+import (
+	"time"
+)
+
+type BlackList struct {
+	Id             int       `xorm:"not null pk autoincr INT(11)"`
+	SupplierId     int    	 `xorm:"INT(11)"`
+	CreateOn       time.Time `xorm:"comment('创建时间') DATETIME"`
+	CreateUserId   int       `xorm:"comment('创建者编号') INT(11)"`
+	CreateBy       string    `xorm:"comment('创建者') VARCHAR(50)"`
+}
+
+type BlackListInfo struct {
+	Id             int       `xorm:"not null pk autoincr INT(11)"`
+	SupplierId     int    	 `xorm:"INT(11)"`
+	SupplierName   string    `xorm:"comment('企业名称') VARCHAR(50)"`
+	CommercialNo   string    `xorm:"comment('工商注册号') VARCHAR(50)"`
+	CreateOn       time.Time `xorm:"comment('创建时间') DATETIME"`
+	CreateUserId   int       `xorm:"comment('创建者编号') INT(11)"`
+	CreateBy       string    `xorm:"comment('创建者') VARCHAR(50)"`
+}

+ 135 - 0
src/dashoo.cn/backend/api/business/oilsupplier/blacklist/blacklistservice.go

@@ -0,0 +1,135 @@
+package BlackList
+
+import (
+	"dashoo.cn/utils"
+	"strconv"
+
+	. "dashoo.cn/backend/api/mydb"
+	. "dashoo.cn/utils/db"
+	"github.com/go-xorm/xorm"
+)
+
+type BlackListService struct {
+	MyServiceBase
+}
+
+func GetBlackListService(xormEngine *xorm.Engine) *BlackListService {
+	s := new(BlackListService)
+	s.DBE = xormEngine
+	return s
+}
+
+func (s *BlackListService) GetMyPagingEntitiesWithOrderBytbl(tableName string, pageIndex, itemsPerPage int64, order string, asc bool, entitiesPtr interface{}, where ...string) (total int64) {
+	var err error
+	var resultsSlice []map[string][]byte
+	//获取表名
+	if len(where) == 0 {
+		if asc {
+			err = s.DBE.Table(tableName).Limit(int(itemsPerPage), (int(pageIndex)-1)*int(itemsPerPage)).Asc(order).Find(entitiesPtr)
+		} else {
+			err = s.DBE.Table(tableName).Limit(int(itemsPerPage), (int(pageIndex)-1)*int(itemsPerPage)).Desc(order).Find(entitiesPtr)
+		}
+		//获取总记录数
+		sql := "SELECT COUNT(*) AS total FROM " + tableName
+		resultsSlice, err = s.DBE.Query(sql)
+
+	} else {
+		if asc {
+			err = s.DBE.Table(tableName).Where(where[0]).Limit(int(itemsPerPage), (int(pageIndex)-1)*int(itemsPerPage)).Asc(order).Find(entitiesPtr)
+		} else {
+			err = s.DBE.Table(tableName).Where(where[0]).Limit(int(itemsPerPage), (int(pageIndex)-1)*int(itemsPerPage)).Desc(order).Find(entitiesPtr)
+		}
+		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 *BlackListService) GetMyPagingEntitiesWithOrderBytbl1(tableName string, pageIndex, itemsPerPage int64, order string, asc bool, entitiesPtr interface{}, where string) (total int64) {
+	var resultsSlice []map[string][]byte
+
+	//获取总记录数
+	sqlCount := `select count(*) from ` + tableName + ` a `
+	sqlCount += ` left join OilSupplier b on a.SupplierId = b.Id`
+	sqlCount += ` where ` + where
+
+	var sql string
+	sql = `select a.Id, a.CreateOn, b.SupplierName, b.CommercialNo `
+	sql += ` from ` + tableName + ` a `
+	sql += ` left join OilSupplier b on a.SupplierId = b.Id`
+	sql += ` where ` + where
+	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 *BlackListService) 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 *BlackListService) GetCounts(where string) (total int64) {
+	var err error
+	var resultsSlice []map[string][]byte
+
+	sql := "select count(*) from OilSupplierCertSub a LEFT JOIN OilSupplierPauseReason b ON b.CertSubId = a.Id 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 *BlackListService) DeleteById(tableName string, id string) (err error) {
+	where := "Id=" + id
+	error := s.DeleteEntityBytbl(tableName, where) //删除表头表数据
+	return error
+}

+ 161 - 0
src/dashoo.cn/backend/api/controllers/oilsupplier/blacklist.go

@@ -0,0 +1,161 @@
+package oilsupplier
+
+import (
+	BlackList "dashoo.cn/backend/api/business/oilsupplier/blacklist"
+	"dashoo.cn/backend/api/business/oilsupplier/supplier"
+	"encoding/json"
+	"strconv"
+	"strings"
+	"time"
+
+	. "dashoo.cn/backend/api/controllers"
+	"dashoo.cn/utils"
+)
+
+type BlackListController struct {
+	BaseController
+}
+
+// @Title 获取所有
+// @Description GetList
+// @Success 200 {object}
+// @router /getList [get]
+func (this *BlackListController) GetList() {
+	//获取分页信息
+	page := this.GetPageInfoForm() //包括当前页、每页书数量
+	CreateOn := this.GetString("CreateOn")
+	SupplierName := this.GetString("SupplierName")
+	CommercialNo := this.GetString("CommercialNo")
+
+
+	where := " 1=1"
+
+	if SupplierName != "" {
+		where = where + " and b.SupplierName like '%" + SupplierName + "%'"
+	}
+	if CommercialNo != "" {
+		where = where + " and b.CommercialNo like '%" + CommercialNo + "%'"
+	}
+
+	if CreateOn != "" {
+		dates := strings.Split(CreateOn, ",")
+		if len(dates) == 2 {
+			minDate := dates[0]
+			maxDate := dates[1]
+			where = where + " and a.CreateOn >= '" + minDate + "' and a.CreateOn <= '" + maxDate + "'"
+		}
+	}
+	orderby := "a.Id"
+	asc := false
+
+	svc := BlackList.GetBlackListService(utils.DBE) //获得数据库引擎
+	var list []BlackList.BlackListInfo
+	total := svc.GetMyPagingEntitiesWithOrderBytbl1("BlackList", 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 获取所有供方信息
+// @Description getCompany
+// @Success 200 {object}
+// @router /getCompany [get]
+func (this *BlackListController) GetCompany() {
+	var model []supplier.OilSupplier
+	svc := BlackList.GetBlackListService(utils.DBE) //获得数据库引擎
+	svc.GetEntitysByWhere(OilSupplierName, "1=1", &model)
+	var datainfo DataInfo
+	datainfo.Items = model
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+
+}
+
+// @Title 添加
+// @Description 新增
+// @Success	200	{object}
+// @router /add [post]
+func (this *BlackListController) AddBlackList() {
+	var model BlackList.BlackList
+	var jsonBlob = this.Ctx.Input.RequestBody
+	var errinfo ErrorDataInfo
+	svc := BlackList.GetBlackListService(utils.DBE)
+	json.Unmarshal(jsonBlob, &model)
+
+	var err error
+
+	//判断名称是否已拥有
+	where := "SupplierId = " + strconv.Itoa(model.SupplierId)
+	svc.GetEntityByWhere("BlackList", where, &model)
+	if model.Id > 0 {
+		errinfo.Message = "该企业已存在"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+	var supp supplier.OilSupplier
+	where = "Id = " + strconv.Itoa(model.SupplierId)
+	svc.GetEntityByWhere(OilSupplierName, where, &supp)
+	if supp.Id == 0 {
+		errinfo.Message = "找不到该企业"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	model.CreateOn = time.Now()
+	model.CreateBy = this.User.Realname
+	model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+
+	_, err = svc.InsertEntityBytbl("BlackList", &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 /deleteBlackList/:Id [delete]
+func (this *BlackListController) DeleteBlackList() {
+	Id := this.Ctx.Input.Param(":Id")
+	var errinfo ErrorInfo
+	if Id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	svc := BlackList.GetBlackListService(utils.DBE)
+
+	err := svc.DeleteById("BlackList", 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

@@ -528,6 +528,12 @@ func init() {
 				&invoice.OilInvoiceController{},
 			),
 		),
+		//黑名单
+		beego.NSNamespace("/blacklist",
+			beego.NSInclude(
+				&oilsupplier.BlackListController{},
+			),
+		),
 	)
 	beego.AddNamespace(ns)
 }

+ 28 - 0
src/dashoo.cn/frontend_web/src/api/oilsupplier/blacklist.js

@@ -0,0 +1,28 @@
+export default {
+  getList (CreateOn, params, myAxios) {
+    return myAxios({
+      url: '/blacklist/getList?CreateOn=' + CreateOn,
+      method: 'GET',
+      params: params
+    })
+  },
+  getSupList (myAxios) {
+    return myAxios({
+      url: '/blacklist/getCompany',
+      method: 'GET'
+    })
+  },
+  addEntity (params, myAxios) {
+    return myAxios({
+      url: '/blacklist/add',
+      method: 'post',
+      data: params
+    })
+  },
+  deleteEntity (entityId, myAxios) {
+    return myAxios({
+      url: '/blacklist/deleteBlackList/' + entityId,
+      method: 'delete'
+    })
+  }
+}

+ 335 - 0
src/dashoo.cn/frontend_web/src/pages/oilsupplier/blacklist/index.vue

@@ -0,0 +1,335 @@
+<template>
+  <div>
+    <!--顶部显示-->
+    <el-breadcrumb class="heading">
+      <el-breadcrumb-item :to="{ path: '/' }">平台首页</el-breadcrumb-item>
+      <el-breadcrumb-item>黑名单</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; margin-top: -5px">
+          <el-form-item label="企业名称">
+            <el-input size="mini" clearable
+                      v-model="searchForm.SupplierName"
+                      placeholder="请输入内容"></el-input>
+          </el-form-item>
+          <el-form-item label="工商注册号">
+            <el-input size="mini" clearable
+                      v-model="searchForm.CommercialNo"
+                      placeholder="请输入内容"></el-input>
+          </el-form-item>
+
+          <el-form-item>
+            <el-dropdown split-button
+                         type="primary"
+                         style="margin-left:8px;"
+                         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 type="primary"
+                       size="mini"
+                       @click="add">添加</el-button>
+          </el-form-item>
+        </el-form>
+      </div>
+
+      <!--内框表格显示-->
+      <el-table stripe
+                highlight-current-row
+                size="mini"
+                :data="entityList"
+                border
+                height="calc(100vh - 243px)"
+                v-loading="tableLoading"
+                style="width: 100%">
+        <!--内框表格剩余栏显示-->
+        <el-table-column label="操作"
+                         align="center"
+                         width="150px">
+          <template slot-scope="scope">
+            <el-button type="primary"
+                       plain
+                       title="删除"
+                       size="mini"
+                       @click="deleterow(scope.row.Id)">删除</el-button>
+          </template>
+        </el-table-column>
+        <el-table-column label="企业名称"
+                         prop="SupplierName"
+                         align="center"
+                         width="260px"></el-table-column>
+        <el-table-column label="工商注册号"
+                         prop="CommercialNo"
+                         align="center"
+                         width="260px"></el-table-column>
+        <el-table-column label="创建时间"
+                         prop="CreateOn"
+                         align="center"
+                         width="100px">
+          <template slot-scope="scope">
+            {{ jstimehandle(scope.row.CreateOn+'') }}
+          </template>
+        </el-table-column>
+      </el-table>
+
+      <!-- 分页 -->
+      <el-pagination @size-change="handleSizeChange"
+                     @current-change="handleCurrentChange"
+                     :current-page="currentPage"
+                     :page-sizes="[10, 15, 20, 25]"
+                     :page-size="size"
+                     layout="total, sizes, prev, pager, next, jumper"
+                     :total="currentItemCount"></el-pagination>
+    </el-card>
+
+    <el-dialog title="黑名单添加" :visible.sync="addShow" width="360px">
+      <el-form label-width="90px" ref="EntityFormref">
+        <el-row>
+          <el-col :span="24">
+            <el-form-item label="企业名称" :rules="{ required: true, message: '企业名称不能为空', trigger: 'change'}">
+              <el-select filterable v-model="SupplierId" placeholder="请选择企业" style="width: 100%">
+                <el-option v-for="item in dataList" :key="item.Id" :label="item.SupplierName"
+                           :value="item.Id">
+                </el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+<!--        <el-row>-->
+<!--          <el-col :span="24">-->
+<!--            <el-form-item label="备注">-->
+<!--              <el-input v-model="appendformData.Remark" type="textarea" placeholder="请输入备注内容">-->
+<!--              </el-input>-->
+<!--            </el-form-item>-->
+<!--          </el-col>-->
+<!--        </el-row>-->
+      </el-form>
+      <span style="float: right;margin-top:-10px;">
+          <el-button size="small" @click="addShow = false">取 消</el-button>
+          <el-button type="primary" size="small" @click="addSup" :loading="addLoading">确 定</el-button>
+        </span>
+      <br>
+    </el-dialog>
+
+  </div>
+</template>
+
+<script>
+import api from '@/api/oilsupplier/blacklist'
+export default {
+  created () {
+    // 执行初始化方法
+    this.initDatas()
+    this.initCompany()
+  },
+  data () {
+    return {
+      tableLoading: false,
+      addLoading: false,
+      addShow: false,
+      // 定义列表数据
+      entityList: [],
+      // 分页参数
+      SupplierId: '',
+      size: 10,
+      currentPage: 1,
+      currentItemCount: 0,
+      dataList: [],
+      searchForm: {
+        SupplierName: '',
+        CommercialNo: ''
+      },
+
+    }
+  },
+
+  methods: {
+    add () {
+      this.addShow = true
+    },
+    deleterow (id) {
+      this.$confirm('确定删除?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      })
+        .then(() => {
+          api.deleteEntity(id, this.$axios)
+            .then(res => {
+              if (res.data.code === 0) {
+                // 刷新列表
+                this.initDatas()
+                this.$message({
+                  type: 'success',
+                  message: res.data.message
+                })
+              } else {
+                this.$message({
+                  type: 'warning',
+                  message: res.data.message
+                })
+              }
+            })
+            .catch(err => {
+              console.error(err)
+            })
+        })
+        .catch(() => { })
+    },
+    addSup () {
+      this.addLoading = true
+      let params = {
+        SupplierId: this.SupplierId
+      }
+      api.addEntity(params, this.$axios)
+        .then(res => {
+          if (res.data.code === 0) {
+            // 刷新列表
+            this.initDatas()
+            this.$message({
+              type: 'success',
+              message: res.data.message
+            })
+          } else {
+            this.$message({
+              type: 'warning',
+              message: res.data.message
+            })
+          }
+          this.addLoading = false
+          this.addShow = false
+        })
+        .catch(err => {
+          console.error(err)
+        })
+    },
+
+    initCompany () {
+      api.getSupList(this.$axios)
+        .then(res => {
+          this.dataList = res.data.items
+        })
+        .catch(err => {
+          console.error(err)
+        })
+    },
+
+    // 初始化列表方法
+    initDatas (event) {
+      if (event != null) {
+        this.currentPage = 1
+      }
+      let params = {
+        _size: this.size,
+        _currentPage: this.currentPage
+      }
+      let myCreateOn = []
+      // 解析时间
+      if (this.CreateOn && this.CreateOn.length == 2) {
+        this.CreateOn[1].setHours(23)
+        this.CreateOn[1].setMinutes(59)
+        this.CreateOn[1].setSeconds(59)
+        myCreateOn.push(this.formatDateTime(this.CreateOn[0]))
+        myCreateOn.push(this.formatDateTime(this.CreateOn[1]))
+      }
+      // 查询条件
+      Object.assign(params, this.searchForm)
+      this.tableLoading = true
+      api.getList(myCreateOn.join(','), 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
+        })
+    },
+
+    // 分页方法
+    handleCurrentChange (value) {
+      this.currentPage = value
+      this.initDatas()
+    },
+    handleSizeChange (value) {
+      this.size = value
+      this.currentPage = 1
+      this.initDatas()
+    },
+
+
+    searchCommand (command) {
+      if (command === 'clear') {
+        this.clearSearch()
+      }
+    },
+    clearSearch () {
+      this.searchForm.SupplierName = ''
+      this.searchForm.CommercialNo = ''
+      this.initDatas()
+    },
+    jstimehandle (val) {
+      if (val === '') {
+        return '----'
+      } else if (val === '0001-01-01T00:00:00Z') {
+        return '----'
+      } else if (val === '0001-01-01T08:00:00+08:00') {
+        return '----'
+      } else if (val === '5000-01-01T23:59:59+08:00') {
+        return '永久'
+      } else {
+        val = val.replace('T', ' ')
+        return val.substring(0, 10)
+      }
+    },
+
+    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
+      return y + '-' + m + '-' + d
+    }
+
+  }
+}
+</script>
+<style>
+.box-card1 {
+  margin-top: 5px;
+}
+.box-card1 .el-card__header {
+  padding: 9px 10px;
+}
+.box-card1 .el-card__body {
+  padding: 5px;
+}
+.box-card1 .el-form-item {
+  margin-bottom: 10px;
+}
+.certForm .el-form-item .el-form-item__label {
+  padding: 0px;
+}
+</style>