Commit 67a7a06e authored by sven's avatar sven

Merge remote-tracking branch 'origin/master'

parents f12904d9 d96918e2
...@@ -32,4 +32,8 @@ export default { ...@@ -32,4 +32,8 @@ export default {
getMonitorInfo(params) { getMonitorInfo(params) {
return http.post('web/toilet/getMonitorInfo', params) return http.post('web/toilet/getMonitorInfo', params)
}, },
//类型数据
typeData(params) {
return http.post('web/type/typeData', params)
},
} }
...@@ -20,90 +20,87 @@ ...@@ -20,90 +20,87 @@
<script> <script>
import EZUIKit from "ezuikit-js"; import EZUIKit from "ezuikit-js";
import api from "@/api/methods/index"
let player = null;
export default { export default {
name: "esu", name: "esu",
props: { props: {
url: String, modelValue: Boolean,
accessToken: String, site_id: Number,
}, },
data(){ data(){
return { return {
next_time:Date.now() next_time:Date.now(),
url:'',
accessToken:'',
player:null,
} }
}, },
watch:{ mounted(){
url(val){ this.$nextTick(()=>{
if(val){ this.getMonitorInfo();
this.$nextTick(()=>{ window.addEventListener('onresize',this.resize);
this.init(); })
window.addEventListener('onresize',this.resize);
})
}
}
}, },
methods: { methods: {
play() { play() {
const playPromise = player.play(); const playPromise = this.player.play();
playPromise.then((data) => { playPromise.then((data) => {
console.log("promise 获取 数据", data) console.log("promise 获取 数据", data)
}) })
}, },
stop() { stop() {
const stopPromise = player.stop(); const stopPromise = this.player.stop();
stopPromise.then((data) => { stopPromise.then((data) => {
console.log("promise 获取 数据", data) console.log("promise 获取 数据", data)
}) })
}, },
getOSDTime() { getOSDTime() {
const getOSDTimePromise = player.getOSDTime(); const getOSDTimePromise = this.player.getOSDTime();
getOSDTimePromise.then((data) => { getOSDTimePromise.then((data) => {
console.log("promise 获取 数据", data) console.log("promise 获取 数据", data)
}) })
}, },
capturePicture() { capturePicture() {
const capturePicturePromise = player.capturePicture(`${new Date().getTime()}`); const capturePicturePromise = this.player.capturePicture(`${new Date().getTime()}`);
capturePicturePromise.then((data) => { capturePicturePromise.then((data) => {
console.log("promise 获取 数据", data) console.log("promise 获取 数据", data)
}) })
}, },
openSound() { openSound() {
const openSoundPromise = player.openSound(); const openSoundPromise = this.player.openSound();
openSoundPromise.then((data) => { openSoundPromise.then((data) => {
console.log("promise 获取 数据", data) console.log("promise 获取 数据", data)
}) })
}, },
closeSound() { closeSound() {
const openSoundPromise = player.closeSound(); const openSoundPromise = this.player.closeSound();
openSoundPromise.then((data) => { openSoundPromise.then((data) => {
console.log("promise 获取 数据", data) console.log("promise 获取 数据", data)
}) })
}, },
startSave() { startSave() {
const startSavePromise = player.startSave(`${new Date().getTime()}`); const startSavePromise = this.player.startSave(`${new Date().getTime()}`);
startSavePromise.then((data) => { startSavePromise.then((data) => {
console.log("promise 获取 数据", data) console.log("promise 获取 数据", data)
}) })
}, },
stopSave() { stopSave() {
const stopSavePromise = player.stopSave(); const stopSavePromise = this.player.stopSave();
stopSavePromise.then((data) => { stopSavePromise.then((data) => {
console.log("promise 获取 数据", data) console.log("promise 获取 数据", data)
}) })
}, },
ezopenStartTalk() { ezopenStartTalk() {
player.startTalk(); this.player.startTalk();
}, },
ezopenStopTalk() { ezopenStopTalk() {
player.stopTalk(); this.player.stopTalk();
}, },
fullScreen() { fullScreen() {
player.fullScreen(); this.player.fullScreen();
}, },
destroy() { destroy() {
const destroyPromise = player.destroy(); const destroyPromise = this.player.destroy();
destroyPromise.then((data) => { destroyPromise.then((data) => {
console.log("promise 获取 数据", data) console.log("promise 获取 数据", data)
}) })
...@@ -113,8 +110,19 @@ ...@@ -113,8 +110,19 @@
this.next_time = Date.now(); this.next_time = Date.now();
} }
}, },
getMonitorInfo() {
api.getMonitorInfo({id:this.site_id}).then((res)=>{
if(res.code==0){
if(res.data.access_token){
this.accessToken = res.data.access_token;
this.url = res.data.camera_url;
this.init();
}
}
});
},
init(){ init(){
player = new EZUIKit.EZUIKitPlayer({ this.player = new EZUIKit.EZUIKitPlayer({
id: 'video-container', // 视频容器ID id: 'video-container', // 视频容器ID
accessToken: this.accessToken, accessToken: this.accessToken,
url: this.url, url: this.url,
...@@ -125,8 +133,10 @@ ...@@ -125,8 +133,10 @@
// height: 400, // height: 400,
}); });
this.$nextTick(()=>{ this.$nextTick(()=>{
player.play(); if(this.player){
}); this.player.play();
}
})
} }
} }
}; };
......
...@@ -86,12 +86,12 @@ ...@@ -86,12 +86,12 @@
<div class="filter-one"> <div class="filter-one">
<p class="filter-name">类型筛选</p> <p class="filter-name">类型筛选</p>
<div class="filter-content"> <div class="filter-content">
<el-select v-model="filter.type_name" class="m-2" placeholder="请选择类型" @change="()=>getHistoryDataList()"> <el-select v-model="filter.type_name" class="m-2" clearable placeholder="请选择类型" @change="()=>getHistoryDataList()">
<el-option <el-option
v-for="item in [{name:'全部类型',value:'',prop:''},...typeList]" v-for="(item,index) in type"
:key="item.prop" :key="index"
:label="item.name" :label="item.typeName"
:value="item.prop" :value="item.typeName"
/> />
</el-select> </el-select>
</div> </div>
...@@ -131,11 +131,24 @@ ...@@ -131,11 +131,24 @@
<div class="cell flex_3">{{item.value}} {{item.unit}}</div> <div class="cell flex_3">{{item.value}} {{item.unit}}</div>
<div class="cell">{{item.CreatedAt}}</div> <div class="cell">{{item.CreatedAt}}</div>
</div> </div>
<div class="no-data" v-show="list.data.length==0">暂无历史数据</div>
</div>
<div class="pagination">
<el-pagination
v-model:currentPage="list.page"
v-model:page-size="list.pageSize"
:page-sizes="[5, 10, 15, 20]"
:small="small"
layout="sizes, prev, pager, next"
:total="list.total"
@size-change="()=>getHistoryDataList()"
@current-change="(val)=>getHistoryDataList(val)"
/>
</div> </div>
</div> </div>
</div> </div>
<div class="body-one monitor" v-else-if="tab=='monitor'"> <div class="body-one monitor" v-else-if="tab=='monitor'">
<esu :url="detail.url" :accessToken="detail.accessToken"></esu> <esu :site_id="site_id"></esu>
</div> </div>
<div class="body-one process" v-else-if="tab=='process'"> <div class="body-one process" v-else-if="tab=='process'">
<div class="process-box"> <div class="process-box">
...@@ -231,6 +244,7 @@ ...@@ -231,6 +244,7 @@
<span class="opt" @click="seeDetail(item)">查看</span> <span class="opt" @click="seeDetail(item)">查看</span>
</div> </div>
</div> </div>
<div class="no-data" v-show="list.data.length==0">暂无巡检工单</div>
</div> </div>
<div class="pagination"> <div class="pagination">
<el-pagination <el-pagination
...@@ -238,12 +252,10 @@ ...@@ -238,12 +252,10 @@
v-model:page-size="list.pageSize" v-model:page-size="list.pageSize"
:page-sizes="[10, 15, 20, 25]" :page-sizes="[10, 15, 20, 25]"
:small="small" :small="small"
:disabled="disabled"
:background="background"
layout="sizes, prev, pager, next" layout="sizes, prev, pager, next"
:total="list.total" :total="list.total"
@size-change="()=>getOrderList()" @size-change="()=>getOrderList()"
@current-change="()=>getOrderList()" @current-change="(val)=>getOrderList(val)"
/> />
</div> </div>
</div> </div>
...@@ -283,9 +295,7 @@ ...@@ -283,9 +295,7 @@
poster:[], poster:[],
index: 0, index: 0,
yewei:0, yewei:0,
type:1, type:1
accessToken:'',
url:'',
}, },
showBanner:false, showBanner:false,
tabs: [ tabs: [
...@@ -323,6 +333,7 @@ ...@@ -323,6 +333,7 @@
time:['',''], time:['',''],
time_order:['',''] time_order:['','']
}, },
type:[],
typeList:[ typeList:[
{ {
name:'液位', name:'液位',
...@@ -414,7 +425,7 @@ ...@@ -414,7 +425,7 @@
list:{ list:{
page:1, page:1,
pageSize:15, pageSize:15,
total:20, total:0,
data:[ data:[
] ]
...@@ -438,18 +449,6 @@ ...@@ -438,18 +449,6 @@
} }
}); });
} }
function getMonitorInfo() {
state.detail.accessToken = '';
state.detail.url = '';
api.getMonitorInfo({id:props.site_id}).then((res)=>{
if(res.code==0){
if(res.data.access_token){
state.detail.accessToken = res.data.access_token;
state.detail.url = res.data.camera_url;
}
}
});
}
function typeChange(type=1) { function typeChange(type=1) {
switch (type) { switch (type) {
case 1: case 1:
...@@ -469,14 +468,15 @@ ...@@ -469,14 +468,15 @@
state.tab = item.value; state.tab = item.value;
state.list.data = []; state.list.data = [];
state.list.page = 1; state.list.page = 1;
state.list.pageSize = 15;
state.list.total = 0;
state.monitorShow = false;
if(item.value=='base'){ if(item.value=='base'){
initGauge(); initGauge();
getYewei(); getYewei();
} }
if(item.value=='monitor'){
getMonitorInfo();
}
if(item.value=='history'){ if(item.value=='history'){
getType();
getHistoryDataList(); getHistoryDataList();
} }
if(item.value=='process'){ if(item.value=='process'){
...@@ -630,6 +630,18 @@ ...@@ -630,6 +630,18 @@
} }
}) })
} }
function getType(){
let p = {
};
api.typeData(p).then((res)=>{
if(res.code==0){
if(Array.isArray(res.data)){
state.type = res.data;
}
}
})
}
function getOrderList(page=1){ function getOrderList(page=1){
let p = { let p = {
page:page, page:page,
...@@ -933,8 +945,17 @@ ...@@ -933,8 +945,17 @@
background-color: #7d848b; background-color: #7d848b;
} }
.table-body{ .table-body{
position: relative;
flex: 1; flex: 1;
overflow-y: auto; overflow-y: auto;
.no-data{
position: absolute;
flex: 1;
display: flex;
justify-content: center;
align-items: center;
color:#999;
}
} }
.row{ .row{
height: 60px; height: 60px;
...@@ -1069,9 +1090,6 @@ ...@@ -1069,9 +1090,6 @@
flex: 1; flex: 1;
overflow-y: auto; overflow-y: auto;
} }
.pagination{
margin:0 auto;
}
.row{ .row{
height: 60px; height: 60px;
display: flex; display: flex;
...@@ -1113,6 +1131,9 @@ ...@@ -1113,6 +1131,9 @@
} }
} }
} }
.pagination{
margin:0 auto;
}
} }
.logo{ .logo{
padding: 10px 20px; padding: 10px 20px;
......
...@@ -6,5 +6,6 @@ type ApiGroup struct { ...@@ -6,5 +6,6 @@ type ApiGroup struct {
QshToiletApi QshToiletApi
QshPartolApi QshPartolApi
QshMonitorDataApi QshMonitorDataApi
QshTypeApi
// Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT. // Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT.
} }
package admin
import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/admin"
adminReq "github.com/flipped-aurora/gin-vue-admin/server/model/admin/request"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
"github.com/flipped-aurora/gin-vue-admin/server/service"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
type QshTypeApi struct {
}
var qshTypeService = service.ServiceGroupApp.AdminServiceGroup.QshTypeService
// CreateQshType 创建QshType
// @Tags QshType
// @Summary 创建QshType
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body admin.QshType true "创建QshType"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /qshType/createQshType [post]
func (qshTypeApi *QshTypeApi) CreateQshType(c *gin.Context) {
var qshType admin.QshType
_ = c.ShouldBindJSON(&qshType)
if err := qshTypeService.CreateQshType(qshType); err != nil {
global.GVA_LOG.Error("创建失败!", zap.Error(err))
response.FailWithMessage("创建失败", c)
} else {
response.OkWithMessage("创建成功", c)
}
}
// DeleteQshType 删除QshType
// @Tags QshType
// @Summary 删除QshType
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body admin.QshType true "删除QshType"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /qshType/deleteQshType [delete]
func (qshTypeApi *QshTypeApi) DeleteQshType(c *gin.Context) {
var qshType admin.QshType
_ = c.ShouldBindJSON(&qshType)
if err := qshTypeService.DeleteQshType(qshType); err != nil {
global.GVA_LOG.Error("删除失败!", zap.Error(err))
response.FailWithMessage("删除失败", c)
} else {
response.OkWithMessage("删除成功", c)
}
}
// DeleteQshTypeByIds 批量删除QshType
// @Tags QshType
// @Summary 批量删除QshType
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "批量删除QshType"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
// @Router /qshType/deleteQshTypeByIds [delete]
func (qshTypeApi *QshTypeApi) DeleteQshTypeByIds(c *gin.Context) {
var IDS request.IdsReq
_ = c.ShouldBindJSON(&IDS)
if err := qshTypeService.DeleteQshTypeByIds(IDS); err != nil {
global.GVA_LOG.Error("批量删除失败!", zap.Error(err))
response.FailWithMessage("批量删除失败", c)
} else {
response.OkWithMessage("批量删除成功", c)
}
}
// UpdateQshType 更新QshType
// @Tags QshType
// @Summary 更新QshType
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body admin.QshType true "更新QshType"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /qshType/updateQshType [put]
func (qshTypeApi *QshTypeApi) UpdateQshType(c *gin.Context) {
var qshType admin.QshType
_ = c.ShouldBindJSON(&qshType)
if err := qshTypeService.UpdateQshType(qshType); err != nil {
global.GVA_LOG.Error("更新失败!", zap.Error(err))
response.FailWithMessage("更新失败", c)
} else {
response.OkWithMessage("更新成功", c)
}
}
// FindQshType 用id查询QshType
// @Tags QshType
// @Summary 用id查询QshType
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query admin.QshType true "用id查询QshType"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /qshType/findQshType [get]
func (qshTypeApi *QshTypeApi) FindQshType(c *gin.Context) {
var qshType admin.QshType
_ = c.ShouldBindQuery(&qshType)
if reqshType, err := qshTypeService.GetQshType(qshType.ID); err != nil {
global.GVA_LOG.Error("查询失败!", zap.Error(err))
response.FailWithMessage("查询失败", c)
} else {
response.OkWithData(gin.H{"reqshType": reqshType}, c)
}
}
// GetQshTypeList 分页获取QshType列表
// @Tags QshType
// @Summary 分页获取QshType列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query adminReq.QshTypeSearch true "分页获取QshType列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /qshType/getQshTypeList [get]
func (qshTypeApi *QshTypeApi) GetQshTypeList(c *gin.Context) {
var pageInfo adminReq.QshTypeSearch
_ = c.ShouldBindQuery(&pageInfo)
if list, total, err := qshTypeService.GetQshTypeInfoList(pageInfo); err != nil {
global.GVA_LOG.Error("获取失败!", zap.Error(err))
response.FailWithMessage("获取失败", c)
} else {
response.OkWithDetailed(response.PageResult{
List: list,
Total: total,
Page: pageInfo.Page,
PageSize: pageInfo.PageSize,
}, "获取成功", c)
}
}
package web
import (
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
"github.com/flipped-aurora/gin-vue-admin/server/service/web"
"github.com/gin-gonic/gin"
)
var TypeService = new(web.TypeService)
func GetType(c *gin.Context) {
typeData, err := TypeService.GetType()
if err != nil {
response.FailWithMessage(err.Error(), c)
return
}
response.OkWithData(typeData, c)
}
...@@ -56,6 +56,7 @@ func RegisterTables(db *gorm.DB) { ...@@ -56,6 +56,7 @@ func RegisterTables(db *gorm.DB) {
admin.QshToilet{}, admin.QshToilet{},
admin.QshPatrol{}, admin.QshPatrol{},
admin.QshMonitorData{}, admin.QshMonitorData{},
admin.QshType{},
// Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT. // Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT.
) )
if err != nil { if err != nil {
......
...@@ -75,6 +75,7 @@ func Routers() *gin.Engine { ...@@ -75,6 +75,7 @@ func Routers() *gin.Engine {
adminRouter.InitQshToiletRouter(PrivateGroup) adminRouter.InitQshToiletRouter(PrivateGroup)
adminRouter.InitQshPartolRouter(PrivateGroup) adminRouter.InitQshPartolRouter(PrivateGroup)
adminRouter.InitQshMonitorDataRouter(PrivateGroup) adminRouter.InitQshMonitorDataRouter(PrivateGroup)
adminRouter.InitQshTypeRouter(PrivateGroup)
// Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT. // Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT.
} }
......
...@@ -8,7 +8,7 @@ import ( ...@@ -8,7 +8,7 @@ import (
"github.com/songzhibin97/gkit/tools/gjson" "github.com/songzhibin97/gkit/tools/gjson"
) )
var exCheck = []string{"/web/login/login", "/web/oss/getOssConfig"} var exCheck = []string{"/web/login/login", "/web/oss/getOssConfig", "/web/type/typeData"}
func Token() gin.HandlerFunc { func Token() gin.HandlerFunc {
return func(c *gin.Context) { return func(c *gin.Context) {
......
// 自动生成模板QshType
package admin
import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
)
// QshType 结构体
type QshType struct {
global.GVA_MODEL
TypeName string `json:"typeName" form:"typeName" gorm:"column:type_name;comment:类型名称;size:191;"`
}
// TableName QshType 表名
func (QshType) TableName() string {
return "qsh_type"
}
...@@ -8,4 +8,6 @@ import ( ...@@ -8,4 +8,6 @@ import (
type QshMonitorDataSearch struct { type QshMonitorDataSearch struct {
admin.QshMonitorData admin.QshMonitorData
request.PageInfo request.PageInfo
StartTime string `json:"start_time" form:"start_time"`
EndTime string `json:"end_time" form:"end_time"`
} }
package request
import (
"github.com/flipped-aurora/gin-vue-admin/server/model/admin"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
)
type QshTypeSearch struct {
admin.QshType
request.PageInfo
}
...@@ -6,5 +6,6 @@ type RouterGroup struct { ...@@ -6,5 +6,6 @@ type RouterGroup struct {
QshToiletRouter QshToiletRouter
QshPartolRouter QshPartolRouter
QshMonitorDataRouter QshMonitorDataRouter
QshTypeRouter
// Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT. // Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT.
} }
package admin
import (
"github.com/flipped-aurora/gin-vue-admin/server/api/v1"
"github.com/flipped-aurora/gin-vue-admin/server/middleware"
"github.com/gin-gonic/gin"
)
type QshTypeRouter struct {
}
// InitQshTypeRouter 初始化 QshType 路由信息
func (s *QshTypeRouter) InitQshTypeRouter(Router *gin.RouterGroup) {
qshTypeRouter := Router.Group("qshType").Use(middleware.OperationRecord())
qshTypeRouterWithoutRecord := Router.Group("qshType")
var qshTypeApi = v1.ApiGroupApp.AdminApiGroup.QshTypeApi
{
qshTypeRouter.POST("createQshType", qshTypeApi.CreateQshType) // 新建QshType
qshTypeRouter.DELETE("deleteQshType", qshTypeApi.DeleteQshType) // 删除QshType
qshTypeRouter.DELETE("deleteQshTypeByIds", qshTypeApi.DeleteQshTypeByIds) // 批量删除QshType
qshTypeRouter.PUT("updateQshType", qshTypeApi.UpdateQshType) // 更新QshType
}
{
qshTypeRouterWithoutRecord.GET("findQshType", qshTypeApi.FindQshType) // 根据ID获取QshType
qshTypeRouterWithoutRecord.GET("getQshTypeList", qshTypeApi.GetQshTypeList) // 获取QshType列表
}
}
...@@ -33,4 +33,9 @@ func InitWebRouter(router *gin.Engine) { ...@@ -33,4 +33,9 @@ func InitWebRouter(router *gin.Engine) {
data.POST("getHistoryDataList", web.GetHistoryDataList) data.POST("getHistoryDataList", web.GetHistoryDataList)
data.POST("getYewei", web.GetYewei) data.POST("getYewei", web.GetYewei)
} }
typeData := webRouter.Group("type")
{
typeData.POST("typeData", web.GetType)
}
} }
...@@ -6,5 +6,6 @@ type ServiceGroup struct { ...@@ -6,5 +6,6 @@ type ServiceGroup struct {
QshToiletService QshToiletService
QshPartolService QshPartolService
QshMonitorDataService QshMonitorDataService
QshTypeService
// Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT. // Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT.
} }
...@@ -60,10 +60,19 @@ func (qshMonitorDataService *QshMonitorDataService) GetQshMonitorDataInfoList(in ...@@ -60,10 +60,19 @@ func (qshMonitorDataService *QshMonitorDataService) GetQshMonitorDataInfoList(in
if info.TypeName != "" { if info.TypeName != "" {
db = db.Where("type_name LIKE ?", "%"+info.TypeName+"%") db = db.Where("type_name LIKE ?", "%"+info.TypeName+"%")
} }
if info.ToiletId != 0 {
db = db.Where("toilet_id = ?", info.ToiletId)
}
if info.StartTime != "" {
db.Where("created_at >= ?", info.StartTime)
}
if info.EndTime != "" {
db.Where("created_at <= ?", info.EndTime)
}
err = db.Count(&total).Error err = db.Count(&total).Error
if err != nil { if err != nil {
return return
} }
err = db.Limit(limit).Offset(offset).Find(&qshMonitorDatas).Error err = db.Limit(limit).Offset(offset).Order("created_at desc").Find(&qshMonitorDatas).Error
return qshMonitorDatas, total, err return qshMonitorDatas, total, err
} }
package admin
import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/admin"
adminReq "github.com/flipped-aurora/gin-vue-admin/server/model/admin/request"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
)
type QshTypeService struct {
}
// CreateQshType 创建QshType记录
// Author [piexlmax](https://github.com/piexlmax)
func (qshTypeService *QshTypeService) CreateQshType(qshType admin.QshType) (err error) {
err = global.GVA_DB.Create(&qshType).Error
return err
}
// DeleteQshType 删除QshType记录
// Author [piexlmax](https://github.com/piexlmax)
func (qshTypeService *QshTypeService) DeleteQshType(qshType admin.QshType) (err error) {
err = global.GVA_DB.Delete(&qshType).Error
return err
}
// DeleteQshTypeByIds 批量删除QshType记录
// Author [piexlmax](https://github.com/piexlmax)
func (qshTypeService *QshTypeService) DeleteQshTypeByIds(ids request.IdsReq) (err error) {
err = global.GVA_DB.Delete(&[]admin.QshType{}, "id in ?", ids.Ids).Error
return err
}
// UpdateQshType 更新QshType记录
// Author [piexlmax](https://github.com/piexlmax)
func (qshTypeService *QshTypeService) UpdateQshType(qshType admin.QshType) (err error) {
err = global.GVA_DB.Save(&qshType).Error
return err
}
// GetQshType 根据id获取QshType记录
// Author [piexlmax](https://github.com/piexlmax)
func (qshTypeService *QshTypeService) GetQshType(id uint) (qshType admin.QshType, err error) {
err = global.GVA_DB.Where("id = ?", id).First(&qshType).Error
return
}
// GetQshTypeInfoList 分页获取QshType记录
// Author [piexlmax](https://github.com/piexlmax)
func (qshTypeService *QshTypeService) GetQshTypeInfoList(info adminReq.QshTypeSearch) (list interface{}, total int64, err error) {
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
// 创建db
db := global.GVA_DB.Model(&admin.QshType{})
var qshTypes []admin.QshType
// 如果有条件搜索 下方会自动创建搜索语句
err = db.Count(&total).Error
if err != nil {
return
}
err = db.Limit(limit).Offset(offset).Find(&qshTypes).Error
return qshTypes, total, err
}
package web
import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/admin"
)
type TypeService struct {
}
func (s *TypeService) GetType() ([]admin.QshType, error) {
var typeData []admin.QshType
err := global.GVA_DB.Model(admin.QshType{}).Find(&typeData).Error
if err != nil {
return typeData, err
}
return typeData, nil
}
import service from '@/utils/request'
// @Tags QshType
// @Summary 创建QshType
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.QshType true "创建QshType"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /qshType/createQshType [post]
export const createQshType = (data) => {
return service({
url: '/qshType/createQshType',
method: 'post',
data
})
}
// @Tags QshType
// @Summary 删除QshType
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.QshType true "删除QshType"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /qshType/deleteQshType [delete]
export const deleteQshType = (data) => {
return service({
url: '/qshType/deleteQshType',
method: 'delete',
data
})
}
// @Tags QshType
// @Summary 删除QshType
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "批量删除QshType"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /qshType/deleteQshType [delete]
export const deleteQshTypeByIds = (data) => {
return service({
url: '/qshType/deleteQshTypeByIds',
method: 'delete',
data
})
}
// @Tags QshType
// @Summary 更新QshType
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.QshType true "更新QshType"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /qshType/updateQshType [put]
export const updateQshType = (data) => {
return service({
url: '/qshType/updateQshType',
method: 'put',
data
})
}
// @Tags QshType
// @Summary 用id查询QshType
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query model.QshType true "用id查询QshType"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /qshType/findQshType [get]
export const findQshType = (params) => {
return service({
url: '/qshType/findQshType',
method: 'get',
params
})
}
// @Tags QshType
// @Summary 分页获取QshType列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query request.PageInfo true "分页获取QshType列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /qshType/getQshTypeList [get]
export const getQshTypeList = (params) => {
return service({
url: '/qshType/getQshTypeList',
method: 'get',
params
})
}
...@@ -3,7 +3,7 @@ import config from '@/core/config' ...@@ -3,7 +3,7 @@ import config from '@/core/config'
export default function getPageTitle(pageTitle, route) { export default function getPageTitle(pageTitle, route) {
if (pageTitle) { if (pageTitle) {
const title = fmtTitle(pageTitle, route) const title = fmtTitle(pageTitle, route)
return `${title} - ${config.appName}` return `${title} - 公厕监控后台`
} }
return `${config.appName}` return `${config.appName}`
} }
...@@ -2,11 +2,31 @@ ...@@ -2,11 +2,31 @@
<div> <div>
<div class="gva-search-box"> <div class="gva-search-box">
<el-form :inline="true" :model="searchInfo" class="demo-form-inline"> <el-form :inline="true" :model="searchInfo" class="demo-form-inline">
<el-form-item label="原始设备ID"> <el-form-item label="公厕名称">
<el-input v-model="searchInfo.rawDeviceId" placeholder="搜索条件"/> <el-select v-model="searchInfo.toiletId" placeholder="请选择" style="width:100%" clearable>
<el-option v-for="(item,key) in toiletList" :key="key" :label="item.name"
:value="item.ID"/>
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="数据类型"> <el-form-item label="数据类型">
<el-input v-model="searchInfo.typeName" placeholder="搜索条件"/> <el-select v-model="searchInfo.typeName" placeholder="请选择" style="width:100%" clearable>
<el-option v-for="(item,key) in typeList" :key="key" :label="item.typeName"
:value="item.typeName"/>
</el-select>
</el-form-item>
<el-form-item label="时间筛选">
<el-date-picker
v-model="time"
type="datetimerange"
format="YYYY-MM-DD HH:mm"
value-format="YYYY-MM-DD HH:mm"
range-separator="至"
start-placeholder="开始时间"
end-placeholder="结束时间"
:teleported="false"
:editable="true"
@change="(val)=>changeTime(val)"
/>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button size="small" type="primary" icon="search" @click="onSubmit">查询</el-button> <el-button size="small" type="primary" icon="search" @click="onSubmit">查询</el-button>
...@@ -15,21 +35,6 @@ ...@@ -15,21 +35,6 @@
</el-form> </el-form>
</div> </div>
<div class="gva-table-box"> <div class="gva-table-box">
<div class="gva-btn-list">
<!--<el-button size="small" type="primary" icon="plus" @click="openDialog">新增</el-button>-->
<el-popover v-model:visible="deleteVisible" placement="top" width="160">
<p>确定要删除吗?</p>
<div style="text-align: right; margin-top: 8px;">
<el-button size="small" type="primary" link @click="deleteVisible = false">取消</el-button>
<el-button size="small" type="primary" @click="onDelete">确定</el-button>
</div>
<template #reference>
<el-button icon="delete" size="small" style="margin-left: 10px;"
:disabled="!multipleSelection.length" @click="deleteVisible = true">删除
</el-button>
</template>
</el-popover>
</div>
<el-table <el-table
ref="multipleTable" ref="multipleTable"
style="flex: 1;" style="flex: 1;"
...@@ -41,11 +46,14 @@ ...@@ -41,11 +46,14 @@
> >
<el-table-column type="selection" width="55"/> <el-table-column type="selection" width="55"/>
<el-table-column align="left" label="原始设备ID" prop="rawDeviceId" min-width="120"/> <el-table-column align="left" label="原始设备编号" prop="rawDeviceId" min-width="120"/>
<el-table-column align="left" label="公厕ID" prop="toiletId" min-width="120"/> <el-table-column align="left" label="公厕名称" prop="toiletId" min-width="180">
<template #default="scope">{{ toiletList.find(one=>one.ID==scope.row.toiletId).name}}</template>
</el-table-column>
<el-table-column align="left" label="数据类型" prop="typeName" min-width="120"/> <el-table-column align="left" label="数据类型" prop="typeName" min-width="120"/>
<el-table-column align="left" label="数据值单位" prop="unit" min-width="120"/> <el-table-column align="left" label="数据值单位" prop="unit" min-width="120"/>
<el-table-column align="left" label="数据值" prop="value" min-width="120"/> <el-table-column align="left" label="数据值" prop="value" min-width="120"/>
<el-table-column align="left" label="创建时间" min-width="180"> <el-table-column align="left" label="创建时间" min-width="180">
<template #default="scope">{{ formatDate(scope.row.CreatedAt) }}</template> <template #default="scope">{{ formatDate(scope.row.CreatedAt) }}</template>
</el-table-column> </el-table-column>
...@@ -54,8 +62,6 @@ ...@@ -54,8 +62,6 @@
<el-button type="primary" link icon="edit" size="small" class="table-button" <el-button type="primary" link icon="edit" size="small" class="table-button"
@click="updateQshMonitorDataFunc(scope.row)">查看 @click="updateQshMonitorDataFunc(scope.row)">查看
</el-button> </el-button>
<el-button type="primary" link icon="delete" size="small" @click="deleteRow(scope.row)">删除
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -73,11 +79,11 @@ ...@@ -73,11 +79,11 @@
</div> </div>
<el-dialog v-model="dialogFormVisible" :before-close="closeDialog" title="历史数据"> <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" title="历史数据">
<el-form :model="formData" label-position="right" label-width="120px"> <el-form :model="formData" label-position="right" label-width="120px">
<el-form-item label="原始设备ID:"> <el-form-item label="原始设备编号:">
<el-input v-model="formData.rawDeviceId" clearable placeholder="请输入"/> <el-input v-model="formData.rawDeviceId" clearable placeholder="请输入"/>
</el-form-item> </el-form-item>
<el-form-item label="公厕ID:"> <el-form-item label="公厕名称:">
<el-input v-model="formData.toiletId" clearable placeholder="请输入"/> <el-input :value="toiletList.find(one=>one.ID==formData.toiletId).name" clearable placeholder="请输入"/>
</el-form-item> </el-form-item>
<el-form-item label="数据类型:"> <el-form-item label="数据类型:">
<el-input v-model="formData.typeName" clearable placeholder="请输入"/> <el-input v-model="formData.typeName" clearable placeholder="请输入"/>
...@@ -115,6 +121,13 @@ ...@@ -115,6 +121,13 @@
getQshMonitorDataList getQshMonitorDataList
} from '@/api/qshMonitorData' } from '@/api/qshMonitorData'
import {
getQshToiletList
} from '@/api/qshToilet'
import {
getQshTypeList
} from '@/api/qshType'
// 全量引入格式化工具 请按需保留 // 全量引入格式化工具 请按需保留
import {getDictFunc, formatDate, formatBoolean, filterDict} from '@/utils/format' import {getDictFunc, formatDate, formatBoolean, filterDict} from '@/utils/format'
import {ElMessage, ElMessageBox} from 'element-plus' import {ElMessage, ElMessageBox} from 'element-plus'
...@@ -133,12 +146,38 @@ ...@@ -133,12 +146,38 @@
const page = ref(1) const page = ref(1)
const total = ref(0) const total = ref(0)
const pageSize = ref(10) const pageSize = ref(10)
const time = ref(['',''])
const tableData = ref([]) const tableData = ref([])
const searchInfo = ref({}) const toiletList = ref([])
const typeList = ref([])
const searchInfo = ref({
toiletId:'',
typeName:'',
start_time:'',
end_time:'',
})
// 重置
const changeTime = (val) => {
if(val){
searchInfo.value.start_time=val[0];
searchInfo.value.end_time=val[1];
}else{
searchInfo.value.start_time='';
searchInfo.value.end_time='';
time.value = ['','']
}
}
// 重置 // 重置
const onReset = () => { const onReset = () => {
searchInfo.value = {} searchInfo.value = {
toiletId:'',
typeName:'',
start_time:'',
end_time:'',
}
time.value = ['',''];
} }
// 搜索 // 搜索
...@@ -170,7 +209,23 @@ ...@@ -170,7 +209,23 @@
pageSize.value = table.data.pageSize pageSize.value = table.data.pageSize
} }
} }
// 查询
const getToiletData = async () => {
const table = await getQshToiletList({page: 1, pageSize: 999})
if (table.code === 0) {
toiletList.value = table.data.list
}
}
// 查询
const getTypeList = async () => {
const table = await getQshTypeList({page: 1, pageSize: 999})
if (table.code === 0) {
typeList.value = table.data.list
}
}
getToiletData()
getTypeList()
getTableData() getTableData()
// ============== 表格控制部分结束 =============== // ============== 表格控制部分结束 ===============
......
...@@ -81,29 +81,30 @@ ...@@ -81,29 +81,30 @@
</div> </div>
</div> </div>
<el-dialog v-model="dialogFormVisible" :before-close="closeDialog" title="公厕详情"> <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" title="公厕详情">
<el-form :model="formData" label-position="right" label-width="120px"> <el-form :model="formData" label-position="right" label-width="120px"
<el-form-item label="点位名称:"> :rules="rules">
<el-form-item label="点位名称:" prop="name">
<el-input v-model="formData.name" clearable placeholder="请输入"/> <el-input v-model="formData.name" clearable placeholder="请输入"/>
</el-form-item> </el-form-item>
<el-form-item label="公厕类型:"> <el-form-item label="公厕类型:" prop="type">
<el-select v-model="formData.type" placeholder="请选择" style="width:100%" clearable> <el-select v-model="formData.type" placeholder="请选择" style="width:100%" clearable>
<el-option v-for="(item,key) in typeOptions" :key="key" :label="item.label" <el-option v-for="(item,key) in typeOptions" :key="key" :label="item.label"
:value="item.value"/> :value="item.value"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="公厕地址:"> <el-form-item label="公厕地址:" prop="address">
<el-input v-model="formData.address" type="textarea" resize="none" clearable placeholder="请输入"/> <el-input v-model="formData.address" type="textarea" resize="none" clearable placeholder="请输入"/>
</el-form-item> </el-form-item>
<el-form-item label="展示图片:"> <el-form-item label="展示图片:" prop="showImage">
<new-upload v-if="dialogFormVisible" :list="[formData.showImage]" @upload="(file)=>formData.showImage = file[0]"></new-upload> <new-upload v-if="dialogFormVisible" :list="[formData.showImage]" @upload="(file)=>formData.showImage = file[0]"></new-upload>
</el-form-item> </el-form-item>
<el-form-item label="轮播图片:"> <el-form-item label="轮播图片:" prop="image">
<new-upload v-if="dialogFormVisible" :limit="9" :list="formData.image?formData.image.split(','):[]" @upload="(file)=>formData.image = file.join(',')" :multiply="true"></new-upload> <new-upload v-if="dialogFormVisible" :limit="9" :list="formData.image?formData.image.split(','):[]" @upload="(file)=>formData.image = file.join(',')" :multiply="true"></new-upload>
</el-form-item> </el-form-item>
<el-form-item label="纬度:"> <el-form-item label="纬度:" prop="lat">
<el-input v-model="formData.lat" clearable placeholder="请输入"/> <el-input v-model="formData.lat" clearable placeholder="请输入"/>
</el-form-item> </el-form-item>
<el-form-item label="经度:"> <el-form-item label="经度:" prop="lng">
<el-input v-model="formData.lng" clearable placeholder="请输入"/> <el-input v-model="formData.lng" clearable placeholder="请输入"/>
</el-form-item> </el-form-item>
<el-form-item label="管理人员:"> <el-form-item label="管理人员:">
...@@ -115,10 +116,10 @@ ...@@ -115,10 +116,10 @@
<el-form-item label="监控账号:"> <el-form-item label="监控账号:">
<el-input v-model="formData.monitor_ac" clearable placeholder="请输入"/> <el-input v-model="formData.monitor_ac" clearable placeholder="请输入"/>
</el-form-item> </el-form-item>
<el-form-item label="监控ID:"> <el-form-item label="监控设备编号:">
<el-input v-model="formData.monitor_id" clearable placeholder="请输入"/> <el-input v-model="formData.monitor_id" clearable placeholder="请输入"/>
</el-form-item> </el-form-item>
<el-form-item label="设备ID:"> <el-form-item label="液位设备编号:">
<el-input v-model="formData.yewei_device" clearable placeholder="请输入"/> <el-input v-model="formData.yewei_device" clearable placeholder="请输入"/>
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -167,9 +168,49 @@ ...@@ -167,9 +168,49 @@
yewei_device: '',//设备ID yewei_device: '',//设备ID
name: '', name: '',
showImage: '', showImage: '',
type: undefined, type: '',
})
const rules = ref({
name: [
{ required: true, message: '', trigger: 'blur' }
],
type: [
{
required: true,
message: '',
trigger: 'change',
},
],
address: [
{
required: true,
message: '',
trigger: 'blur',
},
],
showImage: [
{
type: 'date',
required: true,
message: '',
trigger: 'change',
},
],
image: [
{
type: 'date',
required: true,
message: '',
trigger: 'change',
},
],
lat: [
{ required: true, message: '', trigger: 'blur' }
],
lng: [
{ required: true, message: '', trigger: 'blur' }
],
}) })
// =========== 表格控制部分 =========== // =========== 表格控制部分 ===========
const page = ref(1) const page = ref(1)
const total = ref(0) const total = ref(0)
...@@ -328,12 +369,33 @@ ...@@ -328,12 +369,33 @@
yewei_device: '',//设备ID yewei_device: '',//设备ID
name: '', name: '',
showImage: '', showImage: '',
type: undefined, type: '',
} }
} }
// 弹窗确定 // 弹窗确定
const enterDialog = async () => { const enterDialog = async () => {
let res let res
if(!formData.value.name){
return ElMessage({message:'请填写公厕名称',type:'warning'})
}
if(!formData.value.type){
return ElMessage({message:'请选择公厕类型',type:'warning'})
}
if(!formData.value.address){
return ElMessage({message:'请填写公厕地址',type:'warning'})
}
if(!formData.value.showImage){
return ElMessage({message:'请上传展示图片',type:'warning'})
}
if(!formData.value.image){
return ElMessage({message:'请上传轮播图片',type:'warning'})
}
if(!formData.value.lat){
return ElMessage({message:'请填写经度',type:'warning'})
}
if(!formData.value.lng){
return ElMessage({message:'请填写纬度',type:'warning'})
}
switch (type.value) { switch (type.value) {
case 'create': case 'create':
res = await createQshToilet(formData.value) res = await createQshToilet(formData.value)
......
<template>
<div>
<div class="gva-search-box">
<el-form :inline="true" :model="searchInfo" class="demo-form-inline">
<el-form-item>
<el-button size="small" type="primary" icon="search" @click="onSubmit">查询</el-button>
<el-button size="small" icon="refresh" @click="onReset">重置</el-button>
</el-form-item>
</el-form>
</div>
<div class="gva-table-box">
<div class="gva-btn-list">
<el-button size="small" type="primary" icon="plus" @click="openDialog">新增</el-button>
<el-popover v-model:visible="deleteVisible" placement="top" width="160">
<p>确定要删除吗?</p>
<div style="text-align: right; margin-top: 8px;">
<el-button size="small" type="primary" link @click="deleteVisible = false">取消</el-button>
<el-button size="small" type="primary" @click="onDelete">确定</el-button>
</div>
<template #reference>
<el-button icon="delete" size="small" style="margin-left: 10px;" :disabled="!multipleSelection.length" @click="deleteVisible = true">删除</el-button>
</template>
</el-popover>
</div>
<el-table
ref="multipleTable"
style="width: 100%"
tooltip-effect="dark"
:data="tableData"
row-key="ID"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" />
<el-table-column align="left" label="日期" width="180">
<template #default="scope">{{ formatDate(scope.row.CreatedAt) }}</template>
</el-table-column>
<el-table-column align="left" label="类型名称" prop="typeName" width="120" />
<el-table-column align="left" label="按钮组">
<template #default="scope">
<el-button type="primary" link icon="edit" size="small" class="table-button" @click="updateQshTypeFunc(scope.row)">变更</el-button>
<el-button type="primary" link icon="delete" size="small" @click="deleteRow(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="gva-pagination">
<el-pagination
layout="total, sizes, prev, pager, next, jumper"
:current-page="page"
:page-size="pageSize"
:page-sizes="[10, 30, 50, 100]"
:total="total"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
/>
</div>
</div>
<el-dialog v-model="dialogFormVisible" :before-close="closeDialog" title="弹窗操作">
<el-form :model="formData" label-position="right" label-width="80px">
<el-form-item label="类型名称:">
<el-input v-model="formData.typeName" clearable placeholder="请输入" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button size="small" @click="closeDialog">取 消</el-button>
<el-button size="small" type="primary" @click="enterDialog">确 定</el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script>
export default {
name: 'QshType'
}
</script>
<script setup>
import {
createQshType,
deleteQshType,
deleteQshTypeByIds,
updateQshType,
findQshType,
getQshTypeList
} from '@/api/qshType'
// 全量引入格式化工具 请按需保留
import { getDictFunc, formatDate, formatBoolean, filterDict } from '@/utils/format'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ref } from 'vue'
// 自动化生成的字典(可能为空)以及字段
const formData = ref({
typeName: '',
})
// =========== 表格控制部分 ===========
const page = ref(1)
const total = ref(0)
const pageSize = ref(10)
const tableData = ref([])
const searchInfo = ref({})
// 重置
const onReset = () => {
searchInfo.value = {}
}
// 搜索
const onSubmit = () => {
page.value = 1
pageSize.value = 10
getTableData()
}
// 分页
const handleSizeChange = (val) => {
pageSize.value = val
getTableData()
}
// 修改页面容量
const handleCurrentChange = (val) => {
page.value = val
getTableData()
}
// 查询
const getTableData = async() => {
const table = await getQshTypeList({ page: page.value, pageSize: pageSize.value, ...searchInfo.value })
if (table.code === 0) {
tableData.value = table.data.list
total.value = table.data.total
page.value = table.data.page
pageSize.value = table.data.pageSize
}
}
getTableData()
// ============== 表格控制部分结束 ===============
// 获取需要的字典 可能为空 按需保留
const setOptions = async () =>{
}
// 获取需要的字典 可能为空 按需保留
setOptions()
// 多选数据
const multipleSelection = ref([])
// 多选
const handleSelectionChange = (val) => {
multipleSelection.value = val
}
// 删除行
const deleteRow = (row) => {
ElMessageBox.confirm('确定要删除吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteQshTypeFunc(row)
})
}
// 批量删除控制标记
const deleteVisible = ref(false)
// 多选删除
const onDelete = async() => {
const ids = []
if (multipleSelection.value.length === 0) {
ElMessage({
type: 'warning',
message: '请选择要删除的数据'
})
return
}
multipleSelection.value &&
multipleSelection.value.map(item => {
ids.push(item.ID)
})
const res = await deleteQshTypeByIds({ ids })
if (res.code === 0) {
ElMessage({
type: 'success',
message: '删除成功'
})
if (tableData.value.length === ids.length && page.value > 1) {
page.value--
}
deleteVisible.value = false
getTableData()
}
}
// 行为控制标记(弹窗内部需要增还是改)
const type = ref('')
// 更新行
const updateQshTypeFunc = async(row) => {
const res = await findQshType({ ID: row.ID })
type.value = 'update'
if (res.code === 0) {
formData.value = res.data.reqshType
dialogFormVisible.value = true
}
}
// 删除行
const deleteQshTypeFunc = async (row) => {
const res = await deleteQshType({ ID: row.ID })
if (res.code === 0) {
ElMessage({
type: 'success',
message: '删除成功'
})
if (tableData.value.length === 1 && page.value > 1) {
page.value--
}
getTableData()
}
}
// 弹窗控制标记
const dialogFormVisible = ref(false)
// 打开弹窗
const openDialog = () => {
type.value = 'create'
dialogFormVisible.value = true
}
// 关闭弹窗
const closeDialog = () => {
dialogFormVisible.value = false
formData.value = {
typeName: '',
}
}
// 弹窗确定
const enterDialog = async () => {
let res
switch (type.value) {
case 'create':
res = await createQshType(formData.value)
break
case 'update':
res = await updateQshType(formData.value)
break
default:
res = await createQshType(formData.value)
break
}
if (res.code === 0) {
ElMessage({
type: 'success',
message: '创建/更改成功'
})
closeDialog()
getTableData()
}
}
</script>
<style>
</style>
<template>
<div>
<div class="gva-form-box">
<el-form :model="formData" label-position="right" label-width="80px">
<el-form-item label="类型名称:">
<el-input v-model="formData.typeName" clearable placeholder="请输入" />
</el-form-item>
<el-form-item>
<el-button size="mini" type="primary" @click="save">保存</el-button>
<el-button size="mini" type="primary" @click="back">返回</el-button>
</el-form-item>
</el-form>
</div>
</div>
</template>
<script>
export default {
name: 'QshType'
}
</script>
<script setup>
import {
createQshType,
updateQshType,
findQshType
} from '@/api/qshType'
// 自动获取字典
import { getDictFunc } from '@/utils/format'
import { useRoute, useRouter } from "vue-router"
import { ElMessage } from 'element-plus'
import { ref } from 'vue'
const route = useRoute()
const router = useRouter()
const type = ref('')
const formData = ref({
typeName: '',
})
// 初始化方法
const init = async () => {
// 建议通过url传参获取目标数据ID 调用 find方法进行查询数据操作 从而决定本页面是create还是update 以下为id作为url参数示例
if (route.query.id) {
const res = await findQshType({ ID: route.query.id })
if (res.code === 0) {
formData.value = res.data.reqshType
type.value = 'update'
}
} else {
type.value = 'create'
}
}
init()
// 保存按钮
const save = async() => {
let res
switch (type.value) {
case 'create':
res = await createQshType(formData.value)
break
case 'update':
res = await updateQshType(formData.value)
break
default:
res = await createQshType(formData.value)
break
}
if (res.code === 0) {
ElMessage({
type: 'success',
message: '创建/更改成功'
})
}
}
// 返回按钮
const back = () => {
router.go(-1)
}
</script>
<style>
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment