|
|
@ -3,13 +3,12 @@ |
|
|
<div v-for="(item, index) in formConfig" :key="index"> |
|
|
<div v-for="(item, index) in formConfig" :key="index"> |
|
|
<template v-if="item.type === 'cardItem'"> |
|
|
<template v-if="item.type === 'cardItem'"> |
|
|
<div class="grid-container"> |
|
|
<div class="grid-container"> |
|
|
<div v-for="(sItem, sIndex) in item.config" class="form-item" |
|
|
|
|
|
:class="sItem.span == 1 ? 'full-row' : ''" :key="sIndex"> |
|
|
|
|
|
|
|
|
<div v-for="(sItem, key) in item.config" class="form-item" :class="sItem.span == 1 ? 'full-row' : ''" |
|
|
|
|
|
:key="key"> |
|
|
<template v-if="sItem.type === 'input'"> |
|
|
<template v-if="sItem.type === 'input'"> |
|
|
<div class="form-title">{{ sItem.label }}</div> |
|
|
<div class="form-title">{{ sItem.label }}</div> |
|
|
<Input :maxlength="sItem.maxlength || 30" :disabled="sItem.disabled" |
|
|
|
|
|
v-model="formFields[sIndex]" :class="sItem.borderType | getBorderType" |
|
|
|
|
|
:placeholder="sItem.placeholder ? sItem.placeholder : ('请输入' + sItem.label)" /> |
|
|
|
|
|
|
|
|
<HandleFormItem :item="sItem" :value="formFields[key]" @input="onInput(key, $event)" |
|
|
|
|
|
@copy="onCopy(sItem, key)" /> |
|
|
</template> |
|
|
</template> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
@ -17,24 +16,24 @@ |
|
|
<template v-else-if="item.type === 'conditionItem'"> |
|
|
<template v-else-if="item.type === 'conditionItem'"> |
|
|
<div class="form-item "> |
|
|
<div class="form-item "> |
|
|
<div class="form-title fs-16" v-if="item.label">{{ item.label }}</div> |
|
|
<div class="form-title fs-16" v-if="item.label">{{ item.label }}</div> |
|
|
<div v-for="(sItem, sIndex) in item.config" class="c-Item flex"> |
|
|
|
|
|
<div class="flex1 mr-24"> |
|
|
|
|
|
|
|
|
<div v-for="(sItem, key) in item.config" class="c-Item grid-container"> |
|
|
|
|
|
<div class="p-r-20"> |
|
|
<div class="form-title">{{ sItem.label }}</div> |
|
|
<div class="form-title">{{ sItem.label }}</div> |
|
|
<div class="flex"> |
|
|
|
|
|
<el-select class="flex1" :class="sItem.borderType | getBorderType" v-model="formFields[sIndex]" multiple :placeholder="sItem.placeholder ? sItem.placeholder : ('请选择' + sItem.label)" > |
|
|
|
|
|
<el-option v-for="op in sItem.options" :key="op.value" :label="op.label" |
|
|
|
|
|
:value="op.value"> |
|
|
|
|
|
</el-option> |
|
|
|
|
|
</el-select> |
|
|
|
|
|
|
|
|
<div class="flex "> |
|
|
|
|
|
<HandleFormItem type="select" :item="sItem" :value="formFields[key]" |
|
|
|
|
|
@copy="onCopy(sItem, key)" @change="onSelectChange(key, $event)" /> |
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="flex1" v-show="isShowOther(formFields[sIndex])"> |
|
|
|
|
|
<div class="form-title">其他</div> |
|
|
|
|
|
<div class="flex"> |
|
|
|
|
|
<el-input v-model="formFields[sItem.otherCode]" |
|
|
|
|
|
:class="sItem.borderType | getBorderType"></el-input> |
|
|
|
|
|
|
|
|
<div class="p-r-20"> |
|
|
|
|
|
<div v-show="isShowOther(formFields[key])"> |
|
|
|
|
|
<div class="form-title">其他</div> |
|
|
|
|
|
<div class="flex"> |
|
|
|
|
|
<el-input v-model="formFields[sItem.otherCode]" |
|
|
|
|
|
:class="sItem.borderType | getBorderType"></el-input> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
@ -44,27 +43,26 @@ |
|
|
<div class="form-item "> |
|
|
<div class="form-item "> |
|
|
<div class="form-title fs-16" v-if="item.label">{{ item.label }}</div> |
|
|
<div class="form-title fs-16" v-if="item.label">{{ item.label }}</div> |
|
|
<div class="grid-container"> |
|
|
<div class="grid-container"> |
|
|
<div v-for="(sItem, sIndex) in item.config" class="c-Item " :class="sItem.span == 1 ? 'full-row' : ''" :key = "sIndex"> |
|
|
|
|
|
<div class="form-title" v-if = "sItem.label">{{ sItem.label }}</div> |
|
|
|
|
|
<div v-if = "sItem.type === 'dateTime'"> |
|
|
|
|
|
<el-date-picker |
|
|
|
|
|
v-model="formFields[sIndex]" |
|
|
|
|
|
type="datetime" |
|
|
|
|
|
class="w-100" |
|
|
|
|
|
format = "yyyy/MM/DD HH:mm:ss" |
|
|
|
|
|
value-format = "yyyy/MM/DD HH:mm:ss" |
|
|
|
|
|
:placeholder="sItem.placeholder ? sItem.placeholder : ('请选择' + sItem.label)"> |
|
|
|
|
|
|
|
|
<div v-for="(sItem, key) in item.config" class="c-Item " :class="sItem.span == 1 ? 'full-row' : ''" |
|
|
|
|
|
:key="key"> |
|
|
|
|
|
<div class="form-title" v-if="sItem.label">{{ sItem.label }}</div> |
|
|
|
|
|
<div v-if="sItem.type === 'dateTime'"> |
|
|
|
|
|
<el-date-picker v-model="formFields[key]" type="datetime" class="w-100" |
|
|
|
|
|
format="yyyy/MM/DD HH:mm:ss" value-format="yyyy/MM/DD HH:mm:ss" |
|
|
|
|
|
:placeholder="sItem.placeholder ? sItem.placeholder : ('请选择' + sItem.label)"> |
|
|
</el-date-picker> |
|
|
</el-date-picker> |
|
|
</div> |
|
|
</div> |
|
|
<div v-else-if = "sItem.type === 'select'"> |
|
|
|
|
|
<el-select class="w-100" :class="sItem.borderType | getBorderType" v-model="formFields[sIndex]" multiple :placeholder="sItem.placeholder ? sItem.placeholder : ('请选择' + sItem.label)" > |
|
|
|
|
|
|
|
|
<div v-else-if="sItem.type === 'select'"> |
|
|
|
|
|
<el-select class="w-100" :class="sItem.borderType | getBorderType" v-model="formFields[key]" |
|
|
|
|
|
multiple :placeholder="sItem.placeholder ? sItem.placeholder : ('请选择' + sItem.label)"> |
|
|
<el-option v-for="op in sItem.options" :key="op.value" :label="op.label" |
|
|
<el-option v-for="op in sItem.options" :key="op.value" :label="op.label" |
|
|
:value="op.value"> |
|
|
:value="op.value"> |
|
|
</el-option> |
|
|
</el-option> |
|
|
</el-select> |
|
|
</el-select> |
|
|
</div> |
|
|
</div> |
|
|
<div v-else-if = "sItem.type === 'input'"> |
|
|
|
|
|
<el-input class="w-100" :class="sItem.borderType | getBorderType" v-model="formFields[sIndex]" :placeholder="sItem.placeholder ? sItem.placeholder : ('请输入' + sItem.label)"></el-input> |
|
|
|
|
|
|
|
|
<div v-else-if="sItem.type === 'input'"> |
|
|
|
|
|
<el-input class="w-100" :class="sItem.borderType | getBorderType" v-model="formFields[key]" |
|
|
|
|
|
:placeholder="sItem.placeholder ? sItem.placeholder : ('请输入' + sItem.label)"></el-input> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
@ -76,10 +74,10 @@ |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import Input from "./Input.vue"; |
|
|
|
|
|
|
|
|
import HandleFormItem from "./HandleFormItem.vue" |
|
|
export default { |
|
|
export default { |
|
|
components: { |
|
|
components: { |
|
|
Input |
|
|
|
|
|
|
|
|
HandleFormItem |
|
|
}, |
|
|
}, |
|
|
props: { |
|
|
props: { |
|
|
formConfig: { |
|
|
formConfig: { |
|
|
@ -121,7 +119,8 @@ export default { |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
isShowOther(v = []) { |
|
|
isShowOther(v = []) { |
|
|
return v.includes(-1); |
|
|
|
|
|
|
|
|
console.log(v, "vvv") |
|
|
|
|
|
return v.includes("-1"); |
|
|
}, |
|
|
}, |
|
|
//根据formConifg回填form表单数据 |
|
|
//根据formConifg回填form表单数据 |
|
|
handleFormField() { |
|
|
handleFormField() { |
|
|
@ -153,7 +152,8 @@ export default { |
|
|
}, |
|
|
}, |
|
|
getFormData() { |
|
|
getFormData() { |
|
|
const { formFields, allFieldsConfig } = this; |
|
|
const { formFields, allFieldsConfig } = this; |
|
|
for (const key in formFields) { |
|
|
|
|
|
|
|
|
return new Promise((resolve,reject)=>{ |
|
|
|
|
|
for (const key in formFields) { |
|
|
if (!formFields[key]) { |
|
|
if (!formFields[key]) { |
|
|
const o = allFieldsConfig[key]; |
|
|
const o = allFieldsConfig[key]; |
|
|
let prefix = ""; |
|
|
let prefix = ""; |
|
|
@ -163,11 +163,29 @@ export default { |
|
|
prefix = "选择" |
|
|
prefix = "选择" |
|
|
} |
|
|
} |
|
|
this.$message.error(`${o.label}还未${prefix}请${prefix}后再提交`); |
|
|
this.$message.error(`${o.label}还未${prefix}请${prefix}后再提交`); |
|
|
|
|
|
reject("还未填写完"); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return formFields; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
resolve(formFields) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
onInput(key, val) { |
|
|
|
|
|
this.formFields[key] = val; |
|
|
|
|
|
this.$emit("input", { key, value: val }); |
|
|
|
|
|
}, |
|
|
|
|
|
onSelectChange(key, val) { |
|
|
|
|
|
this.formFields[key] = val; |
|
|
|
|
|
this.$emit("select", { key, value: val }); |
|
|
|
|
|
}, |
|
|
|
|
|
//复制 |
|
|
|
|
|
onCopy(config, key) { |
|
|
|
|
|
const { formFields } = this; |
|
|
|
|
|
if (config.copyFrom) { |
|
|
|
|
|
formFields[key] = formFields[config.copyFrom] |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
@ -179,9 +197,11 @@ export default { |
|
|
/* 默认2列 */ |
|
|
/* 默认2列 */ |
|
|
gap: 0 24px; |
|
|
gap: 0 24px; |
|
|
} |
|
|
} |
|
|
.w-100{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.w-100 { |
|
|
width: 100% !important; |
|
|
width: 100% !important; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.form-item { |
|
|
.form-item { |
|
|
background: #fff; |
|
|
background: #fff; |
|
|
padding: 20px; |
|
|
padding: 20px; |
|
|
@ -197,18 +217,22 @@ export default { |
|
|
.full-row { |
|
|
.full-row { |
|
|
grid-column: span 2; |
|
|
grid-column: span 2; |
|
|
} |
|
|
} |
|
|
.c-Item{ |
|
|
|
|
|
&:not(:last-child){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.c-Item { |
|
|
|
|
|
&:not(:last-child) { |
|
|
margin-bottom: 16px; |
|
|
margin-bottom: 16px; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.form-title { |
|
|
.form-title { |
|
|
margin-bottom: 12px; |
|
|
margin-bottom: 12px; |
|
|
font-size: 14px; |
|
|
font-size: 14px; |
|
|
font-weight: normal; |
|
|
font-weight: normal; |
|
|
color: #606266; |
|
|
color: #606266; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.p-r-20{ |
|
|
|
|
|
padding-right: 20px; |
|
|
|
|
|
} |
|
|
.orange-border { |
|
|
.orange-border { |
|
|
input { |
|
|
input { |
|
|
border-color: #f9c588; |
|
|
border-color: #f9c588; |
|
|
|