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

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

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

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

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

Loading…
Cancel
Save