Browse Source

优化产品列表

master
wanghongjun 2 years ago
parent
commit
c5c8157cc1
  1. 6
      application/index/controller/Product.php
  2. 6
      application/index/view/administrator/index.html
  3. 169
      application/index/view/product/index.html

6
application/index/controller/Product.php

@ -3,6 +3,7 @@
namespace app\index\controller;
use think\Db;
use think\Request;
use think\response\Json;
use think\Exception;
use think\db\exception\DataNotFoundException;
@ -34,6 +35,8 @@ class Product extends Base
*/
public function productList()
{
$request = Request::instance();
$receive = $request->get();
$page = input("get.page") ? input("get.page") : 1;
$page = intval($page);
$limit = input("get.limit") ? input("get.limit") : 1;
@ -41,6 +44,9 @@ class Product extends Base
$start = $limit * ($page - 1);
$where = [];
if (isset($receive['productId']) && !empty($receive['productId'])) {
$where['productId'] = $receive['productId'];
}
$result = Db::table("bs_product")->where($where)->order('id desc')->limit($start, $limit)->select();
$num = Db::table("bs_product")->where($where)->count();

6
application/index/view/administrator/index.html

@ -116,13 +116,13 @@
<li>
<a href="javascript:;">
<i class="layui-icon left-nav-li" lay-tips="产品管理">&#xe653;</i>
<i class="layui-icon left-nav-li" lay-tips="产品管理">&#xe656;</i>
<cite>产品管理</cite>
<i class="iconfont nav_right">&#xe697;</i></a>
<ul class="sub-menu">
<li>
<a onclick="xadmin.add_tab('设备信息总览','/index/Product/index')">
<i class="layui-icon">&#xe663;</i>
<a onclick="xadmin.add_tab('产品信息总览','/index/Product/index')">
<i class="layui-icon">&#xe62a;</i>
<cite>产品信息总览</cite>
</a>
</li>

169
application/index/view/product/index.html

@ -2,7 +2,7 @@
<html class="x-admin-sm">
<head>
<meta charset="UTF-8">
<title>设备信息总览</title>
<title>产品信息总览</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
@ -66,7 +66,7 @@
</select>
</div>
<div class="layui-inline layui-show-xs-block">
<input style="display: none" lay-verify="" id="findText" type="text" name="message"
<input style="display: none" lay-verify="" id="productId" type="text" name="productId"
autocomplete="false" placeholder="" lay-reqText="" class="layui-input">
</div>
<div class="layui-inline layui-show-xs-block">
@ -98,7 +98,7 @@
$("#refresh").click(function () {
$("#myForm")[0].reset();
layui.form.render();
$("#findText").hide();
$("#productId").hide();
parent.layui.notice.remove();
parent.layui.notice.success("设备序列号列表已校准", "<div class = 'layui-icon layui-icon-heart-fill'> 同步成功</div>", parent.noticeOpt6);
table.render({
@ -115,42 +115,17 @@
, first: false //不显示首页
, last: false //不显示尾页
}
, cols: [[ //表头,style: 'background-color: #bee4ca ; color: #2c2525 ' ,style: 'background-color: #acd3ed;color: #2c2525;' ,style: 'background-color: #bda9c5'
{
field: 'productId',
title: '产品ID',
minWidth: 100,
align: 'center'
}
, {
field: 'status', title: '状态',
width: 90, align: 'center',
templet: function (d) {
if (d.status == 1) {
return '<span style="color: #ab3635;font-family: 黑体;font-weight: bold;">正常</span>'
} else {
return '<span style="color: #33912b;font-family: 黑体;font-weight: bold;">停用</span>'
}
}
}
, {
field: 'operation',
title: '操作',
width: 90,
align: 'center',
toolbar: '#barDemo'
}
]]
, cols: [get_cols()]
});
});
//动态显示
parent.layui.notice.remove();
parent.layui.notice.info('设备信息总览', '已进入', parent.noticeOpt1);
parent.layui.notice.info('产品信息总览', '已进入', parent.noticeOpt1);
setTimeout(function () {
$('.flag').show();
tableIns.resize();
},20);
}, 20);
//自定义验证规则
@ -163,7 +138,7 @@
}
// return '请选择搜索项!'
},
message: function (value) {
productId: function (value) {
if (!value) {
parent.layui.notice.remove();
parent.layui.notice.error('请输入要搜索的内容', '操作异常', parent.noticeOpt5);
@ -179,27 +154,27 @@
// console.log(data.elem); //得到select原始DOM对象
// console.log(data.value); //得到被选中的值
// console.log(data.othis); //得到美化后的DOM对象
var findText = $("#findText");
var select = data.value;
let productId = $("#productId");
let select = data.value;
//默认不显示输入框
findText.hide();
productId.hide();
//重置验证类型
findText.attr('lay-verify', '');
productId.attr('lay-verify', '');
//每次切换搜索项后都要清空里面的值
findText.val('');
// console.log(findText.val);
productId.val('');
// console.log(productId.val);
switch (select) {
case "1":
findText.attr('lay-verify', 'message');
findText.attr('placeholder', '请输入要搜索的设备ID');
// findText.attr('lay-reqText', '请输入要搜索的设备ID');
findText.show();
productId.attr('lay-verify', 'productId');
productId.attr('placeholder', '请输入要搜索的产品ID');
// productId.attr('lay-reqText', '请输入要搜索的设备ID');
productId.show();
break;
case "2":
findText.attr('lay-verify', 'message');
findText.attr('placeholder', '请输入要搜索的设备类型');
// findText.attr('lay-reqText', '请输入要搜索的设备类型');
findText.show();
productId.attr('lay-verify', 'productId');
productId.attr('placeholder', '请输入要搜索的产品类型');
// productId.attr('lay-reqText', '请输入要搜索的设备类型');
productId.show();
break;
}
@ -220,69 +195,73 @@
, first: false //不显示首页
, last: false //不显示尾页
}
, cols: [[ //表头,style: 'background-color: #bee4ca ; color: #2c2525 ' ,style: 'background-color: #acd3ed;color: #2c2525;' ,style: 'background-color: #bda9c5'
, cols: [get_cols()]
});
function get_cols() {
return [ //表头,style: 'background-color: #bee4ca ; color: #2c2525 ' ,style: 'background-color: #acd3ed;color: #2c2525;' ,style: 'background-color: #bda9c5'
{
field: 'productId',
title: '设备ID',
title: '产品ID',
minWidth: 100,
align: 'center'
}
, {
field: 'productName',
title: '设备名称',
minWidth: 100,
align: 'center'
}
field: 'productName',
title: '产品名称',
minWidth: 100,
align: 'center'
}
, {
field: 'productDesc',
title: '设备描述',
minWidth: 100,
align: 'center'
}
field: 'productDesc',
title: '产品描述',
minWidth: 100,
align: 'center'
}
, {
field: 'productTypeValue',
title: '产品分类名称',
minWidth: 100,
align: 'center'
}
field: 'productTypeValue',
title: '产品分类名称',
minWidth: 100,
align: 'center'
}
, {
field: 'secondaryTypeValue',
title: '二级分类名称',
minWidth: 100,
align: 'center'
}
field: 'secondaryTypeValue',
title: '二级分类名称',
minWidth: 100,
align: 'center'
}
, {
field: 'thirdTypeValue',
title: '三级分类名称',
minWidth: 100,
align: 'center'
}
field: 'thirdTypeValue',
title: '三级分类名称',
minWidth: 100,
align: 'center'
}
, {
field: 'encryptionType',
title: '加密认证方式',
minWidth: 100,
align: 'center'
}
field: 'encryptionType',
title: '加密认证方式',
minWidth: 100,
align: 'center'
}
, {
field: 'status', title: '状态',
width: 90, align: 'center',
templet: function (d) {
if (d.status == 1) {
return '<span style="color: #33912b;font-family: 黑体;font-weight: bold;">正常</span>'
} else {
return '<span style="color: #ab3635;font-family: 黑体;font-weight: bold;">停用</span>'
}
field: 'status', title: '状态',
width: 90, align: 'center',
templet: function (d) {
if (d.status == 1) {
return '<span style="color: #33912b;font-family: 黑体;font-weight: bold;">正常</span>'
} else {
return '<span style="color: #ab3635;font-family: 黑体;font-weight: bold;">停用</span>'
}
}
}
, {
field: 'operation',
title: '操作',
width: 90,
align: 'center',
toolbar: '#barDemo'
}
]]
});
field: 'operation',
title: '操作',
width: 90,
align: 'center',
toolbar: '#barDemo'
}
]
}
//搜索功能
form.on('submit(search)', function (data) {
@ -292,7 +271,7 @@
tableIns.reload({
where: { //设定异步数据接口的额外参数,任意设
choose: data.field.option
, message: data.field.message
, productId: data.field.productId
}
, page: {
curr: 1 //重新从第 1 页开始

Loading…
Cancel
Save