You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

424 lines
17 KiB
Plaintext

11 months ago

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>词汇选择</title>
<link href="../../Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="../../Scripts/bootstrap/css/font-awesome.css" rel="stylesheet" type="text/css" />
<link href="../../Scripts/bootstrap/bootstrap-table/src/bootstrap-table.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="../../Scripts/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="../../Scripts/bootstrap/bootstrap-table/src/bootstrap-table.js" type="text/javascript"></script>
<script src="../../Scripts/bootstrap/bootstrap-table/src/locale/bootstrap-table-zh-CN.js" type="text/javascript"></script>
<script src="../../Scripts/CommonUnite.js" type="text/javascript"></script>
<!--<script src="../../Scripts/jquery/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>-->
<script src="../../Scripts/QueryString.js" type="text/javascript"></script>
<script src="../../Scripts/config.js" type="text/javascript"></script>
<script language="JavaScript" src="../../Comm/JScript.js" type="text/javascript"></script>
<script type="text/javascript" src="../../Comm/Gener.js"></script>
<style type="text/css">
.bs-checkbox {
width: 20px
}
.nav-tabs > li.active > a, .nav-tabs > li.active > a:hover, .nav-tabs > li.active > a:focus {
color: #555;
cursor: default;
background-color: #fff;
border-right: 1px solid #ddd;
border-bottom-color: transparent;
}
</style>
<script type="text/ecmascript">
var WordsSort;
var AttrKey;
var FK_MapData;
var PKVal = GetQueryString("PKVal");
var FK_Flow = GetQueryString("FK_Flow");
var mapExt;
var lb;
var webUser = new WebUser();
var data;
$(function () {
mapExt = new Entity("BP.Sys.MapExt", PKVal);
var i = mapExt.RetrieveFromDBSources();
if (i == 0) {
$("body").html("<b>设置的扩展属性缺失,请联系管理员。<b>");
return;
}
if (mapExt.Tag1 == "0") {
$("#lsch").css('display', 'none');
}
//初始化赋值.
AttrKey = mapExt.AttrOfOper;
FK_MapData = mapExt.FK_MapData;
$('#myTab a').click(function (e) {
e.preventDefault(); //阻止a链接的跳转行为
$(this).tab('show'); //显示当前选中的链接及关联的content
switch ($(this).text()) {
case "我的词汇":
startBtn(); //允许新增、编辑、删除
runEffect("myWords");
break;
case "历史词汇":
forbiddenBtn(); //禁止新增、编辑、删除
runEffect("hisWords");
break;
case "系统词汇":
forbiddenBtn(); //系统词汇禁止新增、编辑、删除
runEffect("sysWords");
break;
case "读取文件":
forbiddenBtn();
runEffect("readWords");
break;
default:
break;
}
});
$('#myModal').modal('hide');
runEffect("myWords"); //初始化加载我的词汇
});
function startBtn() { //启用按钮
$('#tools').show();
$('#btnAdd').attr("disabled",false);
$('#btnEdit').attr("disabled", false);
$('#btnDel').attr("disabled", false);
}
function forbiddenBtn() { //禁用按钮
$('#tools').hide();
$('#btnAdd').attr("disabled", true);
$('#btnEdit').attr("disabled", true);
$('#btnDel').attr("disabled", true);
}
function runEffect(v) {
lb = v;
LoadGridData(1, 10);
}
function GetSearchData(pageNumber, pageSize) {
var handler = new HttpHandler("BP.WF.HttpHandler.WF_Comm");
handler.AddPara("AttrKey", AttrKey);
handler.AddPara("FK_MapData", FK_MapData);
handler.AddPara("FK_Flow", FK_Flow);
handler.AddPara("FK_Node", GetQueryString("FK_Node"));
handler.AddPara("FK_Emp",mapExt.Tag);
handler.AddPara("pageNumber", pageNumber);
handler.AddPara("pageSize", pageSize);
handler.AddPara("lb", lb);
var data = handler.DoMethodReturnString("HelperWordsData");
if (data.indexOf("err@") == 0) {
$("#newsGrid").html("<b>访问页面出错,请联系管理员。<b>");
return;
}
data =JSON.parse(data);
data = data||[];
return data;
}
function LoadGridData(pageNumber, pageSize) {
$("#newsGrid").html("");
$('#newsGrid').bootstrapTable('load', []);
//$('#newsGrid').bootstrapTable('clearChecked');
var pagination = (lb == "sysWords"?false:true) ;
if (lb == "sysWords") {
data = {};
data1 = [];
var docs = mapExt.Doc;
docs = docs.split('@');
for (var i = 0; i < docs.length; i++) {
var doc = docs[i];
if (doc == null || doc == "")
continue;
data1.push({"MYPK":i,"CURVALUE":doc});
}
data.rows = data1;
data.total = docs.length-1;
}else{
data = GetSearchData(pageNumber,pageSize);
}
var h = "calc(100vh - 120px)"
$('#newsGrid').bootstrapTable({
columns: [
{ checkbox: true, width: 1,
cellStyle: {css: { "width": "1px" } }
},
{ field: 'CURVALUE', title: '', align: 'left' }
],
idField: 'MYPK',
selectOnCheck: false,
clickToSelect: true,
checkOnSelect: true,
singleSelect: false,
data: data,
width: 'auto',
height:'auto',
striped: true,
showHeader:false,
showFooter:false,
pageNumber: 1, //初始化加载第一页,默认第一页
pagination:true,//是否分页
sidePagination:'server',//在服务器分页
pageSize:10,//单页记录数
onPageChange:function(pn,size){
LoadGridData(pn,size);
}
});
$('#newsGrid').bootstrapTable('load', data);
}
//刷新
function RefreshGrid() {
var grid = $('#newsGrid');
//var options = grid.datagrid('getPager').data("pagination").options;
//var curPage = options.pageNumber;
//var pageSize = options.pageSize;
//LoadGridData(curPage, pageSize);
LoadGridData(1, 10);
}
var insEdit = true;
//添加数据
function btnOpenWindow() {
insEdit = true;
if (lb == "readWords" || lb == "hisWords")//如果是文件,历史词汇
return;
$('#TextArea').val('');
$('#myModal').modal('show');
$('#TextArea').focus();
}
function AddWorks() {
var params;
if (insEdit) {//添加
var text = $('#TextArea').val();
text = replaceTrim(text);
if (text == "") {
alert("请输入数据");
$('#TextArea').val('');
$('#TextArea').focus();
return;
}
if (lb == "myWords")//我的词汇
{
//判断是否存在我的词汇
var defVals = new Entities("BP.Sys.DefVals", "FK_MapData", FK_MapData, "AttrKey", AttrKey, "FK_Emp", webUser.No, "LB", "1", "CURVALUE", text);
if (defVals.length != 0) {
alert("该词汇已经存在,不能重复录入");
return;
}
var defVal = new Entity("BP.Sys.DefVal");
defVal.FK_MapData = FK_MapData;
defVal.FK_Emp = webUser.No;
defVal.AttrKey = AttrKey;
defVal.LB = "1";
defVal.CurValue = text;
defVal.Insert();
$('#myModal').modal('hide');
LoadGridData(1, 10);
}
} else {//编辑
var text = $('#TextArea').val();
text = replaceTrim(text);
//没有输入数据
if (text == "") {
alert("请输入数据");
$('#TextArea').val('');
$('#TextArea').focus();
return;
}
//输入数据没有改变
if (text == againText) {
alert("数据没有任何改变哦");
return;
}
//保存数据
var defVal = new Entity("BP.Sys.DefVal",defValPK);
defVal.CurValue = text;
defVal.Update();
$('#myModal').modal('hide');
RefreshGrid();
}
}
var againText;
var defValPK;
//编辑词汇
function btnEdit() {
insEdit = false;
if (lb == "readWords" || lb == "hisWords")//如果是文件,历史
return;
var rows = $('#newsGrid').bootstrapTable('getAllSelections');
if (rows.length == 1) {
againText = rows[0].CURVALUE;
defValPK = rows[0].MYPK;
$('#TextArea').val(rows[0].CURVALUE);
$('#myModal').modal('show');
$('#TextArea').focus();
}
else {
alert("请选择一条数据");
}
}
//字符的操作
function replaceTrim(val) {//去除空格
val = val.replace(/[ ]/g, "");
val = val.replace(/<\/?.+?>/g, "");
val = val.replace(/[\r\n]/g, "");
return val;
}
//删除
function btnDelete() {
if (lb == "readWords" || lb == "hisWords" || lb == "sysWords")//如果是文件,历史
return;
var rows = $('#newsGrid').bootstrapTable('getAllSelections');
if (rows.length >= 1) {
if (confirm('确定要删除这' + rows.length + '条数据吗?') == false)
return;
var oids = '';
$.each(rows, function (n, value) {
var defVal = new Entity("BP.Sys.DefVal", value.MYPK);
defVal.Delete();
});
LoadGridData(1, 10);
}
else {
alert("请选择一条数据");
}
}
//关闭主窗体
function btnClose() {
window.parent.layer.close(window.parent.layer.index);
}
//返回数据
function btnOk() {
var rows = $('#newsGrid').bootstrapTable('getAllSelections');
if (rows.length == 0) {
alert("请选择数据");
return;
}
var str = '';
if (lb == "readWords")//如果是文件
{
$.each(rows, function (n, value) {
str += value.TxtStr;
});
for (var i = 0; true; i++) {
if (str.indexOf("ccflow_lover") != -1) {
str = str.replace("ccflow_lover", "\n");
} else {
break;
}
}
} else {
$.each(rows, function (n, value) {
str += value.CURVALUE + ",";
});
str = str.substr(0, str.length - 1);
}
str = str.replace(/{/g, "");
str = str.replace(/}/g, "");
str = str.replace(/\[/g, "【");
str = str.replace(/\]/g, "】");
str = str.replace(/\"/g, "”");
str = str.replace(/\'/g, "");
if (str == '') {
alert("1.没有选中项<br />2.选中的文件不包含任何数据!");
return;
}
window.parent.changeFastInt(AttrKey, str);
window.parent.layer.close(window.parent.layer.index);
}
</script>
</head>
<body>
<div style=" border: 1px solid #ddd;">
<!--tab标签-->
<div class="tabbable">
<ul class="nav nav-tabs" id="myTab">
<li class="active">
<a data-toggle="tab" href="#home">我的词汇</a>
</li>
<!-- <li id="lsch">
<a data-toggle="tab" href="#messages">历史词汇</a>
</li>-->
<li>
<a data-toggle="tab" href="#dropdown1">系统词汇</a>
</li>
<li>
<a data-toggle="tab" href="#dropdown1">读取文件</a>
</li>
</ul>
</div>
<!--button按钮-->
<div>
<div id="tools" style="text-align: left; float: left;margin:3px 5px">
<button class=" btn btn-info btn-xs" type="button" id="btnAdd" onclick='btnOpenWindow()'><i class="glyphicon-plus"></i> 添加数据</button>
<button class=" btn btn-info btn-xs" type="button" id="btnEdit" onclick='btnEdit()'><i class="fa fa-edit"></i> 编辑</button>
<button class=" btn btn-info btn-xs" type="button" id="btnDel" onclick='btnDelete()'><i class="fa fa-remove"></i> 删除</button>
</div>
<!--<div style="text-align: right; margin:3px 5px">
<button class=" btn btn-success btn-xs" type="button" onclick='btnOk()' id='btnOk'><i class="fa fa-check"></i> 确定</button>
<button class=" btn btn-danger btn-xs" type="button" onclick='btnClose()' id='btnClose'><i class="fa fa-mail-reply"></i> 取消</button>
</div>-->
</div>
<!--table页面-->
<div style="padding: 5px;">
<table id="newsGrid" fit="true"></table>
</div>
<!-- 显示分页信息 -->
<div style="text-align: left;">
<ul class="pagination" id="page_nav"></ul>
<ul class="pagination controls" id="page_info"></ul>
<div style="clear: both;">
</div>
</div>
<div>
<div style="float: right; margin:3px 5px">
<button class=" btn btn-success btn-xs" type="button" onclick='btnOk()' id='btnOk'><i class="fa fa-check"></i> 确定</button>
<button class=" btn btn-danger btn-xs" type="button" onclick='btnClose()' id='btnClose'><i class="fa fa-mail-reply"></i> 取消</button>
</div>
</div>
</div>
<!--bootstrap弹出页面-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">请输入</h4>
</div>
<div class="modal-body">
<textarea id="TextArea" cols="20" rows="2" style="width: 350px; height: 150px; margin-top: 5px; overflow: hidden;"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary" onclick="AddWorks()">保存</a></button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
</body>
</html>