云筑文档(桌面端)
开发指南
快速上手
辅助
Utility辅助类
DataSet 数据集
dataHelper 数据请求助手
通用
icons svg
布局
grid 栅格
综合布局
表单
表 单
树
查找定义
下拉网格
扫码枪
复选框
级联选择
树选择
地图选择
baidu地图
上传
图片
组件
分页
下推
横向面板
纵向面板
排序面板
数据列表
条件面板
Excel导入
树查询面板
编辑器
表达式
上下文菜单
表格
工具条
流程测试
任务中心
图表
图片
对话框
动态组件
流程图
甘特图
calendar
进度条
导航菜单
折叠面板
本文档使用 MrDoc 发布
-
+
首页
表 单
<div class="textDiv">  ------------ 表单 ------------ 代码示例如下 ```html <template> <div> <hi-toolbar :buttons="buttons" :source="deptStore" :addOne="false"> </hi-toolbar> <button @click="precision()">precision()</button> <button @click="hide()">hide()</button> <button @click="show()">show()</button> <button @click="$refs.detailForm.validate()">validate()</button> <button @click="readonlychange">readonlychange</button> <button @click="readonlychange1">fieldrequiredchange</button> <div v-html="deptStore.curRecord">fff</div> <!-- <el-radio-group v-model="deptStore.curRecord.F7"> <el-radio label="11">备选项11</el-radio> <el-radio label="21">备选项21</el-radio> <el-radio label="31">备选项31</el-radio> </el-radio-group> --> <hi-form :dataSource="deptStore" ref="detailForm" :model="deptStore.curRecord" :items="items" :disabled="false" :columnsTotal="3" :labelPosition="labelPosition" :labelWidth="labelWidth" ></hi-form> <!-- <hi-form :model="model" :items="items" :columnsTotal="4" :colPercents="[1,1,1,1]" labelSuffix=" :" :size="size" :disabled="true" ></hi-form> --> </div> </template> <script> import dataHelper from "@/base/dataHelper"; import { bind } from "lodash"; export default { data() { var me = this; return { buttons: [ { kind:"add", // text: "", //type:"primary", size:"small", icon: "el-icon-circle-plus", },{ kind:"del", // text: "删除", // type:"primary", icon: "el-icon-delete" },{ kind:"reset", //text: "取消", // type:"primary", icon: "el-icon-refresh-left" }, { kind:"save", //text: "保存", type:"danger", icon: "el-icon-upload", domProps: { innerHTML: "<i class=\"el-icon-upload el-icon--right\"></i>自定义保存按钮" } }, { kind:"nexttache", // text: "删除", // type:"primary", }, { kind:"backtache", // text: "删除", // type:"primary", }, { kind:"signout", }, { kind:"monitor", }, { kind:"reset1", text: "自定义", type:"primary", icon: "el-icon-refresh-right", click:function(){ alert(0) } }, ], deptStore: null, readonly: false, required: false, test: 2, deptCfg: { modelFile: "eap5csxm.pro/KongJianCeShi.dir/ShuJuZuJian.dir/MoXingCeShi.dir/ShuJuMoXing.moduledir/dataset.datadir/ChaZhaoDingYiCeShi-ShuJuJi.bizstore|vfPrrdr.BizEntity~_extFile", //数据集配置 部门 id: "dept", //主键 primary: ["id"], //操作权限 operations: ["oinsert", "odelete", "oquery", "omodify"], //字段顺序,自动填充的顺充 sortFields: ["id", "name"], fields: { id: { name: "id", //字段ID label: "部门ID", //字段描述 "dbtype":"dbDouble", //数据类型 // required: true, // precision: 31, // readonly: true, readonly: false, length: 50, rules: [], /* default: { //默认值 //rule: "first", //prior 填充规则 exps: (data) => { //填充表达式 return "部门" + new Date().valueOf() }, }, */ }, FGUID: { name: "FGUID", //字段ID label: "FGUID", //字段描述 // dbtype: "dbInt", //数据类型 required: true, // precision: 0, // readonly: true, readonly: false, length: 50, rules: [], }, F7: { name: "F7", //字段ID label: "F7", //字段描述 // dbtype: "dbInt", //数据类型 required: true, // precision: 0, // readonly: true, readonly: false, length: 50, rules: [], // default: { // //默认值 // //rule: "first", //prior 填充规则 // exps: (data) => { // //填充表达式 // return "11" // }, // }, }, name: { name: "name", //字段ID label: "部门名称", //字段描述 // required: true, dbtype: "dbString", //数据类型 readonly: false, default: { //默认值 //rule: "first", //prior 填充规则 exps: (data) => { //填充表达式 return "微信截图_20210621144808.png;4248;eap5csxm/2021-12-16/2b235ef8-36c3-47fb-894b-df46a41e146a.png;;png" // return "部门" + data.desc || data.id; }, }, }, field12: { name: "field12", //字段ID label: "field12", //字段描述 }, field18: { name: "field18", //字段ID label: "field18", //字段描述 dbtype: "dbBoolean", //数据类型 }, field19: { name: "field18", //字段ID label: "field18", //字段描述 }, field13: { lookup: { fieldPair: { "dept": { "targetEntity": "ssss", "returnFields": { "field13": "FC1", "id": "FC2" } } }, }, }, }, }, model: { imageview: "timg.jpg;44322;kankan/2021-02-21/cc976ae7-ec1a-4ace-897e-a87bdfb85b85.jpg;;|f7b3088b5ad1356de979068a23d97b2b_t.jpg;4211;kankan/2021-04-27/375f8772-3589-4ecd-9e61-87bb827b00e8.jpg;;|2a80bfeeb825b32c609c56d7ba0eae1e_t.jpg;154111;kankan/2021-04-27/121596d6-9c7d-4250-a4c7-12c4b6ad2674.jpg;;|6fe2214af5ef7db5d4979c01f594d11c_t.jpg;16630;kankan/2021-04-27/b7749495-fef9-49fe-88b3-e15ed1918fd6.jpg;;|68d51e36da42891bb774e7d6795076e2_t.jpg;39857;kankan/2021-04-27/c154d414-4277-4053-9065-94b94fe7975d.jpg;;|b7a9ee2f34811ba7af8c73c58c8206c5_t.jpg;37189;kankan/2021-04-27/fbd05f7a-e6dd-4ddc-9a09-45958ef9cb86.jpg;;", id:1, name: undefined, desc: "", field1: "活动名称", field2: "", field3: "", field4: "", field5: "1", field6: 2, field7: 7, field8: "", field9: "", field10: "", field11: "", field12: "", field13: undefined, field14: [117.54467554296872, 40.47572620188464], LON: "", LAT: ["szdq", "fujian", "fuzhou", "gulou"], field16: "aaaaaa", field17: 2, field18:false, field19:"", }, size: "mini", labelWidth: "100px", labelPosition: "left", // rules:{ // field1:[{ required: true, message: "请输入活动名称", trigger: "blur" }, // { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur"}] // }, items: [ // { // name: "imageview", // props: { // width: 200, // height: 200, // }, // }, { // element: "hi-textarea", name: "id", label:"id", // labelWidth:"0px", element: "hi-number", props: { // type: "textarea", // precision: 0, // format: "¥0.00", // "controls-position": "right", }, }, { props: { placeholder: "F7", }, name: "F7", children:[ { element:"el-button", slot:"append", props:{ icon:"el-icon-search", }, on: { click: (e)=>{ console.log(this) } } }, { element:"el-select", slot:"prepend", name:"id", props:{ }, children:[ { element: "el-option", props: { value: "选项1", label: "黄金糕" }, }, { element: "el-option", props: { value: "选项2", label: "双皮奶" }, }, { element: "el-option", props: { value: "选项3", label: "蚵仔煎" }, }, ] } ] }, // { // name:"F7", // element: "el-radio-group", // props: { // }, // children: [ // { // element: "el-radio", // props: { value: "11", label: "11" }, // }, // { // element: "el-radio", // props: { value: "21", label: "21" }, // }, // ] // }, { name: "F7", element: "hi-checkbox", props: { lookup:{ multiSelect:false, checkValid:true, active:true, sourceDatas1:[ { "FC1": "a", "FC2": "aa" }, { "FC1": "b", "FC2": "bb" }, { "FC1": "c", "FC2": "cc" } ], // param:new dataHelper.queryHelper.Param( // {where:new dataHelper.queryHelper.Where({ // "join": "and", // "criterionData": { // items:[{ // "sign": "noteq", // "name": "FDESC", // "tablefilter": false, // "dataType": "dbString", // "value":"-1", // "enabled": true // } // ]} // })} // ), "modelFile":"eap5csxm.pro/KongJianCeShi.dir/ShuJuZuJian.dir/MoXingCeShi.dir/ShuJuMoXing.moduledir/dataset.datadir/ChaZhaoDingYiShuJuJi.bizstore|YpDTzIRm.BizEntity~_extFile", // label:"FC2", // filtername:"FCOMMON", // filternames:[{ // name:"FDESC" // },{ // name:"FPINYIN", // operate:"like" // },{ // name:"FJIANPIN" // }], tableprops:{ // border:true, hideRowBorder:true, stripe:true, "show-header":false, //fit:false, size:"mini", "max-height":400, white_space_nowrap:true }, "returnFields": { "a": "FC1", "b": "FC2", "F7":"FC1" }, "columns": [ { "name": "FC1", "label": "简拼", // "width": }, { "name": "FC2", "label": "编号", "width":100 }, /* { "name": "FUSERID", "label": "FUSERID" } */ ] } } }, { name: "FGUID", label: "经纬度", colspan: 1, rowspan: 1, element: "hi-cascader", props: { lookup: { label:"desc", // multiSelect:true, "modelFile": "eap5csxm.pro/KongJianCeShi.dir/ShuJuZuJian.dir/ShuKongJian.moduledir/dataset.datadir/ShuKongJianw_shukongj.bizstore|fDgHULTF.BizEntity~_extFile", // param: { "fid": "-1"}, id: "fguid", pid: "fid", pathLabels: "pathLabels",//标签路径 // returnFields: { // "desc": "name", // "note":"note", // }, sourceDsId:"LttuNS9K", "fieldPair": { //模型数据集 "LttuNS9K": { "targetEntity": "vfPrrdr", "returnFields": { "FGUID": "note", "name": "name" } }, }, }, "show-all-levels": false, props: { value: "note", label: "name", leaf: "leaf", emitPath:false, // multiple: true, // checkStrictly: true, lazy: true } } }, { name: "field19", element: "el-radio-group", children: [ <el-radio label="ANY">独占</el-radio>, <el-radio label="ALL">会签</el-radio>, <el-radio label="SEQUENCE">顺序</el-radio>, ], }, { name: "F6", colspan: 1, element: "hi-select-grid", label: "下拉网格", props: { selectOption: { // remote:true, loading: true, multiple: false, clearable: true, filterable: true, "allow-create": true, "collapse-tags": true, }, lookup:{ active:true, // sourceDatas:data, // param:new dataHelper.queryHelper.Param( // {where:new dataHelper.queryHelper.Where({ // "join": "and", // "criterionData": { // items:[{ // "sign": "noteq", // "name": "FDESC", // "tablefilter": false, // "dataType": "dbString", // "value":"-1", // "enabled": true // } // ]} // })} // ), "modelFile":"eap5csxm.pro/KongJianCeShi.dir/ShuJuZuJian.dir/MoXingCeShi.dir/ShuJuMoXing.moduledir/dataset.datadir/ChaZhaoDingYiShuJuJi.bizstore|YpDTzIRm.BizEntity~_extFile", label:"FJIANPIN", // filtername:"FCOMMON", // filternames:[{ // name:"FDESC" // },{ // name:"FPINYIN", // operate:"like" // },{ // name:"FJIANPIN" // }], tableprops:{ // border:true, hideRowBorder:true, stripe:true, "show-header":false, //fit:false, size:"mini", "max-height":150, white_space_nowrap:true }, "returnFields": { "b": "FC1", "a": "FC2", "F7": "FC1" }, "columns": [ { "name": "FC1", "label": "简拼", // "width": }, // { // "name": "FC2", // "label": "编号", // "width":100 // }, /* { "name": "FUSERID", "label": "FUSERID" } */ ] } }, }, { name: "field13", colspan: 2, element: "hi-data-select", label: "查找定义", props: { disabled: false, required: true, // size: "small", selectOption: { loading: true, multiple: false, clearable: true, filterable: true, // "allow-create":true, "collapse-tags": false, "default-first-option": true, }, lookup: { // filtername: "FCOMMON", /* filternames: [ { name: "FBARCODE" }, { name: "FDESC" }, { name: "FPINYIN", operate: "like" }, { name: "FJIANPIN" }], */ // layout:"updown", /* param:{ FPID:"-1" }, */ where:{ "join": "and", "criterionData": { items:[{ "sign": "noteq", "name": "FPID", "tablefilter": false, "dataType": "dbString", "value":function(dataset,model){ if(!model.desc){ throw new Error(11111) }else{ return model.desc } }, "enabled": true } ] } }, storeCfg: { modelFile: "eap5csxm.pro/KongJianCeShi.dir/ShuJuZuJian.dir/MoXingCeShi.dir/ShuJuMoXing.moduledir/dataset.datadir/ChaZhaoDingYiShuJuJi.bizstore|YpDTzIRm.BizEntity~_extFile", //数据集配置 部门 id: "dept", //主键 primary: ["id"], //操作权限 operations: ["oinsert", "odelete", "oquery", "omodify"], //字段顺序,自动填充的顺充 sortFields: ["FID", "FNUMBER"], fields: { FID: { name: "FID", //字段ID label: "FID", //字段描述 dbtype: "dbInt", //数据类型 required: true, readonly: true, length: 50, rules: [], }, FPID: { name: "FPID", //字段ID label: "FPID", //字段描述 dbtype: "dbString", //数据类型 }, FVALUE: { name: "FJIANPIN", //字段ID label: "FJIANPIN", //字段描述 dbtype: "dbString", //数据类型 }, FDESC: { name: "FDESC", //字段ID label: "FDESC", //字段描述 dbtype: "dbText", //数据类型 }, FUSERID: { name: "FPATH", //字段ID label: "FPATH", //字段描述 dbtype: "dbString", //数据类型 }, }, }, tableprops: { // border:true, hideRowBorder: true, stripe: true, "show-header": true, //fit:false, size: "mini", "max-height": 400, white_space_nowrap: true, }, active: true, /* treeOption:{ "modelFile": "database/base/dataset/SqlBaseEntity.xml", param: { "FPID": "-1", $pageIndex: -1, $pageSize: -1 }, id: "FID", pid: "FPID", leaf: "FLEAF",//叶子节点 treeField:"FID", joinField:"FPID", // "joinType": "eq", props:{ label: "FDESC", }, }, */ addRecord: true, // uniqueFields: ["name"], //唯一字段 multiSelect: false, //multiple checkValid: true, //验证约束 allow-create // "returnFields": { // "desc": "FDESC", // "field13": "FBARCODE" // }, columns: [ { name: "FC1", label: "FC1", width: 100, }, { name: "FC2", label: "FC2", }, ], queryOption: { columnsTotal: 4, fields: [ { name: "FJIANPIN", label: "FID", element: "el-input", }, { name: "FDESC", label: "FPID", element: "el-input", }, ], }, }, }, }, { name: "field1", label: "活动名称mini", colspan: 1, required: true, props: { maxlength: 5, labelWidth: "130px", showWordLimit: true, size: "mini", }, }, { name: "field5", required: true, props: { //format:"¥NNN,NNN", //dbType:"dbInt", "controls-position": "right", }, label: "活动性质", }, { name: "field7", colspan: 2, element: "el-slider", label: "活动形式", props: { "show-input": true, }, }, { name: "field6", element: "el-rate", props: { colors: ["red", "blue", "yellow"], "void-icon-class": "el-icon-set-up", "icon-classes": [ "el-icon-set-up", "el-icon-set-up", "el-icon-set-up", ], }, label: "特殊资源", }, { name: "field8", element: "el-select", label: "多选枚举", props: { multiple: true, placeholder: "请选择", }, children: [ { element: "el-option", props: { value: "选项1", label: "黄金糕" }, }, { element: "el-option", props: { value: "选项2", label: "双皮奶" }, }, { element: "el-option", props: { value: "选项3", label: "蚵仔煎" }, }, ], }, { name: "field9", element: "el-select", label: "单选枚举", props: { placeholder: "请选择", }, children: [ { element: "el-option", domProps: { innerHTML: ` <span style="float: left">选项1</span> <span style="float: right; color: #8492a6; font-size: 13px">黄金糕</span> `, }, props: { value: "选项1", label: "黄金糕" }, }, { element: "el-option", props: { value: "选项2", label: "双皮奶" }, }, { element: "el-option", props: { value: "选项3", label: "蚵仔煎" }, }, ], }, { //label:"button", element: "el-button", // domProps: { // innerHTML: "上传" // }, on: { click: function () { }, }, props: { labelWidth: "0px", round: true, // text:"按钮111", icon: "el-icon-search", }, children: ["上传"], }, { name: "field12", element: "hi-textarea", props: { popup:true, placeholder:"placeholder", type: "textarea", // autosize:{ minRows: 2, maxRows: 4}, rows: 5, }, label: "textarea", }, { element: "el-upload", props: { action: "https://jsonplaceholder.typicode.com/posts/", multiple: true, limit: 2, "list-type": "text", }, children: [ { element: "el-button", domProps: { innerHTML: "附件上传", }, props: { labelWidth: "0px", icon: "el-icon-search", }, }, ], }, { name: "imageview", label: "附件上传", colspan: 3, rowspan: 1, element: "HiImageCropper", props: { // disabled: true, popup:true, size:"mini", "with-credentials": true, accept: "image/png, image/jpeg", limit: 1, fileExtension:"jpg", fileSize:2, // "show-file-list":false, multiple: true, // "listType": "picture-card", }, }, { name: "imageview", label: "附件上传field12", colspan: 3, rowspan: 1, element: "hi-upload", props: { disabled: false, "with-credentials": true, // accept: "image/png, image/jpeg", // "show-file-list":false, multiple: true, // "listType": "picture-card", }, }, { name: "name", label: "附件上传", colspan: 3, rowspan: 1, element: "hi-upload", props: { // disabled: true, "with-credentials": true, accept: "image/png, image/jpeg", // limit: 1, // "show-file-list":false, multiple: true, "listType": "picture", }, }, { name: "field12", label: "附件弹出", colspan: 3, rowspan: 1, element: "hi-upload", props: { clearable: true, uploadName: "附件上传", disabled: true, popup:true, // action:"https://jsonplaceholder.typicode.com/posts/", multiple: true, "listType": "picture-card", }, }, { name: "field14", label: "经纬度", colspan: 3, rowspan: 1, element: "hi-map-select", props: { clearable: true, zoom: 8, lonField: "LON", latField: "LAT", animateFn(resolve) { var option = { zoom: 10, center: [119.27274892109617, 26.042715416136318], }; resolve(option); }, }, }, { name: "LAT", label: "经纬度", colspan: 3, rowspan: 1, // element: "hi-cascader-tab", props: { lookup: { modelFile: "database/base/dataset/SqlBaseEntity.xml", param: { FPID: "-1", $pageIndex: -1, $pageSize: -1 }, id: "FID", pid: "FPID", pathLabels: "id", //标签路径 returnFields: { desc: "FDESC", name: "FPATH", }, }, "show-all-levels": true, props: { value: "FVALUE", label: "FDESC", leaf: "FLEAF", // emitPath:false, // multiple: true, // checkStrictly: true, lazy: true, }, }, }, { name: "field16", colspan: 1, rowspan: 1, element: "el-image", style: { width: "100px", height: "100px", }, injection: "props.src", props: { format: function (val) { return "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"; }, // src: "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg" }, label: "image", }, { element: "div", name: "id", injection: "domProps.innerHTML", style: { color: "blue", }, props: { type: "", format: function (n) { return n == 1 ? "男" : "女"; }, }, domProps: { innerHTML: "", }, }, { element: "div", props:{ labelWidth: "0px", }, domProps: { innerHTML: `<span style="color:red">aaaa</span>`, }, }, { name: "field16", colspan: 1, // element: "hi-select-grid", label: "下拉网格", props: { selectOption: { // remote:true, loading: true, multiple: false, clearable: true, filterable: true, "allow-create": true, "collapse-tags": true, }, lookup: { modelFile: "database/base/dataset/SqlBaseEntity.xml", label: "FDESC", param: { FPID: "-1" }, tableprops: { // border:true, //stripe:true, "show-header": false, //fit:false, size: "mini", "max-height": 400, }, returnFields: { field16: "FVALUE", desc: "FDESC", }, columns: [ // { // "name": "FID", // "label": "FID", // "width":100 // }, { name: "FID", label: "编号", width: 200, }, /* { "name": "FPID", "label": "FPID" }, { "name": "FDESC", "label": "FDESC" }, { "name": "FVALUE", "label": "FVALUE" } */ ], }, }, }, ], }; }, methods: { readonlychange() { this.readonly = !this.readonly; // this.deptStore.setReadonly(this.readonly); this.deptStore.setFieldReadonly(["F7"], true); // this.deptStore.emitter.emit( // "fieldreadonlychange", // this, // ["id", "desc"], // this.readonly // ); }, readonlychange1() { this.required = !this.required; this.deptStore.setFieldRequired("id",this.required) }, precision() { this.items[0].props.precision = 0; }, hide() { // this.$refs.detailForm.hideField(["field13", "desc"]); this.$refs.detailForm.hideField("field16", true); // this.$set(this.items,3,{ // hide:true, // }) }, show() { this.$refs.detailForm.hideField("field16", false); // this.$refs.detailForm.hideField(["field13", "desc"], false); }, }, created() { this.deptStore = this.$dsContainer.createDataSet(this.deptCfg); this.deptStore.on("afterchange",()=>{ }) }, }; </script> ``` </div> ### Attributes | 参数 | 说明 | 类型 | 可选值 | 默认值 | |----------------|-------------------------------------------------|---------|-----------------------|--------| | dataSource | 数据集对象 | object | — | — | | rules | 表单验证规则 | object | — | — | | model | 表单数据对象 | object | — | — | | clearable | 字段删除按钮 | boolean | — | true | | colPercents | 列比例 | Array | — | [1, 1] | | columnsTotal | 总列数 | Number | — | 2 | | items | 字段配置 | Array | — | — | | label-position | 表单域标签的位置,如果值为 left 或者 right 时,则需要设置 label-width | string | right/left/top | right | | labelWidth | 表单域标签的宽度 | string | — | 100px | | lblWidths | 标签宽度比例 | Array | — | [] | | size | 用于控制该表单域下组件的尺寸 | string | medium / small / mini | | | disabled | 是否禁用该表单内的所有组件。 | boolean | | false | ### Form Methods | 方法名 | 说明 | 参数 | |-----------|------|-------------| | hideField | 隐藏字段 | fields,hide | ### Form-Item Attributes | 参数 | 说明 | 类型 | 可选值 | 默认值 | |------------|-------------------------------------------------------------------------------------------------------------------------------------------|--------|------------------------------------|----------| | element | 字段类型 | string | el-input/el-input-number/el-button | el-input | | props | 字段扩展配置,例如{ type:"datetime" } | Object | | | | children | 字段孩子配置,例如el-select》children:[{element:"el-option",props:{value:"选项1",label:"黄金糕"}},{element:"el-option",props:{value:"选项2",label:"双皮奶"}}] | Object | | | | colspan | 跨列数 | Number | — | 1 | | rowspan | 跨行数 | Number | — | 1 | | label | 标签文本 | string | — | | | labelWidth | 表单域标签的的宽度,例如 "50px"。 | string | — | 100px | | size | 用于控制该表单域下组件的尺寸 | string | medium / small / mini | | <style> .textDiv{ border:1px solid #F5F5F5; padding: 20px 35px; border-radius: 4px; } .textDiv:hover{ border-color:#1890ff; } </style>
admin
2024年4月30日 10:45
分享文档
收藏文档
上一篇
下一篇
微信扫一扫
复制链接
手机扫一扫进行分享
复制链接
关于 MrDoc
鲲鹭文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果鲲鹭文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护鲲鹭文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码