main
kgdxpr 2 years ago
parent 76c6e6943e
commit 3b75c8b5ad

@ -121,7 +121,7 @@ body,
.pear-admin .layui-side {
top: 0px;
width: 230px;
box-shadow: 2px 0 6px rgba(0, 21, 41, .35);
box-shadow: 2px 0 6px rgba(0, 21, 41, .20);
z-index: 9999;
}
@ -499,12 +499,6 @@ body,
}
/* 搜索面板 */
.menu-search-content .layui-input-prefix {
position: absolute;
margin-top: 10px;
margin-left: 10px;
}
.menu-search-content .layui-input {
padding-left: 30px;
}

@ -118,4 +118,4 @@
margin-top: -30px;
position: absolute;
display: inline-block;
}
}

@ -64,9 +64,9 @@
}
.desc {
width: 124% !important;
width: 100% !important;
text-align: center !important;
color: red !important;
color: gray !important;
height: 60px !important;
line-height: 60px !important;
}
@ -90,6 +90,7 @@ body {
float: right;
height: 42px;
border: #e6e6e6 1px solid;
cursor: pointer;
}
@media (max-width:768px){

@ -163,7 +163,7 @@
"openType": "_iframe",
"href": "view/document/popup.html"
}]
},{
}, {
"id": 60331,
"title": "高级组件",
"icon": "layui-icon layui-icon-console",
@ -175,7 +175,7 @@
"type": 1,
"openType": "_iframe",
"href": "view/document/tab.html"
},{
}, {
"id": 60132,
"title": "数据菜单",
"icon": "layui-icon layui-icon-face-cry",

@ -1,10 +1,37 @@
{
"status":{"code":200,"message":"操作成功"},
"data": [
{"id":"001","title": "湖南省","checkArr": "0","parentId": "0"},
{"id":"002","title": "湖北省","checkArr": "0","parentId": "0"},
{"id":"003","title": "广东省","checkArr": "0","parentId": "0"},
{"id":"004","title": "浙江省","checkArr": "0","parentId": "0"},
{"id":"005","title": "福建省","checkArr": "0","parentId": "0"}
]
}
"status": {
"code": 200,
"message": "操作成功"
},
"data": [{
"id": "001",
"title": "湖南省",
"checkArr": "0",
"parentId": "0"
},
{
"id": "002",
"title": "湖北省",
"checkArr": "0",
"parentId": "0"
},
{
"id": "003",
"title": "广东省",
"checkArr": "0",
"parentId": "0"
},
{
"id": "004",
"title": "浙江省",
"checkArr": "0",
"parentId": "0"
},
{
"id": "005",
"title": "福建省",
"checkArr": "0",
"parentId": "0"
}
]
}

@ -1,181 +1,181 @@
{
"status": {
"code": 200,
"message": "操作成功"
},
"data": [{
"id": "001",
"title": "湖南省",
"parentId": "0",
"children": [{
"id": "001001",
"title": "长沙市",
"last": true,
"parentId": "001"
},
{
"id": "001002",
"title": "株洲市",
"last": true,
"parentId": "001"
},
{
"id": "001003",
"title": "湘潭市",
"last": true,
"parentId": "001"
},
{
"id": "001004",
"title": "衡阳市",
"last": true,
"parentId": "001"
},
{
"id": "001005",
"title": "郴州市",
"last": true,
"parentId": "001"
}
]
},
{
"id": "002",
"title": "湖北省",
"parentId": "0",
"children": [{
"id": "002001",
"title": "武汉市",
"last": true,
"parentId": "002"
},
{
"id": "002002",
"title": "黄冈市",
"last": true,
"parentId": "002"
},
{
"id": "002003",
"title": "潜江市",
"last": true,
"parentId": "002"
},
{
"id": "002004",
"title": "荆州市",
"last": true,
"parentId": "002"
},
{
"id": "002005",
"title": "襄阳市",
"last": true,
"parentId": "002"
}
]
},
{
"id": "003",
"title": "广东省",
"parentId": "0",
"children": [{
"id": "003001",
"title": "广州市",
"last": false,
"parentId": "003",
"children": [{
"id": "003001001",
"title": "天河区",
"last": true,
"parentId": "003001"
},
{
"id": "003001002",
"title": "花都区",
"last": true,
"parentId": "003001"
}
]
},
{
"id": "003002",
"title": "深圳市",
"last": true,
"parentId": "003"
},
{
"id": "003003",
"title": "中山市",
"last": true,
"parentId": "003"
},
{
"id": "003004",
"title": "东莞市",
"last": true,
"parentId": "003"
},
{
"id": "003005",
"title": "珠海市",
"last": true,
"parentId": "003"
},
{
"id": "003006",
"title": "韶关市",
"last": true,
"parentId": "003"
}
]
},
{
"id": "004",
"title": "浙江省",
"parentId": "0",
"children": [{
"id": "004001",
"title": "杭州市",
"last": true,
"parentId": "004"
},
{
"id": "004002",
"title": "温州市",
"last": true,
"parentId": "004"
},
{
"id": "004003",
"title": "绍兴市",
"last": true,
"parentId": "004"
},
{
"id": "004004",
"title": "金华市",
"last": true,
"parentId": "004"
},
{
"id": "004005",
"title": "义乌市",
"last": true,
"parentId": "004"
}
]
},
{
"id": "005",
"title": "福建省",
"parentId": "0",
"children": [{
"id": "005001",
"title": "厦门市",
"last": true,
"parentId": "005"
}]
}
]
}
"status": {
"code": 200,
"message": "操作成功"
},
"data": [{
"id": "001",
"title": "湖南省",
"parentId": "0",
"children": [{
"id": "001001",
"title": "长沙市",
"last": true,
"parentId": "001"
},
{
"id": "001002",
"title": "株洲市",
"last": true,
"parentId": "001"
},
{
"id": "001003",
"title": "湘潭市",
"last": true,
"parentId": "001"
},
{
"id": "001004",
"title": "衡阳市",
"last": true,
"parentId": "001"
},
{
"id": "001005",
"title": "郴州市",
"last": true,
"parentId": "001"
}
]
},
{
"id": "002",
"title": "湖北省",
"parentId": "0",
"children": [{
"id": "002001",
"title": "武汉市",
"last": true,
"parentId": "002"
},
{
"id": "002002",
"title": "黄冈市",
"last": true,
"parentId": "002"
},
{
"id": "002003",
"title": "潜江市",
"last": true,
"parentId": "002"
},
{
"id": "002004",
"title": "荆州市",
"last": true,
"parentId": "002"
},
{
"id": "002005",
"title": "襄阳市",
"last": true,
"parentId": "002"
}
]
},
{
"id": "003",
"title": "广东省",
"parentId": "0",
"children": [{
"id": "003001",
"title": "广州市",
"last": false,
"parentId": "003",
"children": [{
"id": "003001001",
"title": "天河区",
"last": true,
"parentId": "003001"
},
{
"id": "003001002",
"title": "花都区",
"last": true,
"parentId": "003001"
}
]
},
{
"id": "003002",
"title": "深圳市",
"last": true,
"parentId": "003"
},
{
"id": "003003",
"title": "中山市",
"last": true,
"parentId": "003"
},
{
"id": "003004",
"title": "东莞市",
"last": true,
"parentId": "003"
},
{
"id": "003005",
"title": "珠海市",
"last": true,
"parentId": "003"
},
{
"id": "003006",
"title": "韶关市",
"last": true,
"parentId": "003"
}
]
},
{
"id": "004",
"title": "浙江省",
"parentId": "0",
"children": [{
"id": "004001",
"title": "杭州市",
"last": true,
"parentId": "004"
},
{
"id": "004002",
"title": "温州市",
"last": true,
"parentId": "004"
},
{
"id": "004003",
"title": "绍兴市",
"last": true,
"parentId": "004"
},
{
"id": "004004",
"title": "金华市",
"last": true,
"parentId": "004"
},
{
"id": "004005",
"title": "义乌市",
"last": true,
"parentId": "004"
}
]
},
{
"id": "005",
"title": "福建省",
"parentId": "0",
"children": [{
"id": "005001",
"title": "厦门市",
"last": true,
"parentId": "005"
}]
}
]
}

@ -11,7 +11,6 @@
"type": 1,
"openType": "_iframe",
"href": "view/console/console1.html"
}, {
"id": 13,
"title": "数据分析",
@ -243,6 +242,27 @@
"type": 1,
"openType": "_iframe",
"href": "view/document/topBar.html"
},
{
"id": 2046,
"title": "水印组件",
"type": 1,
"openType": "_iframe",
"href": "view/document/watermark.html"
},
{
"id": 2047,
"title": "全屏组件",
"type": 1,
"openType": "_iframe",
"href": "view/document/fullscreen.html"
},
{
"id": 2048,
"title": "汽泡组件",
"type": 1,
"openType": "_iframe",
"href": "view/document/popover.html"
}
]
}]

@ -85,43 +85,6 @@
{
"id": 3,
"title": "代办",
"children": [{
"id": 11,
"avatar":"https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png",
"title": "你收到了 14 份新周报",
"context": "这是消息内容。",
"form": "就眠仪式",
"time": "刚刚"
}, {
"id": 12,
"avatar":"https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png",
"title": "曲妮妮 已通过第三轮面试",
"context": "这是消息内容。",
"form": "就眠仪式",
"time": "刚刚"
},
{
"id": 11,
"avatar":"https://gw.alipayobjects.com/zos/rmsportal/kISTdvpyTAhtGxpovNWd.png",
"title": "可以区分多种通知类型",
"context": "这是消息内容。",
"form": "就眠仪式",
"time": "刚刚"
}, {
"id": 12,
"avatar":"https://gw.alipayobjects.com/zos/rmsportal/GvqBnKhFgObvnSGkDsje.png",
"title": "左侧图标用于区分不同的类型",
"context": "这是消息内容。",
"form": "就眠仪式",
"time": "刚刚"
},
{
"id": 11,
"avatar":"https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png",
"title": "内容不要超过两行字",
"context": "这是消息内容。",
"form": "就眠仪式",
"time": "刚刚"
}]
"children": []
}
]

@ -7,32 +7,32 @@
"userCount": 324,
"location": "二楼201",
"leader": "皮卡丘"
},{
}, {
"name": "美工部",
"userCount": 98,
"location": "二楼101",
"leader": "皮卡丘"
},{
}, {
"name": "设计部",
"userCount": 43,
"location": "六楼602",
"leader": "皮卡丘"
},{
}, {
"name": "销售部",
"userCount": 12,
"location": "一楼131",
"leader": "皮卡丘"
},{
}, {
"name": "产品部",
"userCount": 128,
"location": "四楼401",
"leader": "皮卡丘"
},{
}, {
"name": "财务部",
"userCount": 23,
"location": "三楼105",
"leader": "皮卡丘"
},{
}, {
"name": "人事部",
"userCount": 67,
"location": "二楼201",

@ -44,7 +44,7 @@
"enable": "1",
"login": "1",
"roleIds": null
},{
}, {
"userId": "4",
"username": "admin",
"password": "$2a$10$1K7E1.IYCrsoZVCb6utOo.5jENtfOzhdKWhc49t2lk.UQd7Oam4FG",
@ -86,7 +86,7 @@
"enable": "1",
"login": "1",
"roleIds": null
},{
}, {
"userId": "7",
"username": "admin",
"password": "$2a$10$1K7E1.IYCrsoZVCb6utOo.5jENtfOzhdKWhc49t2lk.UQd7Oam4FG",
@ -129,4 +129,4 @@
"login": "1",
"roleIds": null
}]
}
}

@ -44,7 +44,7 @@
"enable": "1",
"login": "1",
"roleIds": null
},{
}, {
"userId": "1",
"username": "admin",
"password": "$2a$10$1K7E1.IYCrsoZVCb6utOo.5jENtfOzhdKWhc49t2lk.UQd7Oam4FG",
@ -86,7 +86,7 @@
"enable": "1",
"login": "1",
"roleIds": null
},{
}, {
"userId": "1",
"username": "admin",
"password": "$2a$10$1K7E1.IYCrsoZVCb6utOo.5jENtfOzhdKWhc49t2lk.UQd7Oam4FG",
@ -115,4 +115,4 @@
"login": "1",
"roleIds": null
}]
}
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 26 KiB

@ -0,0 +1,744 @@
/*
* Name: skuTable
* Author: cshaptx4869
* Project: https://github.com/cshaptx4869/skuTable
*/
layui.define(['jquery', 'form', 'upload', 'layer', 'sortable'], function (exports) {
"use strict";
var $ = layui.jquery,
form = layui.form,
upload = layui.upload,
layer = layui.layer,
sortable = layui.sortable,
MOD_NAME = 'skuTable';
//工具类
class Util {
static config = {
shade: [0.02, '#000'],
time: 2000
};
static msg = {
// 成功消息
success: function (msg, callback = null) {
return layer.msg(msg, {
icon: 1,
shade: Util.config.shade,
scrollbar: false,
time: Util.config.time,
shadeClose: true
}, callback);
},
// 失败消息
error: function (msg, callback = null) {
return layer.msg(msg, {
icon: 2,
shade: Util.config.shade,
scrollbar: false,
time: Util.config.time,
shadeClose: true
}, callback);
},
// 警告消息框
alert: function (msg, callback = null) {
return layer.alert(msg, {end: callback, scrollbar: false});
},
// 对话框
confirm: function (msg, ok, no) {
var index = layer.confirm(msg, {title: '操作确认', btn: ['确认', '取消']}, function () {
typeof ok === 'function' && ok.call(this);
}, function () {
typeof no === 'function' && no.call(this);
Util.msg.close(index);
});
return index;
},
// 消息提示
tips: function (msg, callback = null) {
return layer.msg(msg, {
time: Util.config.time,
shade: Util.config.shade,
end: callback,
shadeClose: true
});
},
// 加载中提示
loading: function (msg, callback = null) {
return msg ? layer.msg(msg, {
icon: 16,
scrollbar: false,
shade: Util.config.shade,
time: 0,
end: callback
}) : layer.load(2, {time: 0, scrollbar: false, shade: Util.config.shade, end: callback});
},
// 输入框
prompt: function (option, callback = null) {
return layer.prompt(option, callback);
},
// 关闭消息框
close: function (index) {
return layer.close(index);
}
};
static request = {
post: function (option, ok, no, ex) {
return Util.request.ajax('post', option, ok, no, ex);
},
get: function (option, ok, no, ex) {
return Util.request.ajax('get', option, ok, no, ex);
},
ajax: function (type, option, ok, no, ex) {
type = type || 'get';
option.url = option.url || '';
option.data = option.data || {};
option.statusName = option.statusName || 'code';
option.statusCode = option.statusCode || 200;
ok = ok || function (res) {
};
no = no || function (res) {
var msg = res.msg == undefined ? '返回数据格式有误' : res.msg;
Util.msg.error(msg);
return false;
};
ex = ex || function (res) {
};
if (option.url == '') {
Util.msg.error('请求地址不能为空');
return false;
}
var index = Util.msg.loading('加载中');
$.ajax({
url: option.url,
type: type,
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
dataType: "json",
data: option.data,
timeout: 60000,
success: function (res) {
Util.msg.close(index);
if (res[option.statusName] == option.statusCode) {
return ok(res);
} else {
return no(res);
}
},
error: function (xhr, textstatus, thrown) {
Util.msg.error('Status:' + xhr.status + '' + xhr.statusText + ',请稍后再试!', function () {
ex(xhr);
});
return false;
}
});
}
};
static tool = {
uuid: function uuid(randomLength = 8) {
return Number(Math.random().toString().substr(2, randomLength) + Date.now()).toString(36)
}
}
}
class SkuTable {
options = {
isAttributeValue: 0, //规格类型 0统一规格 1多规格
isAttributeElemId: 'fairy-is-attribute', //规格类型容器id
specTableElemId: 'fairy-spec-table', //规格表容器id
skuTableElemId: 'fairy-sku-table', //SKU表容器id
rowspan: false, //是否开启SKU行合并,
sortable: false, //规格拖拽排序
skuIcon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMDY3IDc5LjE1Nzc0NywgMjAxNS8wMy8zMC0yMzo0MDo0MiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTUgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjczN0RFNzU1MTk1RTExRTlBMEQ5OEEwMEM5NDNFOEE4IiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjczN0RFNzU2MTk1RTExRTlBMEQ5OEEwMEM5NDNFOEE4Ij4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NzM3REU3NTMxOTVFMTFFOUEwRDk4QTAwQzk0M0U4QTgiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6NzM3REU3NTQxOTVFMTFFOUEwRDk4QTAwQzk0M0U4QTgiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz5NHmJUAAAA+0lEQVR42pySPwsBYRzH7zk3KIP34CVIKSOrELLJdpuymyzew90kIwMZvACDsCldWZTFn5WQpPN5rlPXlXJ39en7/J57fn+fR9i2rYT5NNM0B2gC3n/6qHBQDMOwZNYg4LOQ3vcQld40/w6lC13Xbd/eHElC3G1JqL4DFWSNprz7BMpAFJ6YkW+jThaosuxAD/rY6R9lCmeq8IAmtKBA1A1OW9YjtIS9QvPYRZkcXo43EzqjF/mDQ5an7ALShTFk4eQOsgFTWeoNKl4nt68J0oYc1LHLbmtDp1IyLgPe4QCuMkIsyAWSuYbs5HD29DML8OTkHR9F2Ef+EWAAdwmkvBAtw94AAAAASUVORK5CYII=',
uploadUrl: '',
requestSuccessCode: 1, //请求成功返回状态码值
specDataDelete: false, //开启规格删除
productId: '', //商品id 配合specDataUrl和skuDataUrl使用
specData: [], //规格数据
specDataUrl: '', //优先级大于specData
skuData: {}, //SKU数据
skuDataUrl: '', //优先级大于skuDataUrl
skuNameType: 0,
skuNameDelimiter: '-',
//统一规格配置项
singleSkuTableConfig: {
thead: [
{title: '销售价(元)', icon: 'layui-icon-cols'},
{title: '市场价(元)', icon: 'layui-icon-cols'},
{title: '成本价(元)', icon: 'layui-icon-cols'},
{title: '库存', icon: 'layui-icon-cols'},
{title: '状态', icon: ''},
],
tbody: [
{type: 'input', field: 'price', value: '', verify: 'required|number', reqtext: '销售价不能为空'},
{type: 'input', field: 'market_price', value: '0', verify: 'required|number', reqtext: '市场价不能为空'},
{type: 'input', field: 'cost_price', value: '0', verify: 'required|number', reqtext: '成本价不能为空'},
{type: 'input', field: 'stock', value: '0', verify: 'required|number', reqtext: '库存不能为空'},
{type: 'select', field: 'status', option: [{key: '启用', value: '1'}, {key: '禁用', value: '0'}], verify: 'required', reqtext: '状态不能为空'},
]
},
//多规格配置项
multipleSkuTableConfig: {
thead: [
{title: '图片', icon: ''},
{title: '销售价(元)', icon: 'layui-icon-cols'},
{title: '市场价(元)', icon: 'layui-icon-cols'},
{title: '成本价(元)', icon: 'layui-icon-cols'},
{title: '库存', icon: 'layui-icon-cols'},
{title: '状态', icon: ''},
],
tbody: [
{type: 'image', field: 'picture', value: '', verify: '', reqtext: ''},
{type: 'input', field: 'price', value: '', verify: 'required|number', reqtext: '销售价不能为空'},
{type: 'input', field: 'market_price', value: '0', verify: 'required|number', reqtext: '市场价不能为空'},
{type: 'input', field: 'cost_price', value: '0', verify: 'required|number', reqtext: '成本价不能为空'},
{type: 'input', field: 'stock', value: '0', verify: 'required|number', reqtext: '库存不能为空'},
{
type: 'select',
field: 'status',
option: [{key: '启用', value: '1'}, {key: '禁用', value: '0'}],
verify: '',
reqtext: ''
},
]
}
};
constructor(options) {
this.options = $.extend(this.options, options);
if (this.options.skuDataUrl && this.options.productId) {
Util.request.get({
url: this.options.skuDataUrl,
data: {
product_id: this.options.productId
},
statusCode: this.options.requestSuccessCode
}, (res) => {
this.options.skuData = res.data;
this.css();
this.render();
this.listen();
});
} else {
this.css();
this.render();
this.listen();
}
}
css() {
$('head').append(`<style>
${this.options.sortable ? `#${this.options.specTableElemId} tbody tr {cursor: move;transition:unset;-webkit-transition:unset;}` : ''}
#${this.options.specTableElemId} tbody tr td:first-child > i.layui-icon-delete {
margin-left:3px;
}
#${this.options.specTableElemId} tbody tr td:last-child > i.layui-icon-delete {
margin-right:15px;
margin-left:-7px;
vertical-align: top;
}
#${this.options.specTableElemId} tbody tr td div.fairy-spec-value-create,
#${this.options.specTableElemId} tfoot tr td div.fairy-spec-create {
display: inline-block;
color: #1E9FFF;
vertical-align: middle;
padding: 4px 6px;
}
#${this.options.specTableElemId} tfoot tr td div.layui-form-checkbox {
margin-top: 0;
}
#${this.options.specTableElemId} tfoot tr td div.layui-form-checkbox > span{
color: #1E9FFF;
}
#${this.options.skuTableElemId} tbody tr td > img.fairy-sku-img{
width: 16px;
height: 16px;
padding: 6px;
border: 1px solid #eceef1;
vertical-align: middle;
}
#${this.options.specTableElemId} tbody tr td > i.layui-icon-delete,
#${this.options.specTableElemId} tbody tr td div.fairy-spec-value-create,
#${this.options.specTableElemId} tfoot tr td div.fairy-spec-create,
#${this.options.skuTableElemId} thead tr th > i.layui-icon,
#${this.options.skuTableElemId} tbody tr td > img.fairy-sku-img {
cursor: pointer;
}
</style>`
);
}
listen() {
var that = this;
/**
* 监听规格类型选择
*/
form.on('radio(fairy-is-attribute)', function (data) {
that.options.isAttributeValue = data.value;
that.render();
});
/**
* 监听所选规格值的变化
*/
form.on('checkbox(fairy-spec-filter)', function (data) {
var specData = [];
$.each($(`#${that.options.specTableElemId} tbody tr`), function () {
var child = [];
$.each($(this).find('input[type=checkbox]'), function () {
child.push({id: $(this).val(), title: $(this).attr('title'), checked: $(this).is(':checked')});
});
var specItem = {
id: $(this).find('td').eq(0).data('spec-id'),
title: $(this).find('td').eq(0).text(),
child: child
};
specData.push(specItem);
});
that.options.specData = specData;
that.options.skuData = $.extend(that.options.skuData, that.getFormSkuData());
that.resetRender(that.options.skuTableElemId);
that.renderMultipleSkuTable();
});
/**
* 监听批量赋值
*/
$(document).on('click', `#${this.options.skuTableElemId} thead tr th i`, function () {
var thisI = this;
Util.msg.prompt({title: $(thisI).parent().text().trim() + '批量赋值'}, function (value, index, elem) {
$.each($(`#${that.options.skuTableElemId} tbody tr`), function () {
var index = that.options.rowspan ?
$(thisI).parent().index() - ($(`#${that.options.skuTableElemId} thead th.fairy-spec-name`).length - $(this).children('td.fairy-spec-value').length) :
$(thisI).parent().index();
$(this).find('td').eq(index).children('input').val(value);
});
Util.msg.close(index);
});
});
/**
* 监听添加规格
*/
$(document).on('click', `#${this.options.specTableElemId} .fairy-spec-create`, function () {
layer.prompt({title: '规格'}, function (value, index, elem) {
var specTitleArr = [];
$.each(that.options.specData, function (k, v) {
specTitleArr.push(v.title)
})
if (specTitleArr.includes(value)) {
Util.msg.error('规格名已存在');
} else {
that.options.specData.push({id: Util.tool.uuid(), title: value, child: []});
that.resetRender(that.options.specTableElemId);
that.renderSpecTable();
}
Util.msg.close(index);
});
});
/**
* 监听添加规格值
*/
$(document).on('click', `#${this.options.specTableElemId} .fairy-spec-value-create`, function () {
var specId = $(this).parent('td').prev().data('spec-id');
layer.prompt({title: '规格值'}, function (value, index, elem) {
that.options.specData.forEach(function (v, i) {
if (v.id == specId) {
v.child.push({id: Util.tool.uuid(), title: value, checked: false});
}
});
that.resetRender(that.options.specTableElemId);
that.renderSpecTable();
Util.msg.close(index);
});
});
/**
* 监听删除规格/规格值
*/
$(document).on('click', `#${this.options.specTableElemId} i.layui-icon-delete`, function () {
if (typeof $(this).attr('data-spec-index') !== "undefined") {
that.options.specData.splice($(this).data('spec-index'), 1);
that.resetRender([that.options.specTableElemId, that.options.skuTableElemId]);
that.renderSpecTable();
that.renderMultipleSkuTable();
} else if (typeof $(this).attr('data-spec-value-index') !== "undefined") {
var [i, ii] = $(this).data('spec-value-index').split('-');
that.options.specData[i].child.splice(ii, 1);
that.resetRender([that.options.specTableElemId, that.options.skuTableElemId]);
that.renderSpecTable();
that.renderMultipleSkuTable();
}
});
/**
* 监听规格表是否开启删除
*/
form.on('checkbox(fairy-spec-delete-filter)', function (data) {
that.options.specDataDelete = data.elem.checked;
if (data.elem.checked) {
$(`#${that.options.specTableElemId} tbody tr i.layui-icon-delete`).removeClass('layui-hide');
} else {
$(`#${that.options.specTableElemId} tbody tr i.layui-icon-delete`).addClass('layui-hide')
}
});
/**
* 图片移入放大/移出恢复
*/
var imgLayerIndex = null;
$(document).on('mouseenter', '.fairy-sku-img', function () {
imgLayerIndex = layer.tips('<img src="' + $(this).attr('src') + '" style="max-width:200px;" alt=""/>', this, {
tips: [2, 'rgba(41,41,41,.5)'],
time: 0
});
}).on('mouseleave', '.fairy-sku-img', function () {
layer.close(imgLayerIndex);
})
}
/**
* 渲染
*/
render() {
this.resetRender();
this.renderIsAttribute(this.options.isAttributeValue);
if (this.options.isAttributeValue == '1') {
if (this.options.specDataUrl && this.options.productId) {
Util.request.get({
url: this.options.specDataUrl,
productId: this.options.productId,
statusCode: this.options.requestSuccessCode
}, (res) => {
this.options.specData = res.data;
this.renderSpecTable();
this.renderMultipleSkuTable();
});
} else {
this.renderSpecTable();
this.renderMultipleSkuTable();
}
} else {
this.renderSingleSkuTable();
}
}
/**
* 重新渲染
* @param targets
*/
resetRender(targets) {
if (typeof targets === 'string') {
$(`#${targets}`).parents('.layui-form-item').replaceWith(`<div id="${targets}"></div>`);
} else if ($.isArray(targets) && targets.length) {
targets.forEach((item) => {
$(`#${item}`).parents('.layui-form-item').replaceWith(`<div id="${item}"></div>`);
})
} else {
$(`#${this.options.isAttributeElemId}`).parents('.layui-form-item').replaceWith(`<div id="${this.options.isAttributeElemId}"></div>`);
$(`#${this.options.specTableElemId}`).parents('.layui-form-item').replaceWith(`<div id="${this.options.specTableElemId}"></div>`);
$(`#${this.options.skuTableElemId}`).parents('.layui-form-item').replaceWith(`<div id="${this.options.skuTableElemId}"></div>`);
}
}
/**
* 渲染规格类型
* @param checkedValue
*/
renderIsAttribute(checkedValue) {
var html = '';
html += `<input type="radio" name="is_attribute" title="统一规格" value="0" lay-filter="fairy-is-attribute" ${checkedValue == '0' ? 'checked' : ''}>`;
html += `<input type="radio" name="is_attribute" title="多规格" value="1" lay-filter="fairy-is-attribute" ${checkedValue == '1' ? 'checked' : ''}>`;
this.renderFormItem('规格类型', html, this.options.isAttributeElemId);
}
renderSingleSkuTable() {
var that = this,
table = `<table class="layui-table" id="${this.options.skuTableElemId}">`;
table += '<thead>';
table += '<tr>';
this.options.singleSkuTableConfig.thead.forEach((item) => {
table += `<th>${item.title}</th>`;
});
table += '</tr>';
table += '</thead>';
table += '<tbody>';
table += '<tr>';
that.options.singleSkuTableConfig.tbody.forEach(function (item) {
switch (item.type) {
case "select":
table += '<td>';
table += `<select name="${item.field}" lay-verify="${item.verify}" lay-reqtext="${item.reqtext}">`;
item.option.forEach(function (o) {
table += `<option value="${o.value}" ${that.options.skuData[item.field] == o.value ? 'selected' : ''}>${o.key}</option>`;
});
table += '</select>';
table += '</td>';
break;
case "input":
default:
table += '<td>';
table += `<input type="text" name="${item.field}" value="${that.options.skuData[item.field] !== undefined ? that.options.skuData[item.field] : item.value}" class="layui-input" lay-verify="${item.verify}" lay-reqtext="${item.reqtext}">`;
table += '</td>';
break;
}
});
table += '</tr>';
table += '<tbody>';
table += '</table>';
this.renderFormItem('', table, this.options.skuTableElemId);
}
/**
* 渲染规格表
*/
renderSpecTable() {
var that = this,
table = `<table style="width:600px" class="layui-table" id="${this.options.specTableElemId}"><colgroup><col width="100"></colgroup><tbody>`;
$.each(this.options.specData, function (index, item) {
table += that.options.sortable ? `<tr data-id="${item.id}">` : '<tr>';
table += `<td data-spec-id="${item.id}">${item.title}<i class="layui-icon layui-icon-delete layui-anim layui-anim-scale ${that.options.specDataDelete ? '' : 'layui-hide'}" data-spec-index="${index}"></i></td>`;
table += '<td>';
$.each(item.child, function (key, value) {
table += `<input type="checkbox" title="${value.title}" lay-filter="fairy-spec-filter" value="${value.id}" ${value.checked ? 'checked' : ''} /><i class="layui-icon layui-icon-delete layui-anim layui-anim-scale ${that.options.specDataDelete ? '' : 'layui-hide'}" data-spec-value-index="${index}-${key}"></i> `;
});
// table += '<div class="fairy-spec-value-create"><i class="layui-icon layui-icon-addition"></i>规格值</div>'
table += '</td>';
table += '</tr>';
});
table += '</tbody>';
// table += '<tfoot><tr><td colspan="2">';
// table += `<input type="checkbox" title="开启删除" lay-skin="primary" lay-filter="fairy-spec-delete-filter" ${that.options.specDataDelete ? 'checked' : ''}/>`;
// table += `<div class="fairy-spec-create"><i class="layui-icon layui-icon-addition"></i>规格</div>`;
// table += '</td></tr></tfoot>';
table += '</table>';
this.renderFormItem('', table, this.options.specTableElemId);
if (this.options.sortable) {
/**
* 拖拽
*/
var sortableObj = sortable.create($(`#${this.options.specTableElemId} tbody`)[0], {
animation: 1000,
onEnd: (evt) => {
//获取拖动后的排序
var sortArr = sortableObj.toArray(),
sortSpecData = [];
this.options.specData.forEach((item) => {
sortSpecData[sortArr.indexOf(String(item.id))] = item;
});
this.options.specData = sortSpecData;
this.resetRender(that.options.skuTableElemId);
this.renderMultipleSkuTable();
},
});
}
}
/**
* 渲染sku表
*/
renderMultipleSkuTable() {
var that = this, table = `<table style="width:600px" class="layui-table" id="${this.options.skuTableElemId}">`;
if ($(`#${this.options.specTableElemId} tbody input[type=checkbox]:checked`).length) {
var prependThead = [], prependTbody = [];
$.each(this.options.specData, function (index, item) {
var isShow = item.child.some(function (value, index, array) {
return value.checked;
});
if (isShow) {
prependThead.push(item.title);
var prependTbodyItem = [];
$.each(item.child, function (key, value) {
if (value.checked) {
prependTbodyItem.push({id: value.id, title: value.title});
}
});
prependTbody.push(prependTbodyItem);
}
});
table += '<colgroup>' + '<col width="70">'.repeat(prependThead.length + 1) + '</colgroup>';
table += '<thead>';
if (prependThead.length > 0) {
var theadTr = '<tr>';
theadTr += prependThead.map(function (t, i, a) {
return '<th class="fairy-spec-name">' + t + '</th>';
}).join('');
this.options.multipleSkuTableConfig.thead.forEach(function (item) {
theadTr += '<th>' + item.title + (item.icon ? ' <i class="layui-icon ' + item.icon + '"></i>' : '') + '</th>';
});
theadTr += '</tr>';
table += theadTr;
}
table += '</thead>';
if (this.options.rowspan) {
var skuRowspanArr = [];
prependTbody.forEach(function (v, i, a) {
var num = 1, index = i;
while (index < a.length - 1) {
num *= a[index + 1].length;
index++;
}
skuRowspanArr.push(num);
});
}
var prependTbodyTrs = [];
prependTbody.reduce(function (prev, cur, index, array) {
var tmp = [];
prev.forEach(function (a) {
cur.forEach(function (b) {
tmp.push({id: a.id + that.options.skuNameDelimiter + b.id, title: a.title + that.options.skuNameDelimiter + b.title});
})
});
return tmp;
}).forEach(function (item, index, array) {
var tr = '<tr>';
tr += item.title.split(that.options.skuNameDelimiter).map(function (t, i, a) {
if (that.options.rowspan) {
if (index % skuRowspanArr[i] === 0 && skuRowspanArr[i] > 1) {
return '<td class="fairy-spec-value" rowspan="' + skuRowspanArr[i] + '">' + t + '</td>';
} else if (skuRowspanArr[i] === 1) {
return '<td class="fairy-spec-value">' + t + '</td>';
} else {
return '';
}
} else {
return '<td>' + t + '</td>';
}
}).join('');
that.options.multipleSkuTableConfig.tbody.forEach(function (c) {
switch (c.type) {
case "image":
tr += '<td><input type="hidden" name="' + that.makeSkuName(item, c) + '" value="' + (that.options.skuData[that.makeSkuName(item, c)] ? that.options.skuData[that.makeSkuName(item, c)] : c.value) + '" lay-verify="' + c.verify + '" lay-reqtext="' + c.reqtext + '"><img class="fairy-sku-img" src="' + (that.options.skuData[that.makeSkuName(item, c)] ? that.options.skuData[that.makeSkuName(item, c)] : that.options.skuIcon) + '" alt="' + c.field + '图片"></td>';
break;
case "select":
tr += '<td><select name="' + that.makeSkuName(item, c) + '" lay-verify="' + c.verify + '" lay-reqtext="' + c.reqtext + '">';
c.option.forEach(function (o) {
tr += '<option value="' + o.value + '" ' + (that.options.skuData[that.makeSkuName(item, c)] == o.value ? 'selected' : '') + '>' + o.key + '</option>';
});
tr += '</select></td>';
break;
case "input":
default:
tr += '<td><input type="text" name="' + that.makeSkuName(item, c) + '" value="' + (that.options.skuData[that.makeSkuName(item, c)] !== undefined ? that.options.skuData[that.makeSkuName(item, c)] : c.value) + '" class="layui-input" lay-verify="' + c.verify + '" lay-reqtext="' + c.reqtext + '"></td>';
break;
}
});
tr += '</tr>';
tr && prependTbodyTrs.push(tr);
});
table += '<tbody>';
if (prependTbodyTrs.length > 0) {
table += prependTbodyTrs.join('');
}
table += '</tbody>';
} else {
table += '<thead></thead><tbody></tbody><tfoot><tr><td>请选择班型</td></tr></tfoot>';
}
table += '</table>';
this.renderFormItem('', table, this.options.skuTableElemId);
//上传
if (this.options.uploadUrl) {
upload.render({
elem: '.fairy-sku-img',
url: this.options.uploadUrl,
exts: 'png|jpg|ico|jpeg|gif',
accept: 'images',
acceptMime: 'image/*',
multiple: false,
done: function (res) {
if (res.code === that.options.requestSuccessCode) {
var url = res.data.url;
$(this.item).attr('src', url).prev().val(url);
Util.msg.success(res.msg);
} else {
var msg = res.msg == undefined ? '返回数据格式有误' : res.msg;
Util.msg.error(msg);
}
return false;
}
});
}
}
/**
* 渲染表单项
* @param label 标题
* @param content 内容
* @param target id
* @param isRequired
*/
renderFormItem(label, content, target, isRequired = true) {
var html = '';
html += '<div class="layui-form-item">';
// html += `<label class="layui-form-label ${isRequired ? 'required' : ''}">${label.length ? label : ''}</label>`;
html += '<div class="layui-input-block">';
html += content;
html += '</div>';
html += '</div>';
$(`#${target}`).replaceWith(html);
form.render();
}
makeSkuName(sku, conf) {
// return 'skus[' + (this.options.skuNameType === 0 ? sku.id : sku.title) + '][' + conf.field + ']';
return sku.id;
}
getSpecData() {
return this.options.specData;
}
getFormFilter() {
var fariyForm = $('form.fairy-form');
if (!fariyForm.attr('lay-filter')) {
fariyForm.attr('lay-filter', 'fairy-form-filter');
}
return fariyForm.attr('lay-filter');
}
getFormSkuData() {
var skuData = {};
$.each(form.val(this.getFormFilter()), function (key, value) {
if (key.startsWith('skus')) {
skuData[key] = value;
}
});
return skuData;
}
}
exports(MOD_NAME, {
render: function (options) {
return new SkuTable(options);
}
})
});

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

@ -1 +1 @@
html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-view{display:block;position:relative;margin:10px 0;padding:0;border:1px solid #eee;border-left-width:6px;background-color:#fafafa;color:#333;font-family:Courier New;font-size:13px}.layui-code-title{position:relative;padding:0 10px;height:40px;line-height:40px;border-bottom:1px solid #eee;font-size:12px}.layui-code-title>.layui-code-about{position:absolute;right:10px;top:0;color:#b7b7b7}.layui-code-about>a{padding-left:10px}.layui-code-view>.layui-code-ol,.layui-code-view>.layui-code-ul{position:relative;overflow:auto}.layui-code-view>.layui-code-ol>li{position:relative;margin-left:45px;line-height:20px;padding:0 10px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view>.layui-code-ol>li:first-child,.layui-code-view>.layui-code-ul>li:first-child{padding-top:10px}.layui-code-view>.layui-code-ol>li:last-child,.layui-code-view>.layui-code-ul>li:last-child{padding-bottom:10px}.layui-code-view>.layui-code-ul>li{position:relative;line-height:20px;padding:0 10px;list-style-type:none;*list-style-type:none;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-dark{border:1px solid #0c0c0c;border-left-color:#3f3f3f;background-color:#0c0c0c;color:#c2be9e}.layui-code-dark>.layui-code-title{border-bottom:none}.layui-code-dark>.layui-code-ol>li,.layui-code-dark>.layui-code-ul>li{background-color:#3f3f3f;border-left:none}.layui-code-dark>.layui-code-ul>li{margin-left:6px}.layui-code-demo .layui-code{visibility:visible!important;margin:-15px;border-top:none;border-right:none;border-bottom:none}.layui-code-demo .layui-tab-content{padding:15px;border-top:none}
html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #eee;border-left-width:6px;background-color:#FAFAFA;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:40px;line-height:40px;border-bottom:1px solid #eee}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 10px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view .layui-code-ol li:first-child{padding-top:10px}.layui-code-view .layui-code-ol li:last-child{padding-bottom:10px}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none}.layui-code-demo .layui-code{visibility:visible!important;margin:-15px;border-top:none;border-right:none;border-bottom:none}.layui-code-demo .layui-tab-content{padding:15px;border-top:none}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 299 KiB

After

Width:  |  Height:  |  Size: 316 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1,131 @@
body {
overflow-x: hidden;
}
.block {
position: absolute;
left: 0;
top: 0;
}
.sliderContainer {
position: relative;
text-align: center;
line-height: 40px;
background: #f7f9fa;
color: #45494c;
border-radius: 2px;
}
.sliderbg {
position: absolute;
left: 0;
right: 0;
top: 0;
background-color: #f7f9fa;
height: 40px;
border-radius: 2px;
border: 1px solid #e6e8eb;
}
.sliderContainer_active .slider {
top: -1px;
border: 1px solid #1991FA;
}
.sliderContainer_active .sliderMask {
border-width: 1px 0 1px 1px;
}
.sliderContainer_success .slider {
top: -1px;
border: 1px solid #52CCBA;
background-color: #52CCBA !important;
}
.sliderContainer_success .sliderMask {
border: 1px solid #52CCBA;
border-width: 1px 0 1px 1px;
background-color: #D2F4EF;
}
.sliderContainer_success .sliderIcon:before {
content: "\f00c";
}
.sliderContainer_fail .slider {
top: -1px;
border: 1px solid #f57a7a;
background-color: #f57a7a !important;
}
.sliderContainer_fail .sliderMask {
border: 1px solid #f57a7a;
background-color: #fce1e1;
border-width: 1px 0 1px 1px;
}
.sliderContainer_fail .sliderIcon:before {
content: "\f00d";
}
.sliderContainer_active .sliderText, .sliderContainer_success .sliderText, .sliderContainer_fail .sliderText {
display: none;
}
.sliderMask {
position: absolute;
left: 0;
top: 0;
height: 40px;
border: 0 solid #1991FA;
background: #D1E9FE;
border-radius: 2px;
}
.slider {
position: absolute;
top: 0;
left: 0;
width: 40px;
height: 40px;
background: #fff;
box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
cursor: pointer;
transition: background .2s linear;
border-radius: 2px;
display: flex;
align-items: center;
justify-content: center;
}
.slider:hover {
background: #1991FA;
}
.slider:hover .sliderIcon {
background-position: 0 -13px;
}
.sliderText {
position: relative;
}
.sliderIcon {
}
.refreshIcon {
position: absolute;
right: 0;
top: 0;
cursor: pointer;
margin: 6px;
color: rgba(0,0,0,.25);
font-size: 1rem;
z-index: 5;
transition: color .3s linear;
}
.refreshIcon:hover {
color: #6c757d;
}

File diff suppressed because one or more lines are too long

@ -0,0 +1,293 @@
(function ($) {
'use strict';
var SliderCaptcha = function (element, options) {
this.$element = $(element);
this.options = $.extend({}, SliderCaptcha.DEFAULTS, options);
this.$element.css({ 'position': 'relative', 'width': this.options.width + 'px', 'margin': '0 auto' });
this.init();
};
SliderCaptcha.VERSION = '1.0';
SliderCaptcha.Author = 'argo@163.com';
SliderCaptcha.DEFAULTS = {
width: 280, // canvas宽度
height: 155, // canvas高度
PI: Math.PI,
sliderL: 42, // 滑块边长
sliderR: 9, // 滑块半径
offset: 5, // 容错偏差
loadingText: '正在加载中...',
failedText: '再试一次',
barText: '向右滑动填充拼图',
repeatIcon: 'fa fa-repeat',
maxLoadCount: 3,
localImages: function () {
return 'images/Pic' + Math.round(Math.random() * 4) + '.jpg';
}
};
function Plugin(option) {
return this.each(function () {
var $this = $(this);
var data = $this.data('lgb.SliderCaptcha');
var options = typeof option === 'object' && option;
if (data && !/reset/.test(option)) return;
if (!data) $this.data('lgb.SliderCaptcha', data = new SliderCaptcha(this, options));
if (typeof option === 'string') data[option]();
});
}
$.fn.sliderCaptcha = Plugin;
$.fn.sliderCaptcha.Constructor = SliderCaptcha;
var _proto = SliderCaptcha.prototype;
_proto.init = function () {
this.initDOM();
this.initImg();
this.bindEvents();
};
_proto.initDOM = function () {
var createElement = function (tagName, className) {
var elment = document.createElement(tagName);
elment.className = className;
return elment;
};
var createCanvas = function (width, height) {
var canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
return canvas;
};
var canvas = createCanvas(this.options.width - 2, this.options.height) // 画布
var block = canvas.cloneNode(true) // 滑块
var sliderContainer = createElement('div', 'sliderContainer');
var refreshIcon = createElement('i', 'refreshIcon ' + this.options.repeatIcon);
var sliderMask = createElement('div', 'sliderMask');
var sliderbg = createElement('div', 'sliderbg');
var slider = createElement('div', 'slider');
var sliderIcon = createElement('i', 'fa fa-arrow-right sliderIcon');
var text = createElement('span', 'sliderText');
block.className = 'block'
text.innerHTML = this.options.barText;
var el = this.$element;
el.append($(canvas));
el.append($(refreshIcon));
el.append($(block));
slider.appendChild(sliderIcon);
sliderMask.appendChild(slider);
sliderContainer.appendChild(sliderbg);
sliderContainer.appendChild(sliderMask);
sliderContainer.appendChild(text);
el.append($(sliderContainer));
Object.assign(this, {
canvas,
block,
sliderContainer: $(sliderContainer),
refreshIcon,
slider,
sliderMask,
sliderIcon,
text: $(text),
canvasCtx: canvas.getContext('2d'),
blockCtx: block.getContext('2d')
})
};
_proto.initImg = function () {
var that = this;
var isIE = window.navigator.userAgent.indexOf('Trident') > -1;
var L = this.options.sliderL + this.options.sliderR * 2 + 3; // 滑块实际边长
var drawImg = function (ctx, operation) {
var l = that.options.sliderL;
var r = that.options.sliderR;
var PI = that.options.PI;
var x = that.x;
var y = that.y;
ctx.beginPath()
ctx.moveTo(x, y)
ctx.arc(x + l / 2, y - r + 2, r, 0.72 * PI, 2.26 * PI)
ctx.lineTo(x + l, y)
ctx.arc(x + l + r - 2, y + l / 2, r, 1.21 * PI, 2.78 * PI)
ctx.lineTo(x + l, y + l)
ctx.lineTo(x, y + l)
ctx.arc(x + r - 2, y + l / 2, r + 0.4, 2.76 * PI, 1.24 * PI, true)
ctx.lineTo(x, y)
ctx.lineWidth = 2
ctx.fillStyle = 'rgba(255, 255, 255, 0.7)'
ctx.strokeStyle = 'rgba(255, 255, 255, 0.7)'
ctx.stroke()
ctx[operation]()
ctx.globalCompositeOperation = isIE ? 'xor' : 'overlay'
}
var getRandomNumberByRange = function (start, end) {
return Math.round(Math.random() * (end - start) + start);
};
var img = new Image();
img.crossOrigin = "Anonymous";
var loadCount = 0;
img.onload = function () {
// 随机创建滑块的位置
that.x = getRandomNumberByRange(L + 10, that.options.width - (L + 10));
that.y = getRandomNumberByRange(10 + that.options.sliderR * 2, that.options.height - (L + 10));
drawImg(that.canvasCtx, 'fill');
drawImg(that.blockCtx, 'clip');
that.canvasCtx.drawImage(img, 0, 0, that.options.width - 2, that.options.height);
that.blockCtx.drawImage(img, 0, 0, that.options.width - 2, that.options.height);
var y = that.y - that.options.sliderR * 2 - 1;
var ImageData = that.blockCtx.getImageData(that.x - 3, y, L, L);
that.block.width = L;
that.blockCtx.putImageData(ImageData, 0, y);
that.text.text(that.text.attr('data-text'));
};
img.onerror = function () {
loadCount++;
if (window.location.protocol === 'file:') {
loadCount = that.options.maxLoadCount;
console.error("can't load pic resource file from File protocal. Please try http or https");
}
if (loadCount >= that.options.maxLoadCount) {
that.text.text('加载失败').addClass('text-danger');
return;
}
img.src = that.options.localImages();
};
img.setSrc = function () {
var src = '';
loadCount = 0;
that.text.removeClass('text-danger');
if ($.isFunction(that.options.setSrc)) src = that.options.setSrc();
if (!src || src === '') src = 'https://picsum.photos/' + that.options.width + '/' + that.options.height + '/?image=' + Math.round(Math.random() * 20);
if (isIE) { // IE浏览器无法通过img.crossOrigin跨域使用ajax获取图片blob然后转为dataURL显示
var xhr = new XMLHttpRequest()
xhr.onloadend = function (e) {
var file = new FileReader(); // FileReader仅支持IE10+
file.readAsDataURL(e.target.response);
file.onloadend = function (e) {
img.src = e.target.result;
}
}
xhr.open('GET', src);
xhr.responseType = 'blob';
xhr.send();
} else img.src = src;
};
img.setSrc();
this.text.attr('data-text', this.options.barText);
this.text.text(this.options.loadingText);
this.img = img
};
_proto.clean = function () {
this.canvasCtx.clearRect(0, 0, this.options.width, this.options.height);
this.blockCtx.clearRect(0, 0, this.options.width, this.options.height);
this.block.width = this.options.width;
};
_proto.bindEvents = function () {
var that = this;
this.$element.on('selectstart', function () {
return false;
});
$(this.refreshIcon).on('click', function () {
that.text.text(that.options.barText);
that.reset();
if ($.isFunction(that.options.onRefresh)) that.options.onRefresh.call(that.$element);
});
var originX, originY, trail = [],
isMouseDown = false
var handleDragStart = function (e) {
if (that.text.hasClass('text-danger')) return;
originX = e.clientX || e.touches[0].clientX;
originY = e.clientY || e.touches[0].clientY;
isMouseDown = true;
};
var handleDragMove = function (e) {
if (!isMouseDown) return false;
var eventX = e.clientX || e.touches[0].clientX;
var eventY = e.clientY || e.touches[0].clientY;
var moveX = eventX - originX;
var moveY = eventY - originY;
if (moveX < 0 || moveX + 40 > that.options.width) return false;
that.slider.style.left = (moveX - 1) + 'px';
var blockLeft = (that.options.width - 40 - 20) / (that.options.width - 40) * moveX;
that.block.style.left = blockLeft + 'px';
that.sliderContainer.addClass('sliderContainer_active');
that.sliderMask.style.width = (moveX + 4) + 'px';
trail.push(moveY);
};
var handleDragEnd = function (e) {
if (!isMouseDown) return false
isMouseDown = false
var eventX = e.clientX || e.changedTouches[0].clientX
if (eventX == originX) return false
that.sliderContainer.removeClass('sliderContainer_active');
that.trail = trail
var {
spliced,
verified
} = that.verify()
if (spliced && verified) {
that.sliderContainer.addClass('sliderContainer_success');
if ($.isFunction(that.options.onSuccess)) that.options.onSuccess.call(that.$element);
} else {
that.sliderContainer.addClass('sliderContainer_fail');
if ($.isFunction(that.options.onFail)) that.options.onFail.call(that.$element);
setTimeout(() => {
that.text.text(that.options.failedText);
that.reset();
}, 1000);
}
};
this.slider.addEventListener('mousedown', handleDragStart);
this.slider.addEventListener('touchstart', handleDragStart);
document.addEventListener('mousemove', handleDragMove);
document.addEventListener('touchmove', handleDragMove);
document.addEventListener('mouseup', handleDragEnd);
document.addEventListener('touchend', handleDragEnd);
document.addEventListener('mousedown', function () { return false; });
document.addEventListener('touchstart', function () { return false; });
};
_proto.verify = function () {
var sum = function (x, y) { return x + y; };
var square = function (x) { return x * x; };
var arr = this.trail // 拖动时y轴的移动距离
var average = arr.reduce(sum) / arr.length;
var deviations = arr.map(function (x) { return x - average; });
var stddev = Math.sqrt(deviations.map(square).reduce(sum) / arr.length);
var left = parseInt(this.block.style.left);
return {
spliced: Math.abs(left - this.x) < this.options.offset,
verified: stddev !== 0, // 简单验证下拖动轨迹为零时表示Y轴上下没有波动可能非人为操作
}
};
_proto.reset = function () {
this.sliderContainer.removeClass('sliderContainer_fail sliderContainer_success');
this.slider.style.left = 0
this.block.style.left = 0
this.sliderMask.style.width = 0
this.clean()
this.text.attr('data-text', this.text.text());
this.text.text(this.options.loadingText);
this.img.setSrc();
};
})(jQuery);

@ -38,19 +38,19 @@
/** Button 主题 */
.pear-btn-primary {
border: #2D8CF0;
border: 1px solid #2D8CF0;
background-color: #2D8CF0 !important;
}
.pear-btn-danger {
border: #f56c6c;
border: 1px solid #f56c6c;
background-color: #f56c6c !important;
}
.pear-btn-warming {
border: #f6ad55;
border: 1px solid #f6ad55;
background-color: #f6ad55 !important;
}
.pear-btn-success {
border: #36b368;
border: 1px solid #36b368;
background-color: #36b368 !important;
}
@ -59,7 +59,6 @@
}
.pear-btn-primary[plain] {
border: #409eff !important;
color: #409eff !important;
background: #ecf5ff 10% !important;
}
@ -70,7 +69,6 @@
}
.pear-btn-success[plain] {
border: #36b368 !important;
color: #36b368 !important;
background: #f0f9eb !important;
}
@ -81,7 +79,6 @@
}
.pear-btn-warming[plain] {
border: #e6a23c !important;
color: #e6a23c !important;
background: #fdf6ec !important;
}
@ -92,7 +89,6 @@
}
.pear-btn-danger[plain] {
border: #f56c6c !important;
color: #f56c6c !important;
background: #fef0f0 !important;
}

@ -0,0 +1,22 @@
html:-moz-full-screen {
background: grey;
}
html:-webkit-full-screen {
background: grey;
width: 100%;
height: 100%;
}
html:fullscreen{
background: grey;
width: 100% !important;
height: 100% !important;
}
:not(:root):fullscreen::backdrop{
background:whitesmoke;
}
.pear-full-screen {
width: 100% !important;
height: 100% !important;
}

@ -1,6 +1,6 @@
.layui-layer-msg {
border-color: transparent !important;
box-shadow: 2px 0 6px rgb(0 21 41 / 0.05) !important;
box-shadow: 2px 0 6px rgb(0 21 41 / 0.04) !important;
}
/* 扩展动画开始 */

@ -1,6 +1,7 @@
.pear-container {
margin: 10px;
background-color: whitesmoke;
width: calc(100vw - 20px);
}
body::-webkit-scrollbar {

@ -1,5 +1,5 @@
.pear-nav-tree {
width: 230px;
width: 230px !important;
border-radius: 0px;
background-color: #28333E;
}

@ -18,7 +18,6 @@
text-align: center;
border-right: 1px solid whitesmoke;
}
/*排除最后一个 li 右边框*/
.pear-notice .layui-tab-title li:last-child {
border-right: none;
@ -47,7 +46,7 @@
padding-left: 20px;
border-bottom: 1px solid whitesmoke;
padding-top: 10px;
padding-bottom: 10px;
padding-bottom: 15px;
}
.pear-notice-end {
float: right;
@ -82,3 +81,53 @@
.pear-notice *::-webkit-scrollbar-corner {
background: #f6f6f6;
}
/** 增加 empty 样式 */
.pear-empty {
font-size: 14px;
line-height: 1.5715;
min-height: 200px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.pear-empty-normal {
margin: 32px 0;
color: #00000040;
}
.pear-empty-normal .pear-empty-image {
height: 40px;
}
.pear-empty-image {
height: 100px;
margin-bottom: 8px;
}
.pear-empty-image svg {
height: 100%;
margin: auto;
}
.pear-empty-img-simple-g {
stroke: #d9d9d9;
}
.pear-empty-img-default-g {
fill: #fff;
}
.pear-empty-img-simple-path {
fill: #fafafa;
}
.pear-empty-img-default-path-1 {
fill: #aeb8c2;
}
.pear-empty-img-default-path-2 {
fill: url(#linearGradient-1);
}
.pear-empty-img-default-path-3 {
fill: #f5f5f7;
}
.pear-empty-img-default-path-4, .pear-empty-img-default-path-5 {
fill: #dce0e6;
}

File diff suppressed because one or more lines are too long

@ -33,10 +33,6 @@
background-color: #5FB878 !important;
}
.layui-table-view .layui-table{
width: 100%;
}
.layui-table tr {
height: 34px;
line-height: 34px;
@ -59,6 +55,14 @@
font-size: 15px !important;
}
.layui-table-cell .pear-btn {
margin-right: 5px;
}
.layui-table-cell .pear-btn:last-child {
margin-right: 0px;
}
.layui-table-page {
height: 45px !important;
padding-top: 10px !important;

@ -25,4 +25,6 @@
@import url("module/step.css");
@import url("module/card.css");
@import url("module/tab.css");
@import url("module/tag.css");
@import url("module/tag.css");
@import url("module/fullscreen.css");
@import url("module/popover.min.css");

@ -1,4 +1,4 @@
layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'menu', 'frame', 'theme', 'convert'],
layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'menu', 'frame', 'theme', 'convert','fullscreen'],
function(exports) {
"use strict";
@ -11,7 +11,8 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
pearMenu = layui.menu,
pearFrame = layui.frame,
pearTheme = layui.theme,
message = layui.message;
message = layui.message,
fullscreen=layui.fullscreen;
var bodyFrame;
var sideMenu;
@ -515,7 +516,7 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
var createList = function (data) {
var _listHtml = '';
$.each(data, function (index, item) {
_listHtml += '<li smenu-id=' + item.info.id + ' smenu-icon=' + item.info.icon + ' smenu-url=' + item.info.href + ' smenu-title=' + item.info.title + ' smenu-type=' + item.info.type + '>';
_listHtml += '<li smenu-id="' + item.info.id + '" smenu-icon="' + item.info.icon + '" smenu-url="' + item.info.href + '" smenu-title="' + item.info.title + '" smenu-type="' + item.info.type + '">';
_listHtml += ' <span><i style="margin-right:10px" class=" ' + item.info.icon + '"></i>' + item.path + '</span>';
_listHtml += ' <i class="layui-icon layui-icon-right"></i>';
_listHtml += '</li>'
@ -657,11 +658,11 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
body.on("click", ".fullScreen", function() {
if ($(this).hasClass("layui-icon-screen-restore")) {
screenFun(2).then(function() {
fullscreen.fullClose().then(function() {
$(".fullScreen").eq(0).removeClass("layui-icon-screen-restore");
});
} else {
screenFun(1).then(function() {
fullscreen.fullScreen().then(function() {
$(".fullScreen").eq(0).addClass("layui-icon-screen-restore");
});
}
@ -931,46 +932,6 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
}
}
function screenFun(num) {
num = num || 1;
num = num * 1;
var docElm = document.documentElement;
switch (num) {
case 1:
if (docElm.requestFullscreen) {
docElm.requestFullscreen();
} else if (docElm.mozRequestFullScreen) {
docElm.mozRequestFullScreen();
} else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen();
} else if (docElm.msRequestFullscreen) {
docElm.msRequestFullscreen();
}
break;
case 2:
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
break;
}
return new Promise(function(res, rej) {
res("返回值");
});
}
function isFullscreen() {
return document.fullscreenElement ||
document.msFullscreenElement ||
document.mozFullScreenElement ||
document.webkitFullscreenElement || false;
}
function isControl(option) {
if (option.theme.allowCustom) {
if (localStorage.getItem("control") != null) {
@ -1008,13 +969,13 @@ layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'm
}
window.onresize = function() {
if (!isFullscreen()) {
if (!fullscreen.isFullscreen()) {
$(".fullScreen").eq(0).removeClass("layui-icon-screen-restore");
}
}
$(window).on('resize', debounce(function () {
if (!sideMenu.isCollapse && $(window).width() <= 768) {
if (sideMenu && !sideMenu.isCollapse && $(window).width() <= 768) {
collapse();
}
},50));

@ -95,7 +95,11 @@ layui.define(['table', 'laypage','jquery', 'element'], function(exports) {
html += "<div id='cardpage'></div>";
}
else {
html = "<p>没有数据</p>";
if (data.code != option.response.statusCode) {
html = "<p>" + data.msg + "</p>";
} else {
html = "<p>没有数据</p>";
}
}
$(option.elem).html(html);
if (option.page) {
@ -177,7 +181,7 @@ layui.define(['table', 'laypage','jquery', 'element'], function(exports) {
function createCard(elem, linenum, item, no) {
var line = 12 / linenum;
var card =
'<div id=' + item.id + ' onclick="cardTableCheckedCard(' + elem + ',this)" class="layui-col-md' + line + ' ew-datagrid-item" data-index="' + no+'" data-number="1"> <div class="project-list-item"> <img class="project-list-item-cover" src="' +item.image + '"> <div class="project-list-item-body"> <h2>' + item.title + '</h2> <div class="project-list-item-text layui-text">' + item.remark + '</div> <div class="project-list-item-desc"> <span class="time">' +item.time + '</span> <div class="ew-head-list"></div> </div> </div > </div > </div > '
'<div id=' + item.id + ' onclick="cardTableCheckedCard(' + elem + ',this)" class="layui-col-md' + line + ' ew-datagrid-item" data-index="' + no+'" data-number="1"> <div class="project-list-item"> <img class="project-list-item-cover" src="' + item.image + '"> <div class="project-list-item-body"> <h2 class="layui-elip">' + item.title + '</h2> <div class="project-list-item-text layui-text">' + item.remark + '</div> <div class="project-list-item-desc"> <span class="time">' +item.time + '</span> <div class="ew-head-list"></div> </div> </div > </div > </div > '
return card;
}
@ -187,9 +191,12 @@ layui.define(['table', 'laypage','jquery', 'element'], function(exports) {
data.msg = tempData[option.response.msgName];
data.count = tempData[option.response.countName];
var dataList = tempData[option.response.dataName];
if(!dataList){
return data;
}
data.data = [];
for (var i = 0; i < dataList.length; i++) {
var item = {};
var item = dataList[i];
item.id = dataList[i][option.request.idName];
item.image = dataList[i][option.request.imageName];
item.title = dataList[i][option.request.titleName];
@ -212,6 +219,7 @@ layui.define(['table', 'laypage','jquery', 'element'], function(exports) {
$(obj).addClass('layui-table-click').siblings().removeClass('layui-table-click');
var item = {};
item.id = obj.id;
item.index = $(obj).attr('data-index');
item.image = $(obj).find('.project-list-item-cover')[0].src;
item.title = $(obj).find('h2')[0].innerHTML;
item.remark = $(obj).find('.project-list-item-text')[0].innerHTML;

@ -1,71 +1,114 @@
layui.define(['jquery', 'element','table'], function(exports) {
"use strict";
layui.define(['jquery', 'element', 'table'], function (exports) {
"use strict";
/**
* 常用封装类
* */
var MOD_NAME = 'common',
$ = layui.jquery,
table = layui.table,
element = layui.element;
/**
* 常用封装类
* */
var MOD_NAME = 'common',
$ = layui.jquery,
table = layui.table,
element = layui.element;
var common = new function() {
/**
* 获取当前表格选中字段
* @param obj 表格回调参数
* @param field 要获取的字段
* */
this.checkField = function(obj, field) {
let data = table.checkStatus(obj.config.id).data;
if (data.length === 0) {
return "";
}
let ids = "";
for (let i = 0; i < data.length; i++) {
ids += data[i][field] + ",";
}
ids = ids.substr(0, ids.length - 1);
return ids;
}
/**
* 当前是否为与移动端
* */
this.isModile = function(){
if ($(window).width() <= 768) {
return true;
}
return false;
}
/**
* 提交 json 数据
* @param data 提交数据
* @param href 提交接口
* @param table 刷新父级表
*
* */
this.submit = function(data,href,table,callback){
$.ajax({
url:href,
data:JSON.stringify(data),
dataType:'json',
contentType:'application/json',
type:'post',
success:callback !=null?callback(result):function(result){
if(result.success){
layer.msg(result.msg,{icon:1,time:1000},function(){
parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
parent.layui.table.reload(table);
});
}else{
layer.msg(result.msg,{icon:2,time:1000});
}
}
})
}
}
exports(MOD_NAME, common);
var common = new function () {
/**
* 获取当前表格选中字段
* @param obj 表格回调参数
* @param field 要获取的字段
* */
this.checkField = function (obj, field) {
let data = table.checkStatus(obj.config.id).data;
if (data.length === 0) {
return "";
}
let ids = "";
for (let i = 0; i < data.length; i++) {
ids += data[i][field] + ",";
}
ids = ids.substring(0, ids.length - 1);
return ids;
}
/**
* 当前是否为与移动端
* */
this.isModile = function () {
return $(window).width() <= 768;
}
/**
* 提交 json 数据
* @param href 必选 提交接口
* @param data 可选 提交数据
* @param ajaxtype 可选 提交方式(默认为get)
* @param table 可选 刷新父级表
* @param callback 可选 自定义回调函数
* @param dataType 可选 返回数据类型 智能猜测可以是xml, json, script, html
* @param is_async 可选 请求是否异步处理默认是 true
* @param is_cache 可选 浏览器是否缓存被请求页面默认是 true
* */
this.submit = function (href, data, ajaxtype, table, callback, dataType, is_async, is_cache) {
if (data !== undefined) {
$.ajaxSetup({data: JSON.stringify(data)});
} else {
$.ajaxSetup({data: ''});
}
if (dataType !== undefined) {
$.ajaxSetup({dataType: dataType});
}
if (is_async !== undefined) {
$.ajaxSetup({async: is_async});
}
if (is_cache !== undefined) {
$.ajaxSetup({cache: is_cache});
}
$.ajax({
url: href,
contentType: 'application/json',
type: ajaxtype || 'get',
success: callback != null ? callback : function (result) {
if (result.code === 1) {
layer.msg(result.msg, {icon: 1, time: 1000}, function () {
let frameIndex = parent.layer.getFrameIndex(window.name);
if (frameIndex) {
parent.layer.close(frameIndex);//关闭当前页
}
table && parent.layui.table.reload(table);
});
} else {
layer.msg(result.msg, {icon: 2, time: 1000});
}
},
error: function (xhr) {
if (xhr.status === 401) {
layer.msg('权限不足,您无法访问受限资源或数据', {icon: 5});
return;
}
if (xhr.status === 404) {
layer.msg('请求url地址错误请确认后刷新重试', {icon: 5});
return;
}
if (xhr.status === 419) {
layer.msg('长时间未操作,自动刷新后重试!', {icon: 5});
setTimeout(function () {
window.location.reload();
}, 2000);
return;
}
if (xhr.status === 429) {
layer.msg('尝试次数太多,请一分钟后再试', {icon: 5});
return;
}
if (xhr.status === 500) {
layer.msg(xhr.responseJSON.message, {icon: 5});
}
}
, complete: function (xhr, status) {
}
})
}
}
exports(MOD_NAME, common);
});

@ -218,7 +218,7 @@ layui.define(['jquery', 'element', 'layer', 'loading'], function (exports) {
if (area instanceof Array) {
area = area[0];
}
if (area.includes("%")) {
if (area.indexOf("%") != -1) {
left = targetEl.innerWidth() * (1 - area.replace("%", "") / 100);
} else {
left = targetEl.innerWidth() - area;
@ -229,7 +229,7 @@ layui.define(['jquery', 'element', 'layer', 'loading'], function (exports) {
if (area instanceof Array) {
area = area[1];
}
if (area.includes("%")) {
if (area.indexOf("%") != -1) {
top = targetEl.innerHeight() * (1 - area.replace("%", "") / 100);
} else {
top = targetEl.innerHeight() - area;

@ -1,67 +1,71 @@
layui.define(['jquery', 'element'], function (exports) {
layui.define(['jquery', 'element'], function(exports) {
"use strict";
var $ = layui.jquery;
var pearFrame = function (opt) {
var frame = function(opt) {
this.option = opt;
};
pearFrame.prototype.render = function (opt) {
frame.prototype.render = function(opt) {
var option = {
elem: opt.elem,
url: opt.url,
title: opt.title,
width: opt.width,
height: opt.height,
done: opt.done ? opt.done : function () { console.log("菜单渲染成功"); }
done: opt.done ? opt.done : function() {
console.log("菜单渲染成功");
}
}
createFrameHTML(option);
renderContent(option);
$("#" + option.elem).width(option.width);
$("#" + option.elem).height(option.height);
return new pearFrame(option);
return new frame(option);
}
pearFrame.prototype.changePage = function (url, loading) {
frame.prototype.changePage = function(url, loading) {
var $frameLoad = $("#" + this.option.elem).find(".pear-frame-loading");
var $frame = $("#" + this.option.elem + " iframe");
$frame.attr("src", url);
frameLoading($frame, $frameLoad, loading);
renderContentLoading($frame, $frameLoad, loading);
}
pearFrame.prototype.changePageByElement = function (elem, url, title, loading) {
frame.prototype.changePageByElement = function(elem, url, title, loading) {
var $frameLoad = $("#" + elem).find(".pear-frame-loading");
var $frame = $("#" + elem + " iframe");
$frame.attr("src", url);
$("#" + elem + " .title").html(title);
frameLoading($frame, $frameLoad, loading);
renderContentLoading($frame, $frameLoad, loading);
}
pearFrame.prototype.refresh = function (loading) {
frame.prototype.refresh = function(loading) {
var $frameLoad = $("#" + this.option.elem).find(".pear-frame-loading");
var $frame = $("#" + this.option.elem).find("iframe");
$frame.attr("src", $frame.attr("src"));
frameLoading($frame, $frameLoad, loading);
renderContentLoading($frame, $frameLoad, loading);
}
function createFrameHTML(option) {
var iframe = "<iframe class='pear-frame-content' style='width:100%;height:100%;' scrolling='auto' frameborder='0' src='" + option.url + "' ></iframe>";
var loading = '<div class="pear-frame-loading">' +
'<div class="ball-loader">' +
'<span></span><span></span><span></span><span></span>' +
'</div>' +
'</div></div>';
function renderContent(option) {
var iframe = `<iframe class='pear-frame-content' style='width:100%;height:100%;' scrolling='auto' frameborder='0' src='${option.url}' allowfullscreen='true' ></iframe>`;
var loading = `<div class="pear-frame-loading">
<div class="ball-loader">
<span></span><span></span><span></span><span></span>
</div>
</div></div>`;
$("#" + option.elem).html("<div class='pear-frame'>" + iframe + loading + "</div>");
}
function frameLoading(iframeEl, loadingEl, isLoading) {
function renderContentLoading (iframeEl, loadingEl, isLoading) {
if (isLoading) {
loadingEl.css({ display: 'block' });
iframeEl.load(function () {
loadingEl.css({
display: 'block'
});
$(iframeEl).on('load', function() {
loadingEl.fadeOut(1000);
})
}
}
exports('frame', new pearFrame());
exports('frame', new frame());
});

@ -0,0 +1,54 @@
layui.define(['message', 'table', 'jquery', 'element', 'yaml', 'form', 'tab', 'menu', 'frame', 'theme', 'convert'],
function(exports) {
"use strict";
var $ = layui.jquery;
var defer = $.Deferred();
var fullScreen = new function() {
this.func = null;
this.onFullchange = function(func){
this.func = func;
var evts = ['fullscreenchange','webkitfullscreenchange','mozfullscreenchange','MSFullscreenChange'];
for(var i=0;i<evts.length && func;i++) {
window.addEventListener(evts[i], this.func);
}
}
this.fullScreen = function(dom){
var docElm = dom && document.querySelector(dom) || document.documentElement;
if (docElm.requestFullscreen) {
docElm.requestFullscreen();
} else if (docElm.mozRequestFullScreen) {
docElm.mozRequestFullScreen();
} else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen();
} else if (docElm.msRequestFullscreen) {
docElm.msRequestFullscreen();
}else{
defer.reject("");
}
defer.resolve("返回值");
return defer.promise();
}
this.fullClose = function(){
if(this.isFullscreen()) {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
}
defer.resolve("返回值");
return defer.promise();
}
this.isFullscreen = function(){
return document.fullscreenElement ||
document.msFullscreenElement ||
document.mozFullScreenElement ||
document.webkitFullscreenElement || false;
}
};
exports('fullscreen', fullScreen);
})

@ -33,12 +33,19 @@ layui.define(['laypage', 'form'], function(exports) {
click = opts.click,
// 渲染成功后的回调
success = opts.success,
// 前缀 默认使用 layui-icon
ICON_prefix = opts.prefix == null ? "layui-icon" : opts.prefix,
// 异步获取外部字体图标数据
ICON_url = opts.url ,
// json数据
data = {},
// 唯一标识
tmp = new Date().getTime(),
// 是否使用的class数据
isFontClass = opts.type === 'fontClass',
// 是否使用自定义图标数据
isCustom = opts.url !=null && opts.prefix != null,
// 初始化时input的值
ORIGINAL_ELEM_VALUE = $(elem).val(),
TITLE = 'layui-select-title',
@ -52,8 +59,12 @@ layui.define(['laypage', 'form'], function(exports) {
var a = {
init: function() {
data = common.getData[type]();
if(isCustom)
{
data = common.ajaxData(ICON_url,ICON_prefix);
}else{
data = common.getData[type]();
}
a.hideElem().createSelect().createBody().toggleSelect();
a.preventEvent().inputListen();
common.loadCss();
@ -95,8 +106,8 @@ layui.define(['laypage', 'form'], function(exports) {
}
}
if (isFontClass) {
oriIcon = '<i class="layui-icon ' + ORIGINAL_ELEM_VALUE + '">';
if (isFontClass || isCustom) {
oriIcon = '<i class="'+ ICON_prefix + ' ' + ORIGINAL_ELEM_VALUE + '">';
} else {
oriIcon += ORIGINAL_ELEM_VALUE;
}
@ -200,9 +211,10 @@ layui.define(['laypage', 'form'], function(exports) {
// 每个图标dom
var icon = '<div class="layui-iconpicker-icon-item" title="' + obj + '" ' +
style + '>';
if (isFontClass) {
icon += '<i class="layui-icon ' + obj + '"></i>';
} else {
if (isFontClass || isCustom)
{
icon += '<i class="'+ ICON_prefix + ' ' + obj + '"></i>';
}else{
icon += '<i class="layui-icon">' + obj.replace('amp;', '') + '</i>';
}
icon += '</div>';
@ -312,13 +324,14 @@ layui.define(['laypage', 'form'], function(exports) {
check: function() {
var item = '#' + PICKER_BODY + ' .layui-iconpicker-icon-item';
a.event('click', item, function(e) {
var el = $(e.currentTarget).find('.layui-icon'),
var el = $(e.currentTarget).find('.' + ICON_prefix),
icon = '';
if (isFontClass) {
console.log( el.attr('class'));
if (isFontClass || isCustom) {
var clsArr = el.attr('class').split(/[\s\n]/),
cls = clsArr[1],
icon = cls;
$('#' + TITLE_ID).find('.layui-iconpicker-item .layui-icon').html(
$('#' + TITLE_ID).find('.layui-iconpicker-item .' + ICON_prefix).html(
'').attr('class', clsArr.join(' '));
} else {
var cls = el.html(),
@ -354,7 +367,6 @@ layui.define(['laypage', 'form'], function(exports) {
$(BODY).on(evt, el, fn);
}
};
var common = {
/**
* 加载样式表
@ -460,7 +472,29 @@ layui.define(['laypage', 'form'], function(exports) {
"&amp;#xe606;", "&amp;#xe604;", "&amp;#xe600;", "&amp;#xe658;",
"&amp;#x1007;", "&amp;#x1006;", "&amp;#x1005;", "&amp;#xe608;"
];
}
},
},
//通过异步获取自定义图标数据源
ajaxData:function (url,prefix){
var iconlist = [];
$.ajax({
url: url,
type: 'get',
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
async: false,
success: function (ret) {
var exp = eval("/"+prefix+"-(.*):/ig");
var result;
while ((result = exp.exec(ret)) != null) {
iconlist.push(prefix + '-' + result[1]);
}
},
error: function (xhr, textstatus, thrown) {
layer.msg('自定义图标接口有误');
}
});
return iconlist;
}
};

@ -166,8 +166,8 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
$("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents(".pear-nav-tree").find(".layui-this").removeClass(
"layui-this");
if (!$("#" + this.option.elem).is(".pear-nav-mini")) {
let openEle = null;
let openEleHeight = 0;
var openEle = null;
var openEleHeight = 0;
$($("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents('.layui-nav-child').get().reverse()).each(function () {
if (!$(this).parent().is('.layui-nav-itemed')) {
if (openEleHeight == 0) {

@ -98,19 +98,35 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
}
$.each(item.children, function (i, note) {
count++;
noticeContent += '<div class="pear-notice-item" notice-form="' + note.form + '" notice-context="' + note.context +
'" notice-title="' + note.title + '" notice-id="' + note.id + '">' +
'<img src="' + note.avatar + '"/>' +
'<div style="display:inline-block;">' + note.title + '</div>' +
'" notice-title="' + note.title + '" notice-id="' + note.id + '">' ;
if (note.avatar)
noticeContent +='<img src="' + note.avatar + '"/>';
noticeContent +='<div style="display:inline-block;">' + note.title + '</div>' +
'<div class="pear-notice-end">' + note.time + '</div>' +
'</div>';
})
// 空内容
if(item.children.length==0){
noticeContent +='<div class="pear-empty"><div class="pear-empty-image"><svg class="pear-empty-img-default" width="184" height="152" viewBox="0 0 184 152"><g fill="none" fill-rule="evenodd"><g transform="translate(24 31.67)"><ellipse class="pear-empty-img-default-ellipse" cx="67.797" cy="106.89" rx="67.797" ry="12.668"></ellipse><path class="pear-empty-img-default-path-1" d="M122.034 69.674L98.109 40.229c-1.148-1.386-2.826-2.225-4.593-2.225h-51.44c-1.766 0-3.444.839-4.592 2.225L13.56 69.674v15.383h108.475V69.674z"></path><path class="pear-empty-img-default-path-2" d="M101.537 86.214L80.63 61.102c-1.001-1.207-2.507-1.867-4.048-1.867H31.724c-1.54 0-3.047.66-4.048 1.867L6.769 86.214v13.792h94.768V86.214z" transform="translate(13.56)"></path><path class="pear-empty-img-default-path-3" d="M33.83 0h67.933a4 4 0 0 1 4 4v93.344a4 4 0 0 1-4 4H33.83a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4z"></path><path class="pear-empty-img-default-path-4" d="M42.678 9.953h50.237a2 2 0 0 1 2 2V36.91a2 2 0 0 1-2 2H42.678a2 2 0 0 1-2-2V11.953a2 2 0 0 1 2-2zM42.94 49.767h49.713a2.262 2.262 0 1 1 0 4.524H42.94a2.262 2.262 0 0 1 0-4.524zM42.94 61.53h49.713a2.262 2.262 0 1 1 0 4.525H42.94a2.262 2.262 0 0 1 0-4.525zM121.813 105.032c-.775 3.071-3.497 5.36-6.735 5.36H20.515c-3.238 0-5.96-2.29-6.734-5.36a7.309 7.309 0 0 1-.222-1.79V69.675h26.318c2.907 0 5.25 2.448 5.25 5.42v.04c0 2.971 2.37 5.37 5.277 5.37h34.785c2.907 0 5.277-2.421 5.277-5.393V75.1c0-2.972 2.343-5.426 5.25-5.426h26.318v33.569c0 .617-.077 1.216-.221 1.789z"></path></g><path class="pear-empty-img-default-path-5" d="M149.121 33.292l-6.83 2.65a1 1 0 0 1-1.317-1.23l1.937-6.207c-2.589-2.944-4.109-6.534-4.109-10.408C138.802 8.102 148.92 0 161.402 0 173.881 0 184 8.102 184 18.097c0 9.995-10.118 18.097-22.599 18.097-4.528 0-8.744-1.066-12.28-2.902z"></path><g class="pear-empty-img-default-g" transform="translate(149.65 15.383)"><ellipse cx="20.654" cy="3.167" rx="2.849" ry="2.815"></ellipse><path d="M5.698 5.63H0L2.898.704zM9.259.704h4.985V5.63H9.259z"></path></g></g></svg></div><p class="pear-empty-description">暂无数据</p></div>';
}
noticeContent += '</div>';
})
var notice = '<li class="layui-nav-item" lay-unselect="">' +
'<a href="#" class="notice layui-icon layui-icon-notice"><span class="layui-badge-dot"></div></a>' +
'<div class="layui-nav-child layui-tab pear-notice" style="margin-top: 0px;left: -200px;padding:0px;">';
var notice;
if (count > 0){
notice = '<li class="layui-nav-item" lay-unselect="">' +
'<a href="#" class="notice layui-icon layui-icon-notice"><span class="layui-badge-dot"></span></a>' +
'<div class="layui-nav-child layui-tab pear-notice" style="margin-top: 0px;left: -200px;padding:0px;">';
}else {
notice = '<li class="layui-nav-item" lay-unselect="">' +
'<a href="#" class="notice layui-icon layui-icon-notice"></a>' +
'<div class="layui-nav-child layui-tab pear-notice" style="margin-top: 0px;left: -200px;padding:0px;">';
}
noticeTitle += '</ul>';
noticeContent += '</div>';

File diff suppressed because it is too large Load Diff

@ -182,7 +182,7 @@ layui.define(['jquery', 'element'], function(exports) {
title: title,
content: '<iframe id="' + opt.id + '" data-frameid="' + opt.id +
'" scrolling="auto" frameborder="0" src="' +
opt.url + '" style="width:100%;height:100%;"></iframe>',
opt.url + '" style="width:100%;height:100%;" allowfullscreen="true"></>',
id: opt.id
});
tabData.push(opt);
@ -255,7 +255,7 @@ layui.define(['jquery', 'element'], function(exports) {
title: title,
content: '<iframe id="' + opt.id + '" data-frameid="' + opt.id +
'" scrolling="auto" frameborder="0" src="' +
opt.url + '" style="width:100%;height:100%;"></iframe>',
opt.url + '" style="width:100%;height:100%;" allowfullscreen="true"></iframe>',
id: opt.id
});
if (time != false && time != 0) {
@ -276,11 +276,11 @@ layui.define(['jquery', 'element'], function(exports) {
title: title,
content: '<iframe id="' + opt.id + '" data-frameid="' + opt.id +
'" scrolling="auto" frameborder="0" src="' +
opt.url + '" style="width:100%;height:100%;"></iframe>',
opt.url + '" style="width:100%;height:100%;" allowfullscreen="true"></iframe>',
id: opt.id
});
if (time != false && time != 0) {
tabIframeLoading(this.option.elem, opt.id);
tabIframeLoading(elem, opt.id);
}
tabData.push(opt);
sessionStorage.setItem(elem + "-pear-tab-data", JSON.stringify(tabData));
@ -307,7 +307,7 @@ layui.define(['jquery', 'element'], function(exports) {
title: title,
content: '<iframe id="' + opt.id + '" data-frameid="' + opt.id +
'" scrolling="auto" frameborder="0" src="' +
opt.url + '" style="width:100%;height:100%;"></iframe>',
opt.url + '" style="width:100%;height:100%;" allowfullscreen="true"></iframe>',
id: opt.id
});
if (time != false && time != 0) {
@ -342,7 +342,7 @@ layui.define(['jquery', 'element'], function(exports) {
title: title,
content: '<iframe id="' + opt.id + '" data-frameid="' + opt.id +
'" scrolling="auto" frameborder="0" src="' +
opt.url + '" style="width:100%;height:100%;"></iframe>',
opt.url + '" style="width:100%;height:100%;" allowfullscreen="true"></iframe>',
id: opt.id
});
if (time != false && time != 0) {
@ -487,7 +487,7 @@ layui.define(['jquery', 'element'], function(exports) {
content += '<div class="layui-show layui-tab-item"><iframe id="' + item.id +
'" data-frameid="' + item.id +
'" src="' + item.url +
'" frameborder="no" border="0" marginwidth="0" marginheight="0" style="width: 100%;height: 100%;"></iframe></div>'
'" frameborder="no" border="0" marginwidth="0" marginheight="0" style="width: 100%;height: 100%;" allowfullscreen="true"></iframe></div>'
} else {
if (!option.preload) {
item.url = "about:blank";
@ -496,7 +496,7 @@ layui.define(['jquery', 'element'], function(exports) {
content += '<div class="layui-tab-item"><iframe id="' + item.id + '" data-frameid="' +
item.id + '" src="' +
item.url +
'" frameborder="no" border="0" marginwidth="0" marginheight="0" style="width: 100%;height: 100%;"></iframe></div>'
'" frameborder="no" border="0" marginwidth="0" marginheight="0" style="width: 100%;height: 100%;" allowfullscreen="true"></iframe></div>'
}
index++;
});

@ -7,8 +7,8 @@ layui.define(["jquery","layer"], function (exports) {
theme.changeTheme = function (target, autoHead) {
this.autoHead = autoHead;
const color = localStorage.getItem("theme-color-color");
const second = localStorage.getItem("theme-color-second");
var color = localStorage.getItem("theme-color-color");
var second = localStorage.getItem("theme-color-second");
this.colorSet(color, second);
if (target.frames.length == 0) return;
for (var i = 0; i < target.frames.length; i++) {
@ -24,11 +24,12 @@ layui.define(["jquery","layer"], function (exports) {
theme.colorSet = function(color, second) {
let style = '';
var style = '';
style += '.light-theme .pear-nav-tree .layui-this a:hover,.light-theme .pear-nav-tree .layui-this,.light-theme .pear-nav-tree .layui-this a,.pear-nav-tree .layui-this a,.pear-nav-tree .layui-this{background-color: ' +color + '!important;}';
style += '.pear-admin .layui-logo .title{color:' + color + '!important;}';
style += '.pear-frame-title .dot,.pear-tab .layui-this .pear-tab-active{background-color: ' + color +'!important;}';
style += '.bottom-nav li a:hover{background-color:' + color + '!important;}';
style += '.pear-btn-primary {border: 1px solid ' + color + '!important;}';
style += '.pear-admin .layui-header .layui-nav .layui-nav-bar{background-color: ' + color + '!important;}'
style += '.ball-loader>span,.signal-loader>span {background-color: ' + color + '!important;}';
style += '.layui-header .layui-nav-child .layui-this a{background-color:' + color +'!important;color:white!important;}';
@ -82,6 +83,7 @@ layui.define(["jquery","layer"], function (exports) {
style += '.light-theme .pear-nav-tree .layui-this a:hover,.light-theme .pear-nav-tree .layui-this,.light-theme .pear-nav-tree .layui-this a {background-color:'+second+'!important;color:'+color+'!important;}'
style += '.light-theme .pear-nav-tree .layui-this{ border-right: 3px solid '+color+'!important}'
style += '.loader:after {background:'+color+'}'
style += '.layui-laydate .layui-this, .layui-laydate .layui-this>div{background:'+color+'!important}'
if(this.autoHead === true || this.autoHead === "true"){
style += '.pear-admin.banner-layout .layui-header .layui-logo,.pear-admin .layui-header{border:none;background-color:' + color + '!important;}.pear-admin.banner-layout .layui-header .layui-logo .title,.pear-admin .layui-header .layui-nav .layui-nav-item>a{color:whitesmoke!important;}';
style += '.pear-admin.banner-layout .layui-header{ box-shadow: 2px 0 6px rgb(0 21 41 / 35%) }'

@ -0,0 +1,224 @@
/* global Watermark */
layui.define(['jquery', 'element'], function(exports) {
var $=layui.$;
var _parentEle;
var _wmContainer;
var _wmObserver;
var _wmParentObserver;
var _resizeHandler;
var _windowsWidth = window.outerWidth;
var _windowsHeight = window.outerHeight;
var _left = 0;
var _top = 0;
/**
* Create DOM of watermark's container
* @param {Watermark} watermark
*/
var _createContainer = function (watermark) {
watermark._container = document.createElement('div');
watermark._container.classList.add('cell-watermark-container');
watermark._container.style.cssText = 'display: block; pointer-events: none;';
watermark._container.setAttribute('aria-hidden', true);
_parentEle = document.querySelector(watermark.options.appendTo) || document.body;
//获取页面最大宽度
_windowsWidth = Math.min(_parentEle.scrollWidth, _parentEle.clientWidth);
//获取页面最大高度
_windowsHeight = Math.min(_parentEle.scrollHeight, _parentEle.clientHeight);
_parentEle.appendChild(watermark._container);
};
/**
* Create watermark's DOM
* @param {Watermark} watermark
* @param {Object} options
*/
var _createWatermark = function (watermark, options) {
options.rowSpacing = options.rowSpacing || 60;
options.colSpacing = options.colSpacing || 30;
options.width = options.width || 150;
options.height = options.height || 20;
let rows = parseInt(_windowsHeight / (options.height + options.rowSpacing));
let cols = parseInt(_windowsWidth / (options.width + options.colSpacing));
let offsetLeft =_left+ (_windowsWidth - options.width * cols - options.colSpacing * (cols - 1)) / 2;
let offsetTop = _top+(_windowsHeight - options.height * rows - options.rowSpacing * (rows - 1)) / 2;
let watermarkBase = document.createElement('div');
watermarkBase.classList.add('cell-watermark');
watermarkBase.style.cssText =
'transform: rotate(15deg); opacity: 0.1; font-size: 0.85rem; text-align: center;' +
'position: absolute; user-select: none; word-break: break-all; overflow: hidden; z-index: 999999;';
for (let row = 0; row < rows; row++) {
let top = offsetTop + (options.rowSpacing + options.height) * row;
let tempCols = cols;
row % 2 !== 0 && tempCols++;
for (let col = 0; col < tempCols; col++) {
let left = offsetLeft + (options.colSpacing + options.width) * col;
tempCols !== cols && (left -= (options.colSpacing + options.width) / 2);
let watermarkEle = watermarkBase.cloneNode();
watermarkEle.style.cssText += `left: ${left}px; top: ${top}px; width: ${options.width}px; height: ${options.height}px`;
watermarkEle.style.transform = `rotate(${options.rotate}deg)`;
watermarkEle.style.opacity = options.opacity;
watermarkEle.style.fontSize = `${options.fontSize}rem`;
watermarkEle.style.fontFamily = options.fontFamily;
watermarkEle.innerHTML = options.content;
watermark._container.appendChild(watermarkEle);
}
}
//Backup for recover the watermark's container when the its DOM is removed
_wmContainer = watermark._container;
};
/**
* Rerender watermark
* @param {Watermark} watermark
* @param {Object} options
*/
var _render = function (watermark, options) {
_wmObserver.disconnect();
watermark._container.innerHTML = '';
_createWatermark(watermark, options);
_wmObserver.observe(watermark._container, {
attributes: true,
childList: true,
characterData: true,
subtree: true
});
};
/**
* Observe watermark and watermark's parentNode mutations
* @param {Watermark} watermark
*/
var _addObserve = function (watermark) {
//Observe watermark element and its child element
_wmObserver = new MutationObserver(function (mutations, observer) {
_render(watermark, watermark.options);
});
_wmObserver.observe(watermark._container, {
attributes: true,
childList: true,
characterData: true,
subtree: true
});
//Observe parent element, recreate if the element is deleted
_wmParentObserver = new MutationObserver(function (mutations) {
for (let m of mutations) {
if (
m.type === 'childList' &&
m.removedNodes.length > 0 &&
document.querySelectorAll('.cell-watermark-container').length === 0
) {
_parentEle.appendChild(_wmContainer);
}
}
});
_wmParentObserver.observe(watermark._container.parentNode, {
childList: true,
subtree: true
});
};
/**
* Window's resize listener
* @param {Watermark} watermark
*/
var _addResizeListener = function (watermark) {
_resizeHandler = function () {
//获取页面最大宽度
var _windowsWidth_n = Math.max(_parentEle.scrollWidth, _parentEle.clientWidth);
//获取页面最大高度
var _windowsHeight_n = Math.max(_parentEle.scrollHeight, _parentEle.clientHeight);
/*if (window.outerHeight !== _windowsHeight || window.outerWidth !== _windowsWidth) {
_windowsHeight = window.outerHeight;
_windowsWidth = window.outerWidth;
_render(watermark, watermark.options);
}*/
if (_windowsHeight_n !== _windowsHeight || _windowsWidth_n !== _windowsWidth) {
_windowsHeight = _windowsHeight_n;
_windowsWidth = _windowsWidth_n;
_render(watermark, watermark.options);
}
};
window.addEventListener('resize', _resizeHandler);
};
/**
* Watermark.
* Create watermark for webpage and automatic adjust when windows resize.
* @param {Object} options
* @param {String} [options.content] watermark's text
* @param {String} [options.appendTo='body'] parent of watermark's container
* @param {Number} [options.width=150] watermark's width. unit: px
* @param {Number} [options.height=20] watermark's height. unit: px
* @param {Number} [options.rowSpacing=60] row spacing of watermarks. unit: px
* @param {Number} [options.colSpacing=30] col spacing of watermarks. unit: px
* @param {Number} [options.rotate=15] watermark's tangent angle. unit: deg
* @param {Number} [options.opacity=0.1] watermark's transparency
* @param {Number} [options.fontSize=0.85] watermark's fontSize. unit: rem
* @param {Number} [options.fontFamily='inherit'] watermark's fontFamily.
* @namespace Watermark
* @class Watermark
* @version 1.0.3
* @author @Lruihao https://lruihao.cn
*/
function Watermark(options = {}) {
var _proto = Watermark.prototype;
this.options = options;
_createContainer(this);
_createWatermark(this, this.options);
_addObserve(this);
_addResizeListener(this);
/**
* Upload watermark's text content
* @param {String} content watermark's text
*/
_proto.upload = function (content) {
if (!content) {
return;
}
_wmParentObserver.disconnect();
_wmObserver.disconnect();
this.options.content = content;
for (const watermark of this._container.querySelectorAll('.cell-watermark')) {
watermark.innerHTML = content;
}
_wmParentObserver.observe(this._container.parentNode, {
childList: true,
subtree: true
});
_wmObserver.observe(this._container, {
attributes: true,
childList: true,
characterData: true,
subtree: true
});
};
/**
* Rerender watermark
* @param {Object} options
*/
_proto.render = function (options = {}) {
_render(this, Object.assign(this.options, options));
};
/**
* Force destroy watermark
*/
_proto.destroy = function () {
_wmObserver.disconnect();
_wmParentObserver.disconnect();
window.removeEventListener('resize', _resizeHandler);
this._container.parentNode.removeChild(this._container);
};
}
exports("watermark",Watermark);
})

@ -4,43 +4,48 @@ window.rootPath = (function (src) {
: document.scripts[document.scripts.length - 1].src;
return src.substring(0, src.lastIndexOf("/") + 1);
})();
layui.config({
base: rootPath + "module/",
version: "3.9.10"
version: "3.30.0"
}).extend({
admin: "admin", // 框架布局组件
menu: "menu", // 数据菜单组件
frame: "frame", // 内容页面组件
tab: "tab", // 多选项卡组件
echarts: "echarts", // 数据图表组件
echartsTheme: "echartsTheme", // 数据图表主题
encrypt: "encrypt", // 数据加密组件
select: "select", // 下拉多选组件
drawer: "drawer", // 抽屉弹层组件
notice: "notice", // 消息提示组件
step:"step", // 分布表单组件
tag:"tag", // 多标签页组件
popup:"popup", // 弹层封装
treetable:"treetable", // 树状表格
dtree:"dtree", // 树结构
tinymce:"tinymce/tinymce", // 编辑器
area:"area", // 省市级联
count:"count", // 数字滚动
topBar: "topBar", // 置顶组件
button: "button", // 加载按钮
design: "design", // 表单设计
card: "card", // 数据卡片组件
loading: "loading", // 加载组件
cropper:"cropper", // 裁剪组件
convert:"convert", // 数据转换
yaml:"yaml", // yaml 解析组件
context: "context", // 上下文组件
http: "http", // ajax请求组件
theme: "theme", // 主题转换
message: "message", // 通知组件
toast: "toast", // 消息通知
iconPicker: "iconPicker",// 图标选择
nprogress: "nprogress" // 进度过渡
admin: "admin", // 框架布局组件
common: "common", // 公共方法封装
menu: "menu", // 数据菜单组件
frame: "frame", // 内容页面组件
tab: "tab", // 多选项卡组件
echarts: "echarts", // 数据图表组件
echartsTheme: "echartsTheme",// 数据图表主题
encrypt: "encrypt", // 数据加密组件
select: "select", // 下拉多选组件
drawer: "drawer", // 抽屉弹层组件
notice: "notice", // 消息提示组件
step:"step", // 分布表单组件
tag:"tag", // 多标签页组件
popup:"popup", // 弹层封装
treetable:"treetable", // 树状表格
dtree:"dtree", // 树结构
tinymce:"tinymce/tinymce", // 编辑器
area:"area", // 省市级联
count:"count", // 数字滚动
topBar: "topBar", // 置顶组件
button: "button", // 加载按钮
design: "design", // 表单设计
card: "card", // 数据卡片组件
loading: "loading", // 加载组件
cropper:"cropper", // 裁剪组件
convert:"convert", // 数据转换
yaml:"yaml", // yaml 解析组件
context: "context", // 上下文组件
http: "http", // 网络请求组件
theme: "theme", // 主题转换
message: "message", // 通知组件
toast: "toast", // 消息通知
iconPicker: "iconPicker", // 图标选择
nprogress: "nprogress", // 进度过渡
watermark:"watermark/watermark", //水印组件
fullscreen:"fullscreen", //全屏组件
popover:"popover/popover" //汽泡组件
}).use(['layer', 'theme'], function () {
layui.theme.changeTheme(window, false);
});

@ -0,0 +1,70 @@
{
"logo": {
"title": "Pear Admin",
"image": "admin/images/logo.png"
},
"menu": {
"data": "admin/data/menu.json",
"method": "GET",
"accordion": true,
"collapse": false,
"control": false,
"controlWidth": 500,
"select": "10",
"async": true
},
"tab": {
"enable": true,
"keepState": true,
"session": true,
"preload": false,
"max": "30",
"index": {
"id": "10",
"href": "view/console/console1.html",
"title": "首页"
}
},
"theme": {
"defaultColor": "2",
"defaultMenu": "dark-theme",
"defaultHeader": "light-theme",
"allowCustom": true,
"banner": false
},
"colors": [
{
"id": "1",
"color": "#2d8cf0",
"second": "#ecf5ff"
},
{
"id": "2",
"color": "#36b368",
"second": "#f0f9eb"
},
{
"id": "3",
"color": "#f6ad55",
"second": "#fdf6ec"
},
{
"id": "4",
"color": "#f56c6c",
"second": "#fef0f0"
},
{
"id": "5",
"color": "#3963bc",
"second": "#ecf5ff"
}
],
"other": {
"keepLoad": "1200",
"autoHead": false,
"footer": false
},
"header": {
"message": "admin/data/message.json"
}
}

@ -0,0 +1,82 @@
## 网站配置
logo:
## 网站名称
title: "Pear Admin"
## 网站图标
image: "admin/images/logo.png"
## 菜单配置
menu:
## 菜单数据来源
data: "admin/data/menu.json"
## 菜单接口的请求方式 GET / POST
method: "GET"
## 是否同时只打开一个菜单目录
accordion: true
## 侧边默认折叠状态
collapse: false
## 是否开启多系统菜单模式
control: false
## 顶部菜单宽度 PX
controlWidth: 500
## 默认选中的菜单项
select: "10"
## 是否开启异步菜单false 时 data 属性设置为静态数据true 时为后端接口
async: true
## 视图内容配置
tab:
## 是否开启多选项卡
enable: true
## 保持视图状态
keepState: true
## 开启选项卡记忆
session: true
## 浏览器刷新时是否预加载非激活标签页
preload: true
## 可打开的数量, false 不限制极值
max: "30"
## 首页
index:
id: "10" ## 标识 ID , 建议与菜单项中的 ID 一致
href: "view/console/console1.html" ## 页面地址
title: "首页" ## 标题
## 主题配置
theme:
## 默认主题色,对应 colors 配置中的 ID 标识
defaultColor: "2"
## 默认的菜单主题 dark-theme 黑 / light-theme 白
defaultMenu: "dark-theme"
## 默认的顶部主题 dark-theme 黑 / light-theme 白
defaultHeader: "light-theme"
## 是否允许用户切换主题false 时关闭自定义主题面板
allowCustom: true
## 通栏配置
banner: false
## 主题色配置列表
colors:
- id: "1"
color: "#2d8cf0"
second: "#ecf5ff"
- id: "2"
color: "#36b368"
second: "#f0f9eb"
- id: "3"
color: "#f6ad55"
second: "#fdf6ec"
- id: "4"
color: "#f56c6c"
second: "#fef0f0"
- id: "5"
color: "#3963bc"
second: "#ecf5ff"
## 其他配置
other:
## 主页动画时长
keepLoad: "1200"
## 布局顶部主题
autoHead: false
## 页脚
footer: false
## 头部配置
header:
## 站内消息,通过 false 设置关闭
message: "admin/data/message.json"

@ -4,7 +4,7 @@
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="../component/pear/css/pear.css" />
<link rel="stylesheet" href="../../component/pear/css/pear.css" />
</head>
<body class="pear-container">
@ -22,38 +22,8 @@
</button>
</script>
<script type="text/html" id="tableOperate">
{{# if(d.is_run === 0){ }}
<button class="pear-btn pear-btn-warming pear-btn-sm" lay-event="start" title="启动"><i class="icon pear-icon pear-icon-setting"></i>
</button>
{{# } }}
{{# if(d.is_run > 0){ }}
<button class="pear-btn pear-btn-warming pear-btn-sm" lay-event="stop" title="停止"><i class="icon pear-icon pear-icon-stop"></i>
</button>
{{# } }}
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit" title="编辑"><i class="layui-icon layui-icon-edit"></i>
</button>
<button class="pear-btn pear-btn-sm" lay-event="view" title="查看报名情况"><i class="layui-icon layui-icon-form"></i>
</button>
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="export" title="导出报名情况"><i class="icon pear-icon pear-icon-share
"></i>
</button>
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove" title="删除"><i class="layui-icon layui-icon-delete"></i>
</button>
</script>
<script type="text/html" id="taskFill">
{{# if(d.fill_count === 0){ }}
<span>{{ d.fill_count }}</span>
{{# } else { }}
<span style="cursor:pointer;" lay-event="taskFillInfo">{{ d.fill_count }}</span>
{{# } }}
</script>
<script src="../component/layui/layui.js"></script>
<script src="../component/pear/pear.js"></script>
<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>
<script>
layui.use(['table', 'form', 'jquery', 'common'], function () {
@ -64,11 +34,12 @@
let cols = [
[
{ field: '', title: '序号', align: 'center', type: 'numbers', width: "5%" }
, { field: 'task_name', title: '任务名称', align: 'center' }
, { field: 'create_time', title: '创建时间', align: 'center', width: "10%" }
, { field: '', title: '状态', align: 'center', width: "10%", templet: getPublishText }
, { field: '', title: '操作', toolbar: '#tableOperate', align: 'center', width: "25%" }
{ field: 'num', title: '名次', align: 'center', width: "10%" }
, { field: 'person_name', title: '姓名', align: 'center' }
, { field: 'score', title: '得分', align: 'center', width: "10%" }
, { field: 'start_time', title: '开始时间', align: 'center', width: "20%" }
, { field: 'end_time', title: '交卷时间', align: 'center', width: "20%" }
, { field: 'ys', title: '用时', align: 'center', width: "20%" }
]
]
@ -77,181 +48,28 @@
function tableRender() {
table.render({
elem: '#task-table',
url: '/FengHuang/yp/listTask',
url: '/FengHuang/exam/getPageSummary',
page: {
limit: 15
limit: 10
, layout: ['count', 'prev', 'page', 'next', 'skip']
, prev: "上一页"
, next: "下一页"
},
cols: cols,
skin: 'line',
skin: 'line',
toolbar: '#task-toolbar',
defaultToolbar: []
});
}
table.on('tool(task-table)', function (data) {
if (data.event === 'start') {
startTask(data.data.task_id);
} else if (data.event === 'stop') {
stopTask(data.data.task_id);
} else if (data.event === 'edit') {
taskEdit(data.data.task_id);
}
else if (data.event === 'remove') {
taskRemove(data.data.task_id);
} else if (data.event === 'view') {
taskView(data.data.task_id);
} else {
window.location = "/FengHuang/yp/exportExcel?task_id=" + data.data.task_id;
}
});
table.on('toolbar(task-table)', function (data) {
if (data.event === 'add') {
window.taskAdd();
window.location = "/FengHuang/exam/exportExcel";
}
});
// 新增任务
window.taskAdd = function () {
layer.open({
type: 2,
title: '新增任务',
shade: 0.1,
area: ['830px', '500px'],
content: './taskManageAdd.html'
});
}
// 编辑任务
window.taskEdit = function (taskId) {
layer.open({
type: 2,
title: '编辑任务',
shade: 0.1,
area: ['830px', '500px'],
content: './taskManageEdit.html?task_id=' + taskId
});
}
// 删除任务
window.taskRemove = function (taskId) {
layer.confirm('确定要删除该任务?', {
icon: 3,
title: '提示'
}, function (index) {
$.ajax({
url: "/FengHuang/yp/delTask",
data: { "task_id": taskId },
type: 'POST',
success: function (result) {
if (result.success) {
layer.msg("删除成功!", {
icon: 1,
time: 1000
}, function () {
refresh();
});
} else {
layer.msg(result.msg, {
icon: 2,
time: 1000
});
}
}
})
});
}
// 启动任务
window.startTask = function (taskId) {
layer.confirm('启动该任务会自动停止其他任务,确定要启动任务吗?', {
icon: 3,
title: '提示'
}, function (index) {
$.ajax({
url: "/FengHuang/yp/startTask",
data: { "task_id": taskId },
type: 'post',
success: function (result) {
if (result.success) {
layer.msg("启动成功!", {
icon: 1,
time: 1500
}, function () {
refresh();
});
} else {
layer.msg(result.message, {
icon: 2,
time: 1000
});
}
}
});
});
}
// 停止任务
window.stopTask = function (taskId) {
layer.confirm('确定要停止任务吗?', {
icon: 3,
title: '提示'
}, function (index) {
$.ajax({
url: "/FengHuang/yp/stopTask",
data: { "task_id": taskId },
type: 'post',
success: function (result) {
if (result.success) {
layer.msg("停止成功!", {
icon: 1,
time: 1500
}, function () {
refresh();
});
} else {
layer.msg(result.message, {
icon: 2,
time: 1000
});
}
}
});
});
}
// 查看填报情况
window.taskView = function (taskId) {
layer.open({
type: 2,
title: '查看报名情况',
shade: 0.1,
shade: false,
maxmin: false,
move: false,
area: ['100%', '100%'],
content: './taskView.html?task_id=' + taskId
});
}
// 弹出窗口用
window.parentTableRender = function () {
refresh();
}
});
window.refresh = function (param) {
table.reload('task-table');
}
function getPublishText(data) {
if (data.is_run === 0) {
return "<span style='color:red;'>已停止</span>";
} else {
return "<span style='color:green;'>已启动</span>";
}
}
})

Loading…
Cancel
Save