组用户功能修订
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 186 KiB |
|
After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="UTF-8"><link rel="icon" type="image/svg+xml" href="../../favicon.ico"><meta name="viewport" content="width=device-width,initial-scale=1"><title>铃铛学习中心</title><link rel="stylesheet" href="./libs/ztree/zTreeStyle.css"><script src="./libs/jquery.min.js"></script><script src="./libs/lodash.min.js"></script><script src="./libs/ztree/jquery.ztree.all.min.js"></script><script src="https://base.bestsch.com/BschHome/base/js/bschload.min.js?v=2025011001"></script><script src="./js/userType.js?type=teacher"></script><script type="module" crossorigin src="./static/js/main-CNRNr9ff.js"></script><link rel="stylesheet" crossorigin href="./static/css/main-BEI6wsu_.css"></head><body><div id="app"></div></body></html>
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 7.3 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 933 B |
|
After Width: | Height: | Size: 5.4 KiB |
@@ -0,0 +1,628 @@
|
||||
/*
|
||||
* JQuery zTree excheck v3.5.28
|
||||
* http://treejs.cn/
|
||||
*
|
||||
* Copyright (c) 2010 Hunter.z
|
||||
*
|
||||
* Licensed same as jquery - MIT License
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* email: hunter.z@263.net
|
||||
* Date: 2017-01-20
|
||||
*/
|
||||
(function($){
|
||||
//default consts of excheck
|
||||
var _consts = {
|
||||
event: {
|
||||
CHECK: "ztree_check"
|
||||
},
|
||||
id: {
|
||||
CHECK: "_check"
|
||||
},
|
||||
checkbox: {
|
||||
STYLE: "checkbox",
|
||||
DEFAULT: "chk",
|
||||
DISABLED: "disable",
|
||||
FALSE: "false",
|
||||
TRUE: "true",
|
||||
FULL: "full",
|
||||
PART: "part",
|
||||
FOCUS: "focus"
|
||||
},
|
||||
radio: {
|
||||
STYLE: "radio",
|
||||
TYPE_ALL: "all",
|
||||
TYPE_LEVEL: "level"
|
||||
}
|
||||
},
|
||||
//default setting of excheck
|
||||
_setting = {
|
||||
check: {
|
||||
enable: false,
|
||||
autoCheckTrigger: false,
|
||||
chkStyle: _consts.checkbox.STYLE,
|
||||
nocheckInherit: false,
|
||||
chkDisabledInherit: false,
|
||||
radioType: _consts.radio.TYPE_LEVEL,
|
||||
chkboxType: {
|
||||
"Y": "ps",
|
||||
"N": "ps"
|
||||
}
|
||||
},
|
||||
data: {
|
||||
key: {
|
||||
checked: "checked"
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
beforeCheck:null,
|
||||
onCheck:null
|
||||
}
|
||||
},
|
||||
//default root of excheck
|
||||
_initRoot = function (setting) {
|
||||
var r = data.getRoot(setting);
|
||||
r.radioCheckedList = [];
|
||||
},
|
||||
//default cache of excheck
|
||||
_initCache = function(treeId) {},
|
||||
//default bind event of excheck
|
||||
_bindEvent = function(setting) {
|
||||
var o = setting.treeObj,
|
||||
c = consts.event;
|
||||
o.bind(c.CHECK, function (event, srcEvent, treeId, node) {
|
||||
event.srcEvent = srcEvent;
|
||||
tools.apply(setting.callback.onCheck, [event, treeId, node]);
|
||||
});
|
||||
},
|
||||
_unbindEvent = function(setting) {
|
||||
var o = setting.treeObj,
|
||||
c = consts.event;
|
||||
o.unbind(c.CHECK);
|
||||
},
|
||||
//default event proxy of excheck
|
||||
_eventProxy = function(e) {
|
||||
var target = e.target,
|
||||
setting = data.getSetting(e.data.treeId),
|
||||
tId = "", node = null,
|
||||
nodeEventType = "", treeEventType = "",
|
||||
nodeEventCallback = null, treeEventCallback = null;
|
||||
|
||||
if (tools.eqs(e.type, "mouseover")) {
|
||||
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
|
||||
tId = tools.getNodeMainDom(target).id;
|
||||
nodeEventType = "mouseoverCheck";
|
||||
}
|
||||
} else if (tools.eqs(e.type, "mouseout")) {
|
||||
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
|
||||
tId = tools.getNodeMainDom(target).id;
|
||||
nodeEventType = "mouseoutCheck";
|
||||
}
|
||||
} else if (tools.eqs(e.type, "click")) {
|
||||
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
|
||||
tId = tools.getNodeMainDom(target).id;
|
||||
nodeEventType = "checkNode";
|
||||
}
|
||||
}
|
||||
if (tId.length>0) {
|
||||
node = data.getNodeCache(setting, tId);
|
||||
switch (nodeEventType) {
|
||||
case "checkNode" :
|
||||
nodeEventCallback = _handler.onCheckNode;
|
||||
break;
|
||||
case "mouseoverCheck" :
|
||||
nodeEventCallback = _handler.onMouseoverCheck;
|
||||
break;
|
||||
case "mouseoutCheck" :
|
||||
nodeEventCallback = _handler.onMouseoutCheck;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var proxyResult = {
|
||||
stop: nodeEventType === "checkNode",
|
||||
node: node,
|
||||
nodeEventType: nodeEventType,
|
||||
nodeEventCallback: nodeEventCallback,
|
||||
treeEventType: treeEventType,
|
||||
treeEventCallback: treeEventCallback
|
||||
};
|
||||
return proxyResult
|
||||
},
|
||||
//default init node of excheck
|
||||
_initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) {
|
||||
if (!n) return;
|
||||
var checkedKey = setting.data.key.checked;
|
||||
if (typeof n[checkedKey] == "string") n[checkedKey] = tools.eqs(n[checkedKey], "true");
|
||||
n[checkedKey] = !!n[checkedKey];
|
||||
n.checkedOld = n[checkedKey];
|
||||
if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true");
|
||||
n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck);
|
||||
if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true");
|
||||
n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled);
|
||||
if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true");
|
||||
n.halfCheck = !!n.halfCheck;
|
||||
n.check_Child_State = -1;
|
||||
n.check_Focus = false;
|
||||
n.getCheckStatus = function() {return data.getCheckStatus(setting, n);};
|
||||
|
||||
if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && n[checkedKey] ) {
|
||||
var r = data.getRoot(setting);
|
||||
r.radioCheckedList.push(n);
|
||||
}
|
||||
},
|
||||
//add dom for check
|
||||
_beforeA = function(setting, node, html) {
|
||||
var checkedKey = setting.data.key.checked;
|
||||
if (setting.check.enable) {
|
||||
data.makeChkFlag(setting, node);
|
||||
html.push("<span ID='", node.tId, consts.id.CHECK, "' class='", view.makeChkClass(setting, node), "' treeNode", consts.id.CHECK, (node.nocheck === true?" style='display:none;'":""),"></span>");
|
||||
}
|
||||
},
|
||||
//update zTreeObj, add method of check
|
||||
_zTreeTools = function(setting, zTreeTools) {
|
||||
zTreeTools.checkNode = function(node, checked, checkTypeFlag, callbackFlag) {
|
||||
var checkedKey = this.setting.data.key.checked;
|
||||
if (node.chkDisabled === true) return;
|
||||
if (checked !== true && checked !== false) {
|
||||
checked = !node[checkedKey];
|
||||
}
|
||||
callbackFlag = !!callbackFlag;
|
||||
|
||||
if (node[checkedKey] === checked && !checkTypeFlag) {
|
||||
return;
|
||||
} else if (callbackFlag && tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false) {
|
||||
return;
|
||||
}
|
||||
if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) {
|
||||
node[checkedKey] = checked;
|
||||
var checkObj = $$(node, consts.id.CHECK, this.setting);
|
||||
if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node);
|
||||
view.setChkClass(this.setting, checkObj, node);
|
||||
view.repairParentChkClassWithSelf(this.setting, node);
|
||||
if (callbackFlag) {
|
||||
this.setting.treeObj.trigger(consts.event.CHECK, [null, this.setting.treeId, node]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zTreeTools.checkAllNodes = function(checked) {
|
||||
view.repairAllChk(this.setting, !!checked);
|
||||
}
|
||||
|
||||
zTreeTools.getCheckedNodes = function(checked) {
|
||||
var childKey = this.setting.data.key.children;
|
||||
checked = (checked !== false);
|
||||
return data.getTreeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey], checked);
|
||||
}
|
||||
|
||||
zTreeTools.getChangeCheckedNodes = function() {
|
||||
var childKey = this.setting.data.key.children;
|
||||
return data.getTreeChangeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey]);
|
||||
}
|
||||
|
||||
zTreeTools.setChkDisabled = function(node, disabled, inheritParent, inheritChildren) {
|
||||
disabled = !!disabled;
|
||||
inheritParent = !!inheritParent;
|
||||
inheritChildren = !!inheritChildren;
|
||||
view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren);
|
||||
view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent);
|
||||
}
|
||||
|
||||
var _updateNode = zTreeTools.updateNode;
|
||||
zTreeTools.updateNode = function(node, checkTypeFlag) {
|
||||
if (_updateNode) _updateNode.apply(zTreeTools, arguments);
|
||||
if (!node || !this.setting.check.enable) return;
|
||||
var nObj = $$(node, this.setting);
|
||||
if (nObj.get(0) && tools.uCanDo(this.setting)) {
|
||||
var checkObj = $$(node, consts.id.CHECK, this.setting);
|
||||
if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node);
|
||||
view.setChkClass(this.setting, checkObj, node);
|
||||
view.repairParentChkClassWithSelf(this.setting, node);
|
||||
}
|
||||
}
|
||||
},
|
||||
//method of operate data
|
||||
_data = {
|
||||
getRadioCheckedList: function(setting) {
|
||||
var checkedList = data.getRoot(setting).radioCheckedList;
|
||||
for (var i=0, j=checkedList.length; i<j; i++) {
|
||||
if(!data.getNodeCache(setting, checkedList[i].tId)) {
|
||||
checkedList.splice(i, 1);
|
||||
i--; j--;
|
||||
}
|
||||
}
|
||||
return checkedList;
|
||||
},
|
||||
getCheckStatus: function(setting, node) {
|
||||
if (!setting.check.enable || node.nocheck || node.chkDisabled) return null;
|
||||
var checkedKey = setting.data.key.checked,
|
||||
r = {
|
||||
checked: node[checkedKey],
|
||||
half: node.halfCheck ? node.halfCheck : (setting.check.chkStyle == consts.radio.STYLE ? (node.check_Child_State === 2) : (node[checkedKey] ? (node.check_Child_State > -1 && node.check_Child_State < 2) : (node.check_Child_State > 0)))
|
||||
};
|
||||
return r;
|
||||
},
|
||||
getTreeCheckedNodes: function(setting, nodes, checked, results) {
|
||||
if (!nodes) return [];
|
||||
var childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked,
|
||||
onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL);
|
||||
results = !results ? [] : results;
|
||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||
if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) {
|
||||
results.push(nodes[i]);
|
||||
if(onlyOne) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
data.getTreeCheckedNodes(setting, nodes[i][childKey], checked, results);
|
||||
if(onlyOne && results.length > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
},
|
||||
getTreeChangeCheckedNodes: function(setting, nodes, results) {
|
||||
if (!nodes) return [];
|
||||
var childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked;
|
||||
results = !results ? [] : results;
|
||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||
if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] != nodes[i].checkedOld) {
|
||||
results.push(nodes[i]);
|
||||
}
|
||||
data.getTreeChangeCheckedNodes(setting, nodes[i][childKey], results);
|
||||
}
|
||||
return results;
|
||||
},
|
||||
makeChkFlag: function(setting, node) {
|
||||
if (!node) return;
|
||||
var childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked,
|
||||
chkFlag = -1;
|
||||
if (node[childKey]) {
|
||||
for (var i = 0, l = node[childKey].length; i < l; i++) {
|
||||
var cNode = node[childKey][i];
|
||||
var tmp = -1;
|
||||
if (setting.check.chkStyle == consts.radio.STYLE) {
|
||||
if (cNode.nocheck === true || cNode.chkDisabled === true) {
|
||||
tmp = cNode.check_Child_State;
|
||||
} else if (cNode.halfCheck === true) {
|
||||
tmp = 2;
|
||||
} else if (cNode[checkedKey]) {
|
||||
tmp = 2;
|
||||
} else {
|
||||
tmp = cNode.check_Child_State > 0 ? 2:0;
|
||||
}
|
||||
if (tmp == 2) {
|
||||
chkFlag = 2; break;
|
||||
} else if (tmp == 0){
|
||||
chkFlag = 0;
|
||||
}
|
||||
} else if (setting.check.chkStyle == consts.checkbox.STYLE) {
|
||||
if (cNode.nocheck === true || cNode.chkDisabled === true) {
|
||||
tmp = cNode.check_Child_State;
|
||||
} else if (cNode.halfCheck === true) {
|
||||
tmp = 1;
|
||||
} else if (cNode[checkedKey] ) {
|
||||
tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1;
|
||||
} else {
|
||||
tmp = (cNode.check_Child_State > 0) ? 1 : 0;
|
||||
}
|
||||
if (tmp === 1) {
|
||||
chkFlag = 1; break;
|
||||
} else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) {
|
||||
chkFlag = 1; break;
|
||||
} else if (chkFlag === 2 && tmp > -1 && tmp < 2) {
|
||||
chkFlag = 1; break;
|
||||
} else if (tmp > -1) {
|
||||
chkFlag = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
node.check_Child_State = chkFlag;
|
||||
}
|
||||
},
|
||||
//method of event proxy
|
||||
_event = {
|
||||
|
||||
},
|
||||
//method of event handler
|
||||
_handler = {
|
||||
onCheckNode: function (event, node) {
|
||||
if (node.chkDisabled === true) return false;
|
||||
var setting = data.getSetting(event.data.treeId),
|
||||
checkedKey = setting.data.key.checked;
|
||||
if (tools.apply(setting.callback.beforeCheck, [setting.treeId, node], true) == false) return true;
|
||||
node[checkedKey] = !node[checkedKey];
|
||||
view.checkNodeRelation(setting, node);
|
||||
var checkObj = $$(node, consts.id.CHECK, setting);
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
view.repairParentChkClassWithSelf(setting, node);
|
||||
setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]);
|
||||
return true;
|
||||
},
|
||||
onMouseoverCheck: function(event, node) {
|
||||
if (node.chkDisabled === true) return false;
|
||||
var setting = data.getSetting(event.data.treeId),
|
||||
checkObj = $$(node, consts.id.CHECK, setting);
|
||||
node.check_Focus = true;
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
return true;
|
||||
},
|
||||
onMouseoutCheck: function(event, node) {
|
||||
if (node.chkDisabled === true) return false;
|
||||
var setting = data.getSetting(event.data.treeId),
|
||||
checkObj = $$(node, consts.id.CHECK, setting);
|
||||
node.check_Focus = false;
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
//method of tools for zTree
|
||||
_tools = {
|
||||
|
||||
},
|
||||
//method of operate ztree dom
|
||||
_view = {
|
||||
checkNodeRelation: function(setting, node) {
|
||||
var pNode, i, l,
|
||||
childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked,
|
||||
r = consts.radio;
|
||||
if (setting.check.chkStyle == r.STYLE) {
|
||||
var checkedList = data.getRadioCheckedList(setting);
|
||||
if (node[checkedKey]) {
|
||||
if (setting.check.radioType == r.TYPE_ALL) {
|
||||
for (i = checkedList.length-1; i >= 0; i--) {
|
||||
pNode = checkedList[i];
|
||||
if (pNode[checkedKey] && pNode != node) {
|
||||
pNode[checkedKey] = false;
|
||||
checkedList.splice(i, 1);
|
||||
|
||||
view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode);
|
||||
if (pNode.parentTId != node.parentTId) {
|
||||
view.repairParentChkClassWithSelf(setting, pNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
checkedList.push(node);
|
||||
} else {
|
||||
var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting);
|
||||
for (i = 0, l = parentNode[childKey].length; i < l; i++) {
|
||||
pNode = parentNode[childKey][i];
|
||||
if (pNode[checkedKey] && pNode != node) {
|
||||
pNode[checkedKey] = false;
|
||||
view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (setting.check.radioType == r.TYPE_ALL) {
|
||||
for (i = 0, l = checkedList.length; i < l; i++) {
|
||||
if (node == checkedList[i]) {
|
||||
checkedList.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.Y.indexOf("s") > -1)) {
|
||||
view.setSonNodeCheckBox(setting, node, true);
|
||||
}
|
||||
if (!node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.N.indexOf("s") > -1)) {
|
||||
view.setSonNodeCheckBox(setting, node, false);
|
||||
}
|
||||
if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) {
|
||||
view.setParentNodeCheckBox(setting, node, true);
|
||||
}
|
||||
if (!node[checkedKey] && setting.check.chkboxType.N.indexOf("p") > -1) {
|
||||
view.setParentNodeCheckBox(setting, node, false);
|
||||
}
|
||||
}
|
||||
},
|
||||
makeChkClass: function(setting, node) {
|
||||
var checkedKey = setting.data.key.checked,
|
||||
c = consts.checkbox, r = consts.radio,
|
||||
fullStyle = "";
|
||||
if (node.chkDisabled === true) {
|
||||
fullStyle = c.DISABLED;
|
||||
} else if (node.halfCheck) {
|
||||
fullStyle = c.PART;
|
||||
} else if (setting.check.chkStyle == r.STYLE) {
|
||||
fullStyle = (node.check_Child_State < 1)? c.FULL:c.PART;
|
||||
} else {
|
||||
fullStyle = node[checkedKey] ? ((node.check_Child_State === 2 || node.check_Child_State === -1) ? c.FULL:c.PART) : ((node.check_Child_State < 1)? c.FULL:c.PART);
|
||||
}
|
||||
var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle;
|
||||
chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName;
|
||||
return consts.className.BUTTON + " " + c.DEFAULT + " " + chkName;
|
||||
},
|
||||
repairAllChk: function(setting, checked) {
|
||||
if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) {
|
||||
var checkedKey = setting.data.key.checked,
|
||||
childKey = setting.data.key.children,
|
||||
root = data.getRoot(setting);
|
||||
for (var i = 0, l = root[childKey].length; i<l ; i++) {
|
||||
var node = root[childKey][i];
|
||||
if (node.nocheck !== true && node.chkDisabled !== true) {
|
||||
node[checkedKey] = checked;
|
||||
}
|
||||
view.setSonNodeCheckBox(setting, node, checked);
|
||||
}
|
||||
}
|
||||
},
|
||||
repairChkClass: function(setting, node) {
|
||||
if (!node) return;
|
||||
data.makeChkFlag(setting, node);
|
||||
if (node.nocheck !== true) {
|
||||
var checkObj = $$(node, consts.id.CHECK, setting);
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
}
|
||||
},
|
||||
repairParentChkClass: function(setting, node) {
|
||||
if (!node || !node.parentTId) return;
|
||||
var pNode = node.getParentNode();
|
||||
view.repairChkClass(setting, pNode);
|
||||
view.repairParentChkClass(setting, pNode);
|
||||
},
|
||||
repairParentChkClassWithSelf: function(setting, node) {
|
||||
if (!node) return;
|
||||
var childKey = setting.data.key.children;
|
||||
if (node[childKey] && node[childKey].length > 0) {
|
||||
view.repairParentChkClass(setting, node[childKey][0]);
|
||||
} else {
|
||||
view.repairParentChkClass(setting, node);
|
||||
}
|
||||
},
|
||||
repairSonChkDisabled: function(setting, node, chkDisabled, inherit) {
|
||||
if (!node) return;
|
||||
var childKey = setting.data.key.children;
|
||||
if (node.chkDisabled != chkDisabled) {
|
||||
node.chkDisabled = chkDisabled;
|
||||
}
|
||||
view.repairChkClass(setting, node);
|
||||
if (node[childKey] && inherit) {
|
||||
for (var i = 0, l = node[childKey].length; i < l; i++) {
|
||||
var sNode = node[childKey][i];
|
||||
view.repairSonChkDisabled(setting, sNode, chkDisabled, inherit);
|
||||
}
|
||||
}
|
||||
},
|
||||
repairParentChkDisabled: function(setting, node, chkDisabled, inherit) {
|
||||
if (!node) return;
|
||||
if (node.chkDisabled != chkDisabled && inherit) {
|
||||
node.chkDisabled = chkDisabled;
|
||||
}
|
||||
view.repairChkClass(setting, node);
|
||||
view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit);
|
||||
},
|
||||
setChkClass: function(setting, obj, node) {
|
||||
if (!obj) return;
|
||||
if (node.nocheck === true) {
|
||||
obj.hide();
|
||||
} else {
|
||||
obj.show();
|
||||
}
|
||||
obj.attr('class', view.makeChkClass(setting, node));
|
||||
},
|
||||
setParentNodeCheckBox: function(setting, node, value, srcNode) {
|
||||
var childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked,
|
||||
checkObj = $$(node, consts.id.CHECK, setting);
|
||||
if (!srcNode) srcNode = node;
|
||||
data.makeChkFlag(setting, node);
|
||||
if (node.nocheck !== true && node.chkDisabled !== true) {
|
||||
node[checkedKey] = value;
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
if (setting.check.autoCheckTrigger && node != srcNode) {
|
||||
setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
|
||||
}
|
||||
}
|
||||
if (node.parentTId) {
|
||||
var pSign = true;
|
||||
if (!value) {
|
||||
var pNodes = node.getParentNode()[childKey];
|
||||
for (var i = 0, l = pNodes.length; i < l; i++) {
|
||||
if ((pNodes[i].nocheck !== true && pNodes[i].chkDisabled !== true && pNodes[i][checkedKey])
|
||||
|| ((pNodes[i].nocheck === true || pNodes[i].chkDisabled === true) && pNodes[i].check_Child_State > 0)) {
|
||||
pSign = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pSign) {
|
||||
view.setParentNodeCheckBox(setting, node.getParentNode(), value, srcNode);
|
||||
}
|
||||
}
|
||||
},
|
||||
setSonNodeCheckBox: function(setting, node, value, srcNode) {
|
||||
if (!node) return;
|
||||
var childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked,
|
||||
checkObj = $$(node, consts.id.CHECK, setting);
|
||||
if (!srcNode) srcNode = node;
|
||||
|
||||
var hasDisable = false;
|
||||
if (node[childKey]) {
|
||||
for (var i = 0, l = node[childKey].length; i < l; i++) {
|
||||
var sNode = node[childKey][i];
|
||||
view.setSonNodeCheckBox(setting, sNode, value, srcNode);
|
||||
if (sNode.chkDisabled === true) hasDisable = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (node != data.getRoot(setting) && node.chkDisabled !== true) {
|
||||
if (hasDisable && node.nocheck !== true) {
|
||||
data.makeChkFlag(setting, node);
|
||||
}
|
||||
if (node.nocheck !== true && node.chkDisabled !== true) {
|
||||
node[checkedKey] = value;
|
||||
if (!hasDisable) node.check_Child_State = (node[childKey] && node[childKey].length > 0) ? (value ? 2 : 0) : -1;
|
||||
} else {
|
||||
node.check_Child_State = -1;
|
||||
}
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
if (setting.check.autoCheckTrigger && node != srcNode && node.nocheck !== true && node.chkDisabled !== true) {
|
||||
setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
_z = {
|
||||
tools: _tools,
|
||||
view: _view,
|
||||
event: _event,
|
||||
data: _data
|
||||
};
|
||||
$.extend(true, $.fn.zTree.consts, _consts);
|
||||
$.extend(true, $.fn.zTree._z, _z);
|
||||
|
||||
var zt = $.fn.zTree,
|
||||
tools = zt._z.tools,
|
||||
consts = zt.consts,
|
||||
view = zt._z.view,
|
||||
data = zt._z.data,
|
||||
event = zt._z.event,
|
||||
$$ = tools.$;
|
||||
|
||||
data.exSetting(_setting);
|
||||
data.addInitBind(_bindEvent);
|
||||
data.addInitUnBind(_unbindEvent);
|
||||
data.addInitCache(_initCache);
|
||||
data.addInitNode(_initNode);
|
||||
data.addInitProxy(_eventProxy, true);
|
||||
data.addInitRoot(_initRoot);
|
||||
data.addBeforeA(_beforeA);
|
||||
data.addZTreeTools(_zTreeTools);
|
||||
|
||||
var _createNodes = view.createNodes;
|
||||
view.createNodes = function(setting, level, nodes, parentNode, index) {
|
||||
if (_createNodes) _createNodes.apply(view, arguments);
|
||||
if (!nodes) return;
|
||||
view.repairParentChkClassWithSelf(setting, parentNode);
|
||||
}
|
||||
var _removeNode = view.removeNode;
|
||||
view.removeNode = function(setting, node) {
|
||||
var parentNode = node.getParentNode();
|
||||
if (_removeNode) _removeNode.apply(view, arguments);
|
||||
if (!node || !parentNode) return;
|
||||
view.repairChkClass(setting, parentNode);
|
||||
view.repairParentChkClass(setting, parentNode);
|
||||
}
|
||||
|
||||
var _appendNodes = view.appendNodes;
|
||||
view.appendNodes = function(setting, level, nodes, parentNode, index, initFlag, openFlag) {
|
||||
var html = "";
|
||||
if (_appendNodes) {
|
||||
html = _appendNodes.apply(view, arguments);
|
||||
}
|
||||
if (parentNode) {
|
||||
data.makeChkFlag(setting, parentNode);
|
||||
}
|
||||
return html;
|
||||
}
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,378 @@
|
||||
/*-------------------------------------
|
||||
zTree Style
|
||||
|
||||
version: 3.4
|
||||
author: Hunter.z
|
||||
email: hunter.z@263.net
|
||||
website: http://code.google.com/p/jquerytree/
|
||||
|
||||
-------------------------------------*/
|
||||
.ztree * {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
font-family: Verdana, Arial, Helvetica, AppleGothic, sans-serif
|
||||
}
|
||||
|
||||
.ztree {
|
||||
margin: 0;
|
||||
padding: 5px;
|
||||
color: #333
|
||||
}
|
||||
|
||||
.ztree li {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
list-style: none;
|
||||
line-height: 17px;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
outline: 0
|
||||
}
|
||||
|
||||
.ztree li ul {
|
||||
margin: 0;
|
||||
padding: 0 0 0 18px
|
||||
}
|
||||
|
||||
.ztree li ul.line {
|
||||
background: url(./img/line_conn.png) 0 0 repeat-y;
|
||||
}
|
||||
|
||||
.ztree li a {
|
||||
padding-right: 3px;
|
||||
margin: 0;
|
||||
cursor: pointer;
|
||||
height: 21px;
|
||||
color: #333;
|
||||
background-color: transparent;
|
||||
text-decoration: none;
|
||||
vertical-align: top;
|
||||
display: inline-block
|
||||
}
|
||||
|
||||
.ztree li a:hover {
|
||||
text-decoration: underline
|
||||
}
|
||||
|
||||
.ztree li a.curSelectedNode {
|
||||
padding-top: 0px;
|
||||
background-color: #e5e5e5;
|
||||
color: black;
|
||||
height: 21px;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.ztree li a.curSelectedNode_Edit {
|
||||
padding-top: 0px;
|
||||
background-color: #e5e5e5;
|
||||
color: black;
|
||||
height: 21px;
|
||||
border: 1px #666 solid;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.ztree li a.tmpTargetNode_inner {
|
||||
padding-top: 0px;
|
||||
background-color: #aaa;
|
||||
color: white;
|
||||
height: 21px;
|
||||
border: 1px #666 solid;
|
||||
opacity: 0.8;
|
||||
filter: alpha(opacity=80)
|
||||
}
|
||||
|
||||
.ztree li a.tmpTargetNode_prev {}
|
||||
|
||||
.ztree li a.tmpTargetNode_next {}
|
||||
|
||||
.ztree li a input.rename {
|
||||
height: 14px;
|
||||
width: 80px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
border: 1px #585956 solid;
|
||||
*border: 0px
|
||||
}
|
||||
|
||||
.ztree li span {
|
||||
line-height: 21px;
|
||||
margin-right: 2px
|
||||
}
|
||||
|
||||
.ztree li span.button {
|
||||
line-height: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 21px;
|
||||
height: 21px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
border: 0 none;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
background-color: transparent;
|
||||
background-repeat: no-repeat;
|
||||
background-attachment: scroll;
|
||||
background-image: url("./img/bootstrap.png");
|
||||
}
|
||||
|
||||
.ztree li span.button.chk {
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
margin: 0 2px;
|
||||
cursor: auto
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_false_full {
|
||||
background-position: -5px -5px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_false_full_focus {
|
||||
background-position: -5px -26px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_false_part {
|
||||
background-position: -5px -48px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_false_part_focus {
|
||||
background-position: -5px -68px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_false_disable {
|
||||
background-position: -5px -89px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_true_full {
|
||||
background-position: -26px -5px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_true_full_focus {
|
||||
background-position: -26px -26px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_true_part {
|
||||
background-position: -26px -48px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_true_part_focus {
|
||||
background-position: -26px -68px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_true_disable {
|
||||
background-position: -26px -89px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_false_full {
|
||||
background-position: -47px -5px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_false_full_focus {
|
||||
background-position: -47px -26px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_false_part {
|
||||
background-position: -47px -47px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_false_part_focus {
|
||||
background-position: -47px -68px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_false_disable {
|
||||
background-position: -47px -89px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_true_full {
|
||||
background-position: -68px -5px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_true_full_focus {
|
||||
background-position: -68px -26px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_true_part {
|
||||
background-position: -68px -47px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_true_part_focus {
|
||||
background-position: -68px -68px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_true_disable {
|
||||
background-position: -68px -89px;
|
||||
}
|
||||
|
||||
.ztree li span.button.switch {
|
||||
width: 21px;
|
||||
height: 21px
|
||||
}
|
||||
|
||||
.ztree li span.button.root_open {
|
||||
background-position: -105px -63px
|
||||
}
|
||||
|
||||
.ztree li span.button.root_close {
|
||||
background-position: -126px -63px
|
||||
}
|
||||
|
||||
.ztree li span.button.roots_open {
|
||||
background-position: -105px 0;
|
||||
}
|
||||
|
||||
.ztree li span.button.roots_close {
|
||||
background-position: -126px 0;
|
||||
}
|
||||
|
||||
.ztree li span.button.center_open {
|
||||
background-position: -105px -21px;
|
||||
}
|
||||
|
||||
.ztree li span.button.center_close {
|
||||
background-position: -126px -21px;
|
||||
}
|
||||
|
||||
.ztree li span.button.bottom_open {
|
||||
background-position: -105px -42px;
|
||||
}
|
||||
|
||||
.ztree li span.button.bottom_close {
|
||||
background-position: -126px -42px;
|
||||
}
|
||||
|
||||
.ztree li span.button.noline_open {
|
||||
background-position: -105px -84px;
|
||||
}
|
||||
|
||||
.ztree li span.button.noline_close {
|
||||
background-position: -126px -84px;
|
||||
}
|
||||
|
||||
.ztree li span.button.root_docu {
|
||||
background-position: -105px -63px;
|
||||
}
|
||||
|
||||
.ztree li span.button.roots_docu {
|
||||
background-position: -84px 0;
|
||||
}
|
||||
|
||||
.ztree li span.button.center_docu {
|
||||
background-position: -84px -21px;
|
||||
}
|
||||
|
||||
.ztree li span.button.bottom_docu {
|
||||
background-position: -84px -42px;
|
||||
}
|
||||
|
||||
.ztree li span.button.noline_docu {
|
||||
background: none;
|
||||
}
|
||||
|
||||
.ztree li span.button.ico_open {
|
||||
margin-right: 2px;
|
||||
background-position: -147px -21px;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.ico_close {
|
||||
margin-right: 2px;
|
||||
margin-right: 2px;
|
||||
background-position: -147px 0;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.ico_docu {
|
||||
margin-right: 2px;
|
||||
background-position: -147px -43px;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.edit {
|
||||
margin-left: 2px;
|
||||
margin-right: -1px;
|
||||
background-position: -189px -21px;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.edit:hover {
|
||||
background-position: -168px -21px;
|
||||
}
|
||||
|
||||
.ztree li span.button.remove {
|
||||
margin-left: 2px;
|
||||
margin-right: -1px;
|
||||
background-position: -189px -42px;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.remove:hover {
|
||||
background-position: -168px -42px;
|
||||
}
|
||||
|
||||
.ztree li span.button.add {
|
||||
margin-left: 2px;
|
||||
margin-right: -1px;
|
||||
background-position: -189px 0;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.add:hover {
|
||||
background-position: -168px 0;
|
||||
}
|
||||
|
||||
ul.tmpTargetzTree {
|
||||
background-color: #FFE6B0;
|
||||
opacity: 0.8;
|
||||
filter: alpha(opacity=80)
|
||||
}
|
||||
|
||||
span.tmpzTreeMove_arrow {
|
||||
width: 16px;
|
||||
height: 21px;
|
||||
display: inline-block;
|
||||
padding: 0;
|
||||
margin: 2px 0 0 1px;
|
||||
border: 0 none;
|
||||
position: absolute;
|
||||
background-color: transparent;
|
||||
background-repeat: no-repeat;
|
||||
background-attachment: scroll;
|
||||
background-position: -168px -84px;
|
||||
background-image: url("./img/bootstrap.png");
|
||||
z-index: 10000;
|
||||
}
|
||||
|
||||
span.tmpzTreeMove_prev {
|
||||
background: red;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ul.ztree.zTreeDragUL {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
width: auto;
|
||||
height: auto;
|
||||
overflow: hidden;
|
||||
background-color: #cfcfcf;
|
||||
border: 1px #00B83F dotted;
|
||||
opacity: 0.8;
|
||||
filter: alpha(opacity=80)
|
||||
}
|
||||
|
||||
.ztreeMask {
|
||||
z-index: 10000;
|
||||
background-color: #cfcfcf;
|
||||
opacity: 0.0;
|
||||
filter: alpha(opacity=0);
|
||||
position: absolute
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
.ztree li span.button {background-image:url("./img/bootstrap3.png");}
|
||||
span.tmpzTreeMove_arrow {background-image:url("./img/bootstrap3.png");}
|
||||
|
||||
|
After Width: | Height: | Size: 542 KiB |
|
After Width: | Height: | Size: 186 KiB |
@@ -0,0 +1 @@
|
||||
import"./main-CNRNr9ff.js";
|
||||
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 186 KiB |
|
After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="UTF-8"><link rel="icon" type="image/svg+xml" href="../../favicon.ico"><meta name="viewport" content="width=device-width,initial-scale=1"><title>用户中心</title><link rel="stylesheet" href="./libs/ztree/zTreeStyle.css"><script src="./libs/jquery.min.js"></script><script src="./libs/lodash.min.js"></script><script src="./libs/ztree/jquery.ztree.all.min.js"></script><script src="https://base.bestsch.com/BschHome/base/js/bschload.min.js?v=2025011001"></script><script src="./js/userType.js?type=teacher"></script><script type="module" crossorigin src="./static/js/main-DQzyo1z-.js"></script><link rel="stylesheet" crossorigin href="./static/css/main-CDdhe5_3.css"></head><body><div id="app"></div></body></html>
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 7.3 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 933 B |
|
After Width: | Height: | Size: 5.4 KiB |
@@ -0,0 +1,628 @@
|
||||
/*
|
||||
* JQuery zTree excheck v3.5.28
|
||||
* http://treejs.cn/
|
||||
*
|
||||
* Copyright (c) 2010 Hunter.z
|
||||
*
|
||||
* Licensed same as jquery - MIT License
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* email: hunter.z@263.net
|
||||
* Date: 2017-01-20
|
||||
*/
|
||||
(function($){
|
||||
//default consts of excheck
|
||||
var _consts = {
|
||||
event: {
|
||||
CHECK: "ztree_check"
|
||||
},
|
||||
id: {
|
||||
CHECK: "_check"
|
||||
},
|
||||
checkbox: {
|
||||
STYLE: "checkbox",
|
||||
DEFAULT: "chk",
|
||||
DISABLED: "disable",
|
||||
FALSE: "false",
|
||||
TRUE: "true",
|
||||
FULL: "full",
|
||||
PART: "part",
|
||||
FOCUS: "focus"
|
||||
},
|
||||
radio: {
|
||||
STYLE: "radio",
|
||||
TYPE_ALL: "all",
|
||||
TYPE_LEVEL: "level"
|
||||
}
|
||||
},
|
||||
//default setting of excheck
|
||||
_setting = {
|
||||
check: {
|
||||
enable: false,
|
||||
autoCheckTrigger: false,
|
||||
chkStyle: _consts.checkbox.STYLE,
|
||||
nocheckInherit: false,
|
||||
chkDisabledInherit: false,
|
||||
radioType: _consts.radio.TYPE_LEVEL,
|
||||
chkboxType: {
|
||||
"Y": "ps",
|
||||
"N": "ps"
|
||||
}
|
||||
},
|
||||
data: {
|
||||
key: {
|
||||
checked: "checked"
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
beforeCheck:null,
|
||||
onCheck:null
|
||||
}
|
||||
},
|
||||
//default root of excheck
|
||||
_initRoot = function (setting) {
|
||||
var r = data.getRoot(setting);
|
||||
r.radioCheckedList = [];
|
||||
},
|
||||
//default cache of excheck
|
||||
_initCache = function(treeId) {},
|
||||
//default bind event of excheck
|
||||
_bindEvent = function(setting) {
|
||||
var o = setting.treeObj,
|
||||
c = consts.event;
|
||||
o.bind(c.CHECK, function (event, srcEvent, treeId, node) {
|
||||
event.srcEvent = srcEvent;
|
||||
tools.apply(setting.callback.onCheck, [event, treeId, node]);
|
||||
});
|
||||
},
|
||||
_unbindEvent = function(setting) {
|
||||
var o = setting.treeObj,
|
||||
c = consts.event;
|
||||
o.unbind(c.CHECK);
|
||||
},
|
||||
//default event proxy of excheck
|
||||
_eventProxy = function(e) {
|
||||
var target = e.target,
|
||||
setting = data.getSetting(e.data.treeId),
|
||||
tId = "", node = null,
|
||||
nodeEventType = "", treeEventType = "",
|
||||
nodeEventCallback = null, treeEventCallback = null;
|
||||
|
||||
if (tools.eqs(e.type, "mouseover")) {
|
||||
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
|
||||
tId = tools.getNodeMainDom(target).id;
|
||||
nodeEventType = "mouseoverCheck";
|
||||
}
|
||||
} else if (tools.eqs(e.type, "mouseout")) {
|
||||
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
|
||||
tId = tools.getNodeMainDom(target).id;
|
||||
nodeEventType = "mouseoutCheck";
|
||||
}
|
||||
} else if (tools.eqs(e.type, "click")) {
|
||||
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
|
||||
tId = tools.getNodeMainDom(target).id;
|
||||
nodeEventType = "checkNode";
|
||||
}
|
||||
}
|
||||
if (tId.length>0) {
|
||||
node = data.getNodeCache(setting, tId);
|
||||
switch (nodeEventType) {
|
||||
case "checkNode" :
|
||||
nodeEventCallback = _handler.onCheckNode;
|
||||
break;
|
||||
case "mouseoverCheck" :
|
||||
nodeEventCallback = _handler.onMouseoverCheck;
|
||||
break;
|
||||
case "mouseoutCheck" :
|
||||
nodeEventCallback = _handler.onMouseoutCheck;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var proxyResult = {
|
||||
stop: nodeEventType === "checkNode",
|
||||
node: node,
|
||||
nodeEventType: nodeEventType,
|
||||
nodeEventCallback: nodeEventCallback,
|
||||
treeEventType: treeEventType,
|
||||
treeEventCallback: treeEventCallback
|
||||
};
|
||||
return proxyResult
|
||||
},
|
||||
//default init node of excheck
|
||||
_initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) {
|
||||
if (!n) return;
|
||||
var checkedKey = setting.data.key.checked;
|
||||
if (typeof n[checkedKey] == "string") n[checkedKey] = tools.eqs(n[checkedKey], "true");
|
||||
n[checkedKey] = !!n[checkedKey];
|
||||
n.checkedOld = n[checkedKey];
|
||||
if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true");
|
||||
n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck);
|
||||
if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true");
|
||||
n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled);
|
||||
if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true");
|
||||
n.halfCheck = !!n.halfCheck;
|
||||
n.check_Child_State = -1;
|
||||
n.check_Focus = false;
|
||||
n.getCheckStatus = function() {return data.getCheckStatus(setting, n);};
|
||||
|
||||
if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && n[checkedKey] ) {
|
||||
var r = data.getRoot(setting);
|
||||
r.radioCheckedList.push(n);
|
||||
}
|
||||
},
|
||||
//add dom for check
|
||||
_beforeA = function(setting, node, html) {
|
||||
var checkedKey = setting.data.key.checked;
|
||||
if (setting.check.enable) {
|
||||
data.makeChkFlag(setting, node);
|
||||
html.push("<span ID='", node.tId, consts.id.CHECK, "' class='", view.makeChkClass(setting, node), "' treeNode", consts.id.CHECK, (node.nocheck === true?" style='display:none;'":""),"></span>");
|
||||
}
|
||||
},
|
||||
//update zTreeObj, add method of check
|
||||
_zTreeTools = function(setting, zTreeTools) {
|
||||
zTreeTools.checkNode = function(node, checked, checkTypeFlag, callbackFlag) {
|
||||
var checkedKey = this.setting.data.key.checked;
|
||||
if (node.chkDisabled === true) return;
|
||||
if (checked !== true && checked !== false) {
|
||||
checked = !node[checkedKey];
|
||||
}
|
||||
callbackFlag = !!callbackFlag;
|
||||
|
||||
if (node[checkedKey] === checked && !checkTypeFlag) {
|
||||
return;
|
||||
} else if (callbackFlag && tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false) {
|
||||
return;
|
||||
}
|
||||
if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) {
|
||||
node[checkedKey] = checked;
|
||||
var checkObj = $$(node, consts.id.CHECK, this.setting);
|
||||
if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node);
|
||||
view.setChkClass(this.setting, checkObj, node);
|
||||
view.repairParentChkClassWithSelf(this.setting, node);
|
||||
if (callbackFlag) {
|
||||
this.setting.treeObj.trigger(consts.event.CHECK, [null, this.setting.treeId, node]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zTreeTools.checkAllNodes = function(checked) {
|
||||
view.repairAllChk(this.setting, !!checked);
|
||||
}
|
||||
|
||||
zTreeTools.getCheckedNodes = function(checked) {
|
||||
var childKey = this.setting.data.key.children;
|
||||
checked = (checked !== false);
|
||||
return data.getTreeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey], checked);
|
||||
}
|
||||
|
||||
zTreeTools.getChangeCheckedNodes = function() {
|
||||
var childKey = this.setting.data.key.children;
|
||||
return data.getTreeChangeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey]);
|
||||
}
|
||||
|
||||
zTreeTools.setChkDisabled = function(node, disabled, inheritParent, inheritChildren) {
|
||||
disabled = !!disabled;
|
||||
inheritParent = !!inheritParent;
|
||||
inheritChildren = !!inheritChildren;
|
||||
view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren);
|
||||
view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent);
|
||||
}
|
||||
|
||||
var _updateNode = zTreeTools.updateNode;
|
||||
zTreeTools.updateNode = function(node, checkTypeFlag) {
|
||||
if (_updateNode) _updateNode.apply(zTreeTools, arguments);
|
||||
if (!node || !this.setting.check.enable) return;
|
||||
var nObj = $$(node, this.setting);
|
||||
if (nObj.get(0) && tools.uCanDo(this.setting)) {
|
||||
var checkObj = $$(node, consts.id.CHECK, this.setting);
|
||||
if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node);
|
||||
view.setChkClass(this.setting, checkObj, node);
|
||||
view.repairParentChkClassWithSelf(this.setting, node);
|
||||
}
|
||||
}
|
||||
},
|
||||
//method of operate data
|
||||
_data = {
|
||||
getRadioCheckedList: function(setting) {
|
||||
var checkedList = data.getRoot(setting).radioCheckedList;
|
||||
for (var i=0, j=checkedList.length; i<j; i++) {
|
||||
if(!data.getNodeCache(setting, checkedList[i].tId)) {
|
||||
checkedList.splice(i, 1);
|
||||
i--; j--;
|
||||
}
|
||||
}
|
||||
return checkedList;
|
||||
},
|
||||
getCheckStatus: function(setting, node) {
|
||||
if (!setting.check.enable || node.nocheck || node.chkDisabled) return null;
|
||||
var checkedKey = setting.data.key.checked,
|
||||
r = {
|
||||
checked: node[checkedKey],
|
||||
half: node.halfCheck ? node.halfCheck : (setting.check.chkStyle == consts.radio.STYLE ? (node.check_Child_State === 2) : (node[checkedKey] ? (node.check_Child_State > -1 && node.check_Child_State < 2) : (node.check_Child_State > 0)))
|
||||
};
|
||||
return r;
|
||||
},
|
||||
getTreeCheckedNodes: function(setting, nodes, checked, results) {
|
||||
if (!nodes) return [];
|
||||
var childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked,
|
||||
onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL);
|
||||
results = !results ? [] : results;
|
||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||
if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) {
|
||||
results.push(nodes[i]);
|
||||
if(onlyOne) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
data.getTreeCheckedNodes(setting, nodes[i][childKey], checked, results);
|
||||
if(onlyOne && results.length > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
},
|
||||
getTreeChangeCheckedNodes: function(setting, nodes, results) {
|
||||
if (!nodes) return [];
|
||||
var childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked;
|
||||
results = !results ? [] : results;
|
||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||
if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] != nodes[i].checkedOld) {
|
||||
results.push(nodes[i]);
|
||||
}
|
||||
data.getTreeChangeCheckedNodes(setting, nodes[i][childKey], results);
|
||||
}
|
||||
return results;
|
||||
},
|
||||
makeChkFlag: function(setting, node) {
|
||||
if (!node) return;
|
||||
var childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked,
|
||||
chkFlag = -1;
|
||||
if (node[childKey]) {
|
||||
for (var i = 0, l = node[childKey].length; i < l; i++) {
|
||||
var cNode = node[childKey][i];
|
||||
var tmp = -1;
|
||||
if (setting.check.chkStyle == consts.radio.STYLE) {
|
||||
if (cNode.nocheck === true || cNode.chkDisabled === true) {
|
||||
tmp = cNode.check_Child_State;
|
||||
} else if (cNode.halfCheck === true) {
|
||||
tmp = 2;
|
||||
} else if (cNode[checkedKey]) {
|
||||
tmp = 2;
|
||||
} else {
|
||||
tmp = cNode.check_Child_State > 0 ? 2:0;
|
||||
}
|
||||
if (tmp == 2) {
|
||||
chkFlag = 2; break;
|
||||
} else if (tmp == 0){
|
||||
chkFlag = 0;
|
||||
}
|
||||
} else if (setting.check.chkStyle == consts.checkbox.STYLE) {
|
||||
if (cNode.nocheck === true || cNode.chkDisabled === true) {
|
||||
tmp = cNode.check_Child_State;
|
||||
} else if (cNode.halfCheck === true) {
|
||||
tmp = 1;
|
||||
} else if (cNode[checkedKey] ) {
|
||||
tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1;
|
||||
} else {
|
||||
tmp = (cNode.check_Child_State > 0) ? 1 : 0;
|
||||
}
|
||||
if (tmp === 1) {
|
||||
chkFlag = 1; break;
|
||||
} else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) {
|
||||
chkFlag = 1; break;
|
||||
} else if (chkFlag === 2 && tmp > -1 && tmp < 2) {
|
||||
chkFlag = 1; break;
|
||||
} else if (tmp > -1) {
|
||||
chkFlag = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
node.check_Child_State = chkFlag;
|
||||
}
|
||||
},
|
||||
//method of event proxy
|
||||
_event = {
|
||||
|
||||
},
|
||||
//method of event handler
|
||||
_handler = {
|
||||
onCheckNode: function (event, node) {
|
||||
if (node.chkDisabled === true) return false;
|
||||
var setting = data.getSetting(event.data.treeId),
|
||||
checkedKey = setting.data.key.checked;
|
||||
if (tools.apply(setting.callback.beforeCheck, [setting.treeId, node], true) == false) return true;
|
||||
node[checkedKey] = !node[checkedKey];
|
||||
view.checkNodeRelation(setting, node);
|
||||
var checkObj = $$(node, consts.id.CHECK, setting);
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
view.repairParentChkClassWithSelf(setting, node);
|
||||
setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]);
|
||||
return true;
|
||||
},
|
||||
onMouseoverCheck: function(event, node) {
|
||||
if (node.chkDisabled === true) return false;
|
||||
var setting = data.getSetting(event.data.treeId),
|
||||
checkObj = $$(node, consts.id.CHECK, setting);
|
||||
node.check_Focus = true;
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
return true;
|
||||
},
|
||||
onMouseoutCheck: function(event, node) {
|
||||
if (node.chkDisabled === true) return false;
|
||||
var setting = data.getSetting(event.data.treeId),
|
||||
checkObj = $$(node, consts.id.CHECK, setting);
|
||||
node.check_Focus = false;
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
//method of tools for zTree
|
||||
_tools = {
|
||||
|
||||
},
|
||||
//method of operate ztree dom
|
||||
_view = {
|
||||
checkNodeRelation: function(setting, node) {
|
||||
var pNode, i, l,
|
||||
childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked,
|
||||
r = consts.radio;
|
||||
if (setting.check.chkStyle == r.STYLE) {
|
||||
var checkedList = data.getRadioCheckedList(setting);
|
||||
if (node[checkedKey]) {
|
||||
if (setting.check.radioType == r.TYPE_ALL) {
|
||||
for (i = checkedList.length-1; i >= 0; i--) {
|
||||
pNode = checkedList[i];
|
||||
if (pNode[checkedKey] && pNode != node) {
|
||||
pNode[checkedKey] = false;
|
||||
checkedList.splice(i, 1);
|
||||
|
||||
view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode);
|
||||
if (pNode.parentTId != node.parentTId) {
|
||||
view.repairParentChkClassWithSelf(setting, pNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
checkedList.push(node);
|
||||
} else {
|
||||
var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting);
|
||||
for (i = 0, l = parentNode[childKey].length; i < l; i++) {
|
||||
pNode = parentNode[childKey][i];
|
||||
if (pNode[checkedKey] && pNode != node) {
|
||||
pNode[checkedKey] = false;
|
||||
view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (setting.check.radioType == r.TYPE_ALL) {
|
||||
for (i = 0, l = checkedList.length; i < l; i++) {
|
||||
if (node == checkedList[i]) {
|
||||
checkedList.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.Y.indexOf("s") > -1)) {
|
||||
view.setSonNodeCheckBox(setting, node, true);
|
||||
}
|
||||
if (!node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.N.indexOf("s") > -1)) {
|
||||
view.setSonNodeCheckBox(setting, node, false);
|
||||
}
|
||||
if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) {
|
||||
view.setParentNodeCheckBox(setting, node, true);
|
||||
}
|
||||
if (!node[checkedKey] && setting.check.chkboxType.N.indexOf("p") > -1) {
|
||||
view.setParentNodeCheckBox(setting, node, false);
|
||||
}
|
||||
}
|
||||
},
|
||||
makeChkClass: function(setting, node) {
|
||||
var checkedKey = setting.data.key.checked,
|
||||
c = consts.checkbox, r = consts.radio,
|
||||
fullStyle = "";
|
||||
if (node.chkDisabled === true) {
|
||||
fullStyle = c.DISABLED;
|
||||
} else if (node.halfCheck) {
|
||||
fullStyle = c.PART;
|
||||
} else if (setting.check.chkStyle == r.STYLE) {
|
||||
fullStyle = (node.check_Child_State < 1)? c.FULL:c.PART;
|
||||
} else {
|
||||
fullStyle = node[checkedKey] ? ((node.check_Child_State === 2 || node.check_Child_State === -1) ? c.FULL:c.PART) : ((node.check_Child_State < 1)? c.FULL:c.PART);
|
||||
}
|
||||
var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle;
|
||||
chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName;
|
||||
return consts.className.BUTTON + " " + c.DEFAULT + " " + chkName;
|
||||
},
|
||||
repairAllChk: function(setting, checked) {
|
||||
if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) {
|
||||
var checkedKey = setting.data.key.checked,
|
||||
childKey = setting.data.key.children,
|
||||
root = data.getRoot(setting);
|
||||
for (var i = 0, l = root[childKey].length; i<l ; i++) {
|
||||
var node = root[childKey][i];
|
||||
if (node.nocheck !== true && node.chkDisabled !== true) {
|
||||
node[checkedKey] = checked;
|
||||
}
|
||||
view.setSonNodeCheckBox(setting, node, checked);
|
||||
}
|
||||
}
|
||||
},
|
||||
repairChkClass: function(setting, node) {
|
||||
if (!node) return;
|
||||
data.makeChkFlag(setting, node);
|
||||
if (node.nocheck !== true) {
|
||||
var checkObj = $$(node, consts.id.CHECK, setting);
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
}
|
||||
},
|
||||
repairParentChkClass: function(setting, node) {
|
||||
if (!node || !node.parentTId) return;
|
||||
var pNode = node.getParentNode();
|
||||
view.repairChkClass(setting, pNode);
|
||||
view.repairParentChkClass(setting, pNode);
|
||||
},
|
||||
repairParentChkClassWithSelf: function(setting, node) {
|
||||
if (!node) return;
|
||||
var childKey = setting.data.key.children;
|
||||
if (node[childKey] && node[childKey].length > 0) {
|
||||
view.repairParentChkClass(setting, node[childKey][0]);
|
||||
} else {
|
||||
view.repairParentChkClass(setting, node);
|
||||
}
|
||||
},
|
||||
repairSonChkDisabled: function(setting, node, chkDisabled, inherit) {
|
||||
if (!node) return;
|
||||
var childKey = setting.data.key.children;
|
||||
if (node.chkDisabled != chkDisabled) {
|
||||
node.chkDisabled = chkDisabled;
|
||||
}
|
||||
view.repairChkClass(setting, node);
|
||||
if (node[childKey] && inherit) {
|
||||
for (var i = 0, l = node[childKey].length; i < l; i++) {
|
||||
var sNode = node[childKey][i];
|
||||
view.repairSonChkDisabled(setting, sNode, chkDisabled, inherit);
|
||||
}
|
||||
}
|
||||
},
|
||||
repairParentChkDisabled: function(setting, node, chkDisabled, inherit) {
|
||||
if (!node) return;
|
||||
if (node.chkDisabled != chkDisabled && inherit) {
|
||||
node.chkDisabled = chkDisabled;
|
||||
}
|
||||
view.repairChkClass(setting, node);
|
||||
view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit);
|
||||
},
|
||||
setChkClass: function(setting, obj, node) {
|
||||
if (!obj) return;
|
||||
if (node.nocheck === true) {
|
||||
obj.hide();
|
||||
} else {
|
||||
obj.show();
|
||||
}
|
||||
obj.attr('class', view.makeChkClass(setting, node));
|
||||
},
|
||||
setParentNodeCheckBox: function(setting, node, value, srcNode) {
|
||||
var childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked,
|
||||
checkObj = $$(node, consts.id.CHECK, setting);
|
||||
if (!srcNode) srcNode = node;
|
||||
data.makeChkFlag(setting, node);
|
||||
if (node.nocheck !== true && node.chkDisabled !== true) {
|
||||
node[checkedKey] = value;
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
if (setting.check.autoCheckTrigger && node != srcNode) {
|
||||
setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
|
||||
}
|
||||
}
|
||||
if (node.parentTId) {
|
||||
var pSign = true;
|
||||
if (!value) {
|
||||
var pNodes = node.getParentNode()[childKey];
|
||||
for (var i = 0, l = pNodes.length; i < l; i++) {
|
||||
if ((pNodes[i].nocheck !== true && pNodes[i].chkDisabled !== true && pNodes[i][checkedKey])
|
||||
|| ((pNodes[i].nocheck === true || pNodes[i].chkDisabled === true) && pNodes[i].check_Child_State > 0)) {
|
||||
pSign = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pSign) {
|
||||
view.setParentNodeCheckBox(setting, node.getParentNode(), value, srcNode);
|
||||
}
|
||||
}
|
||||
},
|
||||
setSonNodeCheckBox: function(setting, node, value, srcNode) {
|
||||
if (!node) return;
|
||||
var childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked,
|
||||
checkObj = $$(node, consts.id.CHECK, setting);
|
||||
if (!srcNode) srcNode = node;
|
||||
|
||||
var hasDisable = false;
|
||||
if (node[childKey]) {
|
||||
for (var i = 0, l = node[childKey].length; i < l; i++) {
|
||||
var sNode = node[childKey][i];
|
||||
view.setSonNodeCheckBox(setting, sNode, value, srcNode);
|
||||
if (sNode.chkDisabled === true) hasDisable = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (node != data.getRoot(setting) && node.chkDisabled !== true) {
|
||||
if (hasDisable && node.nocheck !== true) {
|
||||
data.makeChkFlag(setting, node);
|
||||
}
|
||||
if (node.nocheck !== true && node.chkDisabled !== true) {
|
||||
node[checkedKey] = value;
|
||||
if (!hasDisable) node.check_Child_State = (node[childKey] && node[childKey].length > 0) ? (value ? 2 : 0) : -1;
|
||||
} else {
|
||||
node.check_Child_State = -1;
|
||||
}
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
if (setting.check.autoCheckTrigger && node != srcNode && node.nocheck !== true && node.chkDisabled !== true) {
|
||||
setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
_z = {
|
||||
tools: _tools,
|
||||
view: _view,
|
||||
event: _event,
|
||||
data: _data
|
||||
};
|
||||
$.extend(true, $.fn.zTree.consts, _consts);
|
||||
$.extend(true, $.fn.zTree._z, _z);
|
||||
|
||||
var zt = $.fn.zTree,
|
||||
tools = zt._z.tools,
|
||||
consts = zt.consts,
|
||||
view = zt._z.view,
|
||||
data = zt._z.data,
|
||||
event = zt._z.event,
|
||||
$$ = tools.$;
|
||||
|
||||
data.exSetting(_setting);
|
||||
data.addInitBind(_bindEvent);
|
||||
data.addInitUnBind(_unbindEvent);
|
||||
data.addInitCache(_initCache);
|
||||
data.addInitNode(_initNode);
|
||||
data.addInitProxy(_eventProxy, true);
|
||||
data.addInitRoot(_initRoot);
|
||||
data.addBeforeA(_beforeA);
|
||||
data.addZTreeTools(_zTreeTools);
|
||||
|
||||
var _createNodes = view.createNodes;
|
||||
view.createNodes = function(setting, level, nodes, parentNode, index) {
|
||||
if (_createNodes) _createNodes.apply(view, arguments);
|
||||
if (!nodes) return;
|
||||
view.repairParentChkClassWithSelf(setting, parentNode);
|
||||
}
|
||||
var _removeNode = view.removeNode;
|
||||
view.removeNode = function(setting, node) {
|
||||
var parentNode = node.getParentNode();
|
||||
if (_removeNode) _removeNode.apply(view, arguments);
|
||||
if (!node || !parentNode) return;
|
||||
view.repairChkClass(setting, parentNode);
|
||||
view.repairParentChkClass(setting, parentNode);
|
||||
}
|
||||
|
||||
var _appendNodes = view.appendNodes;
|
||||
view.appendNodes = function(setting, level, nodes, parentNode, index, initFlag, openFlag) {
|
||||
var html = "";
|
||||
if (_appendNodes) {
|
||||
html = _appendNodes.apply(view, arguments);
|
||||
}
|
||||
if (parentNode) {
|
||||
data.makeChkFlag(setting, parentNode);
|
||||
}
|
||||
return html;
|
||||
}
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,378 @@
|
||||
/*-------------------------------------
|
||||
zTree Style
|
||||
|
||||
version: 3.4
|
||||
author: Hunter.z
|
||||
email: hunter.z@263.net
|
||||
website: http://code.google.com/p/jquerytree/
|
||||
|
||||
-------------------------------------*/
|
||||
.ztree * {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
font-family: Verdana, Arial, Helvetica, AppleGothic, sans-serif
|
||||
}
|
||||
|
||||
.ztree {
|
||||
margin: 0;
|
||||
padding: 5px;
|
||||
color: #333
|
||||
}
|
||||
|
||||
.ztree li {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
list-style: none;
|
||||
line-height: 17px;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
outline: 0
|
||||
}
|
||||
|
||||
.ztree li ul {
|
||||
margin: 0;
|
||||
padding: 0 0 0 18px
|
||||
}
|
||||
|
||||
.ztree li ul.line {
|
||||
background: url(./img/line_conn.png) 0 0 repeat-y;
|
||||
}
|
||||
|
||||
.ztree li a {
|
||||
padding-right: 3px;
|
||||
margin: 0;
|
||||
cursor: pointer;
|
||||
height: 21px;
|
||||
color: #333;
|
||||
background-color: transparent;
|
||||
text-decoration: none;
|
||||
vertical-align: top;
|
||||
display: inline-block
|
||||
}
|
||||
|
||||
.ztree li a:hover {
|
||||
text-decoration: underline
|
||||
}
|
||||
|
||||
.ztree li a.curSelectedNode {
|
||||
padding-top: 0px;
|
||||
background-color: #e5e5e5;
|
||||
color: black;
|
||||
height: 21px;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.ztree li a.curSelectedNode_Edit {
|
||||
padding-top: 0px;
|
||||
background-color: #e5e5e5;
|
||||
color: black;
|
||||
height: 21px;
|
||||
border: 1px #666 solid;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.ztree li a.tmpTargetNode_inner {
|
||||
padding-top: 0px;
|
||||
background-color: #aaa;
|
||||
color: white;
|
||||
height: 21px;
|
||||
border: 1px #666 solid;
|
||||
opacity: 0.8;
|
||||
filter: alpha(opacity=80)
|
||||
}
|
||||
|
||||
.ztree li a.tmpTargetNode_prev {}
|
||||
|
||||
.ztree li a.tmpTargetNode_next {}
|
||||
|
||||
.ztree li a input.rename {
|
||||
height: 14px;
|
||||
width: 80px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
border: 1px #585956 solid;
|
||||
*border: 0px
|
||||
}
|
||||
|
||||
.ztree li span {
|
||||
line-height: 21px;
|
||||
margin-right: 2px
|
||||
}
|
||||
|
||||
.ztree li span.button {
|
||||
line-height: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 21px;
|
||||
height: 21px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
border: 0 none;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
background-color: transparent;
|
||||
background-repeat: no-repeat;
|
||||
background-attachment: scroll;
|
||||
background-image: url("./img/bootstrap.png");
|
||||
}
|
||||
|
||||
.ztree li span.button.chk {
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
margin: 0 2px;
|
||||
cursor: auto
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_false_full {
|
||||
background-position: -5px -5px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_false_full_focus {
|
||||
background-position: -5px -26px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_false_part {
|
||||
background-position: -5px -48px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_false_part_focus {
|
||||
background-position: -5px -68px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_false_disable {
|
||||
background-position: -5px -89px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_true_full {
|
||||
background-position: -26px -5px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_true_full_focus {
|
||||
background-position: -26px -26px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_true_part {
|
||||
background-position: -26px -48px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_true_part_focus {
|
||||
background-position: -26px -68px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_true_disable {
|
||||
background-position: -26px -89px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_false_full {
|
||||
background-position: -47px -5px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_false_full_focus {
|
||||
background-position: -47px -26px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_false_part {
|
||||
background-position: -47px -47px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_false_part_focus {
|
||||
background-position: -47px -68px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_false_disable {
|
||||
background-position: -47px -89px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_true_full {
|
||||
background-position: -68px -5px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_true_full_focus {
|
||||
background-position: -68px -26px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_true_part {
|
||||
background-position: -68px -47px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_true_part_focus {
|
||||
background-position: -68px -68px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_true_disable {
|
||||
background-position: -68px -89px;
|
||||
}
|
||||
|
||||
.ztree li span.button.switch {
|
||||
width: 21px;
|
||||
height: 21px
|
||||
}
|
||||
|
||||
.ztree li span.button.root_open {
|
||||
background-position: -105px -63px
|
||||
}
|
||||
|
||||
.ztree li span.button.root_close {
|
||||
background-position: -126px -63px
|
||||
}
|
||||
|
||||
.ztree li span.button.roots_open {
|
||||
background-position: -105px 0;
|
||||
}
|
||||
|
||||
.ztree li span.button.roots_close {
|
||||
background-position: -126px 0;
|
||||
}
|
||||
|
||||
.ztree li span.button.center_open {
|
||||
background-position: -105px -21px;
|
||||
}
|
||||
|
||||
.ztree li span.button.center_close {
|
||||
background-position: -126px -21px;
|
||||
}
|
||||
|
||||
.ztree li span.button.bottom_open {
|
||||
background-position: -105px -42px;
|
||||
}
|
||||
|
||||
.ztree li span.button.bottom_close {
|
||||
background-position: -126px -42px;
|
||||
}
|
||||
|
||||
.ztree li span.button.noline_open {
|
||||
background-position: -105px -84px;
|
||||
}
|
||||
|
||||
.ztree li span.button.noline_close {
|
||||
background-position: -126px -84px;
|
||||
}
|
||||
|
||||
.ztree li span.button.root_docu {
|
||||
background-position: -105px -63px;
|
||||
}
|
||||
|
||||
.ztree li span.button.roots_docu {
|
||||
background-position: -84px 0;
|
||||
}
|
||||
|
||||
.ztree li span.button.center_docu {
|
||||
background-position: -84px -21px;
|
||||
}
|
||||
|
||||
.ztree li span.button.bottom_docu {
|
||||
background-position: -84px -42px;
|
||||
}
|
||||
|
||||
.ztree li span.button.noline_docu {
|
||||
background: none;
|
||||
}
|
||||
|
||||
.ztree li span.button.ico_open {
|
||||
margin-right: 2px;
|
||||
background-position: -147px -21px;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.ico_close {
|
||||
margin-right: 2px;
|
||||
margin-right: 2px;
|
||||
background-position: -147px 0;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.ico_docu {
|
||||
margin-right: 2px;
|
||||
background-position: -147px -43px;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.edit {
|
||||
margin-left: 2px;
|
||||
margin-right: -1px;
|
||||
background-position: -189px -21px;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.edit:hover {
|
||||
background-position: -168px -21px;
|
||||
}
|
||||
|
||||
.ztree li span.button.remove {
|
||||
margin-left: 2px;
|
||||
margin-right: -1px;
|
||||
background-position: -189px -42px;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.remove:hover {
|
||||
background-position: -168px -42px;
|
||||
}
|
||||
|
||||
.ztree li span.button.add {
|
||||
margin-left: 2px;
|
||||
margin-right: -1px;
|
||||
background-position: -189px 0;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.add:hover {
|
||||
background-position: -168px 0;
|
||||
}
|
||||
|
||||
ul.tmpTargetzTree {
|
||||
background-color: #FFE6B0;
|
||||
opacity: 0.8;
|
||||
filter: alpha(opacity=80)
|
||||
}
|
||||
|
||||
span.tmpzTreeMove_arrow {
|
||||
width: 16px;
|
||||
height: 21px;
|
||||
display: inline-block;
|
||||
padding: 0;
|
||||
margin: 2px 0 0 1px;
|
||||
border: 0 none;
|
||||
position: absolute;
|
||||
background-color: transparent;
|
||||
background-repeat: no-repeat;
|
||||
background-attachment: scroll;
|
||||
background-position: -168px -84px;
|
||||
background-image: url("./img/bootstrap.png");
|
||||
z-index: 10000;
|
||||
}
|
||||
|
||||
span.tmpzTreeMove_prev {
|
||||
background: red;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ul.ztree.zTreeDragUL {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
width: auto;
|
||||
height: auto;
|
||||
overflow: hidden;
|
||||
background-color: #cfcfcf;
|
||||
border: 1px #00B83F dotted;
|
||||
opacity: 0.8;
|
||||
filter: alpha(opacity=80)
|
||||
}
|
||||
|
||||
.ztreeMask {
|
||||
z-index: 10000;
|
||||
background-color: #cfcfcf;
|
||||
opacity: 0.0;
|
||||
filter: alpha(opacity=0);
|
||||
position: absolute
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
.ztree li span.button {background-image:url("./img/bootstrap3.png");}
|
||||
span.tmpzTreeMove_arrow {background-image:url("./img/bootstrap3.png");}
|
||||
|
||||
|
After Width: | Height: | Size: 542 KiB |
|
After Width: | Height: | Size: 186 KiB |
@@ -0,0 +1 @@
|
||||
import"./main-DQzyo1z-.js";
|
||||
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 186 KiB |
|
After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="UTF-8"><link rel="icon" type="image/svg+xml" href="../../favicon.ico"><meta name="viewport" content="width=device-width,initial-scale=1"><title>铃铛学习中心</title><link rel="stylesheet" href="./libs/ztree/zTreeStyle.css"><script src="./libs/jquery.min.js"></script><script src="./libs/lodash.min.js"></script><script src="./libs/ztree/jquery.ztree.all.min.js"></script><script src="https://base.bestsch.com/BschHome/base/js/bschload.min.js?v=2025011001"></script><script src="./js/userType.js?type=teacher"></script><script type="module" crossorigin src="./static/js/main-BQpkDb67.js"></script><link rel="stylesheet" crossorigin href="./static/css/main-QEPDMFdB.css"></head><body><div id="app"></div></body></html>
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 7.3 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 933 B |
|
After Width: | Height: | Size: 5.4 KiB |
@@ -0,0 +1,628 @@
|
||||
/*
|
||||
* JQuery zTree excheck v3.5.28
|
||||
* http://treejs.cn/
|
||||
*
|
||||
* Copyright (c) 2010 Hunter.z
|
||||
*
|
||||
* Licensed same as jquery - MIT License
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* email: hunter.z@263.net
|
||||
* Date: 2017-01-20
|
||||
*/
|
||||
(function($){
|
||||
//default consts of excheck
|
||||
var _consts = {
|
||||
event: {
|
||||
CHECK: "ztree_check"
|
||||
},
|
||||
id: {
|
||||
CHECK: "_check"
|
||||
},
|
||||
checkbox: {
|
||||
STYLE: "checkbox",
|
||||
DEFAULT: "chk",
|
||||
DISABLED: "disable",
|
||||
FALSE: "false",
|
||||
TRUE: "true",
|
||||
FULL: "full",
|
||||
PART: "part",
|
||||
FOCUS: "focus"
|
||||
},
|
||||
radio: {
|
||||
STYLE: "radio",
|
||||
TYPE_ALL: "all",
|
||||
TYPE_LEVEL: "level"
|
||||
}
|
||||
},
|
||||
//default setting of excheck
|
||||
_setting = {
|
||||
check: {
|
||||
enable: false,
|
||||
autoCheckTrigger: false,
|
||||
chkStyle: _consts.checkbox.STYLE,
|
||||
nocheckInherit: false,
|
||||
chkDisabledInherit: false,
|
||||
radioType: _consts.radio.TYPE_LEVEL,
|
||||
chkboxType: {
|
||||
"Y": "ps",
|
||||
"N": "ps"
|
||||
}
|
||||
},
|
||||
data: {
|
||||
key: {
|
||||
checked: "checked"
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
beforeCheck:null,
|
||||
onCheck:null
|
||||
}
|
||||
},
|
||||
//default root of excheck
|
||||
_initRoot = function (setting) {
|
||||
var r = data.getRoot(setting);
|
||||
r.radioCheckedList = [];
|
||||
},
|
||||
//default cache of excheck
|
||||
_initCache = function(treeId) {},
|
||||
//default bind event of excheck
|
||||
_bindEvent = function(setting) {
|
||||
var o = setting.treeObj,
|
||||
c = consts.event;
|
||||
o.bind(c.CHECK, function (event, srcEvent, treeId, node) {
|
||||
event.srcEvent = srcEvent;
|
||||
tools.apply(setting.callback.onCheck, [event, treeId, node]);
|
||||
});
|
||||
},
|
||||
_unbindEvent = function(setting) {
|
||||
var o = setting.treeObj,
|
||||
c = consts.event;
|
||||
o.unbind(c.CHECK);
|
||||
},
|
||||
//default event proxy of excheck
|
||||
_eventProxy = function(e) {
|
||||
var target = e.target,
|
||||
setting = data.getSetting(e.data.treeId),
|
||||
tId = "", node = null,
|
||||
nodeEventType = "", treeEventType = "",
|
||||
nodeEventCallback = null, treeEventCallback = null;
|
||||
|
||||
if (tools.eqs(e.type, "mouseover")) {
|
||||
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
|
||||
tId = tools.getNodeMainDom(target).id;
|
||||
nodeEventType = "mouseoverCheck";
|
||||
}
|
||||
} else if (tools.eqs(e.type, "mouseout")) {
|
||||
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
|
||||
tId = tools.getNodeMainDom(target).id;
|
||||
nodeEventType = "mouseoutCheck";
|
||||
}
|
||||
} else if (tools.eqs(e.type, "click")) {
|
||||
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
|
||||
tId = tools.getNodeMainDom(target).id;
|
||||
nodeEventType = "checkNode";
|
||||
}
|
||||
}
|
||||
if (tId.length>0) {
|
||||
node = data.getNodeCache(setting, tId);
|
||||
switch (nodeEventType) {
|
||||
case "checkNode" :
|
||||
nodeEventCallback = _handler.onCheckNode;
|
||||
break;
|
||||
case "mouseoverCheck" :
|
||||
nodeEventCallback = _handler.onMouseoverCheck;
|
||||
break;
|
||||
case "mouseoutCheck" :
|
||||
nodeEventCallback = _handler.onMouseoutCheck;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var proxyResult = {
|
||||
stop: nodeEventType === "checkNode",
|
||||
node: node,
|
||||
nodeEventType: nodeEventType,
|
||||
nodeEventCallback: nodeEventCallback,
|
||||
treeEventType: treeEventType,
|
||||
treeEventCallback: treeEventCallback
|
||||
};
|
||||
return proxyResult
|
||||
},
|
||||
//default init node of excheck
|
||||
_initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) {
|
||||
if (!n) return;
|
||||
var checkedKey = setting.data.key.checked;
|
||||
if (typeof n[checkedKey] == "string") n[checkedKey] = tools.eqs(n[checkedKey], "true");
|
||||
n[checkedKey] = !!n[checkedKey];
|
||||
n.checkedOld = n[checkedKey];
|
||||
if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true");
|
||||
n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck);
|
||||
if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true");
|
||||
n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled);
|
||||
if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true");
|
||||
n.halfCheck = !!n.halfCheck;
|
||||
n.check_Child_State = -1;
|
||||
n.check_Focus = false;
|
||||
n.getCheckStatus = function() {return data.getCheckStatus(setting, n);};
|
||||
|
||||
if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && n[checkedKey] ) {
|
||||
var r = data.getRoot(setting);
|
||||
r.radioCheckedList.push(n);
|
||||
}
|
||||
},
|
||||
//add dom for check
|
||||
_beforeA = function(setting, node, html) {
|
||||
var checkedKey = setting.data.key.checked;
|
||||
if (setting.check.enable) {
|
||||
data.makeChkFlag(setting, node);
|
||||
html.push("<span ID='", node.tId, consts.id.CHECK, "' class='", view.makeChkClass(setting, node), "' treeNode", consts.id.CHECK, (node.nocheck === true?" style='display:none;'":""),"></span>");
|
||||
}
|
||||
},
|
||||
//update zTreeObj, add method of check
|
||||
_zTreeTools = function(setting, zTreeTools) {
|
||||
zTreeTools.checkNode = function(node, checked, checkTypeFlag, callbackFlag) {
|
||||
var checkedKey = this.setting.data.key.checked;
|
||||
if (node.chkDisabled === true) return;
|
||||
if (checked !== true && checked !== false) {
|
||||
checked = !node[checkedKey];
|
||||
}
|
||||
callbackFlag = !!callbackFlag;
|
||||
|
||||
if (node[checkedKey] === checked && !checkTypeFlag) {
|
||||
return;
|
||||
} else if (callbackFlag && tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false) {
|
||||
return;
|
||||
}
|
||||
if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) {
|
||||
node[checkedKey] = checked;
|
||||
var checkObj = $$(node, consts.id.CHECK, this.setting);
|
||||
if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node);
|
||||
view.setChkClass(this.setting, checkObj, node);
|
||||
view.repairParentChkClassWithSelf(this.setting, node);
|
||||
if (callbackFlag) {
|
||||
this.setting.treeObj.trigger(consts.event.CHECK, [null, this.setting.treeId, node]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zTreeTools.checkAllNodes = function(checked) {
|
||||
view.repairAllChk(this.setting, !!checked);
|
||||
}
|
||||
|
||||
zTreeTools.getCheckedNodes = function(checked) {
|
||||
var childKey = this.setting.data.key.children;
|
||||
checked = (checked !== false);
|
||||
return data.getTreeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey], checked);
|
||||
}
|
||||
|
||||
zTreeTools.getChangeCheckedNodes = function() {
|
||||
var childKey = this.setting.data.key.children;
|
||||
return data.getTreeChangeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey]);
|
||||
}
|
||||
|
||||
zTreeTools.setChkDisabled = function(node, disabled, inheritParent, inheritChildren) {
|
||||
disabled = !!disabled;
|
||||
inheritParent = !!inheritParent;
|
||||
inheritChildren = !!inheritChildren;
|
||||
view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren);
|
||||
view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent);
|
||||
}
|
||||
|
||||
var _updateNode = zTreeTools.updateNode;
|
||||
zTreeTools.updateNode = function(node, checkTypeFlag) {
|
||||
if (_updateNode) _updateNode.apply(zTreeTools, arguments);
|
||||
if (!node || !this.setting.check.enable) return;
|
||||
var nObj = $$(node, this.setting);
|
||||
if (nObj.get(0) && tools.uCanDo(this.setting)) {
|
||||
var checkObj = $$(node, consts.id.CHECK, this.setting);
|
||||
if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node);
|
||||
view.setChkClass(this.setting, checkObj, node);
|
||||
view.repairParentChkClassWithSelf(this.setting, node);
|
||||
}
|
||||
}
|
||||
},
|
||||
//method of operate data
|
||||
_data = {
|
||||
getRadioCheckedList: function(setting) {
|
||||
var checkedList = data.getRoot(setting).radioCheckedList;
|
||||
for (var i=0, j=checkedList.length; i<j; i++) {
|
||||
if(!data.getNodeCache(setting, checkedList[i].tId)) {
|
||||
checkedList.splice(i, 1);
|
||||
i--; j--;
|
||||
}
|
||||
}
|
||||
return checkedList;
|
||||
},
|
||||
getCheckStatus: function(setting, node) {
|
||||
if (!setting.check.enable || node.nocheck || node.chkDisabled) return null;
|
||||
var checkedKey = setting.data.key.checked,
|
||||
r = {
|
||||
checked: node[checkedKey],
|
||||
half: node.halfCheck ? node.halfCheck : (setting.check.chkStyle == consts.radio.STYLE ? (node.check_Child_State === 2) : (node[checkedKey] ? (node.check_Child_State > -1 && node.check_Child_State < 2) : (node.check_Child_State > 0)))
|
||||
};
|
||||
return r;
|
||||
},
|
||||
getTreeCheckedNodes: function(setting, nodes, checked, results) {
|
||||
if (!nodes) return [];
|
||||
var childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked,
|
||||
onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL);
|
||||
results = !results ? [] : results;
|
||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||
if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) {
|
||||
results.push(nodes[i]);
|
||||
if(onlyOne) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
data.getTreeCheckedNodes(setting, nodes[i][childKey], checked, results);
|
||||
if(onlyOne && results.length > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
},
|
||||
getTreeChangeCheckedNodes: function(setting, nodes, results) {
|
||||
if (!nodes) return [];
|
||||
var childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked;
|
||||
results = !results ? [] : results;
|
||||
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||
if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] != nodes[i].checkedOld) {
|
||||
results.push(nodes[i]);
|
||||
}
|
||||
data.getTreeChangeCheckedNodes(setting, nodes[i][childKey], results);
|
||||
}
|
||||
return results;
|
||||
},
|
||||
makeChkFlag: function(setting, node) {
|
||||
if (!node) return;
|
||||
var childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked,
|
||||
chkFlag = -1;
|
||||
if (node[childKey]) {
|
||||
for (var i = 0, l = node[childKey].length; i < l; i++) {
|
||||
var cNode = node[childKey][i];
|
||||
var tmp = -1;
|
||||
if (setting.check.chkStyle == consts.radio.STYLE) {
|
||||
if (cNode.nocheck === true || cNode.chkDisabled === true) {
|
||||
tmp = cNode.check_Child_State;
|
||||
} else if (cNode.halfCheck === true) {
|
||||
tmp = 2;
|
||||
} else if (cNode[checkedKey]) {
|
||||
tmp = 2;
|
||||
} else {
|
||||
tmp = cNode.check_Child_State > 0 ? 2:0;
|
||||
}
|
||||
if (tmp == 2) {
|
||||
chkFlag = 2; break;
|
||||
} else if (tmp == 0){
|
||||
chkFlag = 0;
|
||||
}
|
||||
} else if (setting.check.chkStyle == consts.checkbox.STYLE) {
|
||||
if (cNode.nocheck === true || cNode.chkDisabled === true) {
|
||||
tmp = cNode.check_Child_State;
|
||||
} else if (cNode.halfCheck === true) {
|
||||
tmp = 1;
|
||||
} else if (cNode[checkedKey] ) {
|
||||
tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1;
|
||||
} else {
|
||||
tmp = (cNode.check_Child_State > 0) ? 1 : 0;
|
||||
}
|
||||
if (tmp === 1) {
|
||||
chkFlag = 1; break;
|
||||
} else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) {
|
||||
chkFlag = 1; break;
|
||||
} else if (chkFlag === 2 && tmp > -1 && tmp < 2) {
|
||||
chkFlag = 1; break;
|
||||
} else if (tmp > -1) {
|
||||
chkFlag = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
node.check_Child_State = chkFlag;
|
||||
}
|
||||
},
|
||||
//method of event proxy
|
||||
_event = {
|
||||
|
||||
},
|
||||
//method of event handler
|
||||
_handler = {
|
||||
onCheckNode: function (event, node) {
|
||||
if (node.chkDisabled === true) return false;
|
||||
var setting = data.getSetting(event.data.treeId),
|
||||
checkedKey = setting.data.key.checked;
|
||||
if (tools.apply(setting.callback.beforeCheck, [setting.treeId, node], true) == false) return true;
|
||||
node[checkedKey] = !node[checkedKey];
|
||||
view.checkNodeRelation(setting, node);
|
||||
var checkObj = $$(node, consts.id.CHECK, setting);
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
view.repairParentChkClassWithSelf(setting, node);
|
||||
setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]);
|
||||
return true;
|
||||
},
|
||||
onMouseoverCheck: function(event, node) {
|
||||
if (node.chkDisabled === true) return false;
|
||||
var setting = data.getSetting(event.data.treeId),
|
||||
checkObj = $$(node, consts.id.CHECK, setting);
|
||||
node.check_Focus = true;
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
return true;
|
||||
},
|
||||
onMouseoutCheck: function(event, node) {
|
||||
if (node.chkDisabled === true) return false;
|
||||
var setting = data.getSetting(event.data.treeId),
|
||||
checkObj = $$(node, consts.id.CHECK, setting);
|
||||
node.check_Focus = false;
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
//method of tools for zTree
|
||||
_tools = {
|
||||
|
||||
},
|
||||
//method of operate ztree dom
|
||||
_view = {
|
||||
checkNodeRelation: function(setting, node) {
|
||||
var pNode, i, l,
|
||||
childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked,
|
||||
r = consts.radio;
|
||||
if (setting.check.chkStyle == r.STYLE) {
|
||||
var checkedList = data.getRadioCheckedList(setting);
|
||||
if (node[checkedKey]) {
|
||||
if (setting.check.radioType == r.TYPE_ALL) {
|
||||
for (i = checkedList.length-1; i >= 0; i--) {
|
||||
pNode = checkedList[i];
|
||||
if (pNode[checkedKey] && pNode != node) {
|
||||
pNode[checkedKey] = false;
|
||||
checkedList.splice(i, 1);
|
||||
|
||||
view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode);
|
||||
if (pNode.parentTId != node.parentTId) {
|
||||
view.repairParentChkClassWithSelf(setting, pNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
checkedList.push(node);
|
||||
} else {
|
||||
var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting);
|
||||
for (i = 0, l = parentNode[childKey].length; i < l; i++) {
|
||||
pNode = parentNode[childKey][i];
|
||||
if (pNode[checkedKey] && pNode != node) {
|
||||
pNode[checkedKey] = false;
|
||||
view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (setting.check.radioType == r.TYPE_ALL) {
|
||||
for (i = 0, l = checkedList.length; i < l; i++) {
|
||||
if (node == checkedList[i]) {
|
||||
checkedList.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.Y.indexOf("s") > -1)) {
|
||||
view.setSonNodeCheckBox(setting, node, true);
|
||||
}
|
||||
if (!node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.N.indexOf("s") > -1)) {
|
||||
view.setSonNodeCheckBox(setting, node, false);
|
||||
}
|
||||
if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) {
|
||||
view.setParentNodeCheckBox(setting, node, true);
|
||||
}
|
||||
if (!node[checkedKey] && setting.check.chkboxType.N.indexOf("p") > -1) {
|
||||
view.setParentNodeCheckBox(setting, node, false);
|
||||
}
|
||||
}
|
||||
},
|
||||
makeChkClass: function(setting, node) {
|
||||
var checkedKey = setting.data.key.checked,
|
||||
c = consts.checkbox, r = consts.radio,
|
||||
fullStyle = "";
|
||||
if (node.chkDisabled === true) {
|
||||
fullStyle = c.DISABLED;
|
||||
} else if (node.halfCheck) {
|
||||
fullStyle = c.PART;
|
||||
} else if (setting.check.chkStyle == r.STYLE) {
|
||||
fullStyle = (node.check_Child_State < 1)? c.FULL:c.PART;
|
||||
} else {
|
||||
fullStyle = node[checkedKey] ? ((node.check_Child_State === 2 || node.check_Child_State === -1) ? c.FULL:c.PART) : ((node.check_Child_State < 1)? c.FULL:c.PART);
|
||||
}
|
||||
var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle;
|
||||
chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName;
|
||||
return consts.className.BUTTON + " " + c.DEFAULT + " " + chkName;
|
||||
},
|
||||
repairAllChk: function(setting, checked) {
|
||||
if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) {
|
||||
var checkedKey = setting.data.key.checked,
|
||||
childKey = setting.data.key.children,
|
||||
root = data.getRoot(setting);
|
||||
for (var i = 0, l = root[childKey].length; i<l ; i++) {
|
||||
var node = root[childKey][i];
|
||||
if (node.nocheck !== true && node.chkDisabled !== true) {
|
||||
node[checkedKey] = checked;
|
||||
}
|
||||
view.setSonNodeCheckBox(setting, node, checked);
|
||||
}
|
||||
}
|
||||
},
|
||||
repairChkClass: function(setting, node) {
|
||||
if (!node) return;
|
||||
data.makeChkFlag(setting, node);
|
||||
if (node.nocheck !== true) {
|
||||
var checkObj = $$(node, consts.id.CHECK, setting);
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
}
|
||||
},
|
||||
repairParentChkClass: function(setting, node) {
|
||||
if (!node || !node.parentTId) return;
|
||||
var pNode = node.getParentNode();
|
||||
view.repairChkClass(setting, pNode);
|
||||
view.repairParentChkClass(setting, pNode);
|
||||
},
|
||||
repairParentChkClassWithSelf: function(setting, node) {
|
||||
if (!node) return;
|
||||
var childKey = setting.data.key.children;
|
||||
if (node[childKey] && node[childKey].length > 0) {
|
||||
view.repairParentChkClass(setting, node[childKey][0]);
|
||||
} else {
|
||||
view.repairParentChkClass(setting, node);
|
||||
}
|
||||
},
|
||||
repairSonChkDisabled: function(setting, node, chkDisabled, inherit) {
|
||||
if (!node) return;
|
||||
var childKey = setting.data.key.children;
|
||||
if (node.chkDisabled != chkDisabled) {
|
||||
node.chkDisabled = chkDisabled;
|
||||
}
|
||||
view.repairChkClass(setting, node);
|
||||
if (node[childKey] && inherit) {
|
||||
for (var i = 0, l = node[childKey].length; i < l; i++) {
|
||||
var sNode = node[childKey][i];
|
||||
view.repairSonChkDisabled(setting, sNode, chkDisabled, inherit);
|
||||
}
|
||||
}
|
||||
},
|
||||
repairParentChkDisabled: function(setting, node, chkDisabled, inherit) {
|
||||
if (!node) return;
|
||||
if (node.chkDisabled != chkDisabled && inherit) {
|
||||
node.chkDisabled = chkDisabled;
|
||||
}
|
||||
view.repairChkClass(setting, node);
|
||||
view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit);
|
||||
},
|
||||
setChkClass: function(setting, obj, node) {
|
||||
if (!obj) return;
|
||||
if (node.nocheck === true) {
|
||||
obj.hide();
|
||||
} else {
|
||||
obj.show();
|
||||
}
|
||||
obj.attr('class', view.makeChkClass(setting, node));
|
||||
},
|
||||
setParentNodeCheckBox: function(setting, node, value, srcNode) {
|
||||
var childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked,
|
||||
checkObj = $$(node, consts.id.CHECK, setting);
|
||||
if (!srcNode) srcNode = node;
|
||||
data.makeChkFlag(setting, node);
|
||||
if (node.nocheck !== true && node.chkDisabled !== true) {
|
||||
node[checkedKey] = value;
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
if (setting.check.autoCheckTrigger && node != srcNode) {
|
||||
setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
|
||||
}
|
||||
}
|
||||
if (node.parentTId) {
|
||||
var pSign = true;
|
||||
if (!value) {
|
||||
var pNodes = node.getParentNode()[childKey];
|
||||
for (var i = 0, l = pNodes.length; i < l; i++) {
|
||||
if ((pNodes[i].nocheck !== true && pNodes[i].chkDisabled !== true && pNodes[i][checkedKey])
|
||||
|| ((pNodes[i].nocheck === true || pNodes[i].chkDisabled === true) && pNodes[i].check_Child_State > 0)) {
|
||||
pSign = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pSign) {
|
||||
view.setParentNodeCheckBox(setting, node.getParentNode(), value, srcNode);
|
||||
}
|
||||
}
|
||||
},
|
||||
setSonNodeCheckBox: function(setting, node, value, srcNode) {
|
||||
if (!node) return;
|
||||
var childKey = setting.data.key.children,
|
||||
checkedKey = setting.data.key.checked,
|
||||
checkObj = $$(node, consts.id.CHECK, setting);
|
||||
if (!srcNode) srcNode = node;
|
||||
|
||||
var hasDisable = false;
|
||||
if (node[childKey]) {
|
||||
for (var i = 0, l = node[childKey].length; i < l; i++) {
|
||||
var sNode = node[childKey][i];
|
||||
view.setSonNodeCheckBox(setting, sNode, value, srcNode);
|
||||
if (sNode.chkDisabled === true) hasDisable = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (node != data.getRoot(setting) && node.chkDisabled !== true) {
|
||||
if (hasDisable && node.nocheck !== true) {
|
||||
data.makeChkFlag(setting, node);
|
||||
}
|
||||
if (node.nocheck !== true && node.chkDisabled !== true) {
|
||||
node[checkedKey] = value;
|
||||
if (!hasDisable) node.check_Child_State = (node[childKey] && node[childKey].length > 0) ? (value ? 2 : 0) : -1;
|
||||
} else {
|
||||
node.check_Child_State = -1;
|
||||
}
|
||||
view.setChkClass(setting, checkObj, node);
|
||||
if (setting.check.autoCheckTrigger && node != srcNode && node.nocheck !== true && node.chkDisabled !== true) {
|
||||
setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
_z = {
|
||||
tools: _tools,
|
||||
view: _view,
|
||||
event: _event,
|
||||
data: _data
|
||||
};
|
||||
$.extend(true, $.fn.zTree.consts, _consts);
|
||||
$.extend(true, $.fn.zTree._z, _z);
|
||||
|
||||
var zt = $.fn.zTree,
|
||||
tools = zt._z.tools,
|
||||
consts = zt.consts,
|
||||
view = zt._z.view,
|
||||
data = zt._z.data,
|
||||
event = zt._z.event,
|
||||
$$ = tools.$;
|
||||
|
||||
data.exSetting(_setting);
|
||||
data.addInitBind(_bindEvent);
|
||||
data.addInitUnBind(_unbindEvent);
|
||||
data.addInitCache(_initCache);
|
||||
data.addInitNode(_initNode);
|
||||
data.addInitProxy(_eventProxy, true);
|
||||
data.addInitRoot(_initRoot);
|
||||
data.addBeforeA(_beforeA);
|
||||
data.addZTreeTools(_zTreeTools);
|
||||
|
||||
var _createNodes = view.createNodes;
|
||||
view.createNodes = function(setting, level, nodes, parentNode, index) {
|
||||
if (_createNodes) _createNodes.apply(view, arguments);
|
||||
if (!nodes) return;
|
||||
view.repairParentChkClassWithSelf(setting, parentNode);
|
||||
}
|
||||
var _removeNode = view.removeNode;
|
||||
view.removeNode = function(setting, node) {
|
||||
var parentNode = node.getParentNode();
|
||||
if (_removeNode) _removeNode.apply(view, arguments);
|
||||
if (!node || !parentNode) return;
|
||||
view.repairChkClass(setting, parentNode);
|
||||
view.repairParentChkClass(setting, parentNode);
|
||||
}
|
||||
|
||||
var _appendNodes = view.appendNodes;
|
||||
view.appendNodes = function(setting, level, nodes, parentNode, index, initFlag, openFlag) {
|
||||
var html = "";
|
||||
if (_appendNodes) {
|
||||
html = _appendNodes.apply(view, arguments);
|
||||
}
|
||||
if (parentNode) {
|
||||
data.makeChkFlag(setting, parentNode);
|
||||
}
|
||||
return html;
|
||||
}
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,378 @@
|
||||
/*-------------------------------------
|
||||
zTree Style
|
||||
|
||||
version: 3.4
|
||||
author: Hunter.z
|
||||
email: hunter.z@263.net
|
||||
website: http://code.google.com/p/jquerytree/
|
||||
|
||||
-------------------------------------*/
|
||||
.ztree * {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
font-family: Verdana, Arial, Helvetica, AppleGothic, sans-serif
|
||||
}
|
||||
|
||||
.ztree {
|
||||
margin: 0;
|
||||
padding: 5px;
|
||||
color: #333
|
||||
}
|
||||
|
||||
.ztree li {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
list-style: none;
|
||||
line-height: 17px;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
outline: 0
|
||||
}
|
||||
|
||||
.ztree li ul {
|
||||
margin: 0;
|
||||
padding: 0 0 0 18px
|
||||
}
|
||||
|
||||
.ztree li ul.line {
|
||||
background: url(./img/line_conn.png) 0 0 repeat-y;
|
||||
}
|
||||
|
||||
.ztree li a {
|
||||
padding-right: 3px;
|
||||
margin: 0;
|
||||
cursor: pointer;
|
||||
height: 21px;
|
||||
color: #333;
|
||||
background-color: transparent;
|
||||
text-decoration: none;
|
||||
vertical-align: top;
|
||||
display: inline-block
|
||||
}
|
||||
|
||||
.ztree li a:hover {
|
||||
text-decoration: underline
|
||||
}
|
||||
|
||||
.ztree li a.curSelectedNode {
|
||||
padding-top: 0px;
|
||||
background-color: #e5e5e5;
|
||||
color: black;
|
||||
height: 21px;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.ztree li a.curSelectedNode_Edit {
|
||||
padding-top: 0px;
|
||||
background-color: #e5e5e5;
|
||||
color: black;
|
||||
height: 21px;
|
||||
border: 1px #666 solid;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.ztree li a.tmpTargetNode_inner {
|
||||
padding-top: 0px;
|
||||
background-color: #aaa;
|
||||
color: white;
|
||||
height: 21px;
|
||||
border: 1px #666 solid;
|
||||
opacity: 0.8;
|
||||
filter: alpha(opacity=80)
|
||||
}
|
||||
|
||||
.ztree li a.tmpTargetNode_prev {}
|
||||
|
||||
.ztree li a.tmpTargetNode_next {}
|
||||
|
||||
.ztree li a input.rename {
|
||||
height: 14px;
|
||||
width: 80px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
border: 1px #585956 solid;
|
||||
*border: 0px
|
||||
}
|
||||
|
||||
.ztree li span {
|
||||
line-height: 21px;
|
||||
margin-right: 2px
|
||||
}
|
||||
|
||||
.ztree li span.button {
|
||||
line-height: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 21px;
|
||||
height: 21px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
border: 0 none;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
background-color: transparent;
|
||||
background-repeat: no-repeat;
|
||||
background-attachment: scroll;
|
||||
background-image: url("./img/bootstrap.png");
|
||||
}
|
||||
|
||||
.ztree li span.button.chk {
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
margin: 0 2px;
|
||||
cursor: auto
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_false_full {
|
||||
background-position: -5px -5px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_false_full_focus {
|
||||
background-position: -5px -26px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_false_part {
|
||||
background-position: -5px -48px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_false_part_focus {
|
||||
background-position: -5px -68px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_false_disable {
|
||||
background-position: -5px -89px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_true_full {
|
||||
background-position: -26px -5px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_true_full_focus {
|
||||
background-position: -26px -26px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_true_part {
|
||||
background-position: -26px -48px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_true_part_focus {
|
||||
background-position: -26px -68px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.checkbox_true_disable {
|
||||
background-position: -26px -89px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_false_full {
|
||||
background-position: -47px -5px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_false_full_focus {
|
||||
background-position: -47px -26px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_false_part {
|
||||
background-position: -47px -47px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_false_part_focus {
|
||||
background-position: -47px -68px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_false_disable {
|
||||
background-position: -47px -89px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_true_full {
|
||||
background-position: -68px -5px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_true_full_focus {
|
||||
background-position: -68px -26px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_true_part {
|
||||
background-position: -68px -47px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_true_part_focus {
|
||||
background-position: -68px -68px;
|
||||
}
|
||||
|
||||
.ztree li span.button.chk.radio_true_disable {
|
||||
background-position: -68px -89px;
|
||||
}
|
||||
|
||||
.ztree li span.button.switch {
|
||||
width: 21px;
|
||||
height: 21px
|
||||
}
|
||||
|
||||
.ztree li span.button.root_open {
|
||||
background-position: -105px -63px
|
||||
}
|
||||
|
||||
.ztree li span.button.root_close {
|
||||
background-position: -126px -63px
|
||||
}
|
||||
|
||||
.ztree li span.button.roots_open {
|
||||
background-position: -105px 0;
|
||||
}
|
||||
|
||||
.ztree li span.button.roots_close {
|
||||
background-position: -126px 0;
|
||||
}
|
||||
|
||||
.ztree li span.button.center_open {
|
||||
background-position: -105px -21px;
|
||||
}
|
||||
|
||||
.ztree li span.button.center_close {
|
||||
background-position: -126px -21px;
|
||||
}
|
||||
|
||||
.ztree li span.button.bottom_open {
|
||||
background-position: -105px -42px;
|
||||
}
|
||||
|
||||
.ztree li span.button.bottom_close {
|
||||
background-position: -126px -42px;
|
||||
}
|
||||
|
||||
.ztree li span.button.noline_open {
|
||||
background-position: -105px -84px;
|
||||
}
|
||||
|
||||
.ztree li span.button.noline_close {
|
||||
background-position: -126px -84px;
|
||||
}
|
||||
|
||||
.ztree li span.button.root_docu {
|
||||
background-position: -105px -63px;
|
||||
}
|
||||
|
||||
.ztree li span.button.roots_docu {
|
||||
background-position: -84px 0;
|
||||
}
|
||||
|
||||
.ztree li span.button.center_docu {
|
||||
background-position: -84px -21px;
|
||||
}
|
||||
|
||||
.ztree li span.button.bottom_docu {
|
||||
background-position: -84px -42px;
|
||||
}
|
||||
|
||||
.ztree li span.button.noline_docu {
|
||||
background: none;
|
||||
}
|
||||
|
||||
.ztree li span.button.ico_open {
|
||||
margin-right: 2px;
|
||||
background-position: -147px -21px;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.ico_close {
|
||||
margin-right: 2px;
|
||||
margin-right: 2px;
|
||||
background-position: -147px 0;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.ico_docu {
|
||||
margin-right: 2px;
|
||||
background-position: -147px -43px;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.edit {
|
||||
margin-left: 2px;
|
||||
margin-right: -1px;
|
||||
background-position: -189px -21px;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.edit:hover {
|
||||
background-position: -168px -21px;
|
||||
}
|
||||
|
||||
.ztree li span.button.remove {
|
||||
margin-left: 2px;
|
||||
margin-right: -1px;
|
||||
background-position: -189px -42px;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.remove:hover {
|
||||
background-position: -168px -42px;
|
||||
}
|
||||
|
||||
.ztree li span.button.add {
|
||||
margin-left: 2px;
|
||||
margin-right: -1px;
|
||||
background-position: -189px 0;
|
||||
vertical-align: top;
|
||||
*vertical-align: middle
|
||||
}
|
||||
|
||||
.ztree li span.button.add:hover {
|
||||
background-position: -168px 0;
|
||||
}
|
||||
|
||||
ul.tmpTargetzTree {
|
||||
background-color: #FFE6B0;
|
||||
opacity: 0.8;
|
||||
filter: alpha(opacity=80)
|
||||
}
|
||||
|
||||
span.tmpzTreeMove_arrow {
|
||||
width: 16px;
|
||||
height: 21px;
|
||||
display: inline-block;
|
||||
padding: 0;
|
||||
margin: 2px 0 0 1px;
|
||||
border: 0 none;
|
||||
position: absolute;
|
||||
background-color: transparent;
|
||||
background-repeat: no-repeat;
|
||||
background-attachment: scroll;
|
||||
background-position: -168px -84px;
|
||||
background-image: url("./img/bootstrap.png");
|
||||
z-index: 10000;
|
||||
}
|
||||
|
||||
span.tmpzTreeMove_prev {
|
||||
background: red;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ul.ztree.zTreeDragUL {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
width: auto;
|
||||
height: auto;
|
||||
overflow: hidden;
|
||||
background-color: #cfcfcf;
|
||||
border: 1px #00B83F dotted;
|
||||
opacity: 0.8;
|
||||
filter: alpha(opacity=80)
|
||||
}
|
||||
|
||||
.ztreeMask {
|
||||
z-index: 10000;
|
||||
background-color: #cfcfcf;
|
||||
opacity: 0.0;
|
||||
filter: alpha(opacity=0);
|
||||
position: absolute
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
.ztree li span.button {background-image:url("./img/bootstrap3.png");}
|
||||
span.tmpzTreeMove_arrow {background-image:url("./img/bootstrap3.png");}
|
||||
|
||||
|
After Width: | Height: | Size: 542 KiB |
|
After Width: | Height: | Size: 186 KiB |
@@ -0,0 +1 @@
|
||||
import"./main-BQpkDb67.js";
|
||||
@@ -76,8 +76,14 @@ export default {
|
||||
'SysGroup.sortChildren': ['POST', '/api/sysgroup/SortChildren'],
|
||||
'SysUser.add': ['POST', '/api/sysuser/Add'],
|
||||
'SysUser.delete': ['POST', '/api/sysuser/Delete/{id}'],
|
||||
'SysUser.deleteFromGroup': ['POST', '/api/sysuser/DeleteFromGroup/{userId}/{groupId}'],
|
||||
'SysUser.batchDelete': ['POST', '/api/sysuser/BatchDelete'],
|
||||
'SysUser.disable': ['POST', '/api/sysuser/Disable/{id}'],
|
||||
'SysUser.edit': ['POST', '/api/sysuser/Edit/{id}'],
|
||||
'SysUser.enable': ['POST', '/api/sysuser/Enable/{id}'],
|
||||
'SysUser.list': ['GET', '/api/sysuser/List']
|
||||
'SysUser.list': ['GET', '/api/sysuser/List'],
|
||||
'SysUser.getGroups': ['GET', '/api/sysuser/Groups/{userId}'],
|
||||
'SysUser.changeGroups': ['POST', '/api/sysuser/ChangeGroups'],
|
||||
'SysUser.changeSortNo': ['POST', '/api/sysuser/ChangeSortNo/{userId}'],
|
||||
'SysUser.batchChangeStatus': ['POST', '/api/sysuser/BatchChangeStatus']
|
||||
};
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
<div class="tree-body">
|
||||
<MyTree v-if="!treeLoading" ref="refMyTree" :autoClick="autoClick" :treeData="treeData"
|
||||
:setting="treeSetting" @on-tree-click="treeLink" />
|
||||
:setting="treeSetting" :isCheck="checkable" @on-tree-click="treeLink"
|
||||
@on-tree-check="(node: any) => emit('on-tree-check', node)" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -39,17 +40,20 @@ const props = withDefaults(defineProps<{
|
||||
showCloseButton?: boolean;
|
||||
searchPlaceholder?: string;
|
||||
cacheKey?: string;
|
||||
checkable?: boolean;
|
||||
}>(), {
|
||||
autoClick: false,
|
||||
defaultSearchVisible: true,
|
||||
showCloseButton: false,
|
||||
searchPlaceholder: '输入组名称搜索',
|
||||
cacheKey: DEFAULT_CACHE_KEY,
|
||||
checkable: false,
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
'on-change': [treeNode: any]
|
||||
'on-tree-data': [tree: any[]]
|
||||
'on-tree-check': [treeNode: any]
|
||||
}>()
|
||||
|
||||
const curTreeNode = defineModel<any>('curTreeNode', { default: {} })
|
||||
@@ -63,7 +67,7 @@ const searchVisible = ref(props.defaultSearchVisible)
|
||||
const treeSetting = ref({
|
||||
view: { dblClickExpand: false, showIcon: false },
|
||||
edit: { enable: false, showRemoveBtn: false, showRenameBtn: false, drag: false },
|
||||
check: { enable: false },
|
||||
check: { enable: props.checkable, chkboxType: { Y: '', N: '' } },
|
||||
callback: {},
|
||||
})
|
||||
|
||||
@@ -207,6 +211,14 @@ function getNodeById(id: number) {
|
||||
return refMyTree.value?.getNodeById(id);
|
||||
}
|
||||
|
||||
function getCheckedNodes() {
|
||||
return refMyTree.value?.getCheckedNodes() || [];
|
||||
}
|
||||
|
||||
function checkNodeById(id: number, checked: boolean) {
|
||||
refMyTree.value?.checkNodeById(id, checked);
|
||||
}
|
||||
|
||||
function addNote(pid: number, id: number, name: string, isParent?: boolean, children?: any[]) {
|
||||
refMyTree.value?.addNote(pid, id, name, isParent, children);
|
||||
}
|
||||
@@ -241,6 +253,8 @@ defineExpose({
|
||||
removeNode,
|
||||
renameNode,
|
||||
getNodeById,
|
||||
getCheckedNodes,
|
||||
checkNodeById,
|
||||
addNote,
|
||||
openTree,
|
||||
})
|
||||
|
||||
@@ -141,6 +141,12 @@ export default {
|
||||
var node = treeObj.getNodesByFilter(node => node.id == id, true);
|
||||
return node;
|
||||
},
|
||||
getCheckedNodes() {
|
||||
const _domId = this.domId;
|
||||
var treeObj = $.fn.zTree.getZTreeObj(_domId);
|
||||
if (!treeObj) return [];
|
||||
return treeObj.getCheckedNodes(true);
|
||||
},
|
||||
// 仅更新节点勾选状态,不级联、不触发 onCheck 回调
|
||||
checkNodeById(id, checked) {
|
||||
const _domId = this.domId;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</Table>
|
||||
|
||||
<div class="page-panel">
|
||||
<div class="fl ml-15 align-middle">
|
||||
<div class="fl align-middle">
|
||||
<slot :checkList="selectList" />
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
<template>
|
||||
<Modal v-model="visible" :title="title" :width="720" :mask-closable="false" :loading="submitting"
|
||||
@on-visible-change="onVisibleChange">
|
||||
<div class="adjust-group-body">
|
||||
<div class="left-panel">
|
||||
<div class="panel-title">待选:</div>
|
||||
<div class="tree-wrap">
|
||||
<GroupTreeSearchPanel ref="treePanelRef" :treeApi="treeApi" :checkable="true"
|
||||
:defaultSearchVisible="true" :showCloseButton="false" searchPlaceholder="输入组名称搜索"
|
||||
@on-tree-data="onTreeData" @on-tree-check="onTreeCheck" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="right-panel">
|
||||
<div class="panel-title">已选:</div>
|
||||
<div class="selected-wrap">
|
||||
<div v-if="selectedGroupIds.length === 0" class="empty-tip">暂无已选组</div>
|
||||
<div v-else class="selected-list">
|
||||
<div v-for="id in selectedGroupIds" :key="id" class="selected-item">
|
||||
<div class="item-main">
|
||||
<span class="item-name">{{ nodeMap[id]?.name || id }}</span>
|
||||
<span class="item-path">{{ pathMap[id] || '' }}</span>
|
||||
</div>
|
||||
<Icon type="md-trash" class="item-delete" @click="removeGroup(id)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<Button type="primary" :loading="submitting" @click="handleSubmit">提交</Button>
|
||||
<Button @click="visible = false">取消</Button>
|
||||
</template>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, nextTick } from "vue";
|
||||
import { Message } from "view-ui-plus";
|
||||
import GroupTreeSearchPanel from '@/components/GroupTreeSearchPanel.vue'
|
||||
|
||||
defineOptions({ name: "AdjustGroupContainer" });
|
||||
|
||||
const visible = ref(false);
|
||||
const submitting = ref(false);
|
||||
const userIds = ref<number[]>([]);
|
||||
const userName = ref('');
|
||||
const treeData = ref<any[]>([]);
|
||||
const selectedGroupIds = ref<number[]>([]);
|
||||
const nodeMap = ref<Record<number, any>>({});
|
||||
const pathMap = ref<Record<number, string>>({});
|
||||
const pendingGroupIds = ref<number[] | null>(null);
|
||||
|
||||
let onSuccessCallback: (() => void) | null = null;
|
||||
|
||||
const treePanelRef = ref<InstanceType<typeof GroupTreeSearchPanel> | null>(null);
|
||||
|
||||
const title = computed(() => {
|
||||
if (userIds.value.length === 1) return `调整组:${userName.value || ''}`;
|
||||
return `调整组:已选 ${userIds.value.length} 人`;
|
||||
});
|
||||
|
||||
function treeApi() {
|
||||
return Promise.resolve(treeData.value || []);
|
||||
}
|
||||
|
||||
function buildNodeMap(list: any[], path = '') {
|
||||
list.forEach((n: any) => {
|
||||
const curPath = path ? `${path}/${n.name}` : n.name;
|
||||
nodeMap.value[n.id] = n;
|
||||
pathMap.value[n.id] = curPath;
|
||||
if (n.children?.length) buildNodeMap(n.children, curPath);
|
||||
});
|
||||
}
|
||||
|
||||
function onTreeData(tree: any[]) {
|
||||
buildNodeMap(tree || []);
|
||||
if (userIds.value.length === 1 && pendingGroupIds.value) {
|
||||
initSelected(pendingGroupIds.value);
|
||||
pendingGroupIds.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadUserGroups(userId: number) {
|
||||
try {
|
||||
const groupIds: number[] = await Apis.SysUser.getGroups({ pathParams: { userId }, cacheFor: null });
|
||||
if (treeData.value?.length) {
|
||||
initSelected(groupIds || []);
|
||||
} else {
|
||||
pendingGroupIds.value = groupIds || [];
|
||||
}
|
||||
} catch (e: any) {
|
||||
Message.error(e?.message || '加载用户所在组失败');
|
||||
}
|
||||
}
|
||||
|
||||
function initSelected(groupIds: number[]) {
|
||||
const existIds = groupIds.filter(id => nodeMap.value[id]);
|
||||
selectedGroupIds.value = existIds;
|
||||
nextTick(() => {
|
||||
existIds.forEach(id => treePanelRef.value?.checkNodeById(id, true));
|
||||
});
|
||||
}
|
||||
|
||||
// 勾选/取消勾选即同步右侧:勾选则加入,取消则移除
|
||||
function onTreeCheck() {
|
||||
const checked = treePanelRef.value?.getCheckedNodes() || [];
|
||||
selectedGroupIds.value = checked.map((n: any) => Number(n.id));
|
||||
}
|
||||
|
||||
function removeGroup(id: number) {
|
||||
selectedGroupIds.value = selectedGroupIds.value.filter(x => x !== id);
|
||||
treePanelRef.value?.checkNodeById(id, false);
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (selectedGroupIds.value.length === 0) {
|
||||
Message.error('一个人至少要有一个组');
|
||||
return;
|
||||
}
|
||||
submitting.value = true;
|
||||
try {
|
||||
await Apis.SysUser.changeGroups({
|
||||
data: { userIds: userIds.value, groupIds: selectedGroupIds.value }
|
||||
});
|
||||
Message.success('调整成功');
|
||||
visible.value = false;
|
||||
onSuccessCallback?.();
|
||||
} catch (e: any) {
|
||||
Message.error(e?.message || '调整失败');
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onVisibleChange(show: boolean) {
|
||||
if (!show) {
|
||||
selectedGroupIds.value = [];
|
||||
pendingGroupIds.value = null;
|
||||
treeData.value = [];
|
||||
nodeMap.value = {};
|
||||
pathMap.value = {};
|
||||
}
|
||||
}
|
||||
|
||||
function open(ids: number[], users: any[], tree: any[], onSuccess?: () => void) {
|
||||
if (!ids?.length) {
|
||||
Message.error('请选择待调整用户');
|
||||
return;
|
||||
}
|
||||
userIds.value = ids;
|
||||
userName.value = users?.[0]?.realName || users?.[0]?.account || '';
|
||||
treeData.value = tree || [];
|
||||
selectedGroupIds.value = [];
|
||||
pendingGroupIds.value = null;
|
||||
nodeMap.value = {};
|
||||
pathMap.value = {};
|
||||
onSuccessCallback = onSuccess || null;
|
||||
visible.value = true;
|
||||
|
||||
nextTick(() => {
|
||||
treePanelRef.value?.loadTree();
|
||||
if (ids.length === 1) {
|
||||
loadUserGroups(ids[0]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
defineExpose({ open, visible });
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.adjust-group-body {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
height: 420px;
|
||||
gap: 12px;
|
||||
|
||||
.left-panel,
|
||||
.right-panel {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.panel-title {
|
||||
padding: 10px 12px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.tree-wrap,
|
||||
.selected-wrap {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
text-align: center;
|
||||
color: #999;
|
||||
padding-top: 60px;
|
||||
}
|
||||
|
||||
.selected-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.selected-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 4px;
|
||||
background: #fff;
|
||||
|
||||
&:hover {
|
||||
background: #f5f7fa;
|
||||
}
|
||||
}
|
||||
|
||||
.item-main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.item-name {
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.item-path {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.item-delete {
|
||||
font-size: 18px;
|
||||
color: #ed4014;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
margin-left: 8px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -345,6 +345,7 @@ onMounted(async () => {
|
||||
|
||||
<style lang="scss">
|
||||
.group-user-tree {
|
||||
width: 300px !important;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="page-wrapper tree-wrapper">
|
||||
<div class="page-wrapper tree-wrapper group-user-page">
|
||||
<Group class="tree-container" v-model:curTreeNode="selectedNode" :treeApi="treeApi" @on-change="onTreeChange"
|
||||
@on-tree-data="onTreeData" />
|
||||
<div class="main-container">
|
||||
@@ -7,22 +7,59 @@
|
||||
<Button type="primary" @click="showAddUser">
|
||||
<Icon type="md-add" style="margin-right: 4px" />新增用户
|
||||
</Button>
|
||||
<Button type="success" class="ml-15" @click="showImportUser">批量导入</Button>
|
||||
<Button class="ml-15" @click="onExport">导出组用户</Button>
|
||||
|
||||
<Input placeholder="输入用户名 / 真实姓名搜索" class="fr" search clearable suffix="ios-search" style="width: 220px"
|
||||
v-model="keyword" @on-search="onSearch" @on-clear="onSearch" />
|
||||
v-model="keyword" @on-search="onSearch" @on-clear="onClear" />
|
||||
</div>
|
||||
|
||||
<TablePageAlovaNew ref="tableRef" :dataApi="tableApi" :columns="columns" :tableHeight="tableHeight" />
|
||||
<TablePageAlovaNew ref="tableRef" :dataApi="tableApi" :columns="columns" :tableHeight="tableHeight">
|
||||
<template #default="{ checkList }">
|
||||
<Button type="primary" ghost @click="openAdjust(checkList)">调整组</Button>
|
||||
<Button type="warning" class="ml-15" :disabled="!checkList?.length" @click="openBatchStatus(checkList)">设置状态</Button>
|
||||
<Button type="error" class="ml-15" :disabled="!checkList?.length" @click="openBatchDelete(checkList)">批量删除</Button>
|
||||
</template>
|
||||
</TablePageAlovaNew>
|
||||
|
||||
<!-- 容器组件:新增 / 编辑 -->
|
||||
<!-- 容器组件:新增 / 编辑 / 调整组 / 批量导入 -->
|
||||
<AddUserContainer ref="addRef" />
|
||||
<EditUserContainer ref="editRef" />
|
||||
<AdjustGroupContainer ref="adjustRef" />
|
||||
<BatchImportUser v-model="importModal" :current-group-id="selectedNode?.id" @success="onImportSuccess" />
|
||||
<UserSort v-model:visible="sortModal" :user-id="sortRow?.id ?? null"
|
||||
:user-account="sortRow?.account || sortRow?.realName || ''"
|
||||
:current-sort-no="sortRow?.sortNo ?? null" :group-id="selectedNode?.id ?? null" @saved="onSortSaved" />
|
||||
|
||||
<!-- 批量设置用户状态 -->
|
||||
<Modal v-model="statusModal" title="设置用户的状态" :width="520" :mask-closable="false">
|
||||
<div class="batch-status-body">
|
||||
<div class="user-list-row">
|
||||
<span class="user-list-label">需设置用户:</span>
|
||||
<ul class="user-list">
|
||||
<li v-for="item in statusSelectedRows" :key="item.id">{{ item.realName || item.account }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="status-radio-row">
|
||||
<span class="status-label">选择设置状态:</span>
|
||||
<RadioGroup v-model="statusValue" type="button">
|
||||
<Radio :label="0">正常</Radio>
|
||||
<Radio :label="1">禁用</Radio>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<Button type="primary" :loading="statusSubmitting" @click="confirmBatchStatus">确定</Button>
|
||||
<Button @click="statusModal = false">取消</Button>
|
||||
</template>
|
||||
</Modal>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed } from "vue";
|
||||
import { Message } from "view-ui-plus";
|
||||
import useCurrentInstance from "@/utils/hook/useCurrentInstance";
|
||||
import MyConfirm from "@/components/MyConfirm";
|
||||
import TablePageAlovaNew from '@/components/TablePageAlovaNew.vue';
|
||||
@@ -30,10 +67,13 @@ import { OperatorEnum } from '@/types';
|
||||
import Group from './group/index.vue'
|
||||
import AddUserContainer from './user/AddUserContainer.vue';
|
||||
import EditUserContainer from './user/EditUserContainer.vue';
|
||||
import AdjustGroupContainer from './AdjustGroupContainer.vue';
|
||||
import BatchImportUser from './user/BatchImportUser.vue';
|
||||
import UserSort from './user/UserSort.vue';
|
||||
|
||||
defineOptions({ name: "GroupUser" });
|
||||
|
||||
const { $utils } = useCurrentInstance();
|
||||
const { $utils, $conf } = useCurrentInstance();
|
||||
|
||||
const treeApi = () => Apis.SysGroup.getTree();
|
||||
|
||||
@@ -44,6 +84,7 @@ const treeData = ref<any[]>([])
|
||||
function onTreeChange(node: any) {
|
||||
selectedNode.value = node;
|
||||
dataParams.value.groupId = node?.id ?? null;
|
||||
dataParams.value.withSub = 0;
|
||||
tableRef.value?.refreshData();
|
||||
}
|
||||
function onTreeData(tree: any[]) {
|
||||
@@ -51,6 +92,16 @@ function onTreeData(tree: any[]) {
|
||||
}
|
||||
function onSearch() {
|
||||
dataParams.value.name = keyword.value.trim() || undefined;
|
||||
// 手动搜索:包含子组用户
|
||||
dataParams.value.withSub = 1;
|
||||
tableRef.value?.refreshData();
|
||||
}
|
||||
|
||||
function onClear() {
|
||||
keyword.value = '';
|
||||
dataParams.value.name = undefined;
|
||||
// 取消搜索:回到仅当前组浏览
|
||||
dataParams.value.withSub = 0;
|
||||
tableRef.value?.refreshData();
|
||||
}
|
||||
|
||||
@@ -73,9 +124,12 @@ const keyword = ref('')
|
||||
const dataParams = ref<{
|
||||
name: string | undefined;
|
||||
groupId: number | null;
|
||||
withSub: number;
|
||||
}>({
|
||||
name: undefined,
|
||||
groupId: null,
|
||||
// 默认仅当前组;仅手动搜索时才包含子组
|
||||
withSub: 0,
|
||||
});
|
||||
|
||||
const tableApi = (params: { pageIndex: number; pageSize: number }) => {
|
||||
@@ -83,8 +137,8 @@ const tableApi = (params: { pageIndex: number; pageSize: number }) => {
|
||||
params: {
|
||||
name: dataParams.value.name,
|
||||
groupId: dataParams.value.groupId ?? undefined,
|
||||
// 选中组织时包含子组用户;未选中时不传
|
||||
withSub: dataParams.value.groupId != null ? 1 : undefined,
|
||||
// 默认仅当前组;手动搜索时置 1 才包含子组
|
||||
withSub: dataParams.value.withSub,
|
||||
pageIndex: params.pageIndex,
|
||||
pageSize: params.pageSize,
|
||||
},
|
||||
@@ -119,6 +173,7 @@ function describeRoles(roles: any): string {
|
||||
|
||||
/* ================= 表格列 ================= */
|
||||
const columns = [
|
||||
{ type: 'selection', width: 55, align: 'center' },
|
||||
{ type: 'index', title: '序号', width: 70, align: 'center' },
|
||||
{ title: '用户名', key: 'account', minWidth: 120 },
|
||||
{ title: '真实姓名', key: 'realName', minWidth: 120 },
|
||||
@@ -133,6 +188,10 @@ const columns = [
|
||||
h('Tag', { color: row.disabled ? 'default' : 'success' },
|
||||
row.disabled ? '已禁用' : '启用'),
|
||||
},
|
||||
{
|
||||
title: '排序号', key: 'sortNo', width: 90, align: 'center',
|
||||
render: (h: any, { row }: any) => h('span', row.sortNo == null ? '-' : row.sortNo),
|
||||
},
|
||||
{
|
||||
title: '操作', key: 'action', width: 220, align: 'center', fixed: 'right' as const,
|
||||
render: (h: any, { row }: any) => {
|
||||
@@ -141,20 +200,51 @@ const columns = [
|
||||
style: { marginRight: '8px', color: '#577afb' },
|
||||
onClick: () => handleEdit(row),
|
||||
}, '编辑'),
|
||||
];
|
||||
// 仅「单组浏览」(withSub=0)时开放排序:此时每个用户都直接属于当前组,排序号语义明确;
|
||||
// 含子组搜索(withSub=1)下用户可能属于子组,排序号归属不清,故隐藏。
|
||||
if (dataParams.value.withSub === 0) {
|
||||
opList.push(
|
||||
h('a', {
|
||||
style: { marginRight: '8px', color: '#2d8cf0' },
|
||||
onClick: () => openSort(row),
|
||||
}, '排序'),
|
||||
);
|
||||
}
|
||||
opList.push(
|
||||
h('a', {
|
||||
style: { marginRight: '8px', color: '#ed4014' },
|
||||
style: { color: '#ed4014' },
|
||||
onClick: () => handleDelete(row),
|
||||
}, '删除'),
|
||||
h('a', {
|
||||
style: { color: row.disabled ? '#19be6b' : '#ff9900' },
|
||||
onClick: () => handleToggleStatus(row),
|
||||
}, row.disabled ? '启用' : '禁用'),
|
||||
];
|
||||
);
|
||||
return h('div', opList);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
/* ================= 导出组用户 ================= */
|
||||
function onExport() {
|
||||
const gid = selectedNode.value?.id ?? null;
|
||||
if (gid == null) {
|
||||
Message.warning('请先选择要导出的组');
|
||||
return;
|
||||
}
|
||||
const params = new URLSearchParams();
|
||||
params.set('groupId', String(gid));
|
||||
params.set('withSub', '1');
|
||||
if (dataParams.value.name) params.set('name', dataParams.value.name);
|
||||
window.open(`${$conf.serviceHost}/api/sysuser/Export?${params.toString()}`);
|
||||
}
|
||||
|
||||
/* ================= 批量导入 ================= */
|
||||
const importModal = ref(false);
|
||||
function showImportUser() {
|
||||
importModal.value = true;
|
||||
}
|
||||
function onImportSuccess() {
|
||||
tableRef.value?.reloadData(OperatorEnum.sel);
|
||||
}
|
||||
|
||||
/* ================= 新增 ================= */
|
||||
const addRef = ref();
|
||||
function showAddUser() {
|
||||
@@ -172,14 +262,32 @@ function handleEdit(row: any) {
|
||||
});
|
||||
}
|
||||
|
||||
/* ================= 删除 ================= */
|
||||
/* ================= 调整组 ================= */
|
||||
const adjustRef = ref();
|
||||
function openAdjust(checkList: number[]) {
|
||||
if (!checkList?.length) {
|
||||
Message.error('请选择待调整用户!');
|
||||
return;
|
||||
}
|
||||
const rows = tableRef.value?.list.filter((r: any) => checkList.includes(r.id)) || [];
|
||||
adjustRef.value?.open(checkList, rows, treeData.value, () => {
|
||||
tableRef.value?.reloadData(OperatorEnum.sel);
|
||||
});
|
||||
}
|
||||
|
||||
/* ================= 删除(从当前组移除) ================= */
|
||||
async function handleDelete(row: any) {
|
||||
const gid = selectedNode.value?.id ?? null;
|
||||
if (gid == null) {
|
||||
Message.warning('请先选择组');
|
||||
return;
|
||||
}
|
||||
await MyConfirm({
|
||||
msg: `确定删除用户「${row.realName || row.account}」吗?`,
|
||||
info: '删除后不可恢复!',
|
||||
async onOk() {
|
||||
try {
|
||||
await Apis.SysUser.delete({ pathParams: { id: row.id } });
|
||||
await Apis.SysUser.deleteFromGroup({ pathParams: { userId: row.id, groupId: gid } });
|
||||
Message.success('删除成功!');
|
||||
tableRef.value?.reloadData(OperatorEnum.del);
|
||||
} catch (e: any) {
|
||||
@@ -189,26 +297,132 @@ async function handleDelete(row: any) {
|
||||
});
|
||||
}
|
||||
|
||||
/* ================= 禁用 / 启用 ================= */
|
||||
async function handleToggleStatus(row: any) {
|
||||
const isDisabled = !!row.disabled;
|
||||
/* ================= 批量删除 ================= */
|
||||
const batchDeleteSelected = ref<number[]>([]);
|
||||
async function openBatchDelete(checkList: number[]) {
|
||||
if (!checkList?.length) {
|
||||
Message.error('请选择待删除用户!');
|
||||
return;
|
||||
}
|
||||
batchDeleteSelected.value = checkList;
|
||||
const rows = tableRef.value?.list.filter((r: any) => checkList.includes(r.id)) || [];
|
||||
const names = rows.map((r: any) => r.realName || r.account).join(',');
|
||||
await MyConfirm({
|
||||
msg: `确定要${isDisabled ? '启用' : '禁用'}用户「${row.realName || row.account}」吗?`,
|
||||
msg: `确定删除用户「${names}」这些用户吗?`,
|
||||
info: '删除后不可恢复!',
|
||||
async onOk() {
|
||||
try {
|
||||
if (isDisabled) {
|
||||
await Apis.SysUser.enable({ pathParams: { id: row.id } });
|
||||
} else {
|
||||
await Apis.SysUser.disable({ pathParams: { id: row.id } });
|
||||
const gid = selectedNode.value?.id ?? null;
|
||||
if (gid == null) {
|
||||
Message.warning('请先选择组');
|
||||
return;
|
||||
}
|
||||
Message.success(isDisabled ? '已启用!' : '已禁用!');
|
||||
tableRef.value?.reloadData(OperatorEnum.sel);
|
||||
await Apis.SysUser.batchDelete({
|
||||
data: { userIds: batchDeleteSelected.value, groupId: gid }
|
||||
});
|
||||
Message.success('删除成功!');
|
||||
tableRef.value?.reloadData(OperatorEnum.del);
|
||||
} catch (e: any) {
|
||||
Message.error(e?.message || '操作失败');
|
||||
Message.error(e?.message || '删除失败');
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/* ================= 批量设置状态 ================= */
|
||||
const statusModal = ref(false);
|
||||
const statusSubmitting = ref(false);
|
||||
const statusValue = ref<number>(0);
|
||||
const statusSelectedRows = ref<any[]>([]);
|
||||
|
||||
function openBatchStatus(checkList: number[]) {
|
||||
if (!checkList?.length) {
|
||||
Message.error('请选择待设置用户!');
|
||||
return;
|
||||
}
|
||||
const rows = tableRef.value?.list.filter((r: any) => checkList.includes(r.id)) || [];
|
||||
statusSelectedRows.value = rows;
|
||||
// 默认以第一个选中用户当前状态作为默认选中项
|
||||
statusValue.value = rows[0]?.disabled ? 1 : 0;
|
||||
statusModal.value = true;
|
||||
}
|
||||
|
||||
async function confirmBatchStatus() {
|
||||
if (!statusSelectedRows.value.length) return;
|
||||
statusSubmitting.value = true;
|
||||
try {
|
||||
const userIds = statusSelectedRows.value.map(r => r.id);
|
||||
await Apis.SysUser.batchChangeStatus({
|
||||
data: { userIds, disabled: statusValue.value === 1 }
|
||||
});
|
||||
Message.success('设置成功!');
|
||||
statusModal.value = false;
|
||||
tableRef.value?.reloadData(OperatorEnum.sel);
|
||||
} catch (e: any) {
|
||||
Message.error(e?.message || '设置失败');
|
||||
} finally {
|
||||
statusSubmitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* ================= 组内排序 ================= */
|
||||
const sortModal = ref(false);
|
||||
const sortRow = ref<any>(null);
|
||||
function openSort(row: any) {
|
||||
sortRow.value = row;
|
||||
sortModal.value = true;
|
||||
}
|
||||
function onSortSaved() {
|
||||
tableRef.value?.reloadData(OperatorEnum.sel);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
<style lang="scss">
|
||||
.group-user-page .page-panel {
|
||||
left: 348px !important;
|
||||
}
|
||||
|
||||
.batch-status-body {
|
||||
padding: 8px 12px;
|
||||
|
||||
.user-list-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.user-list-label {
|
||||
flex-shrink: 0;
|
||||
color: #666;
|
||||
line-height: 22px;
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
.user-list {
|
||||
flex: 1;
|
||||
margin: 0;
|
||||
padding-left: 18px;
|
||||
color: #333;
|
||||
line-height: 22px;
|
||||
|
||||
li {
|
||||
margin-bottom: 6px;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.status-radio-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.status-label {
|
||||
flex-shrink: 0;
|
||||
color: #666;
|
||||
margin-right: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
<template>
|
||||
<Modal v-model="visible" title="批量导入用户" :mask-closable="false" :width="520" @on-visible-change="onVisibleChange">
|
||||
<div class="import-wrap">
|
||||
<div class="form-item">
|
||||
<a @click="downloadTemplate" href="javascript:;">点击链接下载[用户导入模板.xlsx]</a>
|
||||
</div>
|
||||
<div class="upload-panel">
|
||||
<Upload type="drag" :action="uploadUrl" :headers="uploadHeaders" :with-credentials="true"
|
||||
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
||||
:before-upload="beforeUpload" :on-success="onUploadSuccess" :on-error="onUploadError">
|
||||
<div class="upload-box">
|
||||
<Icon type="ios-cloud-upload" size="52" style="color: #6281eb"></Icon>
|
||||
<h4>选择要上传的文件</h4>
|
||||
<div class="info">支持扩展名:xls、xlsx;文件大小不超过 10MB</div>
|
||||
</div>
|
||||
</Upload>
|
||||
</div>
|
||||
<Alert v-if="resultMsg" :type="resultType" show-icon>
|
||||
<span v-html="resultMsg"></span>
|
||||
</Alert>
|
||||
<Alert v-else style="margin-bottom: 0" type="warning" show-icon>
|
||||
请按照模板格式填写,组 id 以第二列为准;左侧组名仅供参考。
|
||||
</Alert>
|
||||
</div>
|
||||
<template #footer>
|
||||
<Button @click="close">关闭</Button>
|
||||
</template>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from "vue";
|
||||
import { Message } from "view-ui-plus";
|
||||
import Utils from "@/utils";
|
||||
import { baseConfig } from "@/assets/config/api.config";
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean;
|
||||
currentGroupId?: number | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: boolean];
|
||||
'success': [];
|
||||
}>();
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (val) => emit('update:modelValue', val),
|
||||
});
|
||||
|
||||
const resultMsg = ref("");
|
||||
const resultType = ref<"success" | "error">("success");
|
||||
|
||||
const uploadUrl = computed(() => {
|
||||
const base = String(baseConfig.baseURL || "");
|
||||
return `${base.replace(/\/$/, "")}/api/sysuser/BatchImport`;
|
||||
});
|
||||
|
||||
const uploadHeaders = computed(() => {
|
||||
const roleInfo = Utils.getCurrentRoleInfo() || {} as any;
|
||||
return {
|
||||
yschapirequest: "1",
|
||||
schoolId: roleInfo.schId ?? "",
|
||||
};
|
||||
});
|
||||
|
||||
function close() {
|
||||
visible.value = false;
|
||||
}
|
||||
|
||||
function onVisibleChange(show: boolean) {
|
||||
if (!show) {
|
||||
resultMsg.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
const downloadUrl = computed(() => {
|
||||
const base = String(baseConfig.baseURL || "").replace(/\/$/, "");
|
||||
const gid = props.currentGroupId;
|
||||
return `${base}/api/sysuser/DownloadTemplate${gid ? `?groupId=${gid}` : ""}`;
|
||||
});
|
||||
|
||||
function downloadTemplate() {
|
||||
// 模板由后端生成真实 .xlsx(平铺当前组及子孙组),沿用 BschImport 的下载方式
|
||||
window.location.href = downloadUrl.value;
|
||||
}
|
||||
|
||||
function beforeUpload(file: File) {
|
||||
const isExcel = /\.(xls|xlsx)$/i.test(file.name);
|
||||
if (!isExcel) {
|
||||
Message.error("仅支持 xls/xlsx 格式的 Excel 文件");
|
||||
return false;
|
||||
}
|
||||
if (file.size > 10 * 1024 * 1024) {
|
||||
Message.error("文件大小不能超过 10MB");
|
||||
return false;
|
||||
}
|
||||
resultMsg.value = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
function onUploadSuccess(res: any) {
|
||||
// 后端可能把结果统一包装为 {code,msg,data},也可能直接返回 {total,success,fail,fails},两者都兼容。
|
||||
const wrapped = typeof res?.code === "number";
|
||||
const payload = wrapped && res.data && typeof res.data === "object" ? res.data : res;
|
||||
const code = res?.code;
|
||||
|
||||
// 包装体且业务码非 0 => 失败(含参数错误 code=4、业务错误等)
|
||||
if (wrapped && code !== 0) {
|
||||
resultType.value = "error";
|
||||
resultMsg.value = res?.msg || "导入失败";
|
||||
return;
|
||||
}
|
||||
|
||||
const total = Number(payload?.total ?? 0);
|
||||
const success = Number(payload?.success ?? 0);
|
||||
const fail = Number(payload?.fail ?? 0);
|
||||
const fails = Array.isArray(payload?.fails) ? payload.fails : [];
|
||||
|
||||
if (total === 0 && success === 0 && fail === 0) {
|
||||
// 极端兜底:返回结构异常
|
||||
resultType.value = "error";
|
||||
resultMsg.value = "导入返回结构异常,请联系管理员";
|
||||
return;
|
||||
}
|
||||
|
||||
resultType.value = "success";
|
||||
let msg = `导入完成:共 ${total} 条,成功 ${success} 条,失败 ${fail} 条。`;
|
||||
if (fail > 0 && fails.length) {
|
||||
const lines = fails.slice(0, 5).map((f: any) => `第 ${f.row} 行:${f.reason}`);
|
||||
if (fails.length > 5) lines.push(`…等 ${fails.length} 条`);
|
||||
msg += `<br/>失败明细:<br/>${lines.join("<br/>")}`;
|
||||
}
|
||||
resultMsg.value = msg;
|
||||
|
||||
if (fail === 0 && total > 0) {
|
||||
emit('success');
|
||||
}
|
||||
}
|
||||
|
||||
function onUploadError(err: any) {
|
||||
resultType.value = "error";
|
||||
// 包装体业务错误可能经由 on-error 返回(如 HTTP 非 200),优先取 msg
|
||||
const msg = err?.msg || (typeof err === "string" ? err : err?.message) || "上传失败,请检查网络或后端服务";
|
||||
resultMsg.value = msg;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.import-wrap {
|
||||
padding: 8px 0;
|
||||
|
||||
.form-item {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.upload-panel {
|
||||
.upload-box {
|
||||
background: #f7f8fc;
|
||||
padding: 28px 0;
|
||||
text-align: center;
|
||||
|
||||
h4 {
|
||||
color: #505c7e;
|
||||
margin: 8px 0 4px;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
|
||||
.info {
|
||||
font-size: 13px;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,88 @@
|
||||
<template>
|
||||
<Modal :model-value="props.visible" title="用户排序" :width="420" :mask-closable="false"
|
||||
@on-visible-change="onVisibleChange">
|
||||
<Alert show-icon>排序号为正整数,1 为最靠前,越大越靠后</Alert>
|
||||
<Form :model="form" :label-width="100">
|
||||
<FormItem label="当前排序号:">
|
||||
<span :style="{ color: props.currentSortNo == null ? '#999' : '#333' }">
|
||||
{{ props.currentSortNo == null ? '暂无' : props.currentSortNo }}
|
||||
</span>
|
||||
</FormItem>
|
||||
<FormItem label="当前用户:">
|
||||
<span>{{ props.userAccount || '-' }}</span>
|
||||
</FormItem>
|
||||
<FormItem label="修改排序号:">
|
||||
<InputNumber :max="999" :min="1" v-model="form.sortNo" :style="{ width: '140px' }" />
|
||||
</FormItem>
|
||||
</Form>
|
||||
|
||||
<template #footer>
|
||||
<Button type="primary" :loading="submitting" @click="handleSubmit">提交</Button>
|
||||
<Button @click="onVisibleChange(false)">取消</Button>
|
||||
</template>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref, watch } from "vue";
|
||||
import { Message } from "view-ui-plus";
|
||||
import Apis from "@/api";
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean;
|
||||
userId: number | null;
|
||||
userAccount: string;
|
||||
currentSortNo: number | null;
|
||||
groupId: number | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:visible': [value: boolean];
|
||||
saved: [];
|
||||
}>();
|
||||
|
||||
// 弹窗显示状态变化(点 X / ESC / 取消 都会触发 on-visible-change)一律回写父组件
|
||||
function onVisibleChange(v: boolean) {
|
||||
emit('update:visible', v);
|
||||
}
|
||||
|
||||
const form = reactive<{
|
||||
sortNo: number;
|
||||
}>({
|
||||
sortNo: 1,
|
||||
});
|
||||
|
||||
const submitting = ref(false);
|
||||
|
||||
// 每次打开弹窗:把输入框重置为「自身排序号,没有则默认 1」,不沿用上次输入
|
||||
watch(() => props.visible, (open) => {
|
||||
if (open) {
|
||||
form.sortNo = props.currentSortNo ?? 1;
|
||||
}
|
||||
});
|
||||
|
||||
async function handleSubmit() {
|
||||
if (form.sortNo == null) {
|
||||
Message.warning('请输入排序号(1~999)');
|
||||
return;
|
||||
}
|
||||
if (props.userId == null || props.groupId == null) {
|
||||
Message.warning('请先选择组与用户');
|
||||
return;
|
||||
}
|
||||
submitting.value = true;
|
||||
try {
|
||||
await Apis.SysUser.changeSortNo({
|
||||
pathParams: { userId: props.userId },
|
||||
data: { groupId: props.groupId, sortNo: form.sortNo },
|
||||
});
|
||||
Message.success('排序设置成功');
|
||||
emit('update:visible', false);
|
||||
emit('saved');
|
||||
} catch (e: any) {
|
||||
Message.error(e?.message || '排序设置失败');
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||