当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 0 Fork 2.9K

梁新叶/jeewms
关闭

forked from JeeWMS/JeeWMS 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
popup扩展以支持参数过滤.html 83.81 KB
一键复制 编辑 原始数据 按行查看 历史
MT80 提交于 2019-02-14 21:10 . version20190214
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
<!DOCTYPE html>
<html>
<head>
<title>popup扩展以支持参数过滤</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="file:///C:\Users\admin\.vscode\extensions\shd101wyy.markdown-preview-enhanced-0.3.5\node_modules\@shd101wyy\mume\dependencies\katex\katex.min.css">
<style>
/**
* prism.js Github theme based on GitHub's theme.
* @author Sam Clarke
*/
code[class*="language-"],
pre[class*="language-"] {
color: #333;
background: none;
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.4;
-moz-tab-size: 8;
-o-tab-size: 8;
tab-size: 8;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
/* Code blocks */
pre[class*="language-"] {
padding: .8em;
overflow: auto;
/* border: 1px solid #ddd; */
border-radius: 3px;
/* background: #fff; */
background: #f5f5f5;
}
/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
background: #f5f5f5;
}
.token.comment,
.token.blockquote {
color: #969896;
}
.token.cdata {
color: #183691;
}
.token.doctype,
.token.punctuation,
.token.variable,
.token.macro.property {
color: #333;
}
.token.operator,
.token.important,
.token.keyword,
.token.rule,
.token.builtin {
color: #a71d5d;
}
.token.string,
.token.url,
.token.regex,
.token.attr-value {
color: #183691;
}
.token.property,
.token.number,
.token.boolean,
.token.entity,
.token.atrule,
.token.constant,
.token.symbol,
.token.command,
.token.code {
color: #0086b3;
}
.token.tag,
.token.selector,
.token.prolog {
color: #63a35c;
}
.token.function,
.token.namespace,
.token.pseudo-element,
.token.class,
.token.class-name,
.token.pseudo-class,
.token.id,
.token.url-reference .token.variable,
.token.attr-name {
color: #795da3;
}
.token.entity {
cursor: help;
}
.token.title,
.token.title .token.punctuation {
font-weight: bold;
color: #1d3e81;
}
.token.list {
color: #ed6a43;
}
.token.inserted {
background-color: #eaffea;
color: #55a532;
}
.token.deleted {
background-color: #ffecec;
color: #bd2c00;
}
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
/* JSON */
.language-json .token.property {
color: #183691;
}
.language-markup .token.tag .token.punctuation {
color: #333;
}
/* CSS */
code.language-css,
.language-css .token.function {
color: #0086b3;
}
/* YAML */
.language-yaml .token.atrule {
color: #63a35c;
}
code.language-yaml {
color: #183691;
}
/* Ruby */
.language-ruby .token.function {
color: #333;
}
/* Markdown */
.language-markdown .token.url {
color: #795da3;
}
/* Makefile */
.language-makefile .token.symbol {
color: #795da3;
}
.language-makefile .token.variable {
color: #183691;
}
.language-makefile .token.builtin {
color: #0086b3;
}
/* Bash */
.language-bash .token.keyword {
color: #0086b3;
}html body{font-family:"Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif;font-size:16px;line-height:1.6;color:#333;background-color:#fff;overflow:initial;box-sizing:border-box;word-wrap:break-word}html body>:first-child{margin-top:0}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{line-height:1.2;margin-top:1em;margin-bottom:16px;color:#000}html body h1{font-size:2.25em;font-weight:300;padding-bottom:.3em}html body h2{font-size:1.75em;font-weight:400;padding-bottom:.3em}html body h3{font-size:1.5em;font-weight:500}html body h4{font-size:1.25em;font-weight:600}html body h5{font-size:1.1em;font-weight:600}html body h6{font-size:1em;font-weight:600}html body h1,html body h2,html body h3,html body h4,html body h5{font-weight:600}html body h5{font-size:1em}html body h6{color:#5c5c5c}html body strong{color:#000}html body del{color:#5c5c5c}html body a:not([href]){color:inherit;text-decoration:none}html body a{color:#08c;text-decoration:none}html body a:hover{color:#00a3f5;text-decoration:none}html body img{max-width:100%}html body>p{margin-top:0;margin-bottom:16px;word-wrap:break-word}html body>ul,html body>ol{margin-bottom:16px}html body ul,html body ol{padding-left:2em}html body ul.no-list,html body ol.no-list{padding:0;list-style-type:none}html body ul ul,html body ul ol,html body ol ol,html body ol ul{margin-top:0;margin-bottom:0}html body li{margin-bottom:0}html body li.task-list-item{list-style:none}html body li>p{margin-top:0;margin-bottom:0}html body .task-list-item-checkbox{margin:0 .2em .25em -1.8em;vertical-align:middle}html body .task-list-item-checkbox:hover{cursor:pointer}html body blockquote{margin:16px 0;font-size:inherit;padding:0 15px;color:#5c5c5c;border-left:4px solid #d6d6d6}html body blockquote>:first-child{margin-top:0}html body blockquote>:last-child{margin-bottom:0}html body hr{height:4px;margin:32px 0;background-color:#d6d6d6;border:0 none}html body table{margin:10px 0 15px 0;border-collapse:collapse;border-spacing:0;display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}html body table th{font-weight:bold;color:#000}html body table td,html body table th{border:1px solid #d6d6d6;padding:6px 13px}html body dl{padding:0}html body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:bold}html body dl dd{padding:0 16px;margin-bottom:16px}html body code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:.85em !important;color:#000;background-color:#f0f0f0;border-radius:3px;padding:.2em 0}html body code::before,html body code::after{letter-spacing:-0.2em;content:"\00a0"}html body pre>code{padding:0;margin:0;font-size:.85em !important;word-break:normal;white-space:pre;background:transparent;border:0}html body .highlight{margin-bottom:16px}html body .highlight pre,html body pre{padding:1em;overflow:auto;font-size:.85em !important;line-height:1.45;border:#d6d6d6;border-radius:3px}html body .highlight pre{margin-bottom:0;word-break:normal}html body pre code,html body pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}html body pre code:before,html body pre tt:before,html body pre code:after,html body pre tt:after{content:normal}html body p,html body blockquote,html body ul,html body ol,html body dl,html body pre{margin-top:0;margin-bottom:16px}html body kbd{color:#000;border:1px solid #d6d6d6;border-bottom:2px solid #c7c7c7;padding:2px 4px;background-color:#f0f0f0;border-radius:3px}@media print{html body{background-color:#fff}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{color:#000;page-break-after:avoid}html body blockquote{color:#5c5c5c}html body pre{page-break-inside:avoid}html body table{display:table}html body img{display:block;max-width:100%;max-height:100%}html body pre,html body code{word-wrap:break-word;white-space:pre}}.markdown-preview{width:100%;height:100%;box-sizing:border-box}.markdown-preview .pagebreak,.markdown-preview .newpage{page-break-before:always}.markdown-preview pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}.markdown-preview pre.line-numbers>code{position:relative}.markdown-preview pre.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:1em;font-size:100%;left:0;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-preview pre.line-numbers .line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.markdown-preview pre.line-numbers .line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.markdown-preview .mathjax-exps .MathJax_Display{text-align:center !important}.markdown-preview:not([for="preview"]) .code-chunk .btn-group{display:none}.markdown-preview:not([for="preview"]) .code-chunk .status{display:none}.markdown-preview:not([for="preview"]) .code-chunk .output-div{margin-bottom:16px}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode]){position:relative;width:100%;height:100%;top:0;left:0;margin:0;padding:0;overflow:auto}html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{position:relative;top:0}@media screen and (min-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em calc(50% - 457px)}}@media screen and (max-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{font-size:14px !important;padding:1em}}@media print{html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{display:none}}html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{position:fixed;bottom:8px;left:8px;font-size:28px;cursor:pointer;color:inherit;z-index:99;width:32px;text-align:center;opacity:.4}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] #sidebar-toc-btn{opacity:1}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc{position:fixed;top:0;left:0;width:300px;height:100%;padding:32px 0 48px 0;font-size:14px;box-shadow:0 0 4px rgba(150,150,150,0.33);box-sizing:border-box;overflow:auto;background-color:inherit}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar{width:8px}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc a{text-decoration:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{padding:0 1.6em;margin-top:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc li{margin-bottom:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{list-style-type:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{left:300px;width:calc(100% - 300px);padding:2em calc(50% - 457px - 150px);margin:0;box-sizing:border-box}@media screen and (max-width:1274px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{width:100%}}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .markdown-preview{left:50%;transform:translateX(-50%)}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .md-sidebar-toc{display:none}
</style>
</head>
<body for="html-export">
<div class="mume markdown-preview ">
<ul>
<li><a href="#1-%E6%A6%82%E8%BF%B0">1. 概述</a></li>
<li><a href="#2-popup%E5%AE%9E%E7%8E%B0">2. popup实现</a>
<ul>
<li><a href="#21-%E8%B0%83%E7%94%A8%E6%96%B9%E5%BC%8F">2.1. 调用方式</a></li>
<li><a href="#22-%E5%87%BD%E6%95%B0%E5%AE%9A%E4%B9%89">2.2. 函数定义</a>
<ul>
<li><a href="#221-%E5%87%A0%E5%A4%84%E5%88%A4%E6%96%AD%E9%80%BB%E8%BE%91">2.2.1. 几处判断逻辑</a></li>
<li><a href="#222-%E8%B0%83%E7%94%A8online%E6%8A%A5%E8%A1%A8">2.2.2. 调用online报表</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#3-%E6%89%A9%E5%B1%95%E5%AE%9E%E7%8E%B0%E5%85%B3%E8%81%94%E6%9F%A5%E8%AF%A2%E4%B8%AD%E4%BC%A0%E9%80%92%E5%8F%82%E6%95%B0">3. 扩展实现关联查询中传递参数</a>
<ul>
<li><a href="#31-%E5%AF%B9%E6%AF%94%E6%8A%A5%E8%A1%A8%E5%8A%9F%E8%83%BD%E5%88%86%E6%9E%90">3.1. 对比“报表”功能分析</a></li>
<li><a href="#32-%E4%BF%AE%E6%94%B9curdtools%E5%AE%9E%E7%8E%B0">3.2. 修改curdtools实现</a></li>
<li><a href="#33-%E8%B0%83%E7%94%A8">3.3. 调用</a></li>
<li><a href="#%E6%8A%A5%E8%A1%A8%E5%AE%9A%E4%B9%89">报表定义</a></li>
</ul>
</li>
<li><a href="#4-%E5%B0%8F%E7%BB%93">4. 小结</a></li>
<li><a href="#5-%E9%99%84%E5%BD%95">5. 附录</a>
<ul>
<li><a href="#51-%E4%BF%AE%E6%94%B9%E5%90%8E%E7%9A%84jeecg-popup%E5%AE%9E%E7%8E%B0%E4%BB%A3%E7%A0%81">5.1. 修改后的jeecg popup实现代码</a></li>
</ul>
</li>
</ul>
<h1 class="mume-header" id="1-%E6%A6%82%E8%BF%B0">1. 概述</h1>
<p>本篇对总jeecg popup的实现和注意事项做一个简要说明,并进行了功能的扩展,可供参考、使用。</p>
<h1 class="mume-header" id="2-popup%E5%AE%9E%E7%8E%B0">2. popup实现</h1>
<h2 class="mume-header" id="21-%E8%B0%83%E7%94%A8%E6%96%B9%E5%BC%8F">2.1. 调用方式</h2>
<pre data-role="codeBlock" data-info="javascript" class="language-javascript">onclick<span class="token operator">=</span><span class="token string">"popupClick(this,'ID,标准编码,标准名称,方法名称','methodid,standardCode,standardName,methodName','lims_p_method')"</span>
</pre><h2 class="mume-header" id="22-%E5%87%BD%E6%95%B0%E5%AE%9A%E4%B9%89">2.2. 函数定义</h2>
<p>popupClick定义在curdtools.js中。</p>
<h3 class="mume-header" id="221-%E5%87%A0%E5%A4%84%E5%88%A4%E6%96%AD%E9%80%BB%E8%BE%91">2.2.1. 几处判断逻辑</h3>
<ul>
<li>
<p>typeof(windowapi) == 'undefined'<br>
windowapi = frameElement.api,一般情况下都是defined了的;</p>
</li>
<li>
<p>指定了字典表字段,tablefield != &quot;&quot; &amp;&amp; tablefield != null<br>
如果没有指定字典(报表)中的字段,则报表中的字段name同目标字段;<br>
项目中,字典用在多处,一般需要指定;<br>
(对应<strong>数据库字段不为空</strong>的情况下,根据表单中字典TEXT的值来取popup的值)</p>
</li>
<li>
<p>inputfield.length&gt;1<br>
(对应<strong>数据库字段为空</strong>的情况下并且字典CODE传入<strong>多个值</strong>时,根据表单中字典CODE的值从popup中来取值;<br>
对应<strong>数据库字段为空</strong>的情况下并且字典CODE传入<strong>一个值</strong>时,根据表单中字典TEXT的值从popup中来取值)</p>
</li>
<li>
<p>str.indexOf(&quot;undefined&quot;)==-1<br>
如果在字典中获取不到该值,则将目标字段置为空字符串;<br>
此处要注意,报表中<strong>name是小写</strong>的,不论online设计中是否大写;</p>
</li>
<li>
<p>inputs.length==1<br>
是否是单选,列表中指定name,可以获取多条记录,触发popup,选择多条字典值,更新多条记录的值</p>
</li>
</ul>
<h3 class="mume-header" id="222-%E8%B0%83%E7%94%A8online%E6%8A%A5%E8%A1%A8">2.2.2. 调用online报表</h3>
<ul>
<li><a href="http://cgReportController.do?popup&amp;id=">cgReportController.do?popup&amp;id=</a>&quot;+pcode</li>
</ul>
<h1 class="mume-header" id="3-%E6%89%A9%E5%B1%95%E5%AE%9E%E7%8E%B0%E5%85%B3%E8%81%94%E6%9F%A5%E8%AF%A2%E4%B8%AD%E4%BC%A0%E9%80%92%E5%8F%82%E6%95%B0">3. 扩展实现关联查询中传递参数</h1>
<h2 class="mume-header" id="31-%E5%AF%B9%E6%AF%94%E6%8A%A5%E8%A1%A8%E5%8A%9F%E8%83%BD%E5%88%86%E6%9E%90">3.1. 对比“报表”功能分析</h2>
<p>对比“报表”功能的请求地址:</p>
<pre data-role="codeBlock" data-info="" class="language-"><code>http://localhost/labsharp/cgReportController.do?list&amp;id=lims_ps_method_testid&amp;testid=4028e381646d5a7201646d72ceda0004
</code></pre><ul>
<li>报表功能使用action为list,可传递报表id,以及报表参数。</li>
</ul>
<p>对比两者的Freemarker模板:</p>
<pre data-role="codeBlock" data-info="" class="language-"><code>/org/jeecgframework/web/cgreport/engine/core/cgreportlist.ftl
/org/jeecgframework/web/cgreport/engine/core/cgreportlistpopup.ftl
</code></pre><ul>
<li>报表使用cgreportlist模板,popup使用cgreportlistpopup模板</li>
</ul>
<p>查找Freemarker中dataGrid的数据加载url:</p>
<pre data-role="codeBlock" data-info="" class="language-"><code>url:&apos;cgReportController.do?datagrid&amp;configId=${config_id}${config_params}&apos;
</code></pre><p>两者调用的是同一个action,即popup支持参数就差一哆嗦了。</p>
<h2 class="mume-header" id="32-%E4%BF%AE%E6%94%B9curdtools%E5%AE%9E%E7%8E%B0">3.2. 修改curdtools实现</h2>
<p>popupClick添加pparams参数;<br>
拼接pparams参数到popup Action;</p>
<pre data-role="codeBlock" data-info="JavaScript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">popupClick</span><span class="token punctuation">(</span>pobj<span class="token punctuation">,</span>tablefield<span class="token punctuation">,</span>inputnames<span class="token punctuation">,</span>pcode<span class="token punctuation">,</span>pparams<span class="token punctuation">)</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
<span class="token keyword">var</span> contenturl <span class="token operator">=</span> <span class="token string">"url:cgReportController.do?popup&amp;id="</span><span class="token operator">+</span>pcode<span class="token punctuation">;</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>pparams <span class="token operator">!=</span> <span class="token keyword">null</span> <span class="token operator">&amp;&amp;</span> pparams <span class="token operator">!=</span><span class="token string">""</span> <span class="token operator">&amp;&amp;</span> pparams <span class="token operator">!=</span> <span class="token string">"undefined"</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
contenturl <span class="token operator">+=</span> pparams<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</pre><h2 class="mume-header" id="33-%E8%B0%83%E7%94%A8">3.3. 调用</h2>
<pre data-role="codeBlock" data-info="JavaScript" class="language-javascript">onclick<span class="token operator">=</span><span class="token string">"popupClick(this,'id,标准编码,标准名称,方法名称','methodid,standardCode,standardName,methodName','lims_ps_method_testid','&amp;testid=${mainId}')"</span>
</pre><p>代码中mainId为父子表中的testid。</p>
<h2 class="mume-header" id="%E6%8A%A5%E8%A1%A8%E5%AE%9A%E4%B9%89">报表定义</h2>
<p>Online报表定义如下,jeecg的红色注释可以去掉了。<br>
<img src="https://raw.githubusercontent.com/eyuan/JEECGInAction/master/Doc/Images/popupParam.png" alt="&#x62A5;&#x8868;&#x5B9A;&#x4E49;"></p>
<h1 class="mume-header" id="4-%E5%B0%8F%E7%BB%93">4. 小结</h1>
<ul>
<li>popup传参的应用场景很多,毕竟一个表单上要填写很多信息,这些信息直接经常有级联关系,而且它们还需要从字典库中选择,比如申请单中要填写客户、客户联系人</li>
<li>jeecg很溜的实现了参数,就差一哆嗦了,感谢jeecg</li>
</ul>
<p><strong>码字不易,如果对您有所帮助,请赞一个,谢谢!</strong><br>
<img src="https://raw.githubusercontent.com/eyuan/GunsinAction/master/Doc/Images/0%20WeiXin.jpg" alt=""></p>
<h1 class="mume-header" id="5-%E9%99%84%E5%BD%95">5. 附录</h1>
<h2 class="mume-header" id="51-%E4%BF%AE%E6%94%B9%E5%90%8E%E7%9A%84jeecg-popup%E5%AE%9E%E7%8E%B0%E4%BB%A3%E7%A0%81">5.1. 修改后的jeecg popup实现代码</h2>
<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token comment">/**
* object: pobj当前操作的文本框.
* tablefield:对应字典TEXT,要从popup报表中获取的字段.
* inputnames:对应字典CODE,当前需要回填数据的文本框名称.
* pcode:动态报表的code
* pparams:动态报表的参数和值&amp;p1=v1&amp;p2=v2格式
*/</span>
<span class="token keyword">function</span> <span class="token function">popupClick</span><span class="token punctuation">(</span>pobj<span class="token punctuation">,</span>tablefield<span class="token punctuation">,</span>inputnames<span class="token punctuation">,</span>pcode<span class="token punctuation">,</span>pparams<span class="token punctuation">)</span> <span class="token punctuation">{</span>
$<span class="token punctuation">.</span>dialog<span class="token punctuation">.</span>setting<span class="token punctuation">.</span>zIndex <span class="token operator">=</span> <span class="token function">getzIndex</span><span class="token punctuation">(</span><span class="token boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>inputnames<span class="token operator">==</span><span class="token string">""</span><span class="token operator">||</span>pcode<span class="token operator">==</span><span class="token string">""</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token function">alert</span><span class="token punctuation">(</span><span class="token string">"popup参数配置不全"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">return</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">var</span> contenturl <span class="token operator">=</span> <span class="token string">"url:cgReportController.do?popup&amp;id="</span><span class="token operator">+</span>pcode<span class="token punctuation">;</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>pparams <span class="token operator">!=</span> <span class="token keyword">null</span> <span class="token operator">&amp;&amp;</span> pparams <span class="token operator">!=</span><span class="token string">""</span> <span class="token operator">&amp;&amp;</span> pparams <span class="token operator">!=</span> <span class="token string">"undefined"</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
contenturl <span class="token operator">+=</span> pparams<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">if</span><span class="token punctuation">(</span><span class="token keyword">typeof</span><span class="token punctuation">(</span>windowapi<span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token string">'undefined'</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
$<span class="token punctuation">.</span><span class="token function">dialog</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
content<span class="token punctuation">:</span> contenturl<span class="token punctuation">,</span>
<span class="token comment">//zIndex: getzIndex(), </span>
lock <span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
title<span class="token punctuation">:</span><span class="token string">"选择"</span><span class="token punctuation">,</span>
width<span class="token punctuation">:</span><span class="token number">800</span><span class="token punctuation">,</span>
height<span class="token punctuation">:</span> <span class="token number">400</span><span class="token punctuation">,</span>
cache<span class="token punctuation">:</span><span class="token boolean">false</span><span class="token punctuation">,</span>
ok<span class="token punctuation">:</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
iframe <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span>iframe<span class="token punctuation">.</span>contentWindow<span class="token punctuation">;</span>
<span class="token keyword">var</span> selected <span class="token operator">=</span> iframe<span class="token punctuation">.</span><span class="token function">getSelectRows</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>selected <span class="token operator">==</span> <span class="token string">''</span> <span class="token operator">||</span> selected <span class="token operator">==</span> <span class="token keyword">null</span> <span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token function">alert</span><span class="token punctuation">(</span><span class="token string">"请选择"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token keyword">else</span> <span class="token punctuation">{</span>
<span class="token comment">//对应数据库字段不为空的情况下,根据表单中字典TEXT的值来取popup的值</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>tablefield <span class="token operator">!=</span> <span class="token string">""</span> <span class="token operator">&amp;&amp;</span> tablefield <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">var</span> fields <span class="token operator">=</span> tablefield<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">","</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> inputfield <span class="token operator">=</span> inputnames<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">","</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">var</span> i1<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>i1<span class="token operator">&lt;</span>fields<span class="token punctuation">.</span>length<span class="token punctuation">;</span>i1<span class="token operator">++</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">var</span> str <span class="token operator">=</span> <span class="token string">""</span><span class="token punctuation">;</span>
$<span class="token punctuation">.</span><span class="token function">each</span><span class="token punctuation">(</span> selected<span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>i<span class="token punctuation">,</span> n<span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>i<span class="token operator">==</span><span class="token number">0</span><span class="token punctuation">)</span>
str<span class="token operator">+=</span> n<span class="token punctuation">[</span>fields<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token keyword">else</span><span class="token punctuation">{</span>
str<span class="token operator">+=</span> <span class="token string">","</span><span class="token punctuation">;</span>
str<span class="token operator">+=</span>n<span class="token punctuation">[</span>fields<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> inputname <span class="token operator">=</span> <span class="token function">$</span><span class="token punctuation">(</span>pobj<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">attr</span><span class="token punctuation">(</span><span class="token string">"name"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> inputs <span class="token operator">=</span> inputname<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"."</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//判断传入的this格式是否为 "AA[#index#].aa"的形式</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>str<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"undefined"</span><span class="token punctuation">)</span><span class="token operator">==</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>inputs<span class="token punctuation">.</span>length<span class="token operator">></span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span> <span class="token comment">//update--begin--author:scott date:20171031 for:TASK #2385 online和代码生成器 一对多行popup多字段赋值问题解决-----------</span>
<span class="token keyword">var</span> inpu <span class="token operator">=</span> inputs<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"."</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inpu<span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>inputs<span class="token punctuation">.</span>length<span class="token operator">></span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">var</span> inpu <span class="token operator">=</span> inputs<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"."</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inpu<span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token comment">//对应数据库字段为空的情况下并且字典CODE传入多个值时,根据表单中字典CODE的值从popup中来取值</span>
<span class="token keyword">var</span> inputfield <span class="token operator">=</span> inputnames<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">","</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>inputfield<span class="token punctuation">.</span>length<span class="token operator">></span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">var</span> i1<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>i1<span class="token operator">&lt;</span>inputfield<span class="token punctuation">.</span>length<span class="token punctuation">;</span>i1<span class="token operator">++</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">var</span> str <span class="token operator">=</span> <span class="token string">""</span><span class="token punctuation">;</span>
$<span class="token punctuation">.</span><span class="token function">each</span><span class="token punctuation">(</span> selected<span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>i<span class="token punctuation">,</span> n<span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>i<span class="token operator">==</span><span class="token number">0</span><span class="token punctuation">)</span>
str<span class="token operator">+=</span> n<span class="token punctuation">[</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token keyword">else</span><span class="token punctuation">{</span>
str<span class="token operator">+=</span> <span class="token string">","</span><span class="token punctuation">;</span>
str<span class="token operator">+=</span>n<span class="token punctuation">[</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> inputname <span class="token operator">=</span> <span class="token function">$</span><span class="token punctuation">(</span>pobj<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">attr</span><span class="token punctuation">(</span><span class="token string">"name"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> inputs <span class="token operator">=</span> inputname<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"."</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>str<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"undefined"</span><span class="token punctuation">)</span><span class="token operator">==</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>inputs<span class="token punctuation">.</span>length<span class="token operator">></span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">var</span> inpu <span class="token operator">=</span> inputs<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"."</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inpu<span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>inputs<span class="token punctuation">.</span>length<span class="token operator">></span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">var</span> inpu <span class="token operator">=</span> inputs<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"."</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inpu<span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token comment">//对应数据库字段为空的情况下并且字典CODE传入一个值时,根据表单中字典TEXT的值从popup中来取值</span>
<span class="token keyword">var</span> str <span class="token operator">=</span> <span class="token string">""</span><span class="token punctuation">;</span>
$<span class="token punctuation">.</span><span class="token function">each</span><span class="token punctuation">(</span> selected<span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>i<span class="token punctuation">,</span> n<span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>i<span class="token operator">==</span><span class="token number">0</span><span class="token punctuation">)</span>
str<span class="token operator">+=</span> n<span class="token punctuation">[</span>inputfield<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token keyword">else</span>
str<span class="token operator">+=</span> <span class="token string">","</span><span class="token operator">+</span>n<span class="token punctuation">[</span>inputfield<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> inputname <span class="token operator">=</span> <span class="token function">$</span><span class="token punctuation">(</span>pobj<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">attr</span><span class="token punctuation">(</span><span class="token string">"name"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> inputs <span class="token operator">=</span> inputname<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"."</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>str<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"undefined"</span><span class="token punctuation">)</span><span class="token operator">==</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>inputs<span class="token punctuation">.</span>length<span class="token operator">></span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">var</span> inpu <span class="token operator">=</span> inputs<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"."</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inpu<span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inputfield<span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>inputs<span class="token punctuation">.</span>length<span class="token operator">></span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">var</span> inpu <span class="token operator">=</span> inputs<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"."</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inpu<span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inputfield<span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
cancelVal<span class="token punctuation">:</span> <span class="token string">'关闭'</span><span class="token punctuation">,</span>
cancel<span class="token punctuation">:</span> <span class="token boolean">true</span> <span class="token comment">// 为true等价于function(){}</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
$<span class="token punctuation">.</span><span class="token function">dialog</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
content<span class="token punctuation">:</span> contenturl<span class="token punctuation">,</span>
<span class="token comment">//zIndex: getzIndex(), </span>
lock <span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
title<span class="token punctuation">:</span><span class="token string">"选择"</span><span class="token punctuation">,</span>
width<span class="token punctuation">:</span><span class="token number">800</span><span class="token punctuation">,</span>
height<span class="token punctuation">:</span> <span class="token number">400</span><span class="token punctuation">,</span>
parent<span class="token punctuation">:</span>windowapi<span class="token punctuation">,</span>
cache<span class="token punctuation">:</span><span class="token boolean">false</span><span class="token punctuation">,</span>
ok<span class="token punctuation">:</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
iframe <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span>iframe<span class="token punctuation">.</span>contentWindow<span class="token punctuation">;</span>
<span class="token keyword">var</span> selected <span class="token operator">=</span> iframe<span class="token punctuation">.</span><span class="token function">getSelectRows</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>selected <span class="token operator">==</span> <span class="token string">''</span> <span class="token operator">||</span> selected <span class="token operator">==</span> <span class="token keyword">null</span> <span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token function">alert</span><span class="token punctuation">(</span><span class="token string">"请选择"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token keyword">else</span> <span class="token punctuation">{</span>
<span class="token comment">//对应数据库字段不为空的情况下,根据表单中字典TEXT的值来取popup的值</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>tablefield <span class="token operator">!=</span> <span class="token string">""</span> <span class="token operator">&amp;&amp;</span> tablefield <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">var</span> fields <span class="token operator">=</span> tablefield<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">","</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> inputfield <span class="token operator">=</span> inputnames<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">","</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//循环所有的字段</span>
<span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">var</span> i1<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>i1<span class="token operator">&lt;</span>fields<span class="token punctuation">.</span>length<span class="token punctuation">;</span>i1<span class="token operator">++</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">var</span> str <span class="token operator">=</span> <span class="token string">""</span><span class="token punctuation">;</span>
<span class="token comment">//循环所有选中的行</span>
$<span class="token punctuation">.</span><span class="token function">each</span><span class="token punctuation">(</span> selected<span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>i<span class="token punctuation">,</span> n<span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>i<span class="token operator">==</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
str<span class="token operator">+=</span> n<span class="token punctuation">[</span>fields<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">toLowerCase</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">else</span><span class="token punctuation">{</span>
str<span class="token operator">+=</span> <span class="token string">","</span><span class="token punctuation">;</span>
str<span class="token operator">+=</span>n<span class="token punctuation">[</span>fields<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> inputname <span class="token operator">=</span> <span class="token function">$</span><span class="token punctuation">(</span>pobj<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">attr</span><span class="token punctuation">(</span><span class="token string">"name"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> inputs <span class="token operator">=</span> inputname<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"."</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//判断传入的this格式是否为 "AA[#index#].aa"的形式 </span>
<span class="token keyword">if</span><span class="token punctuation">(</span>str<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"undefined"</span><span class="token punctuation">)</span><span class="token operator">==</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>inputs<span class="token punctuation">.</span>length<span class="token operator">></span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span><span class="token comment">//多选 </span>
<span class="token keyword">var</span> inpu <span class="token operator">=</span> inputs<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"."</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inpu<span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span><span class="token comment">//单选 </span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span><span class="token comment">//没有从弹窗中获取到值,则将表单中的字段值为空 </span>
<span class="token keyword">if</span><span class="token punctuation">(</span>inputs<span class="token punctuation">.</span>length<span class="token operator">></span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span><span class="token comment">//多选</span>
<span class="token keyword">var</span> inpu <span class="token operator">=</span> inputs<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"."</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inpu<span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span><span class="token comment">//单选</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token comment">//对应数据库字段为空的情况下并且字典CODE传入多个值时,根据表单中字典CODE的值从popup中来取值</span>
<span class="token keyword">var</span> inputfield <span class="token operator">=</span> inputnames<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">","</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>inputfield<span class="token punctuation">.</span>length<span class="token operator">></span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">var</span> i1<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>i1<span class="token operator">&lt;</span>inputfield<span class="token punctuation">.</span>length<span class="token punctuation">;</span>i1<span class="token operator">++</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">var</span> str <span class="token operator">=</span> <span class="token string">""</span><span class="token punctuation">;</span>
$<span class="token punctuation">.</span><span class="token function">each</span><span class="token punctuation">(</span> selected<span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>i<span class="token punctuation">,</span> n<span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>i<span class="token operator">==</span><span class="token number">0</span><span class="token punctuation">)</span>
str<span class="token operator">+=</span> n<span class="token punctuation">[</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token keyword">else</span><span class="token punctuation">{</span>
str<span class="token operator">+=</span> <span class="token string">","</span><span class="token punctuation">;</span>
str<span class="token operator">+=</span>n<span class="token punctuation">[</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> inputname <span class="token operator">=</span> <span class="token function">$</span><span class="token punctuation">(</span>pobj<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">attr</span><span class="token punctuation">(</span><span class="token string">"name"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> inputs <span class="token operator">=</span> inputname<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"."</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>str<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"undefined"</span><span class="token punctuation">)</span><span class="token operator">==</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>inputs<span class="token punctuation">.</span>length<span class="token operator">></span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">var</span> inpu <span class="token operator">=</span> inputs<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"."</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inpu<span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>inputs<span class="token punctuation">.</span>length<span class="token operator">></span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">var</span> inpu <span class="token operator">=</span> inputs<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"."</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inpu<span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token comment">//对应数据库字段为空的情况下并且字典CODE传入一个值时,根据表单中字典TEXT的值从popup中来取值</span>
<span class="token keyword">var</span> str <span class="token operator">=</span> <span class="token string">""</span><span class="token punctuation">;</span>
$<span class="token punctuation">.</span><span class="token function">each</span><span class="token punctuation">(</span> selected<span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span>i<span class="token punctuation">,</span> n<span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>i<span class="token operator">==</span><span class="token number">0</span><span class="token punctuation">)</span>
str<span class="token operator">+=</span> n<span class="token punctuation">[</span>inputfield<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token keyword">else</span>
str<span class="token operator">+=</span> <span class="token string">","</span><span class="token operator">+</span>n<span class="token punctuation">[</span>inputfield<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> inputname <span class="token operator">=</span> <span class="token function">$</span><span class="token punctuation">(</span>pobj<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">attr</span><span class="token punctuation">(</span><span class="token string">"name"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> inputs <span class="token operator">=</span> inputname<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"."</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>str<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"undefined"</span><span class="token punctuation">)</span><span class="token operator">==</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>inputs<span class="token punctuation">.</span>length<span class="token operator">></span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">var</span> inpu <span class="token operator">=</span> inputs<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"."</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inpu<span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inputfield<span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>inputs<span class="token punctuation">.</span>length<span class="token operator">></span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">var</span> inpu <span class="token operator">=</span> inputs<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token operator">+</span><span class="token string">"."</span><span class="token operator">+</span>inputfield<span class="token punctuation">[</span>i1<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inpu<span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">"input[name='"</span><span class="token operator">+</span>inputfield<span class="token operator">+</span><span class="token string">"']"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
cancelVal<span class="token punctuation">:</span> <span class="token string">'关闭'</span><span class="token punctuation">,</span>
cancel<span class="token punctuation">:</span> <span class="token boolean">true</span> <span class="token comment">// 为true等价于function(){}</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</pre>
</div>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/liangxinye/jeewms.git
git@gitee.com:liangxinye/jeewms.git
liangxinye
jeewms
jeewms
master

搜索帮助