mirror of https://github.com/layui/layui
commit
7d26f78266
|
@ -5,7 +5,9 @@ body:
|
|||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
在反馈问题之前,请确保:
|
||||
**请注意**:此处只接受 Layui 相关技术问题,其他如 layuiAdmin 或 layim 等主题相关问题请勿在此反馈。
|
||||
<br><br>
|
||||
同时,在反馈问题之前,请确保:
|
||||
- 已查看官方使用文档:**https://layui.dev** ,但没有找到相关解决方案。
|
||||
- 已在 **Issues** 中搜索过类似的问题,但没有找到相关解决方案。
|
||||
- type: input
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
name: 😄 功能建议
|
||||
description: 对 Layui 提出合理且有效的建议。
|
||||
title: ""
|
||||
labels: ["建议"]
|
||||
body:
|
||||
- type: textarea
|
||||
id: related-problem
|
||||
attributes:
|
||||
label: 建议内容
|
||||
placeholder: 阐述提出该建议的出发点,请认真填写。
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: desired-solution
|
||||
attributes:
|
||||
label: 解决方案
|
||||
placeholder: 你希望得到什么样的解决方案?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: additional-context
|
||||
attributes:
|
||||
label: 截图说明
|
||||
placeholder: 在此处添加有关功能请求的相关截图(支持粘贴上传)。
|
||||
validations:
|
||||
required: false
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -78,7 +78,7 @@
|
|||
|
||||
- 若为 `boolean` 类型,即表示是否开启范围选择,若设为 `true`,则开始日期与结束日期默认采用 `-` 连接符
|
||||
- 若为 `string` 类型,则表示开启范围选择,且自定义开始日期与结束日期的连接符。如: `range: '~'`
|
||||
- 若为 `boolean` 类型,即表示开启范围选,且开始日期和结束日期分别赋值在两个目标选择器中,如:
|
||||
- 若为 `array` 类型,即表示开启范围选,且开始日期和结束日期分别赋值在两个目标选择器中,如:
|
||||
|
||||
```
|
||||
range: ['#start', '#end']
|
||||
|
|
|
@ -24,7 +24,7 @@ toc: true
|
|||
- 通过 `<li></li>` 放置菜单列表项
|
||||
- 属性:
|
||||
- 追加 `className` 为 `layui-menu-item-group` 可设置当前菜单为菜单组,即子菜单为纵向层级。
|
||||
- 或追加 `className` 为 `layui-menu-item-parent` 可这支当前菜单为父级菜单,即子菜单为横向层级。
|
||||
- 或追加 `className` 为 `layui-menu-item-parent` 可设置当前菜单为父级菜单,即子菜单为横向层级。
|
||||
- 追加 `className` 为 `layui-menu-item-divider` 可设置分隔线。
|
||||
- 追加 `className` 为 `layui-menu-item-up` 或 `layui-menu-item-down` 可设置子菜单默认收缩或展开。
|
||||
- 追加 `className` 为 `layui-menu-item-checked` 可设置当前菜单为选中状态
|
||||
|
@ -59,4 +59,4 @@ toc: true
|
|||
|
||||
## 贴士
|
||||
|
||||
基础菜单相当于是 `dropdown` 组件的一种静态化呈现,因此在事件等动态操作上需借助 `dropdown` 组件的 API 来完成。
|
||||
基础菜单相当于是 `dropdown` 组件的一种静态化呈现,因此在事件等动态操作上需借助 `dropdown` 组件的 API 来完成。
|
||||
|
|
|
@ -46,6 +46,7 @@ tab 组件提供了三种 UI 风格,分别为:
|
|||
<div class="layui-tab-item">内容-5</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- import layui -->
|
||||
</textarea>
|
||||
</pre>
|
||||
|
||||
|
@ -71,6 +72,7 @@ tab 组件提供了三种 UI 风格,分别为:
|
|||
<div class="layui-tab-item">内容-5</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- import layui -->
|
||||
</textarea>
|
||||
</pre>
|
||||
|
||||
|
@ -96,6 +98,7 @@ tab 组件提供了三种 UI 风格,分别为:
|
|||
<div class="layui-tab-item">内容-5</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- import layui -->
|
||||
</textarea>
|
||||
</pre>
|
||||
|
||||
|
|
|
@ -103,6 +103,7 @@ treeTable.render({
|
|||
| --- | --- | --- | --- |
|
||||
| isSimpleData | 是否简单数据模式 | boolean | `false` |
|
||||
| rootPid | 用于设置根节点的 `pid` 属性值 | string | `null` |
|
||||
| cascade | 用于设置复选的级联方式。支持以下可选值:<ul><li><code>all</code> : 所有节点联动</li><li><code>parent</code> : 仅对父节点联动</li><li><code>children</code> : 仅对子节点联动</li></ul> | string | `all` |
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -11,6 +11,32 @@ toc: true
|
|||
|
||||
> 导读:📑 [Layui 2.8 《升级指南》](/notes/2.8/upgrade-guide.html) · 📑 [Layui 新版文档站上线初衷](/notes/2.8/news.html)
|
||||
|
||||
<h2 id="2.8.12" class="ws-anchor">
|
||||
2.8.12
|
||||
<span class="layui-badge-rim">2023-08-01</span>
|
||||
</h2>
|
||||
|
||||
- #### form
|
||||
- 优化 `input` 数字输入框在前置后置结构中的样式 # I7KTQB
|
||||
- #### layer
|
||||
- 修复 设置 `scrollbar` 属性禁用页面滚动条时,点击最大化再还原导致滚动条又重新出现的问题 # I7NTGX
|
||||
- 修复 弹层容器中的 `id` 值与其他弹层索引值相同时,导致关闭弹层存在冲突问题 # I7PF0O
|
||||
- #### upload
|
||||
- 修复 `auto: false` 时,打开文件选择框并点击取消后,导致文件上传失效的问题 # I7NU31
|
||||
- #### treeTable
|
||||
- 新增 `tree.data.cascade` 属性,用于设置复选的级联方式,默认 `all` # 1309
|
||||
- 修复 右侧固定列选中背景色没有和主体选中状态保持同步的问题 # I7NVCU
|
||||
- 调整 树形转平铺的方法,保留节点的 `children` 信息 # 1309
|
||||
- 调整 重载时的参数拷贝,由默认深拷贝换成默认浅拷贝,以便与 table 组件保持一致 # 1309/I7NN0O
|
||||
- #### tree
|
||||
- 优化 `checked` 属性赋值机制,若初始数据源存在该属性,才对其进行动态赋值
|
||||
- 优化 `spread` 属性赋值机制,若初始数据源存在该属性,则展开和收缩时,自动对其更新状态值
|
||||
- #### 其他
|
||||
- 修正 code 中部分单词拼写错误 # 1310
|
||||
|
||||
### 下载: [layui-v2.8.12.zip](https://gitee.com/layui/layui/attach_files/1482367/download)
|
||||
|
||||
---
|
||||
|
||||
<h2 id="2.8.11" class="ws-anchor">
|
||||
2.8.11
|
||||
|
|
|
@ -33,7 +33,7 @@ layui.use(['treeTable'], function(){
|
|||
{field: 'score', title: '评分', width: 80, sort: true},
|
||||
{field: 'city', title: '城市', width: 150},
|
||||
{field: 'description', title: '描述', minWidth: 200},
|
||||
{field: 'createTime', title: '创建时间', width: 170},
|
||||
{field: 'createTime', title: '创建时间', width: 170, fixed: 'right'},
|
||||
]],
|
||||
page: true
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "layui",
|
||||
"version": "2.8.11",
|
||||
"version": "2.8.12",
|
||||
"description": "Classic modular Front-End UI library",
|
||||
"main": "dist/layui.js",
|
||||
"license": "MIT",
|
||||
|
|
|
@ -764,8 +764,8 @@ a cite{font-style: normal; *cursor:pointer;}
|
|||
.layui-input-group{position: relative; display: table; box-sizing: border-box;}
|
||||
.layui-input-group>*{display: table-cell; vertical-align: middle; position: relative;}
|
||||
.layui-input-group .layui-input{padding-right: 15px;}
|
||||
.layui-input-group .layui-input-prefix{width: auto; border-right: 0;}
|
||||
.layui-input-group .layui-input-suffix{width: auto; border-left: 0;}
|
||||
.layui-input-group > .layui-input-prefix{width: auto; border-right: 0;}
|
||||
.layui-input-group > .layui-input-suffix{width: auto; border-left: 0;}
|
||||
.layui-input-group .layui-input-split{white-space: nowrap;}
|
||||
|
||||
/* 输入框前后缀容器 */
|
||||
|
@ -793,12 +793,12 @@ a cite{font-style: normal; *cursor:pointer;}
|
|||
.layui-input-affix .layui-icon:hover{color: rgba(0,0,0,.6);}
|
||||
|
||||
/* 数字输入框动态点缀 */
|
||||
.layui-input-number{width: 24px; padding: 0;}
|
||||
.layui-input-number .layui-icon{position: absolute; right: 0; width: 100%; height: 50%; line-height: normal; font-size: 12px;}
|
||||
.layui-input-number .layui-icon:before{position: absolute; left: 50%; top: 50%; margin-top: -6px; margin-left: -6px;}
|
||||
.layui-input-number .layui-icon:first-child{top: 0; border-bottom: 1px solid #eee;}
|
||||
.layui-input-number .layui-icon:last-child{bottom: 0;}
|
||||
.layui-input-number .layui-icon:hover{font-weight: 700;}
|
||||
.layui-input-wrap .layui-input-number{width: 24px; padding: 0;}
|
||||
.layui-input-wrap .layui-input-number .layui-icon{position: absolute; right: 0; width: 100%; height: 50%; line-height: normal; font-size: 12px;}
|
||||
.layui-input-wrap .layui-input-number .layui-icon:before{position: absolute; left: 50%; top: 50%; margin-top: -6px; margin-left: -6px;}
|
||||
.layui-input-wrap .layui-input-number .layui-icon:first-child{top: 0; border-bottom: 1px solid #eee;}
|
||||
.layui-input-wrap .layui-input-number .layui-icon:last-child{bottom: 0;}
|
||||
.layui-input-wrap .layui-input-number .layui-icon:hover{font-weight: 700;}
|
||||
.layui-input-wrap .layui-input[type="number"]::-webkit-outer-spin-button,
|
||||
.layui-input-wrap .layui-input[type="number"]::-webkit-inner-spin-button{-webkit-appearance: none !important;}
|
||||
.layui-input-wrap .layui-input[type="number"]{-moz-appearance: textfield;}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
};
|
||||
|
||||
var Layui = function(){
|
||||
this.v = '2.8.11'; // Layui 版本号
|
||||
this.v = '2.8.12'; // Layui 版本号
|
||||
};
|
||||
|
||||
// 识别预先可能定义的指定全局对象
|
||||
|
|
|
@ -475,7 +475,7 @@ Class.pt.creat = function(){
|
|||
that.layero = $('#'+ doms[0] + times);
|
||||
that.shadeo = $('#'+ doms.SHADE + times);
|
||||
|
||||
config.scrollbar || doms.html.css('overflow', 'hidden').attr('layer-full', times);
|
||||
config.scrollbar || ready.setScrollbar(times);
|
||||
}).auto(times);
|
||||
|
||||
// 遮罩
|
||||
|
@ -960,13 +960,17 @@ ready.record = function(layero){
|
|||
layero.attr({area: area});
|
||||
};
|
||||
|
||||
ready.rescrollbar = function(index){
|
||||
// 设置页面滚动条
|
||||
ready.setScrollbar = function(index){
|
||||
doms.html.css('overflow', 'hidden').attr('layer-full', index);
|
||||
};
|
||||
|
||||
// 恢复页面滚动条
|
||||
ready.restScrollbar = function(index){
|
||||
if(doms.html.attr('layer-full') == index){
|
||||
if(doms.html[0].style.removeProperty){
|
||||
doms.html[0].style.removeProperty('overflow');
|
||||
} else {
|
||||
doms.html[0].style.removeAttribute('overflow');
|
||||
}
|
||||
doms.html[0].style[doms.html[0].style.removeProperty
|
||||
? 'removeProperty'
|
||||
: 'removeAttribute']('overflow');
|
||||
doms.html.removeAttr('layer-full');
|
||||
}
|
||||
};
|
||||
|
@ -1097,7 +1101,7 @@ layer.min = function(index, options){
|
|||
|
||||
elemMin.hide();
|
||||
layero.attr('type') === 'page' && layero.find(doms[4]).hide();
|
||||
ready.rescrollbar(index);
|
||||
ready.restScrollbar(index);
|
||||
|
||||
// 隐藏遮罩
|
||||
shadeo.hide();
|
||||
|
@ -1109,6 +1113,7 @@ layer.restore = function(index){
|
|||
var shadeo = $('#'+ doms.SHADE + index);
|
||||
var area = layero.attr('area').split(',');
|
||||
var type = layero.attr('type');
|
||||
var options = layero.data('config') || {};
|
||||
|
||||
layero.removeData('maxminStatus'); // 移除最大最小状态
|
||||
|
||||
|
@ -1125,7 +1130,9 @@ layer.restore = function(index){
|
|||
layero.find('.layui-layer-max').removeClass('layui-layer-maxmin');
|
||||
layero.find('.layui-layer-min').show();
|
||||
type === 'page' && layero.find(doms[4]).show();
|
||||
ready.rescrollbar(index);
|
||||
|
||||
// 恢复页面滚动条弹层打开时的状态
|
||||
options.scrollbar ? ready.restScrollbar(index) : ready.setScrollbar(index);
|
||||
|
||||
// 恢复遮罩
|
||||
shadeo.show();
|
||||
|
@ -1144,7 +1151,7 @@ layer.full = function(index){
|
|||
ready.record(layero); // 记录当前尺寸、坐标
|
||||
|
||||
if(!doms.html.attr('layer-full')){
|
||||
doms.html.css('overflow','hidden').attr('layer-full', index);
|
||||
ready.setScrollbar(index);
|
||||
}
|
||||
|
||||
setTimeout(function(){
|
||||
|
@ -1168,10 +1175,10 @@ layer.title = function(name, index){
|
|||
// 关闭 layer 总方法
|
||||
layer.close = function(index, callback){
|
||||
var layero = function(){
|
||||
var closest = $('.'+ doms[0]).find('#'+ index).closest('.'+ doms[0]);
|
||||
var closest = $('.'+ doms[0]).children('#'+ index).closest('.'+ doms[0]);
|
||||
return closest[0] ? (
|
||||
index = closest.attr('times')
|
||||
,closest
|
||||
index = closest.attr('times'),
|
||||
closest
|
||||
) : $('#'+ doms[0] + index)
|
||||
}();
|
||||
var type = layero.attr('type');
|
||||
|
@ -1243,7 +1250,7 @@ layer.close = function(index, callback){
|
|||
}
|
||||
|
||||
layer.ie == 6 && ready.reselect();
|
||||
ready.rescrollbar(index);
|
||||
ready.restScrollbar(index);
|
||||
|
||||
// 记住被关闭层的最小化堆叠坐标
|
||||
if(typeof layero.attr('minLeft') === 'string'){
|
||||
|
|
|
@ -2559,8 +2559,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
|
||||
var row = $.extend({
|
||||
title: th.text()
|
||||
,colspan: parseInt(th.attr('colspan')) || 0 //列单元格
|
||||
,rowspan: parseInt(th.attr('rowspan')) || 0 //行单元格
|
||||
,colspan: parseInt(th.attr('colspan')) || 1 //列单元格
|
||||
,rowspan: parseInt(th.attr('rowspan')) || 1 //行单元格
|
||||
}, itemData);
|
||||
|
||||
options.cols[i].push(row);
|
||||
|
|
|
@ -296,10 +296,12 @@ layui.define('form', function(exports){
|
|||
elem.removeClass(ELEM_SPREAD);
|
||||
packCont.slideUp(200);
|
||||
iconClick.removeClass(ICON_SUB).addClass(ICON_ADD);
|
||||
that.updateFieldValue(item, 'spread', false);
|
||||
}else{
|
||||
elem.addClass(ELEM_SPREAD);
|
||||
packCont.slideDown(200);
|
||||
iconClick.addClass(ICON_SUB).removeClass(ICON_ADD);
|
||||
that.updateFieldValue(item, 'spread', true);
|
||||
|
||||
// 是否手风琴
|
||||
if(options.accordion){
|
||||
|
@ -328,7 +330,7 @@ layui.define('form', function(exports){
|
|||
|
||||
// 获取选中状态
|
||||
if(elemCheckbox[0]){
|
||||
item['checked'] = elemCheckbox.prop('checked');
|
||||
that.updateFieldValue(item, 'checked', elemCheckbox.prop('checked'));
|
||||
}
|
||||
|
||||
// 点击产生的回调
|
||||
|
@ -339,6 +341,11 @@ layui.define('form', function(exports){
|
|||
});
|
||||
});
|
||||
};
|
||||
|
||||
// 更新数据源 checked,spread 字段值
|
||||
Class.prototype.updateFieldValue = function(obj, field, value){
|
||||
if(field in obj) obj[field] = value;
|
||||
};
|
||||
|
||||
// 计算复选框选中状态
|
||||
Class.prototype.setCheckbox = function(elem, item, elemCheckbox){
|
||||
|
@ -353,8 +360,9 @@ layui.define('form', function(exports){
|
|||
var elemCheckboxs = elem.find('.'+ ELEM_PACK).find('input[same="layuiTreeCheck"]');
|
||||
elemCheckboxs.each(function(index){
|
||||
if(this.disabled) return; // 不可点击则跳过
|
||||
if(item.children[index]) item.children[index]['checked'] = checked;
|
||||
this.checked = checked;
|
||||
var children = item.children[index];
|
||||
if(children) that.updateFieldValue(children, 'checked', checked);
|
||||
that.updateFieldValue(this, 'checked', checked);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -410,7 +418,7 @@ layui.define('form', function(exports){
|
|||
if(elemCheckbox.prop('disabled')) return;
|
||||
|
||||
that.setCheckbox(elem, item, elemCheckbox);
|
||||
item.checked = checked;
|
||||
that.updateFieldValue(item, 'checked', checked);
|
||||
|
||||
// 复选框点击产生的回调
|
||||
options.oncheck && options.oncheck({
|
||||
|
@ -755,7 +763,8 @@ layui.define('form', function(exports){
|
|||
layui.each(data, function(index, item){
|
||||
layui.each(checkId, function(index2, item2){
|
||||
if(item.id == item2){
|
||||
item['checked'] = true;
|
||||
that.updateFieldValue(item, 'checked', true);
|
||||
|
||||
var cloneItem = $.extend({}, item);
|
||||
delete cloneItem.children;
|
||||
|
||||
|
|
|
@ -203,6 +203,10 @@ layui.define(['table'], function (exports) {
|
|||
Class.prototype.init = function () {
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
var cascade = options.tree.data.cascade;
|
||||
if (cascade !== 'parent' && cascade !== 'children') {
|
||||
options.tree.data.cascade = 'all'; // 超出范围的都重置为全联动
|
||||
}
|
||||
|
||||
// 先初始一个空的表格以便拿到对应的表格实例信息
|
||||
var tableIns = table.render($.extend({}, options, {
|
||||
|
@ -243,7 +247,8 @@ layui.define(['table'], function (exports) {
|
|||
},
|
||||
data: {
|
||||
isSimpleData: false, // 是否简单数据模式
|
||||
rootPid: null // 根节点的父 ID 值
|
||||
rootPid: null, // 根节点的父 ID 值
|
||||
cascade: 'all' // 级联方式 默认全部级联:all 可选 级联父 parent 级联子 children
|
||||
},
|
||||
async: {
|
||||
enable: false, // 是否开启异步加载模式,只有开启的时候其他参数才起作用
|
||||
|
@ -321,7 +326,6 @@ layui.define(['table'], function (exports) {
|
|||
layui.each(tableData, function (i1, item1) {
|
||||
var dataIndex = (parentIndex ? parentIndex + '-' : '') + i1;
|
||||
var dataNew = $.extend({}, item1);
|
||||
dataNew[childrenKey] = null;
|
||||
dataNew[pIdKey] = item1[pIdKey] || parentId;
|
||||
flat.push(dataNew);
|
||||
flat = flat.concat(that.treeToFlat(item1[childrenKey], item1[customName.id], dataIndex));
|
||||
|
@ -1085,7 +1089,7 @@ layui.define(['table'], function (exports) {
|
|||
return treeTable.reload.apply(null, args);
|
||||
};
|
||||
|
||||
var updateStatus = function (data, statusObj, childrenKey) {
|
||||
var updateStatus = function (data, statusObj, childrenKey, notCascade) {
|
||||
var dataUpdated = [];
|
||||
layui.each(data, function (i1, item1) {
|
||||
if (layui.type(statusObj) === 'function') {
|
||||
|
@ -1094,18 +1098,18 @@ layui.define(['table'], function (exports) {
|
|||
$.extend(item1, statusObj);
|
||||
}
|
||||
dataUpdated.push($.extend({}, item1));
|
||||
dataUpdated = dataUpdated.concat(updateStatus(item1[childrenKey], statusObj, childrenKey));
|
||||
notCascade || (dataUpdated = dataUpdated.concat(updateStatus(item1[childrenKey], statusObj, childrenKey, notCascade)));
|
||||
});
|
||||
return dataUpdated;
|
||||
}
|
||||
|
||||
Class.prototype.updateStatus = function (data, statusObj) {
|
||||
Class.prototype.updateStatus = function (data, statusObj, notCascade) {
|
||||
var that = this;
|
||||
var options = that.getOptions();
|
||||
var treeOptions = options.tree;
|
||||
data = data || table.cache[options.id];
|
||||
|
||||
return updateStatus(data, statusObj, treeOptions.customName.children);
|
||||
return updateStatus(data, statusObj, treeOptions.customName.children, notCascade);
|
||||
}
|
||||
|
||||
Class.prototype.getTableData = function () {
|
||||
|
@ -1387,6 +1391,8 @@ layui.define(['table'], function (exports) {
|
|||
treeTable.checkStatus = function (id, includeHalfCheck) {
|
||||
var that = getThisTable(id);
|
||||
if (!that) return;
|
||||
var options = that.getOptions();
|
||||
var treeOptions = options.tree;
|
||||
var checkName = table.config.checkName;
|
||||
|
||||
// 需要区分单双选
|
||||
|
@ -1396,7 +1402,7 @@ layui.define(['table'], function (exports) {
|
|||
});
|
||||
|
||||
var isAll = true;
|
||||
layui.each(table.cache[id], function (i1, item1) {
|
||||
layui.each(treeOptions.data.cascade === 'all' ? table.cache[id] : treeTable.getData(id, true), function (i1, item1) {
|
||||
if (!item1[checkName]) {
|
||||
isAll = false;
|
||||
return true;
|
||||
|
@ -1498,6 +1504,24 @@ layui.define(['table'], function (exports) {
|
|||
}
|
||||
})
|
||||
|
||||
// 设置或取消行选中样式
|
||||
Class.prototype.setRowCheckedClass = function(tr, checked){
|
||||
var that = this;
|
||||
var options = that.getOptions();
|
||||
|
||||
var index = tr.data('index');
|
||||
var tableViewElem = options.elem.next();
|
||||
|
||||
tr[checked ? 'addClass' : 'removeClass'](ELEM_CHECKED); // 主体行
|
||||
|
||||
// 右侧固定行
|
||||
tr.each(function(){
|
||||
var index = $(this).data('index');
|
||||
var trFixedR = tableViewElem.find('.layui-table-fixed-r tbody tr[data-index="'+ index +'"]');
|
||||
trFixedR[checked ? 'addClass' : 'removeClass'](ELEM_CHECKED);
|
||||
});
|
||||
};
|
||||
|
||||
// 更新表格的复选框状态
|
||||
Class.prototype.updateCheckStatus = function (dataP, checked) {
|
||||
var that = this;
|
||||
|
@ -1508,15 +1532,18 @@ layui.define(['table'], function (exports) {
|
|||
|
||||
var checkName = table.config.checkName;
|
||||
|
||||
var cascade = treeOptions.data.cascade;
|
||||
var isCascadeParent = cascade === 'all' || cascade === 'parent';
|
||||
|
||||
// 如有必要更新父节点们的状态
|
||||
if (dataP) {
|
||||
if (isCascadeParent && dataP) {
|
||||
var trsP = that.updateParentCheckStatus(dataP, layui.type(checked) === 'boolean' ? checked : null);
|
||||
layui.each(trsP, function (indexP, itemP) {
|
||||
var checkboxElem = tableView.find('tr[lay-data-index="' + itemP[LAY_DATA_INDEX] + '"] input[name="layTableCheckbox"]:not(:disabled)');
|
||||
var checked = itemP[checkName];
|
||||
|
||||
// 标记父节点行背景色
|
||||
checkboxElem.closest('tr')[checked ? 'addClass' : 'removeClass'](ELEM_CHECKED);
|
||||
// 标记父节点行背景色
|
||||
that.setRowCheckedClass(checkboxElem.closest('tr'), checked);
|
||||
|
||||
// 设置原始复选框 checked 属性值并渲染
|
||||
form.render(checkboxElem.prop({
|
||||
|
@ -1529,13 +1556,16 @@ layui.define(['table'], function (exports) {
|
|||
// 更新全选的状态
|
||||
var isAll = true;
|
||||
var isIndeterminate = false;
|
||||
layui.each(table.cache[tableId], function (i1, item1) {
|
||||
layui.each(treeOptions.data.cascade === 'all' ? table.cache[tableId] : treeTable.getData(tableId, true), function (i1, item1) {
|
||||
if (item1[checkName] || item1[LAY_CHECKBOX_HALF]) {
|
||||
isIndeterminate = true;
|
||||
}
|
||||
if (!item1[checkName]) {
|
||||
isAll = false;
|
||||
}
|
||||
if (isIndeterminate && !isAll) {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
isIndeterminate = isIndeterminate && !isAll;
|
||||
form.render(tableView.find('input[name="layTableCheckbox"][lay-filter="layTableAllChoose"]').prop({
|
||||
|
@ -1601,6 +1631,7 @@ layui.define(['table'], function (exports) {
|
|||
var checkNode = function (trElem, checked, callbackFlag) {
|
||||
var that = this;
|
||||
var options = that.getOptions();
|
||||
var treeOptions = options.tree;
|
||||
var tableId = options.id;
|
||||
var tableView = options.elem.next();
|
||||
var inputElem = (trElem.length ? trElem : tableView).find('.laytable-cell-radio, .laytable-cell-checkbox').children('input').last();
|
||||
|
@ -1649,20 +1680,22 @@ layui.define(['table'], function (exports) {
|
|||
if (d[checkName]) {
|
||||
var radioElem = tableView.find('tr[lay-data-index="' + d[LAY_DATA_INDEX] + '"] input[type="radio"][lay-type="layTableRadio"]');
|
||||
d[checkName] = false;
|
||||
radioElem.closest('tr').removeClass(ELEM_CHECKED); // 取消当前选中行背景色
|
||||
|
||||
// 取消当前选中行背景色
|
||||
that.setRowCheckedClass(radioElem.closest('tr'), false);
|
||||
form.render(radioElem.prop('checked', false));
|
||||
}
|
||||
}); // 取消其他的选中状态
|
||||
trData[checkName] = checked;
|
||||
trElem[checked ? 'addClass' : 'removeClass'](ELEM_CHECKED); // 标记当前选中行背景色
|
||||
trElem.siblings().removeClass(ELEM_CHECKED); // 取消其他行背景色
|
||||
|
||||
that.setRowCheckedClass(trElem, checked); // 标记当前选中行背景色
|
||||
that.setRowCheckedClass(trElem.siblings(), false); // 取消其他行背景色
|
||||
|
||||
form.render(trElem.find('input[type="radio"][lay-type="layTableRadio"]').prop('checked', checked));
|
||||
} else {
|
||||
var isParentKey = options.tree.customName.isParent;
|
||||
// 切换只能用到单条,全选到这一步的时候应该是一个确定的状态
|
||||
checked = layui.type(checked) === 'boolean' ? checked : !trData[checkName]; // 状态切换,如果遇到不可操作的节点待处理 todo
|
||||
// 全选或者是一个父节点,将子节点的状态同步为当前节点的状态
|
||||
// if (!trData || trData[isParentKey]) {
|
||||
// 处理不可操作的信息
|
||||
var checkedStatusFn = function (d) {
|
||||
if (!d[table.config.disabledName]) { // 节点不可操作的不处理
|
||||
|
@ -1671,14 +1704,16 @@ layui.define(['table'], function (exports) {
|
|||
}
|
||||
}
|
||||
|
||||
var trs = that.updateStatus(trData ? [trData] : table.cache[tableId], checkedStatusFn);
|
||||
var trs = that.updateStatus(trData ? [trData] : table.cache[tableId], checkedStatusFn, trData && treeOptions.data.cascade === 'parent');
|
||||
var checkboxElem = tableView.find(trs.map(function (value) {
|
||||
return 'tr[lay-data-index="' + value[LAY_DATA_INDEX] + '"] input[name="layTableCheckbox"]:not(:disabled)';
|
||||
}).join(','));
|
||||
checkboxElem.closest('tr')[checked ? 'addClass' : 'removeClass'](ELEM_CHECKED); // 标记当前选中行背景色
|
||||
|
||||
that.setRowCheckedClass(checkboxElem.closest('tr'), checked); // 标记当前选中行背景色
|
||||
form.render(checkboxElem.prop({checked: checked, indeterminate: false}));
|
||||
// }
|
||||
|
||||
var trDataP;
|
||||
|
||||
// 更新父节点以及更上层节点的状态
|
||||
if (trData && trData[LAY_PARENT_INDEX]) {
|
||||
// 找到父节点,然后判断父节点的子节点是否全部选中
|
||||
|
@ -1855,7 +1890,7 @@ layui.define(['table'], function (exports) {
|
|||
|
||||
// 重载
|
||||
treeTable.reload = function (id, options, deep, type) {
|
||||
deep = deep !== false; // 默认采用深拷贝
|
||||
// deep = deep !== false; // 默认采用深拷贝
|
||||
var that = getThisTable(id);
|
||||
if (!that) return;
|
||||
that.reload(options, deep, type);
|
||||
|
|
|
@ -588,8 +588,11 @@ layui.define(['lay','layer'], function(exports){
|
|||
that.elemFile.off('upload.change').on('upload.change', function(){
|
||||
var files = this.files || [];
|
||||
|
||||
if(files.length === 0) return;
|
||||
|
||||
extendAttrs.call(this);
|
||||
setChooseFile(files);
|
||||
|
||||
options.auto ? that.upload() : setChooseText(files); // 是否自动触发上传
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue