Update apply.html

This commit is contained in:
邹景立 2021-08-28 15:32:28 +08:00
parent 4bfb7c16c8
commit 2c65a07730

View File

@ -13,58 +13,58 @@
{block name="script"} {block name="script"}
<script> <script>
window.RoleAction = new function () { require(['jquery.ztree'], function () {
this.data = {}, this.ztree = null, this.setting = { new function () {
view: {showLine: false, showIcon: false, dblClickExpand: false}, var that = this;
check: {enable: true, nocheck: false, chkboxType: {"Y": "ps", "N": "ps"}}, this.data = {}, this.ztree = null, this.setting = {
callback: { view: {showLine: false, showIcon: false, dblClickExpand: false},
beforeClick: function (id, node) { check: {enable: true, nocheck: false, chkboxType: {"Y": "ps", "N": "ps"}}, callback: {
node.children.length < 1 ? RoleAction.ztree.checkNode(node, !node.checked, null, true) : RoleAction.ztree.expandNode(node); beforeClick: function (id, node) {
return false; node.children.length < 1 ? that.ztree.checkNode(node, !node.checked, null, true) : that.ztree.expandNode(node);
return false;
}
} }
} };
}; this.renderChildren = function (list, level) {
this.renderChildren = function (list, level) { var childrens = [];
var childrens = []; for (var i in list) childrens.push({
for (var i in list) childrens.push({ open: true, node: list[i].node, name: list[i].title || list[i].node,
open: true, node: list[i].node, name: list[i].title || list[i].node, checked: list[i].checked || false, children: this.renderChildren(list[i]._sub_, level + 1)
checked: list[i].checked || false, children: this.renderChildren(list[i]._sub_, level + 1)
});
return childrens;
};
this.getData = function (that) {
$.form.load('{:url("apply")}', {id: '{$vo.id}', action: 'get'}, 'post', function (ret) {
return (that.data = that.renderChildren(ret.data, 1)), that.showTree(), false;
});
};
this.showTree = function () {
this.ztree = $.fn.zTree.init($("#zTree"), this.setting, this.data);
while (true) {
var nodes = this.ztree.getNodesByFilter(function (node) {
return (!node.node && node.children.length < 1);
}); });
if (nodes.length < 1) break; return childrens;
for (var i in nodes) this.ztree.removeNode(nodes[i]); };
} this.getData = function () {
$.form.load('{:url("apply")}', {id: '{$vo.id}', action: 'get'}, 'post', function (ret) {
return (that.data = that.renderChildren(ret.data, 1)), that.showTree(), false;
});
};
this.showTree = function () {
this.ztree = $.fn.zTree.init($("#zTree"), this.setting, this.data);
while (true) {
var nodes = this.ztree.getNodesByFilter(function (node) {
return (!node.node && node.children.length < 1);
});
if (nodes.length < 1) break;
for (var i in nodes) this.ztree.removeNode(nodes[i]);
}
};
this.submit = function () {
var nodes = [], data = this.ztree.getCheckedNodes(true);
for (var i in data) if (data[i].node) nodes.push(data[i].node);
$.form.load('{:url("apply")}', {id: '{$vo.id}', action: 'save', nodes: nodes}, 'post');
};
// 刷新数据
this.getData();
// 提交表单
$('[data-submit-role]').on('click', function () {
that.submit();
});
}; };
this.submit = function () { });
var nodes = [], data = this.ztree.getCheckedNodes(true);
for (var i in data) if (data[i].node) nodes.push(data[i].node);
$.form.load('{:url("apply")}', {id: '{$vo.id}', action: 'save', nodes: nodes}, 'post');
};
// 刷新数据
this.getData(this);
// 提交表单
$('[data-submit-role]').on('click', function () {
RoleAction.submit();
});
};
</script> </script>
{/block} {/block}
{block name="style"} {block name="style"}
<link href="__ROOT__/static/plugs/ztree/zTreeStyle/zTreeStyle.css" rel="stylesheet">
<script src="__ROOT__/static/plugs/ztree/ztree.all.min.js"></script>
<style> <style>
ul.ztree li { ul.ztree li {
white-space: normal !important; white-space: normal !important;