QM303176530
4 years ago
18 changed files with 1155 additions and 10 deletions
-
111server/api/v1/sys_dictionary.go
-
111server/api/v1/sys_dictionary_detail.go
-
2server/initialize/db_table.go
-
2server/initialize/router.go
-
8server/model/request/sys_dictionary.go
-
8server/model/request/sys_dictionary_detail.go
-
16server/model/sys_dictionary.go
-
16server/model/sys_dictionary_detail.go
-
15server/resource/template/fe/table.vue.tpl
-
18server/router/sys_dictionary.go
-
18server/router/sys_dictionary_detail.go
-
82server/service/sys_dictionary.go
-
82server/service/sys_dictionary_detail.go
-
1server/service/sys_user.go
-
84web/src/api/sys_dictionary.js
-
84web/src/api/sys_dictionary_detail.js
-
249web/src/view/superAdmin/dictionary/sys_dictionary.vue
-
258web/src/view/superAdmin/dictionary/sys_dictionary_detail.vue
@ -0,0 +1,111 @@ |
|||||
|
package v1 |
||||
|
|
||||
|
import ( |
||||
|
"fmt" |
||||
|
"gin-vue-admin/global/response" |
||||
|
"gin-vue-admin/model" |
||||
|
"gin-vue-admin/model/request" |
||||
|
resp "gin-vue-admin/model/response" |
||||
|
"gin-vue-admin/service" |
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
// @Tags SysDictionary
|
||||
|
// @Summary 创建SysDictionary
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body model.SysDictionary true "创建SysDictionary"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
|
// @Router /sysDictionary/createSysDictionary [post]
|
||||
|
func CreateSysDictionary(c *gin.Context) { |
||||
|
var sysDictionary model.SysDictionary |
||||
|
_ = c.ShouldBindJSON(&sysDictionary) |
||||
|
err := service.CreateSysDictionary(sysDictionary) |
||||
|
if err != nil { |
||||
|
response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c) |
||||
|
} else { |
||||
|
response.OkWithMessage("创建成功", c) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// @Tags SysDictionary
|
||||
|
// @Summary 删除SysDictionary
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body model.SysDictionary true "删除SysDictionary"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
||||
|
// @Router /sysDictionary/deleteSysDictionary [delete]
|
||||
|
func DeleteSysDictionary(c *gin.Context) { |
||||
|
var sysDictionary model.SysDictionary |
||||
|
_ = c.ShouldBindJSON(&sysDictionary) |
||||
|
err := service.DeleteSysDictionary(sysDictionary) |
||||
|
if err != nil { |
||||
|
response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c) |
||||
|
} else { |
||||
|
response.OkWithMessage("删除成功", c) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// @Tags SysDictionary
|
||||
|
// @Summary 更新SysDictionary
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body model.SysDictionary true "更新SysDictionary"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
|
||||
|
// @Router /sysDictionary/updateSysDictionary [put]
|
||||
|
func UpdateSysDictionary(c *gin.Context) { |
||||
|
var sysDictionary model.SysDictionary |
||||
|
_ = c.ShouldBindJSON(&sysDictionary) |
||||
|
err := service.UpdateSysDictionary(&sysDictionary) |
||||
|
if err != nil { |
||||
|
response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c) |
||||
|
} else { |
||||
|
response.OkWithMessage("更新成功", c) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// @Tags SysDictionary
|
||||
|
// @Summary 用id查询SysDictionary
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body model.SysDictionary true "用id查询SysDictionary"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
|
||||
|
// @Router /sysDictionary/findSysDictionary [get]
|
||||
|
func FindSysDictionary(c *gin.Context) { |
||||
|
var sysDictionary model.SysDictionary |
||||
|
_ = c.ShouldBindQuery(&sysDictionary) |
||||
|
err, resysDictionary := service.GetSysDictionary(sysDictionary.ID) |
||||
|
if err != nil { |
||||
|
response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c) |
||||
|
} else { |
||||
|
response.OkWithData(gin.H{"resysDictionary": resysDictionary}, c) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// @Tags SysDictionary
|
||||
|
// @Summary 分页获取SysDictionary列表
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body request.SysDictionarySearch true "分页获取SysDictionary列表"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
|
// @Router /sysDictionary/getSysDictionaryList [get]
|
||||
|
func GetSysDictionaryList(c *gin.Context) { |
||||
|
var pageInfo request.SysDictionarySearch |
||||
|
_ = c.ShouldBindQuery(&pageInfo) |
||||
|
err, list, total := service.GetSysDictionaryInfoList(pageInfo) |
||||
|
if err != nil { |
||||
|
response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c) |
||||
|
} else { |
||||
|
response.OkWithData(resp.PageResult{ |
||||
|
List: list, |
||||
|
Total: total, |
||||
|
Page: pageInfo.Page, |
||||
|
PageSize: pageInfo.PageSize, |
||||
|
}, c) |
||||
|
} |
||||
|
} |
@ -0,0 +1,111 @@ |
|||||
|
package v1 |
||||
|
|
||||
|
import ( |
||||
|
"fmt" |
||||
|
"gin-vue-admin/global/response" |
||||
|
"gin-vue-admin/model" |
||||
|
"gin-vue-admin/model/request" |
||||
|
resp "gin-vue-admin/model/response" |
||||
|
"gin-vue-admin/service" |
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
// @Tags SysDictionaryDetail
|
||||
|
// @Summary 创建SysDictionaryDetail
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body model.SysDictionaryDetail true "创建SysDictionaryDetail"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
|
// @Router /sysDictionaryDetail/createSysDictionaryDetail [post]
|
||||
|
func CreateSysDictionaryDetail(c *gin.Context) { |
||||
|
var sysDictionaryDetail model.SysDictionaryDetail |
||||
|
_ = c.ShouldBindJSON(&sysDictionaryDetail) |
||||
|
err := service.CreateSysDictionaryDetail(sysDictionaryDetail) |
||||
|
if err != nil { |
||||
|
response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c) |
||||
|
} else { |
||||
|
response.OkWithMessage("创建成功", c) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// @Tags SysDictionaryDetail
|
||||
|
// @Summary 删除SysDictionaryDetail
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body model.SysDictionaryDetail true "删除SysDictionaryDetail"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
||||
|
// @Router /sysDictionaryDetail/deleteSysDictionaryDetail [delete]
|
||||
|
func DeleteSysDictionaryDetail(c *gin.Context) { |
||||
|
var sysDictionaryDetail model.SysDictionaryDetail |
||||
|
_ = c.ShouldBindJSON(&sysDictionaryDetail) |
||||
|
err := service.DeleteSysDictionaryDetail(sysDictionaryDetail) |
||||
|
if err != nil { |
||||
|
response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c) |
||||
|
} else { |
||||
|
response.OkWithMessage("删除成功", c) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// @Tags SysDictionaryDetail
|
||||
|
// @Summary 更新SysDictionaryDetail
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body model.SysDictionaryDetail true "更新SysDictionaryDetail"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
|
||||
|
// @Router /sysDictionaryDetail/updateSysDictionaryDetail [put]
|
||||
|
func UpdateSysDictionaryDetail(c *gin.Context) { |
||||
|
var sysDictionaryDetail model.SysDictionaryDetail |
||||
|
_ = c.ShouldBindJSON(&sysDictionaryDetail) |
||||
|
err := service.UpdateSysDictionaryDetail(&sysDictionaryDetail) |
||||
|
if err != nil { |
||||
|
response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c) |
||||
|
} else { |
||||
|
response.OkWithMessage("更新成功", c) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// @Tags SysDictionaryDetail
|
||||
|
// @Summary 用id查询SysDictionaryDetail
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body model.SysDictionaryDetail true "用id查询SysDictionaryDetail"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
|
||||
|
// @Router /sysDictionaryDetail/findSysDictionaryDetail [get]
|
||||
|
func FindSysDictionaryDetail(c *gin.Context) { |
||||
|
var sysDictionaryDetail model.SysDictionaryDetail |
||||
|
_ = c.ShouldBindQuery(&sysDictionaryDetail) |
||||
|
err, resysDictionaryDetail := service.GetSysDictionaryDetail(sysDictionaryDetail.ID) |
||||
|
if err != nil { |
||||
|
response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c) |
||||
|
} else { |
||||
|
response.OkWithData(gin.H{"resysDictionaryDetail": resysDictionaryDetail}, c) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// @Tags SysDictionaryDetail
|
||||
|
// @Summary 分页获取SysDictionaryDetail列表
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body request.SysDictionaryDetailSearch true "分页获取SysDictionaryDetail列表"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
|
// @Router /sysDictionaryDetail/getSysDictionaryDetailList [get]
|
||||
|
func GetSysDictionaryDetailList(c *gin.Context) { |
||||
|
var pageInfo request.SysDictionaryDetailSearch |
||||
|
_ = c.ShouldBindQuery(&pageInfo) |
||||
|
err, list, total := service.GetSysDictionaryDetailInfoList(pageInfo) |
||||
|
if err != nil { |
||||
|
response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c) |
||||
|
} else { |
||||
|
response.OkWithData(resp.PageResult{ |
||||
|
List: list, |
||||
|
Total: total, |
||||
|
Page: pageInfo.Page, |
||||
|
PageSize: pageInfo.PageSize, |
||||
|
}, c) |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
package request |
||||
|
|
||||
|
import "gin-vue-admin/model" |
||||
|
|
||||
|
type SysDictionarySearch struct{ |
||||
|
model.SysDictionary |
||||
|
PageInfo |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
package request |
||||
|
|
||||
|
import "gin-vue-admin/model" |
||||
|
|
||||
|
type SysDictionaryDetailSearch struct{ |
||||
|
model.SysDictionaryDetail |
||||
|
PageInfo |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
// 自动生成模板SysDictionary
|
||||
|
package model |
||||
|
|
||||
|
import ( |
||||
|
"github.com/jinzhu/gorm" |
||||
|
) |
||||
|
|
||||
|
// 如果含有time.Time 请自行import time包
|
||||
|
type SysDictionary struct { |
||||
|
gorm.Model |
||||
|
Name string `json:"name" form:"name" gorm:"column:name;comment:'字典名(中)'"` |
||||
|
Type string `json:"type" form:"type" gorm:"column:type;comment:'字典名(英)'"` |
||||
|
Status *bool `json:"status" form:"status" gorm:"column:status;comment:'状态'"` |
||||
|
Desc string `json:"desc" form:"desc" gorm:"column:desc;comment:'描述'"` |
||||
|
SysDictionaryDetails []SysDictionaryDetail `json:"sysDictionaryDetails" form:"sysDictionaryDetails"` |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
// 自动生成模板SysDictionaryDetail
|
||||
|
package model |
||||
|
|
||||
|
import ( |
||||
|
"github.com/jinzhu/gorm" |
||||
|
) |
||||
|
|
||||
|
// 如果含有time.Time 请自行import time包
|
||||
|
type SysDictionaryDetail struct { |
||||
|
gorm.Model |
||||
|
Label string `json:"label" form:"label" gorm:"column:label;comment:'展示值'"` |
||||
|
Value int `json:"value" form:"value" gorm:"column:value;comment:'字典值'"` |
||||
|
Status *bool `json:"status" form:"status" gorm:"column:status;comment:'启用状态'"` |
||||
|
Sort int `json:"sort" form:"sort" gorm:"column:sort;comment:'排序标记'"` |
||||
|
SysDictionaryID int `json:"sysDictionaryID" form:"sysDictionaryID" gorm:"column:sys_dictionary_id;comment:'关联标记'"` |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package router |
||||
|
|
||||
|
import ( |
||||
|
"gin-vue-admin/api/v1" |
||||
|
"gin-vue-admin/middleware" |
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
func InitSysDictionaryRouter(Router *gin.RouterGroup) { |
||||
|
SysDictionaryRouter := Router.Group("sysDictionary").Use(middleware.JWTAuth()).Use(middleware.CasbinHandler()) |
||||
|
{ |
||||
|
SysDictionaryRouter.POST("createSysDictionary", v1.CreateSysDictionary) // 新建SysDictionary
|
||||
|
SysDictionaryRouter.DELETE("deleteSysDictionary", v1.DeleteSysDictionary) // 删除SysDictionary
|
||||
|
SysDictionaryRouter.PUT("updateSysDictionary", v1.UpdateSysDictionary) // 更新SysDictionary
|
||||
|
SysDictionaryRouter.GET("findSysDictionary", v1.FindSysDictionary) // 根据ID获取SysDictionary
|
||||
|
SysDictionaryRouter.GET("getSysDictionaryList", v1.GetSysDictionaryList) // 获取SysDictionary列表
|
||||
|
} |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package router |
||||
|
|
||||
|
import ( |
||||
|
"gin-vue-admin/api/v1" |
||||
|
"gin-vue-admin/middleware" |
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
func InitSysDictionaryDetailRouter(Router *gin.RouterGroup) { |
||||
|
SysDictionaryDetailRouter := Router.Group("sysDictionaryDetail").Use(middleware.JWTAuth()).Use(middleware.CasbinHandler()) |
||||
|
{ |
||||
|
SysDictionaryDetailRouter.POST("createSysDictionaryDetail", v1.CreateSysDictionaryDetail) // 新建SysDictionaryDetail
|
||||
|
SysDictionaryDetailRouter.DELETE("deleteSysDictionaryDetail", v1.DeleteSysDictionaryDetail) // 删除SysDictionaryDetail
|
||||
|
SysDictionaryDetailRouter.PUT("updateSysDictionaryDetail", v1.UpdateSysDictionaryDetail) // 更新SysDictionaryDetail
|
||||
|
SysDictionaryDetailRouter.GET("findSysDictionaryDetail", v1.FindSysDictionaryDetail) // 根据ID获取SysDictionaryDetail
|
||||
|
SysDictionaryDetailRouter.GET("getSysDictionaryDetailList", v1.GetSysDictionaryDetailList) // 获取SysDictionaryDetail列表
|
||||
|
} |
||||
|
} |
@ -0,0 +1,82 @@ |
|||||
|
package service |
||||
|
|
||||
|
import ( |
||||
|
"gin-vue-admin/global" |
||||
|
"gin-vue-admin/model" |
||||
|
"gin-vue-admin/model/request" |
||||
|
) |
||||
|
|
||||
|
// @title CreateSysDictionary
|
||||
|
// @description create a SysDictionary
|
||||
|
// @param sysDictionary model.SysDictionary
|
||||
|
// @auth (2020/04/05 20:22)
|
||||
|
// @return err error
|
||||
|
|
||||
|
func CreateSysDictionary(sysDictionary model.SysDictionary) (err error) { |
||||
|
err = global.GVA_DB.Create(&sysDictionary).Error |
||||
|
return err |
||||
|
} |
||||
|
|
||||
|
// @title DeleteSysDictionary
|
||||
|
// @description delete a SysDictionary
|
||||
|
// @auth (2020/04/05 20:22)
|
||||
|
// @param sysDictionary model.SysDictionary
|
||||
|
// @return error
|
||||
|
|
||||
|
func DeleteSysDictionary(sysDictionary model.SysDictionary) (err error) { |
||||
|
err = global.GVA_DB.Delete(sysDictionary).Error |
||||
|
return err |
||||
|
} |
||||
|
|
||||
|
// @title UpdateSysDictionary
|
||||
|
// @description update a SysDictionary
|
||||
|
// @param sysDictionary *model.SysDictionary
|
||||
|
// @auth (2020/04/05 20:22)
|
||||
|
// @return error
|
||||
|
|
||||
|
func UpdateSysDictionary(sysDictionary *model.SysDictionary) (err error) { |
||||
|
err = global.GVA_DB.Save(sysDictionary).Error |
||||
|
return err |
||||
|
} |
||||
|
|
||||
|
// @title GetSysDictionary
|
||||
|
// @description get the info of a SysDictionary
|
||||
|
// @auth (2020/04/05 20:22)
|
||||
|
// @param id uint
|
||||
|
// @return error
|
||||
|
// @return SysDictionary SysDictionary
|
||||
|
|
||||
|
func GetSysDictionary(id uint) (err error, sysDictionary model.SysDictionary) { |
||||
|
err = global.GVA_DB.Where("id = ?", id).First(&sysDictionary).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// @title GetSysDictionaryInfoList
|
||||
|
// @description get SysDictionary list by pagination, 分页获取用户列表
|
||||
|
// @auth (2020/04/05 20:22)
|
||||
|
// @param info PageInfo
|
||||
|
// @return error
|
||||
|
|
||||
|
func GetSysDictionaryInfoList(info request.SysDictionarySearch) (err error, list interface{}, total int) { |
||||
|
limit := info.PageSize |
||||
|
offset := info.PageSize * (info.Page - 1) |
||||
|
// 创建db
|
||||
|
db := global.GVA_DB.Model(&model.SysDictionary{}) |
||||
|
var sysDictionarys []model.SysDictionary |
||||
|
// 如果有条件搜索 下方会自动创建搜索语句
|
||||
|
if info.Name != "" { |
||||
|
db = db.Where("name LIKE ?","%"+ info.Name+"%") |
||||
|
} |
||||
|
if info.Type != "" { |
||||
|
db = db.Where("type LIKE ?","%"+ info.Type+"%") |
||||
|
} |
||||
|
if info.Status != nil { |
||||
|
db = db.Where("status = ?",info.Status) |
||||
|
} |
||||
|
if info.Desc != "" { |
||||
|
db = db.Where("desc LIKE ?","%"+ info.Desc+"%") |
||||
|
} |
||||
|
err = db.Count(&total).Error |
||||
|
err = db.Limit(limit).Offset(offset).Find(&sysDictionarys).Error |
||||
|
return err, sysDictionarys, total |
||||
|
} |
@ -0,0 +1,82 @@ |
|||||
|
package service |
||||
|
|
||||
|
import ( |
||||
|
"gin-vue-admin/global" |
||||
|
"gin-vue-admin/model" |
||||
|
"gin-vue-admin/model/request" |
||||
|
) |
||||
|
|
||||
|
// @title CreateSysDictionaryDetail
|
||||
|
// @description create a SysDictionaryDetail
|
||||
|
// @param sysDictionaryDetail model.SysDictionaryDetail
|
||||
|
// @auth (2020/04/05 20:22)
|
||||
|
// @return err error
|
||||
|
|
||||
|
func CreateSysDictionaryDetail(sysDictionaryDetail model.SysDictionaryDetail) (err error) { |
||||
|
err = global.GVA_DB.Create(&sysDictionaryDetail).Error |
||||
|
return err |
||||
|
} |
||||
|
|
||||
|
// @title DeleteSysDictionaryDetail
|
||||
|
// @description delete a SysDictionaryDetail
|
||||
|
// @auth (2020/04/05 20:22)
|
||||
|
// @param sysDictionaryDetail model.SysDictionaryDetail
|
||||
|
// @return error
|
||||
|
|
||||
|
func DeleteSysDictionaryDetail(sysDictionaryDetail model.SysDictionaryDetail) (err error) { |
||||
|
err = global.GVA_DB.Delete(sysDictionaryDetail).Error |
||||
|
return err |
||||
|
} |
||||
|
|
||||
|
// @title UpdateSysDictionaryDetail
|
||||
|
// @description update a SysDictionaryDetail
|
||||
|
// @param sysDictionaryDetail *model.SysDictionaryDetail
|
||||
|
// @auth (2020/04/05 20:22)
|
||||
|
// @return error
|
||||
|
|
||||
|
func UpdateSysDictionaryDetail(sysDictionaryDetail *model.SysDictionaryDetail) (err error) { |
||||
|
err = global.GVA_DB.Save(sysDictionaryDetail).Error |
||||
|
return err |
||||
|
} |
||||
|
|
||||
|
// @title GetSysDictionaryDetail
|
||||
|
// @description get the info of a SysDictionaryDetail
|
||||
|
// @auth (2020/04/05 20:22)
|
||||
|
// @param id uint
|
||||
|
// @return error
|
||||
|
// @return SysDictionaryDetail SysDictionaryDetail
|
||||
|
|
||||
|
func GetSysDictionaryDetail(id uint) (err error, sysDictionaryDetail model.SysDictionaryDetail) { |
||||
|
err = global.GVA_DB.Where("id = ?", id).First(&sysDictionaryDetail).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// @title GetSysDictionaryDetailInfoList
|
||||
|
// @description get SysDictionaryDetail list by pagination, 分页获取用户列表
|
||||
|
// @auth (2020/04/05 20:22)
|
||||
|
// @param info PageInfo
|
||||
|
// @return error
|
||||
|
|
||||
|
func GetSysDictionaryDetailInfoList(info request.SysDictionaryDetailSearch) (err error, list interface{}, total int) { |
||||
|
limit := info.PageSize |
||||
|
offset := info.PageSize * (info.Page - 1) |
||||
|
// 创建db
|
||||
|
db := global.GVA_DB.Model(&model.SysDictionaryDetail{}) |
||||
|
var sysDictionaryDetails []model.SysDictionaryDetail |
||||
|
// 如果有条件搜索 下方会自动创建搜索语句
|
||||
|
if info.Label != "" { |
||||
|
db = db.Where("label LIKE ?", "%"+info.Label+"%") |
||||
|
} |
||||
|
if info.Value != 0 { |
||||
|
db = db.Where("value = ?", info.Value) |
||||
|
} |
||||
|
if info.Status != nil { |
||||
|
db = db.Where("status = ?", info.Status) |
||||
|
} |
||||
|
if info.SysDictionaryID != 0 { |
||||
|
db = db.Where("sys_dictionary_id = ?", info.SysDictionaryID) |
||||
|
} |
||||
|
err = db.Count(&total).Error |
||||
|
err = db.Limit(limit).Offset(offset).Find(&sysDictionaryDetails).Error |
||||
|
return err, sysDictionaryDetails, total |
||||
|
} |
@ -0,0 +1,84 @@ |
|||||
|
import service from '@/utils/request' |
||||
|
|
||||
|
// @Tags SysDictionary
|
||||
|
// @Summary 创建SysDictionary
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body model.SysDictionary true "创建SysDictionary"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
|
// @Router /sysDictionary/createSysDictionary [post]
|
||||
|
export const createSysDictionary = (data) => { |
||||
|
return service({ |
||||
|
url: "/sysDictionary/createSysDictionary", |
||||
|
method: 'post', |
||||
|
data |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// @Tags SysDictionary
|
||||
|
// @Summary 删除SysDictionary
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body model.SysDictionary true "删除SysDictionary"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
||||
|
// @Router /sysDictionary/deleteSysDictionary [delete]
|
||||
|
export const deleteSysDictionary = (data) => { |
||||
|
return service({ |
||||
|
url: "/sysDictionary/deleteSysDictionary", |
||||
|
method: 'delete', |
||||
|
data |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
// @Tags SysDictionary
|
||||
|
// @Summary 更新SysDictionary
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body model.SysDictionary true "更新SysDictionary"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
|
||||
|
// @Router /sysDictionary/updateSysDictionary [put]
|
||||
|
export const updateSysDictionary = (data) => { |
||||
|
return service({ |
||||
|
url: "/sysDictionary/updateSysDictionary", |
||||
|
method: 'put', |
||||
|
data |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// @Tags SysDictionary
|
||||
|
// @Summary 用id查询SysDictionary
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body model.SysDictionary true "用id查询SysDictionary"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
|
||||
|
// @Router /sysDictionary/findSysDictionary [get]
|
||||
|
export const findSysDictionary = (params) => { |
||||
|
return service({ |
||||
|
url: "/sysDictionary/findSysDictionary", |
||||
|
method: 'get', |
||||
|
params |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// @Tags SysDictionary
|
||||
|
// @Summary 分页获取SysDictionary列表
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body request.PageInfo true "分页获取SysDictionary列表"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
|
// @Router /sysDictionary/getSysDictionaryList [get]
|
||||
|
export const getSysDictionaryList = (params) => { |
||||
|
return service({ |
||||
|
url: "/sysDictionary/getSysDictionaryList", |
||||
|
method: 'get', |
||||
|
params |
||||
|
}) |
||||
|
} |
@ -0,0 +1,84 @@ |
|||||
|
import service from '@/utils/request' |
||||
|
|
||||
|
// @Tags SysDictionaryDetail
|
||||
|
// @Summary 创建SysDictionaryDetail
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body model.SysDictionaryDetail true "创建SysDictionaryDetail"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
|
// @Router /sysDictionaryDetail/createSysDictionaryDetail [post]
|
||||
|
export const createSysDictionaryDetail = (data) => { |
||||
|
return service({ |
||||
|
url: "/sysDictionaryDetail/createSysDictionaryDetail", |
||||
|
method: 'post', |
||||
|
data |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// @Tags SysDictionaryDetail
|
||||
|
// @Summary 删除SysDictionaryDetail
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body model.SysDictionaryDetail true "删除SysDictionaryDetail"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
||||
|
// @Router /sysDictionaryDetail/deleteSysDictionaryDetail [delete]
|
||||
|
export const deleteSysDictionaryDetail = (data) => { |
||||
|
return service({ |
||||
|
url: "/sysDictionaryDetail/deleteSysDictionaryDetail", |
||||
|
method: 'delete', |
||||
|
data |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
// @Tags SysDictionaryDetail
|
||||
|
// @Summary 更新SysDictionaryDetail
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body model.SysDictionaryDetail true "更新SysDictionaryDetail"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
|
||||
|
// @Router /sysDictionaryDetail/updateSysDictionaryDetail [put]
|
||||
|
export const updateSysDictionaryDetail = (data) => { |
||||
|
return service({ |
||||
|
url: "/sysDictionaryDetail/updateSysDictionaryDetail", |
||||
|
method: 'put', |
||||
|
data |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// @Tags SysDictionaryDetail
|
||||
|
// @Summary 用id查询SysDictionaryDetail
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body model.SysDictionaryDetail true "用id查询SysDictionaryDetail"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
|
||||
|
// @Router /sysDictionaryDetail/findSysDictionaryDetail [get]
|
||||
|
export const findSysDictionaryDetail = (params) => { |
||||
|
return service({ |
||||
|
url: "/sysDictionaryDetail/findSysDictionaryDetail", |
||||
|
method: 'get', |
||||
|
params |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// @Tags SysDictionaryDetail
|
||||
|
// @Summary 分页获取SysDictionaryDetail列表
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body request.PageInfo true "分页获取SysDictionaryDetail列表"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
|
// @Router /sysDictionaryDetail/getSysDictionaryDetailList [get]
|
||||
|
export const getSysDictionaryDetailList = (params) => { |
||||
|
return service({ |
||||
|
url: "/sysDictionaryDetail/getSysDictionaryDetailList", |
||||
|
method: 'get', |
||||
|
params |
||||
|
}) |
||||
|
} |
@ -0,0 +1,249 @@ |
|||||
|
<template> |
||||
|
<div> |
||||
|
<div class="search-term"> |
||||
|
<el-form :inline="true" :model="searchInfo" class="demo-form-inline"> |
||||
|
<el-form-item label="字典名(中)"> |
||||
|
<el-input placeholder="搜索条件" v-model="searchInfo.name"></el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="字典名(英)"> |
||||
|
<el-input placeholder="搜索条件" v-model="searchInfo.type"></el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="状态" prop="status"> |
||||
|
<el-select v-model="searchInfo.status" clear placeholder="请选择"> |
||||
|
<el-option |
||||
|
key="true" |
||||
|
label="是" |
||||
|
value="true"> |
||||
|
</el-option> |
||||
|
<el-option |
||||
|
key="false" |
||||
|
label="否" |
||||
|
value="false"> |
||||
|
</el-option> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="描述"> |
||||
|
<el-input placeholder="搜索条件" v-model="searchInfo.desc"></el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item> |
||||
|
<el-button @click="onSubmit" type="primary">查询</el-button> |
||||
|
</el-form-item> |
||||
|
<el-form-item> |
||||
|
<el-button @click="openDialog" type="primary">新增字典</el-button> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
</div> |
||||
|
<el-table |
||||
|
:data="tableData" |
||||
|
border |
||||
|
ref="multipleTable" |
||||
|
stripe |
||||
|
style="width: 100%" |
||||
|
tooltip-effect="dark" |
||||
|
> |
||||
|
<el-table-column type="selection" width="55"></el-table-column> |
||||
|
<el-table-column label="日期" width="180"> |
||||
|
<template slot-scope="scope">{{scope.row.CreatedAt|formatDate}}</template> |
||||
|
</el-table-column> |
||||
|
|
||||
|
<el-table-column label="字典名(中)" prop="name" width="120"></el-table-column> |
||||
|
|
||||
|
<el-table-column label="字典名(英)" prop="type" width="120"></el-table-column> |
||||
|
|
||||
|
<el-table-column label="状态" prop="status" width="120"> |
||||
|
<template slot-scope="scope">{{scope.row.status|formatBoolean}}</template> |
||||
|
</el-table-column> |
||||
|
|
||||
|
<el-table-column label="描述" prop="desc" width="280"></el-table-column> |
||||
|
|
||||
|
<el-table-column label="按钮组"> |
||||
|
<template slot-scope="scope"> |
||||
|
<el-button @click="toDetile(scope.row)" size="small" type="success">详情</el-button> |
||||
|
<el-button @click="updateSysDictionary(scope.row)" size="small" type="primary">变更</el-button> |
||||
|
<el-popover placement="top" width="160" v-model="scope.row.visible"> |
||||
|
<p>确定要删除吗?</p> |
||||
|
<div style="text-align: right; margin: 0"> |
||||
|
<el-button size="mini" type="text" @click="scope.row.visible = false">取消</el-button> |
||||
|
<el-button type="primary" size="mini" @click="deleteSysDictionary(scope.row)">确定</el-button> |
||||
|
</div> |
||||
|
<el-button type="danger" icon="el-icon-delete" size="mini" slot="reference">删除</el-button> |
||||
|
</el-popover> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
</el-table> |
||||
|
|
||||
|
<el-pagination |
||||
|
:current-page="page" |
||||
|
:page-size="pageSize" |
||||
|
:page-sizes="[10, 30, 50, 100]" |
||||
|
:style="{float:'right',padding:'20px'}" |
||||
|
:total="total" |
||||
|
@current-change="handleCurrentChange" |
||||
|
@size-change="handleSizeChange" |
||||
|
layout="total, sizes, prev, pager, next, jumper" |
||||
|
></el-pagination> |
||||
|
|
||||
|
<el-dialog :before-close="closeDialog" :visible.sync="dialogFormVisible" title="弹窗操作"> |
||||
|
<el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="110px"> |
||||
|
<el-form-item label="字典名(中)" prop="name"> |
||||
|
<el-input v-model="formData.name" placeholder="请输入字典名(中)" clearable :style="{width: '100%'}"></el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="字典名(英)" prop="type"> |
||||
|
<el-input v-model="formData.type" placeholder="请输入字典名(英)" clearable :style="{width: '100%'}"></el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="状态" prop="status" required> |
||||
|
<el-switch v-model="formData.status" active-text="开启" inactive-text="停用"></el-switch> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="描述" prop="desc"> |
||||
|
<el-input v-model="formData.desc" placeholder="请输入描述" clearable :style="{width: '100%'}"></el-input> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
|
||||
|
<div class="dialog-footer" slot="footer"> |
||||
|
<el-button @click="closeDialog">取 消</el-button> |
||||
|
<el-button @click="enterDialog" type="primary">确 定</el-button> |
||||
|
</div> |
||||
|
</el-dialog> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import { |
||||
|
createSysDictionary, |
||||
|
deleteSysDictionary, |
||||
|
updateSysDictionary, |
||||
|
findSysDictionary, |
||||
|
getSysDictionaryList |
||||
|
} from "@/api/sys_dictionary"; // 此处请自行替换地址 |
||||
|
import { formatTimeToStr } from "@/utils/data"; |
||||
|
import infoList from "@/components/mixins/infoList"; |
||||
|
|
||||
|
export default { |
||||
|
name: "SysDictionary", |
||||
|
mixins: [infoList], |
||||
|
data() { |
||||
|
return { |
||||
|
listApi: getSysDictionaryList, |
||||
|
dialogFormVisible: false, |
||||
|
visible: false, |
||||
|
type: "", |
||||
|
formData: { |
||||
|
name:null,type:null,status:true,desc:null |
||||
|
}, |
||||
|
rules: { |
||||
|
name: [{ |
||||
|
required: true, |
||||
|
message: '请输入字典名(中)', |
||||
|
trigger: 'blur' |
||||
|
}], |
||||
|
type: [{ |
||||
|
required: true, |
||||
|
message: '请输入字典名(英)', |
||||
|
trigger: 'blur' |
||||
|
}], |
||||
|
desc: [{ |
||||
|
required: true, |
||||
|
message: '请输入描述', |
||||
|
trigger: 'blur' |
||||
|
}], |
||||
|
}, |
||||
|
}; |
||||
|
}, |
||||
|
filters: { |
||||
|
formatDate: function(time) { |
||||
|
if (time != null && time != "") { |
||||
|
var date = new Date(time); |
||||
|
return formatTimeToStr(date, "yyyy-MM-dd hh:mm:ss"); |
||||
|
} else { |
||||
|
return ""; |
||||
|
} |
||||
|
}, |
||||
|
formatBoolean: function(bool) { |
||||
|
if (bool != null) { |
||||
|
return bool ? "是" :"否"; |
||||
|
} else { |
||||
|
return ""; |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
toDetile(row){ |
||||
|
this.$router.push({ |
||||
|
name:"dictionaryDetail", |
||||
|
params:{ |
||||
|
id:row.ID |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
//条件搜索前端看此方法 |
||||
|
onSubmit() { |
||||
|
this.page = 1 |
||||
|
this.pageSize = 10 |
||||
|
if (this.searchInfo.status==""){ |
||||
|
this.searchInfo.status=null |
||||
|
} |
||||
|
this.getTableData() |
||||
|
}, |
||||
|
async updateSysDictionary(row) { |
||||
|
const res = await findSysDictionary({ ID: row.ID }); |
||||
|
this.type = "update"; |
||||
|
if (res.code == 0) { |
||||
|
this.formData = res.data.resysDictionary; |
||||
|
this.dialogFormVisible = true; |
||||
|
} |
||||
|
}, |
||||
|
closeDialog() { |
||||
|
this.dialogFormVisible = false; |
||||
|
this.formData = { |
||||
|
name:null, |
||||
|
type:null, |
||||
|
status:true, |
||||
|
desc:null, |
||||
|
}; |
||||
|
}, |
||||
|
async deleteSysDictionary(row) { |
||||
|
this.visible = false; |
||||
|
const res = await deleteSysDictionary({ ID: row.ID }); |
||||
|
if (res.code == 0) { |
||||
|
this.$message({ |
||||
|
type: "success", |
||||
|
message: "删除成功" |
||||
|
}); |
||||
|
this.getTableData(); |
||||
|
} |
||||
|
}, |
||||
|
async enterDialog() { |
||||
|
this.$refs['elForm'].validate(async valid => { |
||||
|
if (!valid) return |
||||
|
let res; |
||||
|
switch (this.type) { |
||||
|
case "create": |
||||
|
res = await createSysDictionary(this.formData); |
||||
|
break; |
||||
|
case "update": |
||||
|
res = await updateSysDictionary(this.formData); |
||||
|
break; |
||||
|
default: |
||||
|
res = await createSysDictionary(this.formData); |
||||
|
break; |
||||
|
} |
||||
|
if (res.code == 0) { |
||||
|
this.closeDialog(); |
||||
|
this.getTableData(); |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
}, |
||||
|
openDialog() { |
||||
|
this.type = "create"; |
||||
|
this.dialogFormVisible = true; |
||||
|
} |
||||
|
}, |
||||
|
created() { |
||||
|
this.getTableData(); |
||||
|
} |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style> |
||||
|
</style> |
@ -0,0 +1,258 @@ |
|||||
|
<template> |
||||
|
<div> |
||||
|
<div class="search-term"> |
||||
|
<el-form :inline="true" :model="searchInfo" class="demo-form-inline"> |
||||
|
<el-form-item label="展示值"> |
||||
|
<el-input placeholder="搜索条件" v-model="searchInfo.label"></el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="字典值"> |
||||
|
<el-input placeholder="搜索条件" v-model="searchInfo.value"></el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="启用状态" prop="status"> |
||||
|
<el-select v-model="searchInfo.status" placeholder="请选择"> |
||||
|
<el-option key="true" label="是" value="true"></el-option> |
||||
|
<el-option key="false" label="否" value="false"></el-option> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
<el-form-item> |
||||
|
<el-button @click="onSubmit" type="primary">查询</el-button> |
||||
|
</el-form-item> |
||||
|
<el-form-item> |
||||
|
<el-button @click="openDialog" type="primary">新增字典项</el-button> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
</div> |
||||
|
<el-table |
||||
|
:data="tableData" |
||||
|
border |
||||
|
ref="multipleTable" |
||||
|
stripe |
||||
|
style="width: 100%" |
||||
|
tooltip-effect="dark" |
||||
|
> |
||||
|
<el-table-column type="selection" width="55"></el-table-column> |
||||
|
<el-table-column label="日期" width="180"> |
||||
|
<template slot-scope="scope">{{scope.row.CreatedAt|formatDate}}</template> |
||||
|
</el-table-column> |
||||
|
|
||||
|
<el-table-column label="展示值" prop="label" width="120"></el-table-column> |
||||
|
|
||||
|
<el-table-column label="字典值" prop="value" width="120"></el-table-column> |
||||
|
|
||||
|
<el-table-column label="启用状态" prop="status" width="120"> |
||||
|
<template slot-scope="scope">{{scope.row.status|formatBoolean}}</template> |
||||
|
</el-table-column> |
||||
|
|
||||
|
<el-table-column label="排序标记" prop="sort" width="120"></el-table-column> |
||||
|
|
||||
|
<el-table-column label="关联标记" prop="sysDictionaryID" width="120"></el-table-column> |
||||
|
|
||||
|
<el-table-column label="按钮组"> |
||||
|
<template slot-scope="scope"> |
||||
|
<el-button @click="updateSysDictionaryDetail(scope.row)" size="small" type="primary">变更</el-button> |
||||
|
<el-popover placement="top" width="160" v-model="scope.row.visible"> |
||||
|
<p>确定要删除吗?</p> |
||||
|
<div style="text-align: right; margin: 0"> |
||||
|
<el-button size="mini" type="text" @click="scope.row.visible = false">取消</el-button> |
||||
|
<el-button type="primary" size="mini" @click="deleteSysDictionaryDetail(scope.row)">确定</el-button> |
||||
|
</div> |
||||
|
<el-button type="danger" icon="el-icon-delete" size="mini" slot="reference">删除</el-button> |
||||
|
</el-popover> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
</el-table> |
||||
|
|
||||
|
<el-pagination |
||||
|
:current-page="page" |
||||
|
:page-size="pageSize" |
||||
|
:page-sizes="[10, 30, 50, 100]" |
||||
|
:style="{float:'right',padding:'20px'}" |
||||
|
:total="total" |
||||
|
@current-change="handleCurrentChange" |
||||
|
@size-change="handleSizeChange" |
||||
|
layout="total, sizes, prev, pager, next, jumper" |
||||
|
></el-pagination> |
||||
|
|
||||
|
<el-dialog :before-close="closeDialog" :visible.sync="dialogFormVisible" title="弹窗操作"> |
||||
|
<el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="110px"> |
||||
|
<el-form-item label="展示值" prop="label"> |
||||
|
<el-input |
||||
|
v-model="formData.label" |
||||
|
placeholder="请输入展示值" |
||||
|
clearable |
||||
|
:style="{width: '100%'}" |
||||
|
></el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="字典值" prop="value"> |
||||
|
<el-input-number |
||||
|
v-model.number="formData.value" |
||||
|
step-strictly |
||||
|
:step="1" |
||||
|
placeholder="请输入字典值" |
||||
|
clearable |
||||
|
:style="{width: '100%'}" |
||||
|
></el-input-number> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="启用状态" prop="status" required> |
||||
|
<el-switch v-model="formData.status" active-text="开启" inactive-text="停用"></el-switch> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="排序标记" prop="sort"> |
||||
|
<el-input-number v-model.number="formData.sort" placeholder="排序标记"></el-input-number> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
<div class="dialog-footer" slot="footer"> |
||||
|
<el-button @click="closeDialog">取 消</el-button> |
||||
|
<el-button @click="enterDialog" type="primary">确 定</el-button> |
||||
|
</div> |
||||
|
</el-dialog> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import { |
||||
|
createSysDictionaryDetail, |
||||
|
deleteSysDictionaryDetail, |
||||
|
updateSysDictionaryDetail, |
||||
|
findSysDictionaryDetail, |
||||
|
getSysDictionaryDetailList |
||||
|
} from "@/api/sys_dictionary_detail"; // 此处请自行替换地址 |
||||
|
import { formatTimeToStr } from "@/utils/data"; |
||||
|
import infoList from "@/components/mixins/infoList"; |
||||
|
|
||||
|
export default { |
||||
|
name: "SysDictionaryDetail", |
||||
|
mixins: [infoList], |
||||
|
data() { |
||||
|
return { |
||||
|
listApi: getSysDictionaryDetailList, |
||||
|
dialogFormVisible: false, |
||||
|
visible: false, |
||||
|
type: "", |
||||
|
formData: { |
||||
|
label: null, |
||||
|
value: null, |
||||
|
status: true, |
||||
|
sort: null |
||||
|
}, |
||||
|
rules: { |
||||
|
label: [ |
||||
|
{ |
||||
|
required: true, |
||||
|
message: "请输入展示值", |
||||
|
trigger: "blur" |
||||
|
} |
||||
|
], |
||||
|
value: [ |
||||
|
{ |
||||
|
required: true, |
||||
|
message: "请输入字典值", |
||||
|
trigger: "blur" |
||||
|
} |
||||
|
], |
||||
|
sort: [ |
||||
|
{ |
||||
|
required: true, |
||||
|
message: "排序标记", |
||||
|
trigger: "blur" |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
}; |
||||
|
}, |
||||
|
filters: { |
||||
|
formatDate: function(time) { |
||||
|
if (time != null && time != "") { |
||||
|
var date = new Date(time); |
||||
|
return formatTimeToStr(date, "yyyy-MM-dd hh:mm:ss"); |
||||
|
} else { |
||||
|
return ""; |
||||
|
} |
||||
|
}, |
||||
|
formatBoolean: function(bool) { |
||||
|
if (bool != null) { |
||||
|
return bool ? "是" : "否"; |
||||
|
} else { |
||||
|
return ""; |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
//条件搜索前端看此方法 |
||||
|
onSubmit() { |
||||
|
this.page = 1; |
||||
|
this.pageSize = 10; |
||||
|
if (this.searchInfo.status == "") { |
||||
|
this.searchInfo.status = null; |
||||
|
} |
||||
|
this.getTableData(); |
||||
|
}, |
||||
|
async updateSysDictionaryDetail(row) { |
||||
|
const res = await findSysDictionaryDetail({ ID: row.ID }); |
||||
|
this.type = "update"; |
||||
|
if (res.code == 0) { |
||||
|
this.formData = res.data.resysDictionaryDetail; |
||||
|
this.dialogFormVisible = true; |
||||
|
} |
||||
|
}, |
||||
|
closeDialog() { |
||||
|
this.dialogFormVisible = false; |
||||
|
this.formData = { |
||||
|
label: null, |
||||
|
value: null, |
||||
|
status: true, |
||||
|
sort: null, |
||||
|
sysDictionaryID: "" |
||||
|
}; |
||||
|
}, |
||||
|
async deleteSysDictionaryDetail(row) { |
||||
|
this.visible = false; |
||||
|
const res = await deleteSysDictionaryDetail({ ID: row.ID }); |
||||
|
if (res.code == 0) { |
||||
|
this.$message({ |
||||
|
type: "success", |
||||
|
message: "删除成功" |
||||
|
}); |
||||
|
this.getTableData(); |
||||
|
} |
||||
|
}, |
||||
|
async enterDialog() { |
||||
|
this.formData.sysDictionaryID = Number(this.$route.params.id) |
||||
|
this.$refs['elForm'].validate(async valid => { |
||||
|
if (!valid) return |
||||
|
let res; |
||||
|
switch (this.type) { |
||||
|
case "create": |
||||
|
res = await createSysDictionaryDetail(this.formData); |
||||
|
break; |
||||
|
case "update": |
||||
|
res = await updateSysDictionaryDetail(this.formData); |
||||
|
break; |
||||
|
default: |
||||
|
res = await createSysDictionaryDetail(this.formData); |
||||
|
break; |
||||
|
} |
||||
|
if (res.code == 0) { |
||||
|
this.$message({ |
||||
|
type:"success", |
||||
|
message:"创建/更改成功" |
||||
|
}) |
||||
|
this.closeDialog(); |
||||
|
this.getTableData(); |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
}, |
||||
|
openDialog() { |
||||
|
this.type = "create"; |
||||
|
this.dialogFormVisible = true; |
||||
|
} |
||||
|
}, |
||||
|
created() { |
||||
|
this.searchInfo.sysDictionaryID = this.$route.params.id |
||||
|
this.getTableData(); |
||||
|
} |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style> |
||||
|
</style> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue