parent
c729f60980
commit
2cfffd648d
@ -0,0 +1,3 @@
|
||||
{
|
||||
"java.compile.nullAnalysis.mode": "automatic"
|
||||
}
|
@ -1,17 +1,32 @@
|
||||
package com.example.zxweb;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
@Slf4j
|
||||
@SpringBootApplication
|
||||
public class KafkaApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ConfigurableApplicationContext context = SpringApplication.run(KafkaApplication.class, args);
|
||||
Environment bean = context.getBean(Environment.class);
|
||||
System.out.println("---启动完成,当前使用端口:[" + bean.getProperty("local.server.port") + "]---");
|
||||
public static void main(String[] args) throws UnknownHostException {
|
||||
ConfigurableApplicationContext application = SpringApplication.run(KafkaApplication.class, args);
|
||||
Environment env = application.getEnvironment();
|
||||
String ip = InetAddress.getLocalHost().getHostAddress();
|
||||
String port = env.getProperty("server.port");
|
||||
String path = env.getProperty("server.servlet.context-path");
|
||||
path=path==null?"":path;
|
||||
log.info("---启动完成,当前使用端口:[" + port + "]---");
|
||||
log.info("\n----------------------------------------------------------\n\t" +
|
||||
"Application Jeecg-Boot is running! Access URLs:\n\t" +
|
||||
"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
|
||||
"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
|
||||
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
|
||||
"----------------------------------------------------------");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.example.zxweb.config;
|
||||
package com.example.zxweb.common.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
@ -0,0 +1,19 @@
|
||||
package com.example.zxweb.common.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
* @Author ZhouWenTao
|
||||
* @Date 2023/9/13 17:15
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMVCConfig extends WebMvcConfigurationSupport {
|
||||
@Override
|
||||
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/static/**")
|
||||
.addResourceLocations("classpath:/static/");
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.example.zxweb.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.example.zxweb.common.api.vo.Result;
|
||||
import com.example.zxweb.entity.ZxCelue;
|
||||
import com.example.zxweb.service.IZxCelueService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Description 策略管理接口
|
||||
* @Author ZhouWenTao
|
||||
* @Date 2023/9/13 11:50
|
||||
*/
|
||||
@Api(tags = "策略管理")
|
||||
@RequestMapping("/celue")
|
||||
@RestController
|
||||
public class CelueController {
|
||||
@Resource
|
||||
IZxCelueService zxCelueService;
|
||||
|
||||
@ApiOperation(value = "策略列表")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<?> list(@RequestParam(value = "page",defaultValue = "1")Integer page,@RequestParam(value = "limit",defaultValue = "10")Integer limit,
|
||||
@RequestParam(value = "name",defaultValue = "")String name,@RequestParam(value = "status",defaultValue = "")String status){
|
||||
LambdaQueryWrapper<ZxCelue> queryWrapper=new LambdaQueryWrapper<>();
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
queryWrapper.like(ZxCelue::getName,name);
|
||||
}
|
||||
if (StringUtils.isNotBlank(status)) {
|
||||
queryWrapper.eq(ZxCelue::getStatus,status);
|
||||
}
|
||||
Page<ZxCelue> pageList = zxCelueService.page(new Page<>(page, limit),queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "策略列表-全部")
|
||||
@GetMapping(value = "/listAll")
|
||||
public Result<?> listAll(){
|
||||
return Result.OK(zxCelueService.list());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "详情")
|
||||
@GetMapping
|
||||
public Result<?> getDetail(@RequestParam String id){
|
||||
return Result.OK(zxCelueService.getById(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增")
|
||||
@PostMapping
|
||||
public Result<?>add(@RequestBody ZxCelue zxCelue){
|
||||
zxCelueService.save(zxCelue);
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "编辑")
|
||||
@PutMapping
|
||||
public Result<?>edit(@RequestBody ZxCelue zxCelue){
|
||||
zxCelueService.updateById(zxCelue);
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "编辑")
|
||||
@PutMapping("/status")
|
||||
public Result<?>status(@RequestBody ZxCelue zxCelue){
|
||||
ZxCelue celue = zxCelueService.getById(zxCelue.getCelueid());
|
||||
LambdaUpdateWrapper<ZxCelue> updateWrapper=new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(ZxCelue::getCelueid,celue.getCelueid());
|
||||
if ("0".equals(celue.getStatus())) {
|
||||
updateWrapper.set(ZxCelue::getStatus,"1");
|
||||
}else{
|
||||
updateWrapper.set(ZxCelue::getStatus,"0");
|
||||
}
|
||||
zxCelueService.update(updateWrapper);
|
||||
return Result.OK();
|
||||
}
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@ApiOperation(value="删除", notes="删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name="id") String id) {
|
||||
zxCelueService.removeById(id);
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.example.zxweb.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.example.zxweb.common.api.vo.Result;
|
||||
import com.example.zxweb.entity.ZxCelue;
|
||||
import com.example.zxweb.entity.ZxDevice;
|
||||
import com.example.zxweb.service.IZxCelueService;
|
||||
import com.example.zxweb.service.IZxDeviceService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Description 设备管理接口
|
||||
* @Author ZhouWenTao
|
||||
* @Date 2023/9/14 9:16
|
||||
*/
|
||||
@Api(tags = "设备管理")
|
||||
@RequestMapping("/device")
|
||||
@RestController
|
||||
public class DeviceController {
|
||||
@Resource
|
||||
IZxDeviceService zxDeviceService;
|
||||
|
||||
@ApiOperation(value = "设备列表")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<?> list(@RequestParam(value = "page",defaultValue = "1")Integer page,@RequestParam(value = "limit",defaultValue = "10")Integer limit){
|
||||
LambdaQueryWrapper<ZxDevice> queryWrapper=new LambdaQueryWrapper<>();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.example.zxweb.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
* @Author ZhouWenTao
|
||||
* @Date 2023/9/13 11:39
|
||||
*/
|
||||
@Controller
|
||||
public class ThymeleafController {
|
||||
|
||||
@RequestMapping("/")
|
||||
public String getString(HttpServletRequest request){
|
||||
String name = "全栈学习笔记";
|
||||
return "index.html";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.example.zxweb.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Description 设备 对象
|
||||
* @Author ZhouWenTao
|
||||
* @Date 2023/9/13 13:41
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="zx_device对象", description="zx_device对象")
|
||||
@TableName(value = "zx_device")
|
||||
public class ZxDevice implements Serializable {
|
||||
@TableId
|
||||
@ApiModelProperty(value = "设备id")
|
||||
private String serial;
|
||||
@ApiModelProperty(value = "设备名称")
|
||||
private String terminalName;
|
||||
@ApiModelProperty(value = "设备类型")
|
||||
private String modelCode;
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.example.zxweb.init;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.example.zxweb.common.constant.DevConstant;
|
||||
import com.example.zxweb.common.constant.enums.IotApiEnum;
|
||||
import com.example.zxweb.entity.ZxCelue;
|
||||
import com.example.zxweb.service.IZxCelueService;
|
||||
import com.example.zxweb.utils.IotUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description 启动项目后获取策略信息
|
||||
* @Author ZhouWenTao
|
||||
* @Date 2023/9/13 13:48
|
||||
*/
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class LoadCelueInit implements ApplicationRunner{
|
||||
@Resource
|
||||
IZxCelueService zxCelueService;
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
//获取网关的数据,同步到数据库中
|
||||
/*String gateway_5lqh = DevConstant.gateway.gateway_5lqh;//5楼网关
|
||||
String format = String.format("{\"serial\":\"%s\",\"productId\":\"\",\"methodName\":\"celueListQuery\",\"inputData\":{\"devid\":\"%s\"}}", gateway_5lqh,gateway_5lqh);
|
||||
JSONObject requestBody = JSONObject.parseObject(format);
|
||||
JSONObject responseBody = IotUtils.postApi(IotApiEnum.getPathByText("向设备发送方法"), requestBody);
|
||||
JSONObject data = responseBody.getJSONObject("data");
|
||||
if (data!=null) {
|
||||
JSONObject outputData = data.getJSONObject("outputData");
|
||||
if (outputData!=null) {
|
||||
JSONArray list = outputData.getJSONArray("list");
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
List<ZxCelue> zxCelues = list.toJavaList(ZxCelue.class);
|
||||
//更新库表
|
||||
zxCelueService.saveOrUpdateBatch(zxCelues);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.example.zxweb.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.example.zxweb.entity.ZxCelue;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
* @Author ZhouWenTao
|
||||
* @Date 2023/9/13 14:05
|
||||
*/
|
||||
@Mapper
|
||||
public interface ZxCelueMapper extends BaseMapper<ZxCelue> {
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.example.zxweb.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.example.zxweb.entity.ZxDevice;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
* @Author ZhouWenTao
|
||||
* @Date 2023/9/13 14:05
|
||||
*/
|
||||
@Mapper
|
||||
public interface ZxDeviceMapper extends BaseMapper<ZxDevice> {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.example.zxweb.mapper.ZxCelueMapper">
|
||||
</mapper>
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.example.zxweb.mapper.ZxDeviceMapper">
|
||||
</mapper>
|
@ -0,0 +1,12 @@
|
||||
package com.example.zxweb.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.example.zxweb.entity.ZxCelue;
|
||||
|
||||
/**
|
||||
* @Description 策略信息
|
||||
* @Author ZhouWenTao
|
||||
* @Date 2023/9/13 14:07
|
||||
*/
|
||||
public interface IZxCelueService extends IService<ZxCelue> {
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.example.zxweb.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.example.zxweb.entity.ZxDevice;
|
||||
|
||||
/**
|
||||
* @Description 设备信息
|
||||
* @Author ZhouWenTao
|
||||
* @Date 2023/9/14 9:14
|
||||
*/
|
||||
public interface IZxDeviceService extends IService<ZxDevice> {
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.example.zxweb.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.example.zxweb.entity.ZxCelue;
|
||||
import com.example.zxweb.mapper.ZxCelueMapper;
|
||||
import com.example.zxweb.service.IZxCelueService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Description 策略信息
|
||||
* @Author ZhouWenTao
|
||||
* @Date 2023/9/13 14:09
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ZxCelueServiceImpl extends ServiceImpl<ZxCelueMapper, ZxCelue> implements IZxCelueService {
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.example.zxweb.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.example.zxweb.entity.ZxDevice;
|
||||
import com.example.zxweb.mapper.ZxDeviceMapper;
|
||||
import com.example.zxweb.service.IZxDeviceService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Description 设备信息
|
||||
* @Author ZhouWenTao
|
||||
* @Date 2023/9/14 9:14
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ZxDeviceServiceImpl extends ServiceImpl<ZxDeviceMapper, ZxDevice> implements IZxDeviceService {
|
||||
}
|
File diff suppressed because one or more lines are too long
Binary file not shown.
After Width: | Height: | Size: 322 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -0,0 +1,222 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="https://www.thymeleaf.org/">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<!-- 引入 layui.css -->
|
||||
<link href="../static/layui-v2.8.11/css/layui.css" rel="stylesheet">
|
||||
<!-- 引入 layui.js -->
|
||||
<script src="../static/layui-v2.8.11/layui.js"></script>
|
||||
<style>
|
||||
body {
|
||||
background-color: #f5f5f5;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.body {
|
||||
padding: 23.8px;
|
||||
}
|
||||
|
||||
.left-title {
|
||||
font-size: 22px;
|
||||
margin-bottom: 15px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.z-body {
|
||||
}
|
||||
|
||||
.z-body .layui-form-label {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.z-body .layui-input-inline .layui-btn {
|
||||
padding: 0;
|
||||
width: 56px;
|
||||
}
|
||||
|
||||
.z-search {
|
||||
|
||||
}
|
||||
|
||||
.z-search .layui-form-item {
|
||||
margin: 10px 0px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
table th {
|
||||
background-color: #fafafa;
|
||||
color: #2c2a29;
|
||||
}
|
||||
|
||||
.layui-form-onswitch {
|
||||
border-color: #1890ff;
|
||||
background-color: #1890ff;
|
||||
}
|
||||
|
||||
.layui-table-body .layui-table-cell {
|
||||
height: 56px;
|
||||
line-height: 41px;
|
||||
}
|
||||
|
||||
.layui-laypage {
|
||||
margin-bottom: 15px !important;
|
||||
}
|
||||
|
||||
.layui-table-column {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="body">
|
||||
<div class="left-title layui-row">
|
||||
<div class="layui-col-md6 layui-col-xs6 layui-col-sm6 layui-col-lg6 layui-col-xl6">
|
||||
<p>控制策略</p>
|
||||
</div>
|
||||
<div class="layui-col-md6 layui-col-xs6 layui-col-sm6 layui-col-lg6 layui-col-xl6">
|
||||
<button type="button" class="layui-btn" style="font-size: 16px;float: right;background-color: #41a69a">+新增</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="z-body">
|
||||
<div class="layui-card layui-panel">
|
||||
<div class="layui-card-body z-search">
|
||||
<form class="layui-form" action="form.html">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">策略名称:</label>
|
||||
<div class="layui-input-inline" style="width: 240px">
|
||||
<input type="text" id="name" name="name" lay-verify="required" placeholder="请填写关键字···"
|
||||
autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
<label class="layui-form-label">执行状态:</label>
|
||||
<div class="layui-input-inline" style="width: 240px">
|
||||
<select name="interest" id="status" lay-filter="aihao">
|
||||
<option value="" selected>请选择···</option>
|
||||
<option value="1">启动</option>
|
||||
<option value="0">停用</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<button type="button" onclick="loadTable()" class="layui-btn layui-btn-normal" style="width: 58px">查询</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 内容主体区域 -->
|
||||
<div class="layui-card layui-panel">
|
||||
<div class="layui-card-body">
|
||||
<table class="layui-hide" id="ID-table-demo-data"></table>
|
||||
<div id="demo-laypage-all"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/html" id="templet-status-switch">
|
||||
<!-- 这里的 checked 的状态值判断仅作为演示 -->
|
||||
<input type="checkbox" name="status" id="{{=d.celueid}}" value="{{=d.status}}" title="启用|停用" lay-skin="switch"
|
||||
lay-filter="demo-templet-status" {{=d.status=='1'?"checked":"" }}>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="templet-theads-tool">
|
||||
<div class="layui-clear-space" style="padding-left: 20px">
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail"
|
||||
style="width: 46px;height: 26px;padding: 1px;background-color: #3cb754;color: white">
|
||||
查看
|
||||
</a>
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit"
|
||||
style="width: 46px;height: 26px;padding: 1px;border: #f52f64 solid 1px;color: #f52f64">
|
||||
删除
|
||||
</a>
|
||||
</div>
|
||||
</script>
|
||||
<script>
|
||||
var pageNum=2;
|
||||
var pageSize=10;
|
||||
var total=0;
|
||||
var laypage;
|
||||
var name='';
|
||||
var status='';
|
||||
loadTable();
|
||||
var form;
|
||||
function loadTable(){
|
||||
layui.use('table', function () {
|
||||
var table = layui.table;
|
||||
var $=layui.$;
|
||||
form = layui.form;
|
||||
name=$("#name").val();
|
||||
status = $("#status").val();
|
||||
laypage = layui.laypage;
|
||||
// 已知数据渲染
|
||||
var inst = table.render({
|
||||
elem: '#ID-table-demo-data'
|
||||
, cols: [ [ //标题栏
|
||||
{field: 'number', title: '序号', width: 80, sort: false, align: 'center', type: 'numbers'}
|
||||
, {field: 'name', title: '策略名称', width: 360}
|
||||
, {field: 'xunhuanzhouqi', title: '循环周期', minwidth: 360}
|
||||
, {field: 'status', title: '执行状态', width: 160, templet: '#templet-status-switch'}
|
||||
, {field: 'description', title: '备注', minwidth: 344}
|
||||
, {field: 'experience', title: '操作', width: 220, templet: '#templet-theads-tool', sort: false}
|
||||
]
|
||||
]
|
||||
,url:'/celue/list?name='+name+"&status="+status
|
||||
,method:'get'
|
||||
,async: true
|
||||
,headers: {//携带token
|
||||
},/*data: []*/
|
||||
parseData: function(res){ //res 即为原始返回的数据
|
||||
console.log(res)
|
||||
total=res.result.total;
|
||||
return {
|
||||
"code": res.code==200?0:res.code, //解析接口状态
|
||||
"msg": res.msg, //解析提示文本
|
||||
"count": res.result.total, //解析数据长度
|
||||
"data": res.result.records //解析数据列表
|
||||
};
|
||||
},
|
||||
done: function (res, curr, count) {
|
||||
if (res.success) {
|
||||
//成功
|
||||
loadpage();
|
||||
}else{
|
||||
//异常
|
||||
}
|
||||
},
|
||||
limits: [5,10, 15, 20],
|
||||
limit: 10,
|
||||
page: true,
|
||||
//,skin: 'line' // 表格风格
|
||||
//,even: true
|
||||
//,page: true // 是否显示分页
|
||||
//,limits: [5, 10, 15]
|
||||
//,limit: 5 // 每页默认显示的数量
|
||||
});
|
||||
|
||||
form.on('switch(demo-templet-status)', function(obj){
|
||||
var id = this.id;
|
||||
var obj = JSON.stringify({'celueid':id});
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
url: "/celue/status",
|
||||
data: obj,
|
||||
contentType: 'application/json;charset=utf-8',
|
||||
success: function(res){
|
||||
console.log(res)
|
||||
}
|
||||
});
|
||||
console.log(id)
|
||||
/*layer.tips(id + ' ' + name + ': '+ obj.elem.checked, obj.othis);*/
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1 @@
|
||||
[{"id":"1","celueName":"灯光-1F走廊","xunhuanzhouqi":"每天 18:00-6:00","status":"1","description":"夜间照明自动控制"},{"id":"2","celueName":"灯光-1F外墙广告牌","xunhuanzhouqi":"每天 19:00-23:00","status":"1","description":null}]
|
Loading…
Reference in new issue