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.
139 lines
2.4 KiB
139 lines
2.4 KiB
<template>
|
|
<el-form-item
|
|
v-if="getShowValue(item)"
|
|
:key="index"
|
|
:prop="`${propPrefix || ''}${item.field}`"
|
|
:rules="item.rules"
|
|
:class="[item.className || '', `is-${item.form_type}`]"
|
|
:style="{width: item.style_percent ? `${item.style_percent}%` : 'auto'}"
|
|
class="wk-form-item">
|
|
<template slot="label">
|
|
{{ item.name }}
|
|
<el-tooltip
|
|
v-if="item.tipType == 'tooltip'"
|
|
effect="dark"
|
|
placement="top">
|
|
<div slot="content" v-html="getTips(item)"/>
|
|
<i class="wk wk-help wk-help-tips"/>
|
|
</el-tooltip>
|
|
<span v-else style="color:#999;">
|
|
{{ getTips(item) }}
|
|
</span>
|
|
</template>
|
|
<wk-field
|
|
:item="item"
|
|
:index="index"
|
|
:field-from="fieldFrom"
|
|
:ignore-fields="ignoreFields"
|
|
:disabled="disabled"
|
|
@change="fieldChange"
|
|
>
|
|
<template slot-scope="{ data, index }">
|
|
<slot :data="data" :index="index" />
|
|
</template>
|
|
</wk-field>
|
|
</el-form-item>
|
|
</template>
|
|
|
|
<script>
|
|
import WkField from './WkField'
|
|
|
|
import Mixin from './Mixin'
|
|
|
|
export default {
|
|
// item
|
|
name: 'WkFormItem',
|
|
|
|
components: {
|
|
WkField
|
|
},
|
|
|
|
mixins: [Mixin],
|
|
|
|
props: {
|
|
// 表单验证前缀
|
|
propPrefix: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
item: Object,
|
|
index: Number,
|
|
fieldFrom: {
|
|
type: Object,
|
|
default: () => {
|
|
return {}
|
|
}
|
|
},
|
|
// 忽略的字段直接输出
|
|
ignoreFields: {
|
|
type: Array,
|
|
default: () => {
|
|
return []
|
|
}
|
|
},
|
|
disabled: Boolean
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
}
|
|
},
|
|
|
|
computed: {},
|
|
|
|
watch: {},
|
|
|
|
created() {},
|
|
|
|
mounted() {},
|
|
|
|
beforeDestroy() {},
|
|
|
|
methods: {
|
|
fieldChange(item, index, value, valueList) {
|
|
this.$emit('change', item, index, value, valueList)
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.wk-form-item {
|
|
.el-form-item__label {
|
|
line-height: 1.5;
|
|
padding-bottom: 8px;
|
|
word-break: break-all;
|
|
word-wrap: break-word;
|
|
color: #333;
|
|
}
|
|
|
|
.el-form-item__error {
|
|
position: relative;
|
|
top: auto;
|
|
left: auto;
|
|
}
|
|
|
|
.el-form-item.is-desc_text {
|
|
.el-form-item__label {
|
|
display: none;
|
|
}
|
|
}
|
|
}
|
|
</style>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
.wk-form-item {
|
|
padding: 12px 12px 0;
|
|
margin-bottom: 0;
|
|
}
|
|
.el-form-item.is-user {
|
|
display: flex ;
|
|
flex-direction: column ;
|
|
}
|
|
.el-form-item.is-structure {
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
</style>
|