@chp
2018-07-18T07:36:07.000000Z
字数 11959
阅读 896
项目
mini.get('approval').setData([{ name: '未审核' }, { name: '审核通过' }, { name: '审核不通过' }]);
approval 页面字段的id
enabled="false"
required="true"
vtype="maxLength:18"
vtype="int"
allowInput="false"
<input id="udicTecOqCurVal" style="width:65%;" class="mini-buttonedit" onbuttonclick="onButtonEdit" textName="udicTecOqCurValName" name="udicTecOqCurVal" textField="udicTecOqCurVal" valueField="code" label="申请任职资格" />
<script type="text/javascript">
mini.parse();
function onButtonEdit(e) {
var btnEdit = this;
mini.open({
url: contextPath +"/personnelinformation-personnelinformation/personnelinformation-findUdicTecOqCurVal-data.html",
showMaxButton: false,
title: "请选择",
width: 350,
height: 350,
ondestroy: function(action) {
if (action == "ok") {
var iframe = this.getIFrameEl();
var data = iframe.contentWindow.GetData();
data = mini.clone(data);
if (data) {
btnEdit.setValue(data.code);
btnEdit.setText((data.name).replace(data.code, ""));
}
}
}
});
}
</script>
/jsp和js 语法*/
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="/WEB-INF/jsp/common/js-container.jsp" %>
<style type="text/css">
body {
padding: 0px;
margin: 0px;
border: 0;
width: 100%;
height: 100%;
}
.search-box .mini-textbox,
.search-box .mini-buttonedit,
.search-box .search-btn {
margin-bottom: 10px;
}
#-authority-btn {
float: right;
height: 36px;
}
#-authority-btn a {
margin: 0 2px;
float: left
}
</style>
</head>
<body>
<div class="mini-toolbar" style="text-align:center;line-height:30px;" borderStyle="border-left:0;border-top:0;border-right:0;">
<label>名称:</label>
<input id="key" class="mini-textbox" style="width:150px;" onenter="onKeyEnter" />
<a class="mini-button" style="width:60px;" onclick="search()">查询</a>
</div>
<div class="mini-fit">
<ul id="tree1" class="mini-tree" style="width:100%;height:100%;" showTreeIcon="true" textField="name" idField="code" parentField="parentCode" resultAsTree="false" expandOnLoad="false" onnodedblclick="onNodeDblClick" expandOnDblClick="false">
</ul>
</div>
<div class="mini-toolbar" style="text-align:center;padding-top:8px;padding-bottom:8px;" borderStyle="border-left:0;border-bottom:0;border-right:0;">
<a class="mini-button" style="width:60px;" onclick="onOk()">确定</a>
<span style="display:inline-block;width:25px;"></span>
<a class="mini-button" style="width:60px;" onclick="onCancel()">取消</a>
</div>
</body>
<script type="text/javascript">
mini.parse();
var tree = mini.get("tree1");
tree.setUrl(contextPath + '/udic-udic/udic-selectedLanuageCode-load-data.html');
function GetData() {
var node = tree.getSelectedNode();
return node;
};
function search() {
var key = mini.get("key").getValue();
if (key == "") {
tree.clearFilter();
} else {
key = key.toLowerCase();
tree.filter(function(node) {
var text = node.name ? node.name.toLowerCase() : "";
if (text.indexOf(key) != -1) {
return true;
}
});
}
};
function onKeyEnter(e) {
search();
}
function onNodeDblClick(e) {
onOk();
};
function CloseWindow(action) {
if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
else window.close();
};
function onOk() {
var node = tree.getSelectedNode();
if (node && tree.isLeaf(node) == false) {
alert("不能选中父节点");
return;
}
CloseWindow("ok");
};
function onCancel() {
CloseWindow("cancel");
};
</script>
</html>
mini.get('declareYear').on('focus', function () {
var jq = jQuery("#validGroup1");
jq.html('<a href="javascript:;">申报年度:填写职称申报的年度。例如:2010年申报职称应填写2010。</a>');
});
//validGroup1内容需要显示的div的id
emptyText="所学专业"
showNullItem="true"
<li style="width:100%;">
<img class="personnalView" src="/personnelinformation-personnelinformation/personnelinformation-dataloadPic.html" id="personnalView" style="text-align: center; display:block;margin: 0 auto;" onerror="javascript:this.src='${contextPath}/resources/images/default-head-image.png';" data-placement="right" />
</li>
action层
/*
* *个人信息照片的读取
*/
@Action("/personnelinformation-personnelinformation/personnelinformation-dataloadPic")
public void dataloadPic() {
try {
this.response.setContentType("image/jpeg");
final ServletOutputStream outs = this.response.getOutputStream();
final Blob blob = this.personnelInformationService.queryPicture();
if (null != blob) {
final InputStream is = blob.getBinaryStream(); // 转换成输入流
final int blobSize = (int) blob.length();
final byte[] blobBytes = new byte[blobSize];
int bytesRead = 0;
while ((bytesRead = is.read(blobBytes)) != -1) {
outs.write(blobBytes, 0, bytesRead);// 输出图片
}
is.close();
}
outs.flush();// 清空缓存
} catch (final Exception e) {
LOGGER.error("Action:StudentAction Method:studentCourseDetailLoadData error ", e);
sendFailMsg("", "查询失败!");
}
}
service层
@Override
public Blob queryPicture() {
final UserSession userSession = UserThreadLocal.getUserSession();
BasePersonnelInformationPojo basePersonnelInformationPojo = new BasePersonnelInformationPojo();
basePersonnelInformationPojo =
this.findUniqueBy(BasePersonnelInformationPojo.LOGIN_NAME, userSession.getUserName());
String info = basePersonnelInformationPojo.getCode();
final StringBuilder sql = new StringBuilder();
final Map map = Maps.newHashMap();
map.put("fkUserCode", info);
sql.append("SELECT PICTURE picture, FK_USER_CODE fkUserCode FROM BASE_PERSON_PICTURE WHERE 1 = 1 AND BASE_PERSON_PICTURE.FK_USER_CODE =:fkUserCode ");
final SQLQuery sQLQuery = this.iCustomDao.buildSQLQuery(sql.toString(), map);
sQLQuery.addScalar("picture", StandardBasicTypes.BLOB);
List<SQLQuery> pic = sQLQuery.list();
Blob picture = null;
if (null != pic && 0 < pic.size()) {
picture = (Blob) sQLQuery.list().get(0);
}
return picture;
}
<div id="honorskil-show" class="mini-panel" title="荣誉称号信息-有附件" style="width:100%;height:300px;" collapseOnTitleClick="true" showCollapseButton="true" bodyStyle="padding:0;" expanded="false">
<div class="mini-toolbar auxiliary-toolbar">
<div id="authority-btn">
<a class="mini-button search-btn" id="add-button-honorskil">添加</a>
<a class="mini-button search-btn" style="display:none" id="edit-button-honorskil">修改</a>
<a class="mini-button search-btn" style="display:none" id="delete-button-honorskil">删除</a>
</div>
<div style="height:230px">
<div class="mini-dataGrid" id="honorskil-grid" allowAlternating="true" sizeList="${sizeList}" multiSelect="true" allowResizeColumn="false" allowMoveColumn="false" allowSortColumn="true" showEmptyText="true" emptyText="暂无数据" style="width: 100%; height: 100%">
</div>
</div>
</div>
</div>
mini.get('downloadModel').on('click', function () {
window.location.href = contextPath + "/attached/template/model.xlsx";
});
---jsp页面
<body>
<div class="mini-fit">
<ul class="form-group" id="import-form">
<li><label class="control-label"><span style="color:red">*</span>上传文件(xls):</label>
<input type="file" id="demo" name="file" style="width: 250px;" />
<input class="mini-hidden" name="fileName" id="fileName" allowInput="false" style="width: 280px;" />
</li>
</ul>
</div>
<div class="mini-panel-toolbar">
<a class="mini-button ok">确定</a>
<a class="mini-button cancel">取消</a>
</div>
<script src="${contextPath}/resources/js/achievements/achievements-import.js"></script>
</body>
//js
var TechnologicalachievementsPage = {
init: function() {
mini.parse();
this.setEvents();
},
setEvents: function() {
var me = this;
//保存
$(".ok").click(function() {
me.save();
});
$(".cancel").click(function() {
me.closeWin('close');
});
$('#demo').change(function() {
me.ajaxUpload({
id: 'demo',
frameName: 'frameName',
url: '/file/upload-file.html',
format: ['xlsx'],
callBack: function(data) {
var resluts = mini.decode(data, false);
mini.get('fileName').setValue(resluts.savePath);
}
});
});
},
closeWin: function(action) {
if (window.CloseOwnerWindow) {
window.CloseOwnerWindow(action);
} else {
window.close();
}
},
downloadTemplate: function() {
window.location.href = contextPath + "/template/achievementsModel.xlsx";
},
save: function() {
var self = this;
var form = new mini.Form("import-form");
form.validate();
if (form.isValid() == false) {
return;
}
var fileName = mini.get("fileName").getValue();
if ("" == fileName) {
alert("请选择文件");
return;
}
var formData = form.getData(true, false);
var params = Constants.isAttributeEmpty(formData);
form.loading();
$.ajax({
url: "/technologicalachievements-technologicalachievements/save-by-excel.html",
type: "POST",
dataType: "json",
data: params,
success: function(data) {
form.unmask();
mini.alert(data.message, "提示", function(action) {
if (action) {
self.closeWin('success');
}
});
},
error: function() {}
});
},
ajaxUpload: function(opt) {
var iName = opt.frameName; // 太长了,变短点
var iframe, form, file, fileParent;
// 创建iframe和form表单
iframe = $('<iframe name="' + iName + '" />');
form = $('<form method="post" style="display:none;" target="' + iName + '" action="' + opt.url + '" name="form_' + iName + '" enctype="multipart/form-data" />');
file = $('#' + opt.id); // 通过id获取flie控件
fileParent = file.parent(); // 存父级
file.appendTo(form);
// 插入body
$(document.body).append(iframe).append(form);
// 取得所选文件的扩展名
var fileFormat = /\.[a-zA-Z]+$/.exec(file.val())[0].substring(1);
if (opt.format.join('-').indexOf(fileFormat) != -1) {
form.submit(); // 格式通过验证后提交表单;
} else {
file.appendTo(fileParent); // 将file控件放回到页面
iframe.remove();
form.remove();
alert('文件格式错误,请重新选择!');
return;
};
// 文件提交完后
iframe.load(function() {
var data = $(this).contents().find('body').text();
file.appendTo(fileParent);
iframe.remove();
form.remove();
opt.callBack(mini.decode(data));
})
}
}
$(function() {
TechnologicalachievementsPage.init();
});
ACTION.java
@Override
public void saveByExcel(XSSFWorkbook xssfWorkbook) {
final XSSFSheet xssSheet0 = xssfWorkbook.getSheetAt(0);
XSSFRow row;
final List<BaseTechnologicalAchievementsImportVo> vos = Lists.newArrayList();
BaseTechnologicalAchievementsImportVo vo = null;
for (int i = 1; i < xssSheet0.getPhysicalNumberOfRows(); i++) {
row = xssSheet0.getRow(i);
if (row == null) {
break;
}
final Double year = row.getCell(0).getNumericCellValue();// 年度
final String certificateNumber = row.getCell(1).getStringCellValue();// 奖励证书编号
final String winningProject = row.getCell(2).getStringCellValue();// 获奖项目名称
final String awardName = row.getCell(3).getStringCellValue();// 奖励名称
final String mainCompletionUnit = row.getCell(4).getStringCellValue();// 主要完成单位
final String alumniDepartment = row.getCell(5).getStringCellValue();// 受奖部门
final String udicWonLevele = row.getCell(6).getStringCellValue();// 奖励等级
final String udicWonType = row.getCell(7).getStringCellValue();// 奖励种类
if (null == year || StringUtils.isBlank(certificateNumber) || StringUtils.isBlank(winningProject)
|| StringUtils.isBlank(awardName) || StringUtils.isBlank(mainCompletionUnit)
|| StringUtils.isBlank(alumniDepartment) || StringUtils.isBlank(udicWonLevele)
|| StringUtils.isBlank(udicWonType)) {
continue;
}
Integer years = Integer.valueOf(year.intValue());
String udicWonLeveleCode = udicDao.findUdicWonLeveleCode(udicWonLevele);
String udicWonTypeCode = udicDao.findUdicWonTypeCode(udicWonType);
vo = new BaseTechnologicalAchievementsImportVo();
vo.setYear(years);
vo.setCertificateNumber(certificateNumber);
vo.setWinningProject(winningProject);
vo.setAwardName(awardName);
vo.setMainCompletionUnit(mainCompletionUnit);
vo.setAlumniDepartment(alumniDepartment);
vo.setUdicWonLevele(udicWonLevele);
vo.setUdicWonType(udicWonType);
vo.setUdicWonLeveleCode(udicWonLeveleCode);
vo.setUdicWonTypeCode(udicWonTypeCode);
vos.add(vo);
}
saveImport(vos);
}
private void saveImport(List<BaseTechnologicalAchievementsImportVo> vos) {
BaseTechnologicalAchievementsPojo pojo = null;
final UserSession userSession = UserThreadLocal.getUserSession();
for (final BaseTechnologicalAchievementsImportVo vo : vos) {
pojo = new BaseTechnologicalAchievementsPojo();
pojo.setDictDeletedValue(DictDeletedType.NOT_DELTEED.getId());
pojo.setDictDeletedName(DictDeletedType.NOT_DELTEED.getNameCn());
pojo.setCreateUserId(userSession.getUserId());
pojo.setCreateUserName(userSession.getUserName());
pojo.setCreateTime(new Date());
pojo.setLastUpdateTime(new Date());
pojo.setCode(IdKit.uuid());
pojo.setYear(vo.getYear());
pojo.setCertificateNumber(vo.getCertificateNumber());
pojo.setWinningProject(vo.getWinningProject());
pojo.setAwardName(vo.getAwardName());
pojo.setMainCompletionUnit(vo.getMainCompletionUnit());
pojo.setAlumniDepartment(vo.getAlumniDepartment());
pojo.setUdicWonLevele(vo.getUdicWonLevele());
pojo.setUdicWonType(vo.getUdicWonType());
pojo.setUdicWonLeveleCode(vo.getUdicWonLeveleCode());
pojo.setUdicWonTypeCode(vo.getUdicWonTypeCode());
this.dao.save(pojo);
}
}