封装搜索、表格、新增表单
This commit is contained in:
@@ -0,0 +1,274 @@
|
||||
<template>
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<a-form-model :model="formInline" v-if="isFormInline" class="formAdd" :rules="rules" ref="ruleForm">
|
||||
<a-row :gutter="24">
|
||||
<div v-for="(item,index) in dataList" :key="index">
|
||||
<a-col :span="12" v-if="item.type === 'INPUT'">
|
||||
<div class="box-title-text">
|
||||
<div class="title-text">
|
||||
<span class="Required">*</span>
|
||||
<span :class="{'title-text-text':false}">{{item.enName}}</span><br>
|
||||
<span :class="{'title-text-text':false}">{{item.name}}</span>
|
||||
</div>
|
||||
<a-form-model-item class="itemModel" :prop="item.attrModel">
|
||||
<a-input class="box-input" v-model="formInline[item.attrModel]" :placeholder="item.placeholder"/>
|
||||
</a-form-model-item>
|
||||
</div>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="12" v-else-if="item.type === 'CHECKBOX'">
|
||||
<div class="box-title-text">
|
||||
<div class="title-text">
|
||||
<span class="Required">*</span>
|
||||
<span :class="{'title-text-text':false}">{{item.enName}}</span><br>
|
||||
<span :class="{'title-text-text':false}">{{item.name}}</span>
|
||||
</div>
|
||||
<a-form-model-item class="itemModel" :prop="item.attrModel">
|
||||
<j-multi-select-tag class="box-input" v-model="formInline[item.attrModel]"
|
||||
:placeholder="$t('selectStatus')" :type="'checkbox'"
|
||||
:triggerChange="false" dictCode="valid_status"/>
|
||||
</a-form-model-item>
|
||||
</div>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="12" v-else-if="item.type === 'DATE'">
|
||||
<div class="box-title-text">
|
||||
<div class="title-text">
|
||||
<span class="Required">*</span>
|
||||
<span :class="{'title-text-text':false}">{{item.enName}}</span><br>
|
||||
<span :class="{'title-text-text':false}">{{item.name}}</span>
|
||||
</div>
|
||||
<a-form-model-item class="itemModel" :prop="item.name">
|
||||
<a-date-picker class="box-input" v-model="formInline[item.attrModel]" @change="onChange"
|
||||
style="width: 100%"/>
|
||||
</a-form-model-item>
|
||||
</div>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="12" v-else-if="item.type === 'SELECT'">
|
||||
<div class="box-title-text">
|
||||
<div class="title-text">
|
||||
<span class="Required">*</span>
|
||||
<span :class="{'title-text-text':false}">{{item.enName}}</span><br>
|
||||
<span :class="{'title-text-text':false}">{{item.name}}</span>
|
||||
</div>
|
||||
<a-form-model-item class="itemModel" :prop="item.name">
|
||||
<j-dict-select-tag class="box-input" v-model="formInline[item.attrModel]"
|
||||
:placeholder="$t('selectStatus')" :type="'select'"
|
||||
:triggerChange="false" dictCode="valid_status"/>
|
||||
</a-form-model-item>
|
||||
</div>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="12" v-else-if="item.type === 'SELECTALL'">
|
||||
<div class="box-title-text">
|
||||
<div class="title-text">
|
||||
<span class="Required">*</span>
|
||||
<span :class="{'title-text-text':false}">{{item.enName}}</span><br>
|
||||
<span :class="{'title-text-text':false}">{{item.name}}</span>
|
||||
</div>
|
||||
<a-form-model-item class="itemModel" :prop="item.name">
|
||||
<j-multi-select-tag class="box-input" v-model="formInline[item.attrModel]"
|
||||
:placeholder="$t('selectStatus')" :type="'select'"
|
||||
:triggerChange="false" dictCode="valid_status"/>
|
||||
</a-form-model-item>
|
||||
</div>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="12" v-else-if="item.type === 'RADIO'">
|
||||
<div class="box-title-text">
|
||||
<div class="title-text">
|
||||
<span class="Required">*</span>
|
||||
<span :class="{'title-text-text':false}">{{item.enName}}</span><br>
|
||||
<span :class="{'title-text-text':false}">{{item.name}}</span>
|
||||
</div>
|
||||
<a-form-model-item class="itemModel" :prop="item.name">
|
||||
<j-dict-select-tag v-model="formInline[item.attrModel]" :placeholder="$t('selectStatus')"
|
||||
:type="'radio'" :triggerChange="false" dictCode="valid_status"/>
|
||||
</a-form-model-item>
|
||||
</div>
|
||||
</a-col>
|
||||
</div>
|
||||
|
||||
</a-row>
|
||||
</a-form-model>
|
||||
</a-spin>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'index',
|
||||
props: {
|
||||
url: {
|
||||
type: Object,
|
||||
default: {}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
formInline: {},
|
||||
isFormInline: false,
|
||||
rules: {
|
||||
title: [
|
||||
{ required: true, message: 'Please input Activity name', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
labelCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 6 }
|
||||
},
|
||||
wrapperCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 17 }
|
||||
},
|
||||
dataList: [
|
||||
{
|
||||
id: 1,
|
||||
type: 'INPUT',
|
||||
name: '名称',
|
||||
placeholder: '请输入名称',
|
||||
attrModel: 'name',
|
||||
enName: 'Name'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
type: 'INPUT',
|
||||
name: '标题',
|
||||
placeholder: '请输入标题',
|
||||
attrModel: 'title',
|
||||
enName: 'title'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
type: 'RADIO',
|
||||
name: '单选',
|
||||
placeholder: '请输入标题',
|
||||
enName: 'Single choice',
|
||||
validStatus: 'valid_status',
|
||||
attrModel: 'radio'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
type: 'CHECKBOX',
|
||||
name: '多选',
|
||||
enName: 'title',
|
||||
placeholder: '请输入标题',
|
||||
attrModel: 'checkbox',
|
||||
validStatus:'valid_status',
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
type: 'SELECT',
|
||||
name: '下拉单选',
|
||||
enName: 'title',
|
||||
placeholder: '请输入标题',
|
||||
attrModel: 'radio',
|
||||
validStatus:'valid_status',
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
type: 'SELECTALL',
|
||||
name: '下拉多选',
|
||||
enName: 'title',
|
||||
placeholder: '请输入标题',
|
||||
validStatus:'valid_status',
|
||||
attrModel: 'selectAll'
|
||||
}
|
||||
],
|
||||
validatorRules: {},
|
||||
confirmLoading: false
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.isFormInline = false
|
||||
this.isFormInline = true
|
||||
},
|
||||
methods: {
|
||||
sumber() {
|
||||
console.log(1)
|
||||
this.$refs.ruleForm.validate(valid => {
|
||||
if (valid) {
|
||||
alert('submit!')
|
||||
} else {
|
||||
console.log('error submit!!')
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.formAdd .ant-form-item-label {
|
||||
width: 130px;
|
||||
}
|
||||
|
||||
.formAdd .ant-form-item-control-wrapper {
|
||||
display: inline-block;
|
||||
width: calc(100% - 130px);
|
||||
}
|
||||
|
||||
.formAdd .ant-form-item {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.itemModel .ant-form-item-control-wrapper {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.box-input .ant-select-selection--single {
|
||||
height: 38px;
|
||||
}
|
||||
|
||||
.box-input .ant-select-selection--multiple {
|
||||
height: 38px;
|
||||
}
|
||||
|
||||
.box-input .ant-select-selection__rendered {
|
||||
line-height: 38px;
|
||||
height: 38px;
|
||||
}
|
||||
.box-input .ant-select-selection--multiple .ant-select-selection__rendered > ul > li{
|
||||
margin-top:6px;
|
||||
}
|
||||
</style>
|
||||
<style scoped>
|
||||
.box-title-text {
|
||||
line-height: 1.4;
|
||||
display: flex;
|
||||
/*align-items: center;*/
|
||||
}
|
||||
|
||||
.title-text {
|
||||
width: 114px;
|
||||
text-align: right;
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
font-size: 14px;
|
||||
margin-right: 16px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.box-input {
|
||||
display: inline-block;
|
||||
height: 38px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.itemModel {
|
||||
width: calc(100% - 130px);
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.Required {
|
||||
color: red;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.title-text-text {
|
||||
margin-top: 11px;
|
||||
display: inline-block;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user