世界之大 發表於 2024-7-10 11:41:00

泛微OA E9前端开发常用函数及方法

<h2>1、获取单个字段值</h2>
<pre class="language-javascript highlighter-hljs"><code class="highlighter-hljs language-javascript hljs"><span class="hljs-comment">//获取主表值
<span class="hljs-keyword">var fieldvalue = <span class="hljs-title class_">WfForm.<span class="hljs-title function_">getFieldValue(<span class="hljs-string">"field110");
<span class="hljs-comment">//获取明细表:字段_+行号(从0开始算)
<span class="hljs-keyword">var field19112Value = <span class="hljs-title class_">WfForm.<span class="hljs-title function_">getFieldValue(<span class="hljs-string">"field19112_"+rowIndex);</span></span></span></span></span></span></span></span></span></span></code></pre>
<h2>2、修改单个字段值</h2>
<pre class="language-javascript highlighter-hljs"><code class="highlighter-hljs language-javascript hljs"><span class="hljs-comment">//主表:修改文本框、多行文本、选择框等字段类型
<span class="hljs-title class_">WfForm.<span class="hljs-title function_">changeFieldValue(<span class="hljs-string">"field123", {<span class="hljs-attr">value:<span class="hljs-string">"1.234"});
<span class="hljs-comment">//明细表:字段_行号
<span class="hljs-title class_">WfForm.<span class="hljs-title function_">changeFieldValue(<span class="hljs-string">"field19113_"+rowIndex, {<span class="hljs-attr">value:<span class="hljs-string">"值"});
<span class="hljs-comment">//延时修改值
<span class="hljs-variable language_">window.<span class="hljs-built_in">setTimeout(<span class="hljs-keyword">function(<span class="hljs-params">){
    <span class="hljs-title class_">WfForm.<span class="hljs-title function_">changeFieldValue(<span class="hljs-string">"field19637_"+rowMax, {<span class="hljs-attr">value:newVal});
}, <span class="hljs-number">100);</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
<h2>3、明细字段值变化触发事件:支持删除行时也触发</h2>
<pre class="language-javascript highlighter-hljs"><code class="highlighter-hljs language-javascript hljs"><span class="hljs-comment">//可多个拼接逗号隔开,例如:field110,field111
<span class="hljs-comment">//参数1:字段标示(field27583),参数2:行标示,参数3:修改后的值
&lt;script&gt;
    <span class="hljs-title function_">jQuery(<span class="hljs-variable language_">document).<span class="hljs-title function_">ready(<span class="hljs-keyword">function(<span class="hljs-params">){
    <span class="hljs-title class_">WfForm.<span class="hljs-title function_">bindDetailFieldChangeEvent(<span class="hljs-string">"field19112",<span class="hljs-keyword">function(<span class="hljs-params">id,rowIndex,value){
      <span class="hljs-keyword">var rowArr = <span class="hljs-title class_">WfForm.<span class="hljs-title function_">getDetailAllRowIndexStr(<span class="hljs-string">"detail_3").<span class="hljs-title function_">split(<span class="hljs-string">",");
      <span class="hljs-keyword">var map = {};
      <span class="hljs-keyword">for(<span class="hljs-keyword">var i = <span class="hljs-number">0; i &lt; rowArr.<span class="hljs-property">length; i++){
          <span class="hljs-keyword">var rowNumber = rowArr;
          <span class="hljs-keyword">var field19112Value = <span class="hljs-title class_">WfForm.<span class="hljs-title function_">getFieldValue(<span class="hljs-string">"field19112_"+rowNumber);
          <span class="hljs-keyword">if(map.<span class="hljs-title function_">hasOwnProperty(field19112Value)){
            map = ++map;
          }<span class="hljs-keyword">else{
            map = <span class="hljs-number">1;
          }
          <span class="hljs-keyword">var val = map;
          <span class="hljs-title class_">WfForm.<span class="hljs-title function_">changeFieldValue(<span class="hljs-string">"field19113_"+rowNumber, {<span class="hljs-attr">value:val});
      }      
      
    });      
});
&lt;/script&gt;</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
<h2>4、T100项次等于行号:新增删除行时行号自动赋值给项次(行号从0开始,项次从1开始)</h2>
<pre class="language-javascript highlighter-hljs"><code class="highlighter-hljs language-javascript hljs">&lt;script&gt;
    <span class="hljs-title function_">jQuery(<span class="hljs-variable language_">document).<span class="hljs-title function_">ready(<span class="hljs-keyword">function(<span class="hljs-params">){
      <span class="hljs-title class_">WfForm.<span class="hljs-title function_">changeFieldValue(<span class="hljs-string">"field19110_" + <span class="hljs-number">0, {<span class="hljs-attr">value: <span class="hljs-number">1});
      <span class="hljs-title class_">WfForm.<span class="hljs-title function_">registerAction(<span class="hljs-title class_">WfForm.<span class="hljs-property">ACTION_ADDROW+<span class="hljs-string">"1", <span class="hljs-keyword">function(<span class="hljs-params">index){
          <span class="hljs-keyword">let key = <span class="hljs-title class_">WfForm.<span class="hljs-title function_">getDetailRowSerailNum(<span class="hljs-string">"detail_1", index);
          <span class="hljs-comment">//修改文本框、多行文本、选择框等字段类型
          <span class="hljs-title class_">WfForm.<span class="hljs-title function_">changeFieldValue(<span class="hljs-string">"field19110_" + index, {<span class="hljs-attr">value: key});
      });
      
      <span class="hljs-title class_">WfForm.<span class="hljs-title function_">registerAction(<span class="hljs-title class_">WfForm.<span class="hljs-property">ACTION_DELROW+<span class="hljs-string">"1", <span class="hljs-keyword">function(<span class="hljs-params">arg){
      <span class="hljs-keyword">var rowArr = <span class="hljs-title class_">WfForm.<span class="hljs-title function_">getDetailAllRowIndexStr(<span class="hljs-string">"detail_1").<span class="hljs-title function_">split(<span class="hljs-string">",");
      <span class="hljs-keyword">for(<span class="hljs-keyword">var i=<span class="hljs-number">0; i&lt;rowArr.<span class="hljs-property">length; i++){
            <span class="hljs-keyword">var rowNumber = rowArr;
            <span class="hljs-keyword">if(rowNumber !== <span class="hljs-string">""){
                <span class="hljs-keyword">let key = <span class="hljs-title class_">WfForm.<span class="hljs-title function_">getDetailRowSerailNum(<span class="hljs-string">"detail_1", rowNumber);
                <span class="hljs-title class_">WfForm.<span class="hljs-title function_">changeFieldValue(<span class="hljs-string">"field19110_" + rowNumber, {<span class="hljs-attr">value: key});
            }
      }
      });      
});
&lt;/script&gt;</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
<h2>5、JSON返回null值时转换</h2>
<pre class="language-javascript highlighter-hljs"><code class="highlighter-hljs language-javascript hljs"><span class="hljs-attr">field19675:{<span class="hljs-attr">value:(dataArray.<span class="hljs-property">xmdd025 !== <span class="hljs-literal">null ? <span class="hljs-string">"" : dataArray.<span class="hljs-property">xmdd025)}</span></span></span></span></span></span></code></pre>
<p>&nbsp;引用:泛微OA E9前端开发常用函数及方法 - 滔天蟹 - 博客园 (cnblogs.com)</p><br><br>
来源:https://www.cnblogs.com/marie-yl/p/18293737
頁: [1]
查看完整版本: 泛微OA E9前端开发常用函数及方法