数通互联化工云平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
20 KiB

/* empty css */import{o as s,c as a,ai as n}from"./index-3679850f.js";const p=""+new URL("use-form4-3c4c3b8a.png",import.meta.url).href,t=""+new URL("use-form3-566535e7.png",import.meta.url).href,e=""+new URL("use-form1-08d01fcf.png",import.meta.url).href,l=""+new URL("use-form2-c95c310f.png",import.meta.url).href,o={class:"marked-body"},r=n(`<h1 id="表单设计">表单设计</h1><h2 id="基础字段">基础字段</h2><p>表单设计基本常用组件,直接拖动设计区域,设置好相应的属性配置即可,各组件使用见系统管理各栏目</p><p><strong>•树形控件</strong></p><p>使用方法详见<a href="/#/design/dataSource">系统管理部门管理</a> 新增弹窗</p><h2 id="高级字段">高级字段</h2><p><strong>•子表:</strong></p><p>使用方法详见<a href="/#/design/dataSource">新增表单数据源</a></p><p><strong>•自定义组件</strong></p><p>自定义组件需全局注册,<code>导出vue文件</code>使用可使用当前页面导入的。组件需要v-model才级实现更新</p><p>引入当前页面组件时建议使用markRaw,如:</p><pre class="language-javascript"><code class="hljs"><span class="hljs-comment">// import component from &#39;xxx.vue&#39;</span>
<span class="hljs-attr">config</span>: {
<span class="hljs-attr">componentName</span>: <span class="hljs-title function_">markRaw</span>(component)
}</code></pre><p>使</p><p><a href="/#/design/dataList/list"></a> </p><p><a href="/#/system/role">-</a> </p><p><img src="`+p+'" alt=""></p><h2 id=""></h2><p><strong></strong></p><p>使<a href="/#/system/dict"></a></p><p><img src="'+t+`" alt=""></p><h2 id="使">使</h2><p>使</p><p><strong></strong></p><p>src/views/design/form/templatetsjson/javascript</p><pre class="language-javascript"><code class="hljs"><span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> imgPath = <span class="hljs-string">&#39;demo.png&#39;</span> <span class="hljs-comment">// </span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> title = <span class="hljs-string">&#39;&#39;</span> <span class="hljs-comment">// </span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> formData = {} <span class="hljs-comment">// </span></code></pre><h2 id=""></h2><p></p><h2 id=""></h2><p></p><pre class="language-text"><code class="hljs">{
list:[
type:&#39;input&#39;,
control:{
// 这里对应的当前组件所有props参数,可见elementUi组件
}
]
}</code></pre><h2 id="vue">vue</h2><p>vue使</p><h2 id=""></h2><p><code>vue</code>使</p><h2 id=""></h2><h3 id=""></h3><p><strong></strong></p><p>namename{name:&#39;xx&#39;}get[formName]ControlByName(name) name</p><p><strong></strong></p><p>label</p><p><strong>Input/</strong></p><p>selectinput使</p><p>1.select =&gt; Input/true =&gt; </p><p><img src="`+e+'" alt=""></p><p>2.<code>key:</code></p><p><img src="'+l+`" alt=""></p><p><strong></strong></p><p>使&amp;&amp;||//<code>$</code> name=sexname=agesex1age20</p><pre class="language-text"><code class="hljs">$.sex===1&amp;&amp;$.age&gt;20</code></pre><h3 id=""></h3><p><strong>1.</strong></p><p><code></code></p><p><strong>2.</strong></p><p>URLURLapikey</p><p><strong>label/value</strong></p><p>label/value:</p><pre class="language-javascript"><code class="hljs"><span class="hljs-comment">// name/idlabel=&quot;name&quot;,value=&quot;id&quot;</span>
<span class="hljs-keyword">const</span> result =[{<span class="hljs-attr">name</span>:<span class="hljs-string">&#39;name&#39;</span>,<span class="hljs-attr">id</span>:<span class="hljs-string">&#39;1&#39;</span>}]
<span class="hljs-comment">// 转换后的数据</span>
<span class="hljs-keyword">const</span> format =[{<span class="hljs-attr">label</span>:<span class="hljs-string">&#39;name&#39;</span>,<span class="hljs-attr">value</span>:<span class="hljs-string">&#39;1&#39;</span>}]</code></pre><p><code>afterResponse</code></p><p><strong>value</strong></p><p>valuestringnumber</p><p><code>beforeRequest</code>使<code>afterResponse</code>return<code>beforeRequest</code> <code>afterResponse</code></p><pre class="language-javascript"><code class="hljs"><span class="hljs-comment">// beforeRequest</span>
opt = <span class="hljs-function">(<span class="hljs-params">data, route, form</span>) =&gt;</span> {
<span class="hljs-comment">// data表求的数据 route 页面路由信息 form当前表单值</span>
<span class="hljs-keyword">return</span> data
}</code></pre><p>URL optionsFun/api?id=\${key}keyname=key</p><pre class="language-javascript"><code class="hljs">[
{
<span class="hljs-attr">type</span>: <span class="hljs-string">&quot;select&quot;</span>,
<span class="hljs-attr">control</span>:
{
<span class="hljs-attr">modelValue</span>: <span class="hljs-string">&quot;&quot;</span>,
<span class="hljs-attr">appendToBody</span>: <span class="hljs-literal">true</span>
},
<span class="hljs-attr">options</span>: [],
<span class="hljs-attr">config</span>:
{
<span class="hljs-attr">optionsType</span>: <span class="hljs-number">0</span>
},
<span class="hljs-attr">name</span>: <span class="hljs-string">&quot;province&quot;</span>,
<span class="hljs-attr">item</span>:
{
<span class="hljs-attr">label</span>: <span class="hljs-string">&quot;&quot;</span>
}
},
{
<span class="hljs-attr">type</span>: <span class="hljs-string">&quot;select&quot;</span>,
<span class="hljs-attr">control</span>:
{
<span class="hljs-attr">modelValue</span>: <span class="hljs-string">&quot;&quot;</span>,
<span class="hljs-attr">appendToBody</span>: <span class="hljs-literal">true</span>
},
<span class="hljs-attr">options</span>: [],
<span class="hljs-attr">config</span>:
{
<span class="hljs-attr">optionsType</span>: <span class="hljs-number">1</span>,
<span class="hljs-attr">optionsFun</span>: <span class="hljs-string">&quot;/api/getCity?id=\${province}&quot;</span>, <span class="hljs-comment">// province[{label:&#39;x&#39;,value:&#39;xx&#39;}]</span>
<span class="hljs-attr">method</span>: <span class="hljs-string">&quot;get&quot;</span>
},
<span class="hljs-attr">name</span>: <span class="hljs-string">&quot;city&quot;</span>,
<span class="hljs-attr">item</span>:
{
<span class="hljs-attr">label</span>: <span class="hljs-string">&quot;&quot;</span>
}
}]</code></pre><p>使<a href="/#/design/dataList/list"></a></p><p><strong>3.</strong></p><p><code>vue</code>使<a href="/#/docs/form">setOptions</a></p><pre class="language-javascript"><code class="hljs"><span class="hljs-title function_">provide</span>(<span class="hljs-string">&#39;methodsName&#39;</span>, {<span class="hljs-attr">label</span>: <span class="hljs-string">&#39;x&#39;</span>, <span class="hljs-attr">value</span>: <span class="hljs-string">&#39;xx&#39;</span>})</code></pre><p><strong>4.</strong></p><p>URL怀<code>-</code></p><h3 id=""></h3><p><strong>1.</strong></p><p>1.便</p><p>2.</p><p>3.<code>vue</code>myFn:</p><pre class="language-javascript"><code class="hljs"><span class="hljs-title function_">provide</span>(<span class="hljs-string">&quot;myFn&quot;</span>, <span class="hljs-function">(<span class="hljs-params">rule, value, callback</span>) =&gt;</span> {
<span class="hljs-keyword">if</span> (value === <span class="hljs-string">&#39;&#39;</span>) {
<span class="hljs-title function_">callback</span>(<span class="hljs-keyword">new</span> <span class="hljs-title class_">Error</span>(<span class="hljs-string">&#39;Please input the password again&#39;</span>))
} <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (value !== <span class="hljs-string">&#39;abc&#39;</span>) {
<span class="hljs-title function_">callback</span>(<span class="hljs-keyword">new</span> <span class="hljs-title class_">Error</span>(<span class="hljs-string">&quot;Two inputs don&#39;t match!&quot;</span>))
} <span class="hljs-keyword">else</span> {
<span class="hljs-title function_">callback</span>()
}
})</code></pre><p>4../design/form/components/validate.ts</p><p><strong>2.</strong> UI</p><pre class="language-javascript"><code class="hljs">opt = [
{<span class="hljs-attr">required</span>: <span class="hljs-literal">true</span>, <span class="hljs-attr">message</span>: <span class="hljs-string">&#39;age is required&#39;</span>},
{<span class="hljs-attr">type</span>: <span class="hljs-string">&#39;number&#39;</span>, <span class="hljs-attr">message</span>: <span class="hljs-string">&#39;age must be a number&#39;</span>}
]</code></pre><p>*inputselectcheckbox</p><h3 id=""></h3><p>proppropUIprop</p><h2 id=""></h2><p><strong></strong></p><p><strong></strong></p><p></p><p>mysqlurlurl <a href="/#/docs/use-dataSource">使</a></p><p><strong></strong></p><p>get[formName]ControlByNameget[formName]ValueByNameformName使</p><p><strong></strong></p><p>FormItemlabel-width</p><p><strong></strong></p><p>css</p><p><strong></strong></p><p>url</p><p><strong></strong></p><p>headstyle.vuestyle scopedcss</p><p><strong></strong></p><p>checkbox <code></code> key</p><pre class="language-json"><code class="hljs"><span class="hljs-punctuation">{</span>
<span class="hljs-attr">&quot;sex&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
<span class="hljs-attr">&quot;0&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;&quot;</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">&quot;1&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;&quot;</span>
<span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">&quot;status&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
<span class="hljs-attr">&quot;1&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;&quot;</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">&quot;0&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;&quot;</span>
<span class="hljs-punctuation">}</span>
<span class="hljs-punctuation">}</span></code></pre><h3 id=""></h3><p><strong>1.url</strong></p><p>url<code>vue</code>使props.addUrl<strong></strong></p><p><strong>2.url</strong></p><p>urlprops.editUrl</p><p><strong>3.url</strong></p><p>urlprops.requestUrl</p><p><strong>4.beforeRequest</strong></p><p>props.beforeRequest</p><pre class="language-javascript"><code class="hljs"><span class="hljs-keyword">const</span> <span class="hljs-title function_">beforeRequest</span> = (<span class="hljs-params">params, route</span>) =&gt; {
<span class="hljs-comment">// 此处可对请求参数params进行修改处理后返回,route为当前路由信息</span>
<span class="hljs-comment">// 如当路由参数name为true时,添加id参数</span>
<span class="hljs-keyword">if</span> (route.<span class="hljs-property">query</span>.<span class="hljs-property">name</span>) {
params.<span class="hljs-property">id</span> = route.<span class="hljs-property">query</span>.<span class="hljs-property">name</span>
}
<span class="hljs-keyword">return</span> params <span class="hljs-comment">// return false时将发不请求</span>
}</code></pre><p><strong>5.afterResponse</strong></p><p>props.afterResponse<code>requestUrl</code></p><pre class="language-javascript"><code class="hljs"><span class="hljs-keyword">const</span> <span class="hljs-title function_">afterResponse</span> = (<span class="hljs-params">result</span>) =&gt; {
<span class="hljs-comment">// 这里是处理逻辑</span>
<span class="hljs-keyword">return</span> result <span class="hljs-comment">// return false时不处理请求结果</span>
}</code></pre><p>线<code>afterResponse</code>key<code>/utils/formatResult</code></p><pre class="language-javascript"><code class="hljs"><span class="hljs-comment">// const afterResponse = &#39;formatTest&#39;</span>
<span class="hljs-keyword">const</span> <span class="hljs-title function_">formatResult</span> = (<span class="hljs-params">res: any, key: string</span>) =&gt; {
<span class="hljs-comment">// key即为formatTest,可根据设置的key设置不同的处理方法</span>
<span class="hljs-keyword">return</span> res
}</code></pre><p>使</p><p><strong>6.beforeSubmit</strong></p><p>props.beforeSubmitbeforeRequest</p><p><strong>7.afterSubmit</strong></p><p>props.afterSubmitafterResponse</p><p><strong>8.change:</strong></p><p>props.change<code>/utils/formChangeValue</code></p><pre class="language-javascript"><code class="hljs">opt=<span class="hljs-function">(<span class="hljs-params">key,model</span>) =&gt;</span> {
<span class="hljs-comment">// name当前改变组件的值,model表单的值</span>
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&#39;onChange&#39;</span>,key)
<span class="hljs-keyword">return</span> model
}</code></pre><h3 id=""></h3><p><strong>get[formName]ControlByName</strong></p><p> formName -使</p><p> nameformData(name:string)</p><p><strong>get[formName]ValueByName</strong></p><p>name</p><p><a href="/#/system/user">-</a></p>`,130),c=[r],m={__name:"use-form",setup(h){return(u,i)=>(s(),a("div",o,c))}};export{m as default};