Commit 3e606e98 authored by 雍欢's avatar 雍欢

1、添加/编辑功能的时候通过easy-search来选择菜单url(未完待续)

parent 53e5fba1
package com.huigou.uasp.bmp.opm.domain.model.resource;
import com.huigou.data.domain.model.AbstractEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* Spring MVC 请求地址。
*
* @author yonghuan
*/
@Table(name = "sa_oplink")
@Entity
public class Link extends AbstractEntity {
/**
* 地址
*/
private String url;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
package com.huigou.uasp.bmp.opm.repository.org;
import com.huigou.uasp.bmp.opm.domain.model.resource.Link;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @author yonghuan
*/
public interface LinkRepository extends JpaRepository<Link, String> {
}
package com.huigou.uasp.bmp.opm.application;
import com.huigou.uasp.bmp.opm.domain.model.resource.Link;
import java.util.List;
public interface LinkApplication {
void syncLinks(List<Link> links);
}
package com.huigou.uasp.bmp.opm.application.impl;
import com.huigou.uasp.bmp.opm.application.LinkApplication;
import com.huigou.uasp.bmp.opm.domain.model.resource.Link;
import com.huigou.uasp.bmp.opm.repository.org.LinkRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @author yonghuan
*/
@Service
public class LinkApplicationImpl implements LinkApplication {
private LinkRepository linkRepository;
@Autowired
public void setLinkRepository(LinkRepository linkRepository) {
this.linkRepository = linkRepository;
}
@Transactional(rollbackFor = RuntimeException.class)
@Override
public void syncLinks(List<Link> links) {
linkRepository.deleteAll();
linkRepository.save(links);
}
}
package com.huigou.uasp.bmp.opm.controller;
import com.huigou.uasp.annotation.ControllerMapping;
import com.huigou.uasp.bmp.opm.application.LinkApplication;
import com.huigou.uasp.bmp.opm.domain.model.resource.Link;
import com.huigou.uasp.client.CommonController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import java.util.Collections;
import java.util.List;
/**
* @author yonghuan
*/
@ControllerMapping("link")
@Controller
public class LinkController extends CommonController {
@Autowired
private LinkApplication linkApplication;
public String syncLinks() {
List<Link> links = Collections.emptyList();
linkApplication.syncLinks(links);
return success();
}
}
...@@ -119,8 +119,8 @@ ...@@ -119,8 +119,8 @@
<condition column="status" name="status" symbol="in" alias="t"/> <condition column="status" name="status" symbol="in" alias="t"/>
<condition column="is_virtual" name="isVirtual" symbol="in" alias="t"/> <condition column="is_virtual" name="isVirtual" symbol="in" alias="t"/>
<condition column="dept_level" name="deptLevel" symbol="=" alias="t"/> <condition column="dept_level" name="deptLevel" symbol="=" alias="t"/>
<condition column="full_id" name="orgRoot" symbol="like" alias="t"/>
<condition column="full_id" name="orgFullId" symbol="like" alias="t"/> <condition column="full_id" name="orgFullId" symbol="like" alias="t"/>
<condition column="full_id" name="orgRoot" symbol="like" alias="t"/>
</easy-search> </easy-search>
<easy-search name="orgSelectProxy" desc="代理人选择"> <easy-search name="orgSelectProxy" desc="代理人选择">
...@@ -305,4 +305,27 @@ ...@@ -305,4 +305,27 @@
<orderby>sequence</orderby> <orderby>sequence</orderby>
</easy-search> </easy-search>
<easy-search name="icon" desc="菜单图标">
<sql>
select t.id,
t.code,
t.html
from sa_opicon t
where 1=1
</sql>
<field name="图标" code="html" width="50"/>
<field name="编码" code="code" width="150"/>
</easy-search>
<easy-search name="link" desc="mvc请求处理地址">
<sql>
select t.id,
t.url
from sa_oplink t
where 1=1
</sql>
<field name="地址" code="url" width="300"/>
</easy-search>
</easy-search-mappings> </easy-search-mappings>
var treeManager, gridManager, refreshFlag = false, selectFunctionDialog, lastSelectedId = 0; var treeManager, gridManager, refreshFlag = false, selectFunctionDialog, lastSelectedId = 0;
$(function() { $(function () {
bindEvents(); bindEvents();
loadFunctionTree(); loadFunctionTree();
...@@ -8,11 +8,11 @@ $(function() { ...@@ -8,11 +8,11 @@ $(function() {
initializeGrid(); initializeGrid();
function initializeUI() { function initializeUI() {
UICtrl.layout("#layout", { leftWidth: 3 }); UICtrl.layout("#layout", {leftWidth: 3});
} }
function bindEvents() { function bindEvents() {
$("#name").live("blur", function() { $("#name").live("blur", function () {
if (!$("#fullName").val()) { if (!$("#fullName").val()) {
$("#fullName").val($("#name").val()); $("#fullName").val($("#name").val());
} }
...@@ -27,39 +27,50 @@ $(function() { ...@@ -27,39 +27,50 @@ $(function() {
saveSortIDHandler: updateFunctionSequence, saveSortIDHandler: updateFunctionSequence,
enableHandler: enableHandler, enableHandler: enableHandler,
disableHandler: disableHandler, disableHandler: disableHandler,
moveHandler:moveHandler, moveHandler: moveHandler,
buildPermission: { id:'buildPermission',text:'生成权限',img:'fa-cubes',click:buildPermission } buildPermission: {id: 'buildPermission', text: '生成权限', img: 'fa-cubes', click: buildPermission},
syncIcons: {id: 'syncIcons', text: '同步图标', img: 'fa-list-alt', click: syncIcons},
syncLinks: {id: 'syncLinks', text: '同步链接', img: 'fa-list-alt', click: syncLinks},
}; };
var toolbarOptions = UICtrl.getDefaultToolbarOptions(toolbarparam); var toolbarOptions = UICtrl.getDefaultToolbarOptions(toolbarparam);
gridManager = UICtrl.grid("#maingrid", { gridManager = UICtrl.grid("#maingrid", {
columns: [ columns: [
{ display: '图标', name: 'icon', width: 60, minWidth: 60, type: "string", align: "center", isAutoWidth: 0, {
render: function(item) { display: '图标',
name: 'icon',
width: 60,
minWidth: 60,
type: "string",
align: "center",
isAutoWidth: 0,
render: function (item) {
if (!Public.isBlank(item.icon)) { if (!Public.isBlank(item.icon)) {
return '<span style="font-size:16px;"><i class="fa '+item.icon+'"></i></span>'; return '<span style="font-size:16px;"><i class="fa ' + item.icon + '"></i></span>';
} }
return ''; return '';
} }
}, },
{ display: '编码', name: 'code', width: 200, minWidth: 60, type: "string", align: "left" }, {display: '编码', name: 'code', width: 200, minWidth: 60, type: "string", align: "left"},
{ display: '名称', name: 'name', width: 150, minWidth: 60, type: "string", align: "left" }, {display: '名称', name: 'name', width: 150, minWidth: 60, type: "string", align: "left"},
{ display: '描述', name: 'description', width: 150, minWidth: 60, type: "string", align: "left" }, {display: '描述', name: 'description', width: 150, minWidth: 60, type: "string", align: "left"},
{ display: '状态', name: 'status', width: 60, minWidth: 60, type: "int", align: "left", {
render: function(item) { display: '状态', name: 'status', width: 60, minWidth: 60, type: "int", align: "left",
render: function (item) {
return UICtrl.getStatusInfo(item.status); return UICtrl.getStatusInfo(item.status);
} }
}, },
{ display: '全名称', name: 'fullName', width: 150, minWidth: 60, type: "string", align: "left" }, {display: '全名称', name: 'fullName', width: 150, minWidth: 60, type: "string", align: "left"},
{ display: 'Url', name: 'url', width: 280, minWidth: 60, type: "string", align: "left", hide: 0 }, {display: 'Url', name: 'url', width: 280, minWidth: 60, type: "string", align: "left", hide: 0},
{ display: "排序号", name: "sequence", width: 60, minWidth: 60, type: "int", align: "left", {
render: function(item) { display: "排序号", name: "sequence", width: 60, minWidth: 60, type: "int", align: "left",
return "<input type='text' id='txtSequence_"+ item.id+ "' class='textbox' value='"+ item.sequence + "' />"; render: function (item) {
return "<input type='text' id='txtSequence_" + item.id + "' class='textbox' value='" + item.sequence + "' />";
} }
} }
], ],
dataAction: 'server', dataAction: 'server',
url: web_app.name+ "/sysFunction/queryFunctions.ajax", url: web_app.name + "/sysFunction/queryFunctions.ajax",
parms: {parentId: 0}, parms: {parentId: 0},
usePager: false, usePager: false,
sortName: "sequence", sortName: "sequence",
...@@ -71,7 +82,7 @@ $(function() { ...@@ -71,7 +82,7 @@ $(function() {
checkbox: true, checkbox: true,
fixedCellHeight: true, fixedCellHeight: true,
selectRowButtonOnly: true, selectRowButtonOnly: true,
onDblClickRow: function(data, rowindex, rowobj) { onDblClickRow: function (data, rowindex, rowobj) {
doShowUpdateDialog(data.id); doShowUpdateDialog(data.id);
} }
}); });
...@@ -82,10 +93,10 @@ $(function() { ...@@ -82,10 +93,10 @@ $(function() {
function loadFunctionTree() { function loadFunctionTree() {
$('#maintree').commonTree({ $('#maintree').commonTree({
loadTreesAction: "sysFunction/queryFunctions.ajax", loadTreesAction: "sysFunction/queryFunctions.ajax",
isLeaf: function(data) { isLeaf: function (data) {
return data.hasChildren == 0; return data.hasChildren == 0;
}, },
onClick: function(data) { onClick: function (data) {
if (data && lastSelectedId != data.id) { if (data && lastSelectedId != data.id) {
reloadGrid3(data.id, data.name); reloadGrid3(data.id, data.name);
} }
...@@ -98,6 +109,7 @@ $(function() { ...@@ -98,6 +109,7 @@ $(function() {
function getId() { function getId() {
return $("#id").val(); return $("#id").val();
} }
//查询 //查询
function query(obj) { function query(obj) {
var param = $(obj).formToJSON(); var param = $(obj).formToJSON();
...@@ -108,6 +120,7 @@ function query(obj) { ...@@ -108,6 +120,7 @@ function query(obj) {
function resetForm(obj) { function resetForm(obj) {
$(obj).formClean(); $(obj).formClean();
} }
function reloadGrid() { function reloadGrid() {
$("#maintree").commonTree('refresh', lastSelectedId); $("#maintree").commonTree('refresh', lastSelectedId);
var params = $("#queryMainForm").formToJSON(); var params = $("#queryMainForm").formToJSON();
...@@ -120,7 +133,7 @@ function reloadGrid2() { ...@@ -120,7 +133,7 @@ function reloadGrid2() {
} }
function reloadGrid3(id, name) { function reloadGrid3(id, name) {
$('#layout').layout('setCenterTitle',"<span class=\"tomato-color\">[" + name+ "]</span>子功能列表"); $('#layout').layout('setCenterTitle', "<span class=\"tomato-color\">[" + name + "]</span>子功能列表");
lastSelectedId = id; lastSelectedId = id;
var params = $("#queryMainForm").formToJSON(); var params = $("#queryMainForm").formToJSON();
params.parentId = id; params.parentId = id;
...@@ -144,42 +157,100 @@ function showInsertDialog() { ...@@ -144,42 +157,100 @@ function showInsertDialog() {
parentId: $('#maintree').commonTree('getSelectedId') parentId: $('#maintree').commonTree('getSelectedId')
}, },
width: 400, width: 400,
url: web_app.name+ '/sysFunction/showFunctionDetail.load', url: web_app.name + '/sysFunction/showFunctionDetail.load',
ok: doSaveFunction, ok: doSaveFunction,
close: onDialogCloseHandler, close: onDialogCloseHandler,
init:initDetail init: initDetail
}); });
} }
function doShowUpdateDialog(id) { function doShowUpdateDialog(id) {
UICtrl.showAjaxDialog({ UICtrl.showAjaxDialog({
url: web_app.name + '/sysFunction/loadFunction.load', url: web_app.name + '/sysFunction/loadFunction.load',
param: { id: id }, param: {id: id},
title: "修改功能", title: "修改功能",
width: 400, width: 400,
ok: doSaveFunction, ok: doSaveFunction,
close: onDialogCloseHandler, close: onDialogCloseHandler,
init:initDetail init: initDetail
}); });
} }
function initDetail(div){ function initDetail(div) {
var _icon=$('input[name="icon"]',div); var _icon = $('input[name="icon"]', div);
var _showIcon=function(icon){ var _showIcon = function (icon) {
var span=$('span.show-icon',div).empty(); var span = $('span.show-icon', div).empty();
if (!Public.isBlank(icon)) { if (!Public.isBlank(icon)) {
span.append('<i class="fa '+icon+'"></i>'); span.append('<i class="fa ' + icon + '"></i>');
} }
}; };
_icon.on('blur',function(){ _icon.on('blur', function () {
_showIcon($(this).val()); _showIcon($(this).val());
}); });
_icon.searchbox({
type: 'sys',
name: 'icon',
getParam: function () {
return {};
},
back: {
'code': '#icon'
},
onChange: function (data) {
_icon.val(data.code);
$('#icon_text').val(data.code);
_showIcon(_icon.val());
}
});
_showIcon(_icon.val()); _showIcon(_icon.val());
$('#nodeKindId', div).combox({
onChange: function (data) {
var _url = $('#url', div);
if (data.value == 'fun') {
UICtrl.setElRequiredFlag(_url, true);
} else {
_url.val(null);
UICtrl.setElRequiredFlag(_url, false);
}
}
});
$('#url_click button', div).click(function () {
$('#url-selector-container').remove();
$('<div id="url-selector-container"><input id="urlSelector" name="urlSelector" /></div>').insertBefore('#url_click');
$('#urlSelector').searchbox({
type: 'sys',
name: 'link',
getParam: function () {
return {};
},
onChange: function (data) {
$('#url', div).val(data.text);
}
});
$('#url-selector-container').css({
height: 1,
width: 1,
})
$('#url-selector-container .input-group input').css({
width: 0.1,
height: 0.1,
padding: 0,
margin: 0
});
$('#url-selector-container .input-group-btn').remove();
$('#url-selector-container #urlSelector_text').trigger('click');
});
} }
function showUpdateDialog() { function showUpdateDialog() {
var id = DataUtil.getUpdateRowId(gridManager); var id = DataUtil.getUpdateRowId(gridManager);
if (!id){ return; } if (!id) {
return;
}
doShowUpdateDialog(id); doShowUpdateDialog(id);
} }
...@@ -188,8 +259,8 @@ function doSaveFunction() { ...@@ -188,8 +259,8 @@ function doSaveFunction() {
var _self = this; var _self = this;
var id = getId(); var id = getId();
$('#submitForm').ajaxSubmit({ $('#submitForm').ajaxSubmit({
url: web_app.name+ (id ? '/sysFunction/updateFunction.ajax': '/sysFunction/insertFunction.ajax'), url: web_app.name + (id ? '/sysFunction/updateFunction.ajax' : '/sysFunction/insertFunction.ajax'),
success: function() { success: function () {
refreshFlag = true; refreshFlag = true;
_self.close(); _self.close();
} }
...@@ -218,42 +289,44 @@ function updateFunctionSequence() { ...@@ -218,42 +289,44 @@ function updateFunctionSequence() {
* 移动 * 移动
*/ */
function moveHandler() { function moveHandler() {
var excludeIds=DataUtil.getSelectedIds({ var excludeIds = DataUtil.getSelectedIds({
gridManager: gridManager gridManager: gridManager
}); });
if (!excludeIds || excludeIds.length < 1) { if (!excludeIds || excludeIds.length < 1) {
Public.tip('请选择数据!'); Public.tip('请选择数据!');
return; return;
} }
UICtrl.showDialog({title:'移动到...',width:300, UICtrl.showDialog({
content:'<div style="overflow-x: hidden; overflow-y: auto; width:280px;height:250px;"><ul class="move-tree"></ul></div>', title: '移动到...', width: 300,
init:function(doc){ content: '<div style="overflow-x: hidden; overflow-y: auto; width:280px;height:250px;"><ul class="move-tree"></ul></div>',
$('ul.move-tree',doc).commonTree({ init: function (doc) {
$('ul.move-tree', doc).commonTree({
loadTreesAction: 'sysFunction/queryFunctions.ajax', loadTreesAction: 'sysFunction/queryFunctions.ajax',
getParam:function(){ getParam: function () {
//排除当前选中节点 //排除当前选中节点
return {excludeIds:excludeIds.join(',')}; return {excludeIds: excludeIds.join(',')};
}, },
IsShowMenu: false IsShowMenu: false
}); });
}, },
ok:function(doc){ ok: function (doc) {
var parentId=$('ul.move-tree',doc).commonTree('getSelectedId'); var parentId = $('ul.move-tree', doc).commonTree('getSelectedId');
if(!parentId){ if (!parentId) {
Public.tip('请选择树节点!'); Public.tip('请选择树节点!');
return false; return false;
} }
var _self=this; var _self = this;
DataUtil.updateById({action:'sysFunction/moveFunctions.ajax', DataUtil.updateById({
gridManager:gridManager,idFieldName:'id',param:{parentId:parentId}, action: 'sysFunction/moveFunctions.ajax',
onSuccess:function(){ gridManager: gridManager, idFieldName: 'id', param: {parentId: parentId},
onSuccess: function () {
reloadGrid4(); reloadGrid4();
_self.close(); _self.close();
} }
}); });
}, },
close: function (doc) { close: function (doc) {
$('ul.move-tree',doc).removeAllNode(); $('ul.move-tree', doc).removeAllNode();
return true; return true;
} }
}); });
...@@ -267,32 +340,48 @@ function onDialogCloseHandler() { ...@@ -267,32 +340,48 @@ function onDialogCloseHandler() {
} }
} }
function updateStatus(message, status){ function updateStatus(message, status) {
DataUtil.updateById({ action: 'sysFunction/updateSysFunctionsStatus.ajax', DataUtil.updateById({
gridManager: gridManager, param:{status: status}, action: 'sysFunction/updateSysFunctionsStatus.ajax',
gridManager: gridManager, param: {status: status},
message: message, message: message,
onSuccess:function(){ onSuccess: function () {
reloadGrid(); reloadGrid();
} }
}); });
} }
function enableHandler(){ function enableHandler() {
updateStatus('确实要启用选中数据吗?', 1); updateStatus('确实要启用选中数据吗?', 1);
} }
//禁用 //禁用
function disableHandler(){ function disableHandler() {
updateStatus('确实要禁用选中数据吗?', 0); updateStatus('确实要禁用选中数据吗?', 0);
} }
function buildPermission(){ function buildPermission() {
var rows = gridManager.getSelectedRows(); var rows = gridManager.getSelectedRows();
if (rows.length != 1){ if (rows.length != 1) {
Public.errorTip("请选择一条数据。"); Public.errorTip("请选择一条数据。");
return false; return false;
} }
var url = web_app.name + '/sysFunction/buildPermission.ajax'; var url = web_app.name + '/sysFunction/buildPermission.ajax';
Public.ajax(url, { fullId: rows[0].fullId}, function (data) {}); Public.ajax(url, {fullId: rows[0].fullId}, function (data) {
});
}
function syncIcons() {
Public.ajax(web_app.name + '/icon/syncIcons.ajax',
null,
function (data) {
});
}
function syncLinks() {
Public.ajax(web_app.name + '/link/syncLinks.ajax',
null,
function (data) {
});
} }
\ No newline at end of file
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
<x:inputC name="name" required="true" label="名称" maxlength="64" fieldCol="10" /> <x:inputC name="name" required="true" label="名称" maxlength="64" fieldCol="10" />
<x:inputC name="description" label="描述" maxlength="64" fieldCol="10" /> <x:inputC name="description" label="描述" maxlength="64" fieldCol="10" />
<x:selectC name="nodeKindId" required="true" list="nodeKindList" label="类型" fieldCol="10" /> <x:selectC name="nodeKindId" required="true" list="nodeKindList" label="类型" fieldCol="10" />
<x:inputC name="url" label="Url" readonly="false" maxlength="128" fieldCol="10" /> <x:inputC name="url" label="Url" readonly="false" maxlength="128" fieldCol="10" wrapper="select" />
<x:hidden name="urlSelector" />
<div class="col-xs-2 col-md-2"> <div class="col-xs-2 col-md-2">
<label class="hg-form-label required" id="code_label">图标&nbsp;:</label> <label class="hg-form-label required" id="code_label">图标&nbsp;:</label>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment