#Typora快捷键
#Vue 公用组件使用说明
MyForm表单
对element-ui 中 form表单的二次封装支持如下模块
下面的代码封装支持 栅格布局 -普通常规布局
<template>
<el-form
:ref="refName"
:size="size"
:inline="inline"
:label-width="labelWidth"
:model="formData"
:rules="myFormRules"
:label-position="labelPosition"
:class="myFormClass"
>
<template v-if="customStyle">
<template v-for="(formCfgItem, index) in formCfg">
<el-row :key="index">
<template v-for="(item, index) in formCfgItem">
<el-col
:key="index"
:xs="customCol[0] || null"
:sm="customCol[1] || null"
:md="customCol[2] || null"
:lg="customCol[3] || null"
:xl="customCol[4] || null"
>
<el-form-item
v-if="!item.hide"
:label="item.label"
:style="item.style"
:label-width="item.labelWidth"
:prop="getProp(item, index)"
:key="item.prop"
:class="getFormItemClass(item)"
>
<template v-if="item.type === 'custom'">
<slot :name="item.prop" :item="item">slot>
template>
<template v-if="item.customLabel || item.labelFormatter">
<slot slot="label">
<div
class="custom_label"
v-html="getCustomLabel(item)"
>div>
slot>
template>
<template v-if="item.type != 'title' && item.type !== 'custom'">
<el-input
v-if="item.type === 'input' || item.type === 'password'"
v-model="formData[item.prop]"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
:type="item.inputType"
:maxlength="item.maxlength"
:style="{ width: item.width }"
:placeholder="getInputPlaceholder(item.placeholder)"
>el-input>
<el-input
v-else-if="item.type === 'textarea'"
type="textarea"
:disabled="item.disabled"
@change="item.change && item.change(formData[item.prop])"
:placeholder="getInputPlaceholder(item.placeholder)"
:maxlength="item.maxlength"
:show-word-limit="item.maxlength ? true : false"
:autosize="getTextareaAutosize(item)"
v-model="formData[item.prop]"
:style="{ width: item.width }"
>el-input>
<el-select
v-else-if="item.type === 'select'"
v-model="formData[item.prop]"
:style="{ width: item.width ? item.width : '100%' }"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
:placeholder="getSelectPlaceholder(item.placeholder)"
>
<el-option
v-for="(op, opIndex) in item.options"
:label="item.valueMap ? op[item.valueMap[1]] : op.value"
:value="item.valueMap ? op[item.valueMap[0]] : op.key"
:key="
item.valueMap + opIndex
? op[item.valueMap[0]] + opIndex
: op.key + opIndex
"
>el-option>
el-select>
<el-radio-group
v-else-if="item.type === 'radio'"
v-model="formData[item.prop]"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
>
<el-radio
v-for="ra in item.radios"
:label="item.valueMap ? ra[item.valueMap[1]] : ra.value"
:key="item.valueMap ? ra[item.valueMap[0]] : ra.key"
>
{{ item.valueMap ? ra[item.valueMap[1]] : ra.value }}
el-radio>
el-radio-group>
<el-radio-group
v-else-if="item.type === 'radioButton'"
v-model="formData[item.prop]"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
>
<el-radio-button
v-for="ra in item.radios"
:label="item.valueMap ? ra[item.valueMap[1]] : ra.value"
:key="item.valueMap ? ra[item.valueMap[0]] : ra.key"
>
{{ item.valueMap ? ra[item.valueMap[1]] : ra.value }}
el-radio-button>
el-radio-group>
<el-checkbox-group
v-else-if="item.type === 'checkbox'"
v-model="formData[item.prop]"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
>
<el-checkbox
v-for="ch in item.checkboxs"
:label="item.valueMap ? ch[item.valueMap[0]] : ch.key"
:key="item.valueMap ? ch[item.valueMap[0]] : ch.key"
:border="item.border"
>{{
item.valueMap ? ch[item.valueMap[1]] : ch.value
}}el-checkbox
>
el-checkbox-group>
<el-date-picker
v-else-if="item.type === 'date'"
v-model="formData[item.prop]"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
>el-date-picker>
<el-time-select
v-else-if="item.type === 'time'"
v-model="formData[item.prop]"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
>
el-time-select>
<el-date-picker
v-else-if="item.type === 'datetime'"
type="datetime"
v-model="formData[item.prop]"
:prop="item.prop[0]"
@change="item.change && item.change(formData[item.prop])"
:placeholder="
item.placeholder ? item.placeholder[0] : '开始时间'
"
:disabled="item.disabled"
>el-date-picker>
<template v-else-if="item.type === 'datetimerange'">
<el-col :span="11">
<el-form-item
class="mr0"
:picker-options="
dateConfig ? dateConfig.pickerOptionsStart : null
"
:prop="item.prop[0]"
>
<el-date-picker
style="width: 100%"
type="datetime"
v-model="formData[item.prop[0]]"
@change="
datetimerangeValue =>
datetimerangeChange(item, datetimerangeValue, 0)
"
:placeholder="
item.placeholder ? item.placeholder[0] : '开始时间'
"
:disabled="item.disabled"
>el-date-picker>
el-form-item>
el-col>
<el-col :span="1"
><span class="yzf_telephone_line">-span>el-col
>
<el-col :span="12">
<el-form-item :prop="item.prop[1]">
<el-date-picker
:picker-options="
dateConfig ? dateConfig.pickerOptionsEnd : null
"
style="width: 100%"
type="datetime"
v-model="formData[item.prop[1]]"
@change="
datetimerangeValue =>
datetimerangeChange(item, datetimerangeValue, 1)
"
:placeholder="
item.placeholder ? item.placeholder[1] : '结束时间'
"
:disabled="item.disabled"
>el-date-picker>
el-form-item>
el-col>
template>
<template v-else-if="item.type === 'ordinaryDate'">
<el-col :span="11">
<el-form-item
class="mr0"
:picker-options="
dateConfig ? dateConfig.pickerOptionsStart : null
"
:prop="item.prop[0]"
>
<el-date-picker
style="width: 100%"
v-model="formData[item.prop[0]]"
@change="
ordinaryValue =>
ordinaryDateChange(item, ordinaryValue, 0)
"
:placeholder="
item.placeholder ? item.placeholder[0] : '开始时间'
"
:disabled="item.disabled"
>el-date-picker>
el-form-item>
el-col>
<el-col :span="1"
><span class="yzf_telephone_line">-span>el-col
>
<el-col :span="12">
<el-form-item :prop="item.prop[1]">
<el-date-picker
:picker-options="
dateConfig ? dateConfig.pickerOptionsEnd : null
"
style="width: 100%"
v-model="formData[item.prop[1]]"
@change="
ordinaryValue =>
ordinaryDateChange(item, ordinaryValue, 1)
"
:placeholder="
item.placeholder ? item.placeholder[1] : '结束时间'
"
:disabled="item.disabled"
>el-date-picker>
el-form-item>
el-col>
template>
<el-switch
v-else-if="item.type === 'switch'"
v-model="formData[item.prop]"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
>
el-switch>
<el-cascader
v-else-if="item.type === 'cascader'"
v-model="formData[item.prop]"
style="width: 100%"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
:props="item.props"
:show-all-levels="item.showAllLevels"
:options="item.options"
>
el-cascader>
<template v-else-if="item.type === 'custom'">
<slot :name="item.prop" :data="formData">slot>
template>
<template v-else-if="item.type === 'uploadImage'">
<div
class="yzf_image_box"
v-for="(listItem, listIndex) in formData[item.prop[0]]"
:key="listIndex"
>
<el-image
fit="cover"
class="yzf_image_item"
:src="ImageTool.getSmallImg(listItem[item.imageName])"
>
<div slot="error" class="el-image__error">
<i class="el-icon-picture-outline">i>
div>
el-image>
<div
class="yzf_image_item_dlt"
@click="deleteImage(item, listItem, listIndex)"
>
删除
div>
div>
<el-upload
v-if="
formData[item.prop[0]].length >= item.limit
? false
: true
"
class="yzf_upload"
:multiple="item.limit > 1 ? true : false"
:limit="item.limit"
:ref="getUploadImageRef(index)"
:headers="uploadImageHead"
:action="item.action"
accept="image/gif, image/jpeg, image/jpg, image/png"
:show-file-list="false"
:file-list="formData[item.prop[0]]"
:on-exceed="
(files, fileList) => {
handleExceed(item, files, fileList);
}
"
:http-request="
file => {
uploadImageHttpRequest(item, file);
}
"
>
<div slot="trigger">
新增图片相册<br />{{ "(暂定最多" + item.limit + "张)" }}
div>
el-upload>
template>
<template v-else-if="item.type === 'telephone'">
<el-col :span="5">
<el-form-item :prop="item.prop[0]">
<el-input
v-model="formData[item.prop[0]]"
@change="telephoneChange(item)"
maxlength="4"
:disabled="item.disabled"
placeholder="区号"
>
el-input>
el-form-item>
el-col>
<el-col :span="1"
><span class="yzf_telephone_line">-span>el-col
>
<el-col :span="18">
<el-form-item :prop="item.prop[1]">
<el-input
v-model="formData[item.prop[1]]"
@change="telephoneChange(item)"
:maxlength="8"
:disabled="item.disabled"
placeholder="电话号"
>
el-input>
el-form-item>
el-col>
template>
<template v-else-if="item.type === 'button'">
<el-row :gutter="20">
<template v-for="(action, index) in formAction">
<el-button
:disabled="btLoading"
v-waves
v-if="!getAtionFormatter(action).hide"
:style="action.style"
:type="action.type || null"
@click="actionButtonClick(action)"
:key="index"
>
<i v-if="action.icon" :class="action.icon">i>
{{ getAtionFormatter(action).label }}
el-button>
template>
el-row>
template>
template>
el-form-item>
el-col>
template>
el-row>
template>
template>
<template v-if="!customStyle">
<template v-for="(item, index) in formCfg">
<el-form-item
v-if="!item.hide"
:label="item.label"
:style="customStyle ? `${getWidth(item)} ${item.style} ` : item.style"
:label-width="item.labelWidth"
:prop="getProp(item, index)"
:key="item.type + index"
:class="getFormItemClass(item)"
>
<template v-if="item.type === 'custom'">
<slot :name="item.prop" :item="item">slot>
template>
<template v-if="item.customLabel || item.labelFormatter">
<slot slot="label">
<div class="custom_label" v-html="getCustomLabel(item)">div>
slot>
template>
<template v-if="item.type != 'title' && item.type !== 'custom'">
<el-input
v-if="item.type === 'input' || item.type === 'password'"
v-model="formData[item.prop]"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
:type="item.inputType"
:maxlength="item.maxlength"
:style="{ width: item.width }"
:placeholder="getInputPlaceholder(item.placeholder)"
>el-input>
<el-input
v-else-if="item.type === 'textarea'"
type="textarea"
:disabled="item.disabled"
@change="item.change && item.change(formData[item.prop])"
:placeholder="getInputPlaceholder(item.placeholder)"
:maxlength="item.maxlength"
:show-word-limit="item.maxlength ? true : false"
:autosize="getTextareaAutosize(item)"
v-model="formData[item.prop]"
:style="{ width: item.width }"
>el-input>
<el-select
v-else-if="item.type === 'select'"
v-model="formData[item.prop]"
:style="{ width: item.width ? item.width : '100%' }"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
:placeholder="getSelectPlaceholder(item.placeholder)"
>
<el-option
v-for="(op, opIndex) in item.options"
:label="item.valueMap ? op[item.valueMap[1]] : op.value"
:value="item.valueMap ? op[item.valueMap[0]] : op.key"
:key="
item.valueMap + opIndex
? op[item.valueMap[0]] + opIndex
: op.key + opIndex
"
>el-option>
el-select>
<el-radio-group
v-else-if="item.type === 'radio'"
v-model="formData[item.prop]"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
>
<el-radio
v-for="ra in item.radios"
:label="item.valueMap ? ra[item.valueMap[1]] : ra.value"
:key="item.valueMap ? ra[item.valueMap[0]] : ra.key"
>
{{ item.valueMap ? ra[item.valueMap[1]] : ra.value }}
el-radio>
el-radio-group>
<el-radio-group
v-else-if="item.type === 'radioButton'"
v-model="formData[item.prop]"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
>
<el-radio-button
v-for="ra in item.radios"
:label="item.valueMap ? ra[item.valueMap[1]] : ra.value"
:key="item.valueMap ? ra[item.valueMap[0]] : ra.key"
>
{{ item.valueMap ? ra[item.valueMap[1]] : ra.value }}
el-radio-button>
el-radio-group>
<el-checkbox-group
v-else-if="item.type === 'checkbox'"
v-model="formData[item.prop]"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
>
<el-checkbox
v-for="ch in item.checkboxs"
:label="item.valueMap ? ch[item.valueMap[0]] : ch.key"
:key="item.valueMap ? ch[item.valueMap[0]] : ch.key"
:border="item.border"
>{{
item.valueMap ? ch[item.valueMap[1]] : ch.value
}}el-checkbox
>
el-checkbox-group>
<el-date-picker
v-else-if="item.type === 'date'"
v-model="formData[item.prop]"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
>el-date-picker>
<el-time-select
v-else-if="item.type === 'time'"
v-model="formData[item.prop]"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
>
el-time-select>
<el-date-picker
v-else-if="item.type === 'datetime'"
type="datetime"
v-model="formData[item.prop]"
:prop="item.prop[0]"
@change="item.change && item.change(formData[item.prop])"
:placeholder="item.placeholder ? item.placeholder[0] : '开始时间'"
:disabled="item.disabled"
>el-date-picker>
<template v-else-if="item.type === 'datetimerange'">
<el-col :span="11">
<el-form-item
class="mr0"
:picker-options="
dateConfig ? dateConfig.pickerOptionsStart : null
"
:prop="item.prop[0]"
>
<el-date-picker
style="width: 100%"
type="datetime"
v-model="formData[item.prop[0]]"
@change="
datetimerangeValue =>
datetimerangeChange(item, datetimerangeValue, 0)
"
:placeholder="
item.placeholder ? item.placeholder[0] : '开始时间'
"
:disabled="item.disabled"
>el-date-picker>
el-form-item>
el-col>
<el-col :span="1"
><span class="yzf_telephone_line">-span>el-col
>
<el-col :span="12">
<el-form-item :prop="item.prop[1]">
<el-date-picker
:picker-options="
dateConfig ? dateConfig.pickerOptionsEnd : null
"
style="width: 100%"
type="datetime"
v-model="formData[item.prop[1]]"
@change="
datetimerangeValue =>
datetimerangeChange(item, datetimerangeValue, 1)
"
:placeholder="
item.placeholder ? item.placeholder[1] : '结束时间'
"
:disabled="item.disabled"
>el-date-picker>
el-form-item>
el-col>
template>
<template v-else-if="item.type === 'ordinaryDate'">
<el-col :span="11">
<el-form-item
class="mr0"
:picker-options="
dateConfig ? dateConfig.pickerOptionsStart : null
"
:prop="item.prop[0]"
>
<el-date-picker
style="width: 100%"
v-model="formData[item.prop[0]]"
@change="
ordinaryValue =>
ordinaryDateChange(item, ordinaryValue, 0)
"
:placeholder="
item.placeholder ? item.placeholder[0] : '开始时间'
"
:disabled="item.disabled"
>el-date-picker>
el-form-item>
el-col>
<el-col :span="1"
><span class="yzf_telephone_line">-span>el-col
>
<el-col :span="12">
<el-form-item :prop="item.prop[1]">
<el-date-picker
:picker-options="
dateConfig ? dateConfig.pickerOptionsEnd : null
"
style="width: 100%"
v-model="formData[item.prop[1]]"
@change="
ordinaryValue =>
ordinaryDateChange(item, ordinaryValue, 1)
"
:placeholder="
item.placeholder ? item.placeholder[1] : '结束时间'
"
:disabled="item.disabled"
>el-date-picker>
el-form-item>
el-col>
template>
<el-switch
v-else-if="item.type === 'switch'"
v-model="formData[item.prop]"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
>
el-switch>
<el-cascader
v-else-if="item.type === 'cascader'"
v-model="formData[item.prop]"
style="width: 100%"
@change="item.change && item.change(formData[item.prop])"
:disabled="item.disabled"
:props="item.props"
:show-all-levels="item.showAllLevels"
:options="item.options"
>
el-cascader>
<template v-else-if="item.type === 'custom'">
<slot :name="item.prop" :data="formData">slot>
template>
<template v-else-if="item.type === 'uploadImage'">
<div
class="yzf_image_box"
v-for="(listItem, listIndex) in formData[item.prop[0]]"
:key="listIndex"
>
<el-image
fit="cover"
class="yzf_image_item"
:src="ImageTool.getSmallImg(listItem[item.imageName])"
>
<div slot="error" class="el-image__error">
<i class="el-icon-picture-outline">i>
div>
el-image>
<div
class="yzf_image_item_dlt"
@click="deleteImage(item, listItem, listIndex)"
>
删除
div>
div>
<el-upload
v-if="
formData[item.prop[0]].length >= item.limit ? false : true
"
class="yzf_upload"
:multiple="item.limit > 1 ? true : false"
:limit="item.limit"
:ref="getUploadImageRef(index)"
:headers="uploadImageHead"
:action="item.action"
accept="image/gif, image/jpeg, image/jpg, image/png"
:show-file-list="false"
:file-list="formData[item.prop[0]]"
:on-exceed="
(files, fileList) => {
handleExceed(item, files, fileList);
}
"
:http-request="
file => {
uploadImageHttpRequest(item, file);
}
"
>
<div slot="trigger">
新增图片相册<br />{{ "(暂定最多" + item.limit + "张)" }}
div>
el-upload>
template>
<template v-else-if="item.type === 'telephone'">
<el-col :span="5">
<el-form-item :prop="item.prop[0]">
<el-input
v-model="formData[item.prop[0]]"
@change="telephoneChange(item)"
maxlength="4"
:disabled="item.disabled"
placeholder="区号"
>
el-input>
el-form-item>
el-col>
<el-col :span="1"
><span class="yzf_telephone_line">-span>el-col
>
<el-col :span="18">
<el-form-item :prop="item.prop[1]">
<el-input
v-model="formData[item.prop[1]]"
@change="telephoneChange(item)"
:maxlength="8"
:disabled="item.disabled"
placeholder="电话号"
>
el-input>
el-form-item>
el-col>
template>
template>
el-form-item>
template>
template>
<div v-if="formAction && actionInline && !customStyle">
<el-form-item>
<template v-for="(action, index) in formAction">
<el-button
:disabled="btLoading"
v-waves
v-if="!getAtionFormatter(action).hide"
:style="action.style"
:type="action.type || null"
@click="actionButtonClick(action)"
:key="index"
>
<i v-if="action.icon" :class="action.icon">i>
{{ getAtionFormatter(action).label }}
el-button>
template>
el-form-item>
div>
<el-form-item v-else-if="formAction && !customStyle">
<template v-for="(action, index) in formAction">
<el-button
:disabled="btLoading"
v-waves
v-if="!getAtionFormatter(action).hide"
:style="action.style"
:type="action.type || null"
@click="actionButtonClick(action)"
:key="index"
><i v-if="action.icon" :class="action.icon">i>
{{ getAtionFormatter(action).label }}el-button
>
template>
el-form-item>
el-form>
template>
<script lang="ts">
import {
Component,
Vue,
Provide,
Prop,
Watch,
Emit
} from "vue-property-decorator";
import { State, Action, namespace, Getter } from "vuex-class";
@Component
export default class MyForm extends Vue {
@Prop(Boolean) btLoading: boolean;
@Prop(Boolean) customStyle: boolean;
@Prop(String) myFormClass: string;
@Prop({ type: String, required: false, default: "editForm" }) refName: string;
@Prop({ type: Object, required: false, default: () => {} })
dateConfig: any;
@Prop({ type: Boolean, required: false, default: false }) inline: boolean;
@Prop({ type: String, required: false, default: "" }) labelWidth: string;
@Prop({ type: String, required: false, default: "medium" }) size: string;
@Prop({ type: Array, required: false, default: () => [24, 8, 8, 8, 8] })
customCol: any;
@Prop({ type: Array, required: false, default: () => [] }) formCfg: any;
@Prop({ type: Object, required: false, default: () => {} }) formData: any;
@Prop({ type: Object, required: false, default: null }) formRules: any;
@Prop({ type: Array, required: false, default: () => [] }) formAction: any;
@Prop({ type: Boolean, required: false, default: false })
actionInline: boolean;
@Prop({ type: String, required: false, default: "left" })
labelPosition: string;
@Prop({ type: Number, required: false, default: 0 })
column: number;
private dyData: object = {};
private myFormRules: any;
private get uploadImageHead() {
return { "X-AUTH-TOKEN": this.getSessionKey };
}
created() {
this.initRules();
}
getWidth(item: any) {
let widthStr = "";
if (item.width) {
widthStr = "width:" + item.width + "px;";
} else if (item.span) {
widthStr = "width:" + 4 * item.span + "%;";
} else if (this.column) {
widthStr = "width:" + 100 / this.column + "%;";
} else {
widthStr = "width:100%;";
}
return widthStr;
}
getCustomLabel(item: any) {
if (item.labelFormatter) {
let customL = item.labelFormatter(this.formData);
console.log("customL", customL || item.customLabel);
return customL || item.customLabel;
} else {
return item.customLabel;
}
}
getProp(item: any, index: number) {
if (Object.prototype.toString.call(item.prop) === "[object String]") {
return item.prop;
} else if (item.type === "uploadImage" || item.type === "datetimerange") {
return item.prop[0];
} else {
return "";
}
}
initRules() {
if (!this.formRules) {
this.myFormRules = {};
} else {
this.myFormRules = this.formRules;
}
this.formCfg.map((item: any) => {
if (item.type === "telephone") {
let validateAreaCode = (rule: any, value: any, callback: any) => {
if (this.formData[item.prop[1]] && !this.formData[item.prop[0]]) {
callback(new Error("请输入区号"));
} else {
callback();
}
};
let areaCodeRuleArr: any = [
{ validator: validateAreaCode, trigger: "blur" }
];
let validateTelephone = (rule: any, value: any, callback: any) => {
console.log(
"this.formData[item.prop[0]]",
this.formData[item.prop[0]],
this.formData[item.prop[1]]
);
if (this.formData[item.prop[0]] && !this.formData[item.prop[1]]) {
callback(new Error("请输入电话号"));
} else if (
this.formData[item.prop[0]] &&
this.formData[item.prop[1]]
) {
if (
this.formData[item.prop[0]].length +
this.formData[item.prop[1]].length >
11
) {
callback(new Error("区号与电话号码长度不能超过11"));
} else {
callback();
}
} else {
callback();
}
};
let ruleArr: any = [{ validator: validateTelephone, trigger: "blur" }];
if (item.required) {
areaCodeRuleArr.push({
required: true,
message: "请输入区号",
trigger: "blur"
});
ruleArr.push({
required: true,
message: "请输入电话号",
trigger: "blur"
});
}
this.$set(this.myFormRules, item.prop[0], areaCodeRuleArr);
this.$set(this.myFormRules, item.prop[1], ruleArr);
}
});
}
actionButtonClick(data: any) {
if (data.isClear) {
this.resetFields();
this.formCfg.map((item: any, index: number) => {
if (item.type === "datetimerange") {
let dateArr = [
this.formData[item.prop[0]],
this.formData[item.prop[1]]
];
this.$set(this.dyData, "datetimerangeArray" + index, dateArr);
}
});
}
if (data.click) {
data.click();
}
}
resetFields() {
(this.$refs[this.refName] as HTMLElement).resetFields();
}
validate(cb: Function) {
(this.$refs[this.refName] as HTMLElement).validate((valid: boolean) => {
cb(valid);
});
}
getInputPlaceholder(str: string): String {
return str || "请输入";
}
getSelectPlaceholder(str: string): String {
return str || "请选择";
}
getTextareaAutosize(data: any) {
if (data.minRows && data.maxRows) {
return { minRows: data.minRows, maxRows: data.maxRows };
} else if (data.minRows && !data.maxRows) {
return { minRows: data.minRows };
} else if (!data.minRows && data.maxRows) {
return { maxRows: data.maxRows };
} else {
return false;
}
}
getFormItemClass(data: any) {
if (data.type === "title") {
return "yzf_form_item_title " + (data.class ? data.class : "");
} else {
return data.class ? data.class : "";
}
}
telephoneChange(item: any) {
if (item.prop && item.change) {
let data = JSON.parse(
JSON.stringify([
this.formData[item.prop[0]],
this.formData[item.prop[1]]
])
);
item.change(data);
}
}
gettelNumberMaxlength(areaCode: any) {
if (areaCode.length === 3) {
return 8;
} else {
return 7;
}
}
getUploadImageRef(index: any) {
return "uploadImage" + this.refName + index;
}
async uploadImageHttpRequest(item: any, params: any) {
console.log("file--", params);
let formData = new FormData();
formData.append("file", params.file);
formData.append("data", JSON.stringify(item.data));
let res: any = await this.uploadFile(item.action, formData, false);
if (
res.resultCode === 0 &&
res.resultData &&
res.resultData.imageList.length > 0
) {
this.$set(
this.formData[item.prop[0]],
this.formData[item.prop[0]].length,
res.resultData.imageList[0]
);
return true;
}
return false;
}
uploadFile(url: any, data: any, loading: any) {
}
deleteImage(item: any, imageItem: any, index: any) {
let self = this;
this.$confirm("确定删除此图片", "提示", {
type: "warning",
callback: function(action, instance) {
if (action === "confirm") {
self.$delete(self.formData[item.prop[0]], index);
self.formData[item.prop[1]].push(imageItem);
}
}
});
}
beforeUploadImage(item: any, file: any) {
return true;
}
handleExceed(item: any, files: any, fileList: any) {
this.$message.warning({
message: "最多只能上传" + item.limit + "张图片"
});
}
datetimerangeChange(item: any, datetimerangeValue: any, index: any) {
if (datetimerangeValue) {
if (index === 0) {
this.formData[item.prop[0]] = this.$dateParseTime(datetimerangeValue);
} else if (index === 1) {
this.formData[item.prop[1]] = this.$dateParseTime(
datetimerangeValue,
true
);
}
} else {
if (index === 0) {
this.formData[item.prop[0]] = "";
} else if (index === 1) {
this.formData[item.prop[1]] = "";
}
}
}
ordinaryDateChange(item: any, ordinaryValue: any, index: any) {
if (ordinaryValue) {
if (index === 0) {
this.formData[item.prop[0]] = this.$filterDate(ordinaryValue, "start");
} else if (index === 1) {
this.formData[item.prop[1]] = this.$filterDate(ordinaryValue, "end");
}
} else {
if (index === 0) {
this.formData[item.prop[0]] = "";
} else if (index === 1) {
this.formData[item.prop[1]] = "";
}
}
}
getAtionFormatter(action: any) {
if (action.formatter) {
let newAction = action.formatter(Object.assign({}, action));
if (newAction) {
action = Object.assign(action, newAction);
}
}
return action;
}
}
script>
<style lang="scss" scoped>
/deep/.yzf_form_item_title {
.el-form-item__label {
font-size: 15px;
font-weight: 600;
}
}
/deep/.el-select .el-input__inner {
padding-right: 14px;
}
.el-form--inline .el-form-item {
margin-right: 30px;
}
@media (max-width: 1450px) {
.el-form--inline .el-form-item {
margin-right: 10px;
}
}
.yzf_image_box {
overflow: hidden;
position: relative;
cursor: pointer;
width: 120px;
height: 120px;
line-height: 116px;
margin: 5px;
padding: 0px;
text-align: center;
float: left;
border: 1px solid #ccc;
margin-top: 15px;
border-radius: 5px;
box-shadow: #e6e6e6 0px 0px 7px 1px;
.yzf_image_item {
width: 100%;
height: 100%;
}
.yzf_image_item_dlt {
width: 100%;
height: 24px;
position: absolute;
background: #e7e7e7;
bottom: 0;
left: 0;
z-index: 20;
text-align: center;
line-height: 24px;
border: 0;
border-top-width: 0px;
}
}
.yzf_upload {
cursor: pointer;
width: 120px;
height: 86px;
background: #ddd;
float: left;
margin: 5px;
margin-top: 15px;
text-align: center;
line-height: 20px;
padding-top: 35px;
border: 1px solid #ccc;
}
.yzf_telephone_line {
width: 100%;
text-align: center;
display: block;
}
.mr0 {
margin-right: 0;
}
.custom_label {
line-height: 20px;
}
style>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
- 226
- 227
- 228
- 229
- 230
- 231
- 232
- 233
- 234
- 235
- 236
- 237
- 238
- 239
- 240
- 241
- 242
- 243
- 244
- 245
- 246
- 247
- 248
- 249
- 250
- 251
- 252
- 253
- 254
- 255
- 256
- 257
- 258
- 259
- 260
- 261
- 262
- 263
- 264
- 265
- 266
- 267
- 268
- 269
- 270
- 271
- 272
- 273
- 274
- 275
- 276
- 277
- 278
- 279
- 280
- 281
- 282
- 283
- 284
- 285
- 286
- 287
- 288
- 289
- 290
- 291
- 292
- 293
- 294
- 295
- 296
- 297
- 298
- 299
- 300
- 301
- 302
- 303
- 304
- 305
- 306
- 307
- 308
- 309
- 310
- 311
- 312
- 313
- 314
- 315
- 316
- 317
- 318
- 319
- 320
- 321
- 322
- 323
- 324
- 325
- 326
- 327
- 328
- 329
- 330
- 331
- 332
- 333
- 334
- 335
- 336
- 337
- 338
- 339
- 340
- 341
- 342
- 343
- 344
- 345
- 346
- 347
- 348
- 349
- 350
- 351
- 352
- 353
- 354
- 355
- 356
- 357
- 358
- 359
- 360
- 361
- 362
- 363
- 364
- 365
- 366
- 367
- 368
- 369
- 370
- 371
- 372
- 373
- 374
- 375
- 376
- 377
- 378
- 379
- 380
- 381
- 382
- 383
- 384
- 385
- 386
- 387
- 388
- 389
- 390
- 391
- 392
- 393
- 394
- 395
- 396
- 397
- 398
- 399
- 400
- 401
- 402
- 403
- 404
- 405
- 406
- 407
- 408
- 409
- 410
- 411
- 412
- 413
- 414
- 415
- 416
- 417
- 418
- 419
- 420
- 421
- 422
- 423
- 424
- 425
- 426
- 427
- 428
- 429
- 430
- 431
- 432
- 433
- 434
- 435
- 436
- 437
- 438
- 439
- 440
- 441
- 442
- 443
- 444
- 445
- 446
- 447
- 448
- 449
- 450
- 451
- 452
- 453
- 454
- 455
- 456
- 457
- 458
- 459
- 460
- 461
- 462
- 463
- 464
- 465
- 466
- 467
- 468
- 469
- 470
- 471
- 472
- 473
- 474
- 475
- 476
- 477
- 478
- 479
- 480
- 481
- 482
- 483
- 484
- 485
- 486
- 487
- 488
- 489
- 490
- 491
- 492
- 493
- 494
- 495
- 496
- 497
- 498
- 499
- 500
- 501
- 502
- 503
- 504
- 505
- 506
- 507
- 508
- 509
- 510
- 511
- 512
- 513
- 514
- 515
- 516
- 517
- 518
- 519
- 520
- 521
- 522
- 523
- 524
- 525
- 526
- 527
- 528
- 529
- 530
- 531
- 532
- 533
- 534
- 535
- 536
- 537
- 538
- 539
- 540
- 541
- 542
- 543
- 544
- 545
- 546
- 547
- 548
- 549
- 550
- 551
- 552
- 553
- 554
- 555
- 556
- 557
- 558
- 559
- 560
- 561
- 562
- 563
- 564
- 565
- 566
- 567
- 568
- 569
- 570
- 571
- 572
- 573
- 574
- 575
- 576
- 577
- 578
- 579
- 580
- 581
- 582
- 583
- 584
- 585
- 586
- 587
- 588
- 589
- 590
- 591
- 592
- 593
- 594
- 595
- 596
- 597
- 598
- 599
- 600
- 601
- 602
- 603
- 604
- 605
- 606
- 607
- 608
- 609
- 610
- 611
- 612
- 613
- 614
- 615
- 616
- 617
- 618
- 619
- 620
- 621
- 622
- 623
- 624
- 625
- 626
- 627
- 628
- 629
- 630
- 631
- 632
- 633
- 634
- 635
- 636
- 637
- 638
- 639
- 640
- 641
- 642
- 643
- 644
- 645
- 646
- 647
- 648
- 649
- 650
- 651
- 652
- 653
- 654
- 655
- 656
- 657
- 658
- 659
- 660
- 661
- 662
- 663
- 664
- 665
- 666
- 667
- 668
- 669
- 670
- 671
- 672
- 673
- 674
- 675
- 676
- 677
- 678
- 679
- 680
- 681
- 682
- 683
- 684
- 685
- 686
- 687
- 688
- 689
- 690
- 691
- 692
- 693
- 694
- 695
- 696
- 697
- 698
- 699
- 700
- 701
- 702
- 703
- 704
- 705
- 706
- 707
- 708
- 709
- 710
- 711
- 712
- 713
- 714
- 715
- 716
- 717
- 718
- 719
- 720
- 721
- 722
- 723
- 724
- 725
- 726
- 727
- 728
- 729
- 730
- 731
- 732
- 733
- 734
- 735
- 736
- 737
- 738
- 739
- 740
- 741
- 742
- 743
- 744
- 745
- 746
- 747
- 748
- 749
- 750
- 751
- 752
- 753
- 754
- 755
- 756
- 757
- 758
- 759
- 760
- 761
- 762
- 763
- 764
- 765
- 766
- 767
- 768
- 769
- 770
- 771
- 772
- 773
- 774
- 775
- 776
- 777
- 778
- 779
- 780
- 781
- 782
- 783
- 784
- 785
- 786
- 787
- 788
- 789
- 790
- 791
- 792
- 793
- 794
- 795
- 796
- 797
- 798
- 799
- 800
- 801
- 802
- 803
- 804
- 805
- 806
- 807
- 808
- 809
- 810
- 811
- 812
- 813
- 814
- 815
- 816
- 817
- 818
- 819
- 820
- 821
- 822
- 823
- 824
- 825
- 826
- 827
- 828
- 829
- 830
- 831
- 832
- 833
- 834
- 835
- 836
- 837
- 838
- 839
- 840
- 841
- 842
- 843
- 844
- 845
- 846
- 847
- 848
- 849
- 850
- 851
- 852
- 853
- 854
- 855
- 856
- 857
- 858
- 859
- 860
- 861
- 862
- 863
- 864
- 865
- 866
- 867
- 868
- 869
- 870
- 871
- 872
- 873
- 874
- 875
- 876
- 877
- 878
- 879
- 880
- 881
- 882
- 883
- 884
- 885
- 886
- 887
- 888
- 889
- 890
- 891
- 892
- 893
- 894
- 895
- 896
- 897
- 898
- 899
- 900
- 901
- 902
- 903
- 904
- 905
- 906
- 907
- 908
- 909
- 910
- 911
- 912
- 913
- 914
- 915
- 916
- 917
- 918
- 919
- 920
- 921
- 922
- 923
- 924
- 925
- 926
- 927
- 928
- 929
- 930
- 931
- 932
- 933
- 934
- 935
- 936
- 937
- 938
- 939
- 940
- 941
- 942
- 943
- 944
- 945
- 946
- 947
- 948
- 949
- 950
- 951
- 952
- 953
- 954
- 955
- 956
- 957
- 958
- 959
- 960
- 961
- 962
- 963
- 964
- 965
- 966
- 967
- 968
- 969
- 970
- 971
- 972
- 973
- 974
- 975
- 976
- 977
- 978
- 979
- 980
- 981
- 982
- 983
- 984
- 985
- 986
- 987
- 988
- 989
- 990
- 991
- 992
- 993
- 994
- 995
- 996
- 997
- 998
- 999
- 1000
- 1001
- 1002
- 1003
- 1004
- 1005
- 1006
- 1007
- 1008
- 1009
- 1010
- 1011
- 1012
- 1013
- 1014
- 1015
- 1016
- 1017
- 1018
- 1019
- 1020
- 1021
- 1022
- 1023
- 1024
- 1025
- 1026
- 1027
- 1028
- 1029
- 1030
- 1031
- 1032
- 1033
- 1034
- 1035
- 1036
- 1037
- 1038
- 1039
- 1040
- 1041
- 1042
- 1043
- 1044
- 1045
- 1046
- 1047
- 1048
- 1049
- 1050
- 1051
- 1052
- 1053
- 1054
- 1055
- 1056
- 1057
- 1058
- 1059
- 1060
- 1061
- 1062
- 1063
- 1064
- 1065
- 1066
- 1067
- 1068
- 1069
- 1070
- 1071
- 1072
- 1073
- 1074
- 1075
- 1076
- 1077
- 1078
- 1079
- 1080
- 1081
- 1082
- 1083
- 1084
- 1085
- 1086
- 1087
- 1088
- 1089
- 1090
- 1091
- 1092
- 1093
- 1094
- 1095
- 1096
- 1097
- 1098
- 1099
- 1100
- 1101
- 1102
- 1103
- 1104
- 1105
- 1106
- 1107
- 1108
- 1109
- 1110
- 1111
- 1112
- 1113
- 1114
- 1115
- 1116
- 1117
- 1118
- 1119
- 1120
- 1121
- 1122
- 1123
- 1124
- 1125
- 1126
- 1127
- 1128
- 1129
- 1130
- 1131
- 1132
- 1133
- 1134
- 1135
- 1136
- 1137
- 1138
- 1139
- 1140
- 1141
- 1142
- 1143
- 1144
- 1145
- 1146
- 1147
- 1148
- 1149
- 1150
- 1151
- 1152
- 1153
- 1154
- 1155
- 1156
- 1157
- 1158
- 1159
- 1160
- 1161
- 1162
- 1163
- 1164
- 1165
- 1166
- 1167
- 1168
- 1169
- 1170
- 1171
- 1172
- 1173
- 1174
- 1175
- 1176
- 1177
- 1178
- 1179
- 1180
- 1181
- 1182
- 1183
- 1184
- 1185
- 1186
- 1187
- 1188
- 1189
- 1190
- 1191
- 1192
- 1193
- 1194
- 1195
- 1196
- 1197
- 1198
- 1199
- 1200
- 1201
- 1202
- 1203
- 1204
- 1205
- 1206
- 1207
- 1208
- 1209
- 1210
- 1211
- 1212
- 1213
- 1214
- 1215
- 1216
- 1217
- 1218
- 1219
- 1220
- 1221
- 1222
- 1223
- 1224
- 1225
- 1226
- 1227
- 1228
- 1229
- 1230
- 1231
- 1232
- 1233
- 1234
- 1235
- 1236
- 1237
- 1238
- 1239
- 1240
- 1241
- 1242
- 1243
- 1244
- 1245
- 1246
- 1247
- 1248
- 1249
- 1250
- 1251
- 1252
- 1253
- 1254
- 1255
- 1256
- 1257
- 1258
- 1259
- 1260
- 1261
- 1262
- 1263
- 1264
- 1265
- 1266
- 1267
- 1268
- 1269
- 1270
- 1271
- 1272
- 1273
- 1274
- 1275
- 1276
- 1277
- 1278
- 1279
- 1280
- 1281
- 1282
- 1283
- 1284
- 1285
- 1286
- 1287
- 1288
- 1289
- 1290
- 1291
- 1292
- 1293
- 1294
- 1295
- 1296
- 1297
- 1298
- 1299
- 1300
- 1301
- 1302
- 1303
- 1304
- 1305
- 1306
- 1307
- 1308
- 1309
- 1310
- 1311
- 1312
- 1313
- 1314
MyForm表单传参
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
refName | 主键的ref名称 | string | - | editForm |
size | 表单组件大小 | string | medium(中) / small (小)/ mini(超小) | medium(中) |
inline | 表单是否换行 | boolean | - | false |
labelWidth | 表头宽度 | string | - | - |
formData | 表单数据 | object | - | - |
formRules | 表单提交数据校验规则 | array | - | null |
labelPosition | 表头位置 | string | right/left/top | left |
formCfg | 表单配置项 | array | - | - |
formAction | 表单操作按钮 | array | - | - |
actionInline | 表单操作按钮是否换行 | boolean | - | false |
MyForm-formCfg 表单配置项
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
hide | 隐藏显示该配置项 | boolean | true, false | false |
label | 配置项标 题 | string | - | - |
labelWidth | 标题宽度 | string | - | - |
prop | 绑定表单字段名 | string / array | - | - |
class | 表单样式名称 | string | - | - |
type | 表单配置类型 | string | title / input / textarea / select / radio / radioButton / checkbox / date / time / datetime / datetimerange/ switch / cascader / custom / uploadImage / telephone | - |
标题栏 (type = title)
无需绑定prop数据, 只展示标题项
参数 | 说明 | 类型 | 示例 | 可选值 | 默认值 |
---|
customLabel | 标题文本 | string | { customLabel: ‘销售价: (最低建议销售价)’, type: ‘custom’, prop: ‘表单所定义的prop’, } | - | - |
labelFormatter | 标题格式 | function | | function(data) data: object 表单数据 return: string 自定义标题 支持 v-html | |
###输入框 (type = input)
参数 | 说明 | 类型 | 示例 | 可选值 | 默认值 |
---|
disabled | 禁用 | boolean | | - | - |
inputType | 输入框类型 | string | | text,textarea 和其他 原生 input 的 type 值 | - |
placeholder | 提示 | string | | - | - |
change | 修改回调 | function | change: (data) => { console.log(‘文本域内容’,data) } | - | - |
maxlength | 输入框最大字数 | number | | | |
###文本域 (type = textarea)
参数 | 说明 | 类型 | 示例 | 可选值 | 默认值 |
---|
disabled | 禁用 | boolean | - | - | - |
placeholder | 提示 | string | - | - | - |
maxlength | 最大输入长度 | string | - | - | - |
minRows | 最小行数 | string | - | - | - |
maxRows | 最大行数 | string | - | - | - |
width | 设置文本作用域容器宽度 | string | - | - | - |
change | 修改回调 | function | change: (data) => { console.log(‘文本域内容’,data) } | - | - |
下拉框 (type = select)
参数 | 说明 | 类型 | 可选值 | 默认值 | 示例 |
---|
disabled | 禁用 | boolean | - | - | - |
placeholder | 提示 | string | - | - | - |
options | 选择项数据 | array | - | 默认[{key: “”, value: “"}]数组对象 | [{ key: ‘1’, value: ‘默认’ }] |
valueMap | 下拉列表options数据,所绑定(对应的键值)名称 | array | - | 默认[“”, “"] | valueMap: [‘supplierAccountNumberId’, ‘supplierName’] ,options: [ supplierName: ‘刘备’,supplierAccountNumberId: ‘123’] |
change | 修改回调 | function (data) data: 选中key | | | |
###单选框 (type = radio)
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
disabled | 禁用 | boolean | - | - |
radios | 选择项 | array | - | 默认[{key: “”, value: “"}]数组 |
change | 修改回调 | function (data) data: 选中key | - | - |
单选按钮 (type = radioButton)
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
disabled | 禁用 | boolean | - | - |
radios | 选择项 | array | - | 默认[{key: “”, value: “"}]数组 |
change | 修改回调 | function (data) data: 选中key | - | - |
###复选框 (type = checkbox)
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
disabled | 禁用 | boolean | - | - |
checkboxs | 选择项 | array | - | 默认[{key: “”, value: “"}]数组 |
valueMap | 选择项绑定数据的键值名称 | array | - | 默认[“”, “"] |
change | 修改回调 | function (data) data: 选中key | - | - |
###日期选择器 (type = date)
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
disabled | 禁用 | boolean | - | - |
change | 修改回调 | function (data) data: 选中key | - | - |
###时间选择器 (type = time)
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
disabled | 禁用 | boolean | - | - |
change | 修改回调 | function (data) data: 选中key | - | - |
###日期时间选择器 (type = datetime)
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
disabled | 禁用 | boolean | - | - |
change | 修改回调 | function (data) data: 选中key | - | - |
日期时间区间选择器 (type = datetimerange)
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
disabled | 禁用 | boolean | - | - |
placeholder | 提示文字 | array | - | 默认[“”, “"] |
###滑动开关 (type = switch)
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
disabled | 禁用 | boolean | - | - |
change | 修改回调 | function (data) 选种数据 | - | - |
滑动开关 (type = switch)
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
disabled | 禁用 | boolean | - | - |
change | 修改回调 | function (data) 选种数据 | - | - |
联级选择器 (type = cascader)
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
disabled | 禁用 | boolean | - | - |
change | 修改回调 | function (data) 选种数据 | - | - |
options | 选择项 | array | - | - |
showAllLevels | 输入框中是否显示选中值的完整路径 | boolean | - | - |
###自定义插槽 (type = custom)
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
prop | 插槽名称 | string | - | - |
###图片上传 (type = uploadImage)
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
prop | 绑定数据 | array | - | [“绑定上传图片列表字段名称”,”绑定删除图片列表字段名称"] |
imageName | 图片数据列表展示Url名称 | string | - | - |
limit | 最大上传文件数 | number | - | - |
action | 图片上传地址 | string | - | - |
data | 图片上传参数 | object | - | - |
电话号码 (type = telephone)
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
prop | 绑定数据 | array | - | [“绑定区号字段名称”,”绑定电话号字段名称"] |
disabled | 禁用 | boolean | - | - |
###表单按钮 formAction
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
type | 按钮类型 | string | primary / success / warning / danger / info / text | - |
| 图标类型 | string | 可参考element.ui | - |
isClear | 是否清空表单 | boolean | - | - |
click | 点击事件 | function () | - | - |
label | 按钮标题 | string | - | - |
formatter | 按钮格式器 | function (action) action: 按钮数据 | - | 可设置按钮标题(label), 是否隐藏(hide) |
表单弹框 MyFormDialog
MyForm添加到弹框的嵌套封装, 具体使用参数参考MyForm说明, 目前不支持 formCfg配置项type = custom类型
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
title | 弹框标题 | string | - | - |
show | 是否显示弹框 | boolean | - | - |
refName | 表单ref名称 | string | - | editForm |
formData | 表单数据 | object | - | - |
formRules | 表单提交数据校验规则 | array | - | - |
labelPosition | 表头位置 | string | right/left/top | left |
formCfg | 表单配置项 | array | - | - |
formAction | 表单操作按钮 | array | - | - |
#表格 MyTable
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
refName | 表格ref名称 | string | - | myTable |
select | 是否显示勾选项 | boolean | - | false |
selectionChange | 复选框-勾选回调函数 | function (data) data: 勾选表格项List | - | - |
selectWidth | 复选框-勾选项宽度 | string | - | -null |
tableData | 表格数据 | array | - | - |
tableColumns | 表格配置项 | array | - | - |
spanMethod | 表格合并项 | function | | |
page | 分页配置项 | object | - | - |
表格配置项 tableColumns
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
type | 配置项类型 | string | options(常规项) / html(动态标签项) / action(按钮项) / custom(自定义-插槽) | - |
fixed | 列是否固定在左侧或者右侧,true 表示固定在左侧 | string / boolean | - | - |
prop | 绑定数据字段名称(后台返回的表格字段) | string | - | - |
label | 表头标题 | string | - | - |
width | 该列宽度 | string / number | - | - |
align | 对齐方式 | string | left / center / right | center |
headerAlign | 表头对齐方式 | string | left / center / right | center |
###常规项 (type = options)
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
formatter | 格式类 | function (row, column, cellValue, index) | - | 返回内容 |
动态标签项 (type = html)
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
formatter | 格式类 | function(row) | - | 返回富文本字符串 |
按钮项 (type = action)
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
actions | 按钮数据 | array | - | - |
-hide | 是否隐藏 | boolean | - | - |
-label | 按钮标题 | string | - | - |
-formatter | 格式类 | function (action, row) action: 按钮数据 row: 列表项数据 | - | 修改action需返回action对象 |
-click | 点击方法 | function (row) row: 列表项数据 | - | - |
-copyFormatter | 拷贝内容格式类 | function (row) row: 列表数据 | - | 需返回拷贝内容数据字符串 |
btnType | 按钮类型 | primary / success / warning / danger / info / text | | text |
插槽项 (type = custom)
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
prop | 插槽名称 | string | - | - |
分页项 page
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
count | 总页数 | number | - | - |
currentPage | 当前页 | number | - | - |
length | 每页长度 | number | - | - |
tableChange | 页码变化回调 | function () | - | - |
###富文本编辑器
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
defaultMsg | 富文本内容 | string | - | - |
imageType | 富文本图片类型 | number | - | - |
###上传文件插件 MyUploadFile
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
limit | 上传文件数量 | number | - | 1 |
uploadType | 上传文件类型 | string | Image(可扩展配置) | image |
action | 上传路由 | string | - | /yhtplus/image/uploadImageList.action |
uploadFileCb | 文件数量修改回调 | function | - | - |
actionParam | 参数 | object | - | - |