123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446 |
- <template>
- <div>
- <k-form-build :value="jsonData" ref="KFB" @submit="handleSubmit" />
- <button @click="hide">隐藏</button>
- <button @click="show">显示</button>
- <button @click="disable">禁用</button>
- <button @click="enable">启用</button>
- <button @click="getData">提交</button>
- </div>
- </template>
- <script>
- export default {
- name: "Demo",
- data() {
- return {
- jsonData: {
- list: [
- {
- type: "button",
- label: "按钮",
- options: {
- type: "primary",
- handle: "submit",
- dynamicFun: "",
- hidden: true,
- disabled: false
- },
- key: "button_1619948868332"
- },
- {
- type: "slider",
- label: "滑动输入条",
- icon: "icon-menu",
- options: {
- width: "100%",
- defaultValue: 0,
- disabled: false,
- hidden: false,
- min: 0,
- max: 100,
- step: 1,
- showInput: false
- },
- model: "slider_1619948887083",
- key: "slider_1619948887083",
- help: "",
- rules: [{ required: false, message: "必填项" }]
- },
- {
- type: "rate",
- label: "评分",
- icon: "icon-pingfen_moren",
- options: {
- defaultValue: 0,
- max: 5,
- disabled: false,
- hidden: false,
- allowHalf: false
- },
- model: "rate_1619948887483",
- key: "rate_1619948887483",
- help: "",
- rules: [{ required: false, message: "必填项" }]
- },
- {
- type: "uploadImg",
- label: "上传图片",
- icon: "icon-image",
- options: {
- defaultValue: "[]",
- multiple: false,
- hidden: false,
- disabled: false,
- width: "100%",
- data: "{}",
- limit: 3,
- placeholder: "上传",
- fileName: "image",
- headers: {},
- action: "http://cdn.kcz66.com/upload-img.txt",
- listType: "picture-card"
- },
- model: "uploadImg_1619948887819",
- key: "uploadImg_1619948887819",
- help: "",
- rules: [{ required: false, message: "必填项" }]
- },
- {
- type: "card",
- label: "卡片布局",
- list: [
- {
- type: "date",
- label: "日期选择框",
- icon: "icon-calendar",
- options: {
- width: "100%",
- defaultValue: "",
- rangeDefaultValue: [],
- range: false,
- showTime: false,
- disabled: false,
- hidden: false,
- clearable: false,
- placeholder: "请选择",
- rangePlaceholder: ["开始时间", "结束时间"],
- format: "YYYY-MM-DD"
- },
- model: "date_1619948975172",
- key: "date_1619948975172",
- help: "",
- rules: [{ required: false, message: "必填项" }]
- },
- {
- type: "input",
- label: "输入框",
- icon: "icon-write",
- options: {
- type: "text",
- width: "100%",
- defaultValue: "",
- placeholder: "请输入",
- clearable: false,
- maxLength: null,
- hidden: false,
- disabled: false
- },
- model: "input_1619948973892",
- key: "input_1619948973892",
- help: "",
- prefix: "",
- suffix: "",
- rules: [{ required: false, message: "必填项" }]
- },
- {
- type: "textarea",
- label: "文本框",
- icon: "icon-edit",
- options: {
- width: "100%",
- minRows: 4,
- maxRows: 6,
- maxLength: null,
- defaultValue: "",
- clearable: false,
- hidden: false,
- disabled: false,
- placeholder: "请输入"
- },
- model: "textarea_1619948974269",
- key: "textarea_1619948974269",
- help: "",
- rules: [{ required: false, message: "必填项" }]
- }
- ],
- key: "card_1619948983395"
- },
- {
- type: "table",
- label: "表格布局",
- trs: [
- {
- tds: [
- {
- colspan: 1,
- rowspan: 1,
- list: [
- {
- type: "slider",
- label: "滑动输入条",
- icon: "icon-menu",
- options: {
- width: "100%",
- defaultValue: 0,
- disabled: false,
- hidden: false,
- min: 0,
- max: 100,
- step: 1,
- showInput: false
- },
- model: "slider_1619948976300",
- key: "slider_1619948976300",
- help: "",
- rules: [{ required: false, message: "必填项" }]
- }
- ]
- },
- {
- colspan: 1,
- rowspan: 1,
- list: [
- {
- type: "uploadImg",
- label: "上传图片",
- icon: "icon-image",
- options: {
- defaultValue: "[]",
- multiple: false,
- hidden: false,
- disabled: false,
- width: "100%",
- data: "{}",
- limit: 3,
- placeholder: "上传",
- fileName: "image",
- headers: {},
- action: "http://cdn.kcz66.com/upload-img.txt",
- listType: "picture-card"
- },
- model: "uploadImg_1619948977239",
- key: "uploadImg_1619948977239",
- help: "",
- rules: [{ required: false, message: "必填项" }]
- },
- {
- type: "time",
- label: "时间选择框",
- icon: "icon-time",
- options: {
- width: "100%",
- defaultValue: "",
- disabled: false,
- hidden: false,
- clearable: false,
- placeholder: "请选择",
- format: "HH:mm:ss"
- },
- model: "time_1619948975820",
- key: "time_1619948975820",
- help: "",
- rules: [{ required: false, message: "必填项" }]
- }
- ]
- }
- ]
- },
- {
- tds: [
- {
- colspan: 1,
- rowspan: 1,
- list: [
- {
- type: "radio",
- label: "单选框",
- icon: "icon-danxuan-cuxiantiao",
- options: {
- disabled: false,
- hidden: false,
- defaultValue: "",
- dynamicKey: "",
- dynamic: false,
- options: [
- { value: "1", label: "选项1" },
- { value: "2", label: "选项2" },
- { value: "3", label: "选项3" }
- ]
- },
- model: "radio_1619948974588",
- key: "radio_1619948974588",
- help: "",
- rules: [{ required: false, message: "必填项" }]
- }
- ]
- },
- {
- colspan: 1,
- rowspan: 1,
- list: [
- {
- type: "date",
- label: "日期选择框",
- icon: "icon-calendar",
- options: {
- width: "100%",
- defaultValue: "",
- rangeDefaultValue: [],
- range: false,
- showTime: false,
- disabled: false,
- hidden: false,
- clearable: false,
- placeholder: "请选择",
- rangePlaceholder: ["开始时间", "结束时间"],
- format: "YYYY-MM-DD"
- },
- model: "date_1619948975548",
- key: "date_1619948975548",
- help: "",
- rules: [{ required: false, message: "必填项" }]
- }
- ]
- }
- ]
- }
- ],
- options: {
- width: "100%",
- bordered: true,
- bright: false,
- small: true,
- customStyle: ""
- },
- key: "table_1619948992003"
- },
- {
- type: "uploadFile",
- label: "上传文件",
- icon: "icon-upload",
- options: {
- defaultValue: "[]",
- multiple: false,
- disabled: false,
- hidden: false,
- drag: false,
- downloadWay: "a",
- dynamicFun: "",
- width: "100%",
- limit: 3,
- data: "{}",
- fileName: "file",
- headers: {},
- action: "http://cdn.kcz66.com/uploadFile.txt",
- placeholder: "上传"
- },
- model: "uploadFile_1619948976948",
- key: "uploadFile_1619948976948",
- help: "",
- rules: [{ required: false, message: "必填项" }]
- },
- {
- type: "cascader",
- label: "级联选择器",
- icon: "icon-guanlian",
- options: {
- disabled: false,
- hidden: false,
- showSearch: false,
- placeholder: "请选择",
- clearable: false,
- dynamicKey: "",
- dynamic: true,
- options: [
- {
- value: "1",
- label: "选项1",
- children: [{ value: "11", label: "选项11" }]
- },
- {
- value: "2",
- label: "选项2",
- children: [{ value: "22", label: "选项22" }]
- }
- ]
- },
- model: "cascader_1619948977724",
- key: "cascader_1619948977724",
- help: "",
- rules: [{ required: false, message: "必填项" }]
- },
- {
- type: "treeSelect",
- label: "树选择器",
- icon: "icon-tree",
- options: {
- disabled: false,
- multiple: false,
- hidden: false,
- clearable: false,
- showSearch: false,
- treeCheckable: false,
- placeholder: "请选择",
- dynamicKey: "",
- dynamic: true,
- options: [
- {
- value: "1",
- label: "选项1",
- children: [{ value: "11", label: "选项11" }]
- },
- {
- value: "2",
- label: "选项2",
- children: [{ value: "22", label: "选项22" }]
- }
- ]
- },
- model: "treeSelect_1619948978156",
- key: "treeSelect_1619948978156",
- help: "",
- prefix: "",
- suffix: "",
- rules: [{ required: false, message: "必填项" }]
- }
- ],
- config: {
- layout: "horizontal",
- labelCol: { xs: 4, sm: 4, md: 4, lg: 4, xl: 4, xxl: 4 },
- wrapperCol: { xs: 18, sm: 18, md: 18, lg: 18, xl: 18, xxl: 18 },
- hideRequiredMark: false,
- customStyle: ""
- }
- }
- };
- },
- methods: {
- handleSubmit(p) {
- // 通过表单提交按钮触发,获取promise对象
- p()
- .then(res => {
- // 获取数据成功
- alert(JSON.stringify(res));
- })
- .catch(err => {
- console.log(err, "校验失败");
- });
- },
- show() {
- this.$refs.KFB.show(["date_1619948975172"]);
- },
- hide() {
- this.$refs.KFB.hide(["date_1619948975172"]);
- },
- disable() {
- this.$refs.KFB.disable(["date_1619948975172"]);
- },
- enable() {
- this.$refs.KFB.enable(["date_1619948975172"]);
- },
- getData() {
- // 通过函数获取数据
- this.$refs.KFB.getData()
- .then(res => {
- // 获取数据成功
- alert(JSON.stringify(res));
- })
- .catch(err => {
- console.log(err, "校验失败");
- });
- }
- }
- };
- </script>
|