fix(components): 修复高级组件中的默认值和响应式问题
This commit is contained in:
@@ -10,11 +10,11 @@
|
|||||||
<el-col v-if="showSelect" :span="2" class="selection-box">
|
<el-col v-if="showSelect" :span="2" class="selection-box">
|
||||||
已选 <font class="selection-count">{{ crud.selection && crud.selection.length }}</font> 条
|
已选 <font class="selection-count">{{ crud.selection && crud.selection.length }}</font> 条
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="11" style="text-align: left">
|
<el-col :span="showSelect ? 11 : 12" style="text-align: left">
|
||||||
<!-- 通过 <template v-slot:batchArea> 插槽,数据表格上方左侧 添加 批量操作入口 -->
|
<!-- 通过 <template v-slot:batchArea> 插槽,数据表格上方左侧 添加 批量操作入口 -->
|
||||||
<slot name="batchArea" />
|
<slot name="batchArea" />
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="11" style="text-align: left">
|
<el-col :span="showSelect ? 11 : 12" style="text-align: left">
|
||||||
<!-- 通过 <template v-slot:toolArea> 插槽,数据表格上方右侧 添加 工具入口,比如导出 -->
|
<!-- 通过 <template v-slot:toolArea> 插槽,数据表格上方右侧 添加 工具入口,比如导出 -->
|
||||||
<slot name="toolArea" />
|
<slot name="toolArea" />
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -59,7 +59,7 @@ export default {
|
|||||||
primaryKey: {
|
primaryKey: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
default: null
|
default: 'id'
|
||||||
},
|
},
|
||||||
fetch: {
|
fetch: {
|
||||||
type: Function,
|
type: Function,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
style="width: 100%;"
|
style="width: 100%;"
|
||||||
highlight-current-row
|
highlight-current-row
|
||||||
>
|
>
|
||||||
<el-table-column v-for="item in schema" :key="item[primaryKey]" :prop="item.name" :label="item.title">
|
<el-table-column v-for="item in schema" :key="item.name" :prop="item.name" :label="item.title">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-input
|
<el-input
|
||||||
v-if="item.type === 'input'"
|
v-if="item.type === 'input'"
|
||||||
@@ -86,7 +86,7 @@ export default {
|
|||||||
*/
|
*/
|
||||||
schema: {
|
schema: {
|
||||||
type: Array,
|
type: Array,
|
||||||
require: true,
|
required: true,
|
||||||
default: function() {
|
default: function() {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,14 @@ export default {
|
|||||||
dataSource: []
|
dataSource: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
watch: {
|
||||||
|
value(newVal) {
|
||||||
|
if (newVal && newVal.length > 0) {
|
||||||
|
this.dataSource = newVal
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
if (this.value && this.value.length > 0) {
|
if (this.value && this.value.length > 0) {
|
||||||
this.dataSource = this.value
|
this.dataSource = this.value
|
||||||
}
|
}
|
||||||
@@ -205,21 +212,3 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
@import "~@/assets/styles/variables";
|
|
||||||
|
|
||||||
.selection-box {
|
|
||||||
text-align: left;
|
|
||||||
font-size: 12px;
|
|
||||||
padding-left: 10px;
|
|
||||||
min-height: 26.7px;
|
|
||||||
max-height: 26.7px;
|
|
||||||
padding-top: 7px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.selection-count {
|
|
||||||
color: $menuActiveText;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,9 @@ export default {
|
|||||||
model: {
|
model: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
default: null
|
default: function() {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -132,7 +134,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
::v-deep(.el-dialog__body) {
|
::v-deep(.el-dialog__body) {
|
||||||
padding: 20px 20px !important;
|
padding: 10px 10px !important;
|
||||||
height: 90%;
|
height: 90%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -177,14 +177,16 @@ export default {
|
|||||||
const schema = this.schema
|
const schema = this.schema
|
||||||
const formRules = {}
|
const formRules = {}
|
||||||
let trigger = 'blur'
|
let trigger = 'blur'
|
||||||
|
let tip = '请输入'
|
||||||
for (const element of schema) {
|
for (const element of schema) {
|
||||||
if (element.type === 'input') {
|
if (element.type === 'input') {
|
||||||
trigger = 'blur'
|
trigger = 'blur'
|
||||||
} else {
|
} else {
|
||||||
trigger = 'change'
|
trigger = 'change'
|
||||||
|
tip = '请选择'
|
||||||
}
|
}
|
||||||
formRules[element.name] = [
|
formRules[element.name] = [
|
||||||
{ required: element.required === true, message: '请输入' + element.title, trigger: trigger }
|
{ required: element.required === true, message: tip + element.title, trigger: trigger }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
return formRules
|
return formRules
|
||||||
@@ -260,7 +262,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
::v-deep(.el-dialog__body) {
|
::v-deep(.el-dialog__body) {
|
||||||
padding: 20px 20px !important;
|
padding: 10px 10px !important;
|
||||||
height: 90%;
|
height: 90%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
<el-divider />
|
<el-divider />
|
||||||
<div class="dialog-footer">
|
<div class="dialog-footer">
|
||||||
<el-button type="danger" @click="hidden">取 消</el-button>
|
<el-button type="danger" @click="hidden">取 消</el-button>
|
||||||
|
<el-button v-if="showReset" @click="resetForm('form')">重 置</el-button>
|
||||||
<el-button v-prevent-re-click type="primary" @click="submitForm('form')">提 交</el-button>
|
<el-button v-prevent-re-click type="primary" @click="submitForm('form')">提 交</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
@@ -49,7 +50,9 @@ export default {
|
|||||||
model: {
|
model: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
default: null
|
default: function() {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
|||||||
@@ -173,14 +173,16 @@ export default {
|
|||||||
const schema = this.schema
|
const schema = this.schema
|
||||||
const formRules = {}
|
const formRules = {}
|
||||||
let trigger = 'blur'
|
let trigger = 'blur'
|
||||||
|
let tip = '请输入'
|
||||||
for (const element of schema) {
|
for (const element of schema) {
|
||||||
if (element.type === 'input') {
|
if (element.type === 'input') {
|
||||||
trigger = 'blur'
|
trigger = 'blur'
|
||||||
} else {
|
} else {
|
||||||
trigger = 'change'
|
trigger = 'change'
|
||||||
|
tip = '请选择'
|
||||||
}
|
}
|
||||||
formRules[element.name] = [
|
formRules[element.name] = [
|
||||||
{ required: element.required === true, message: '请输入' + element.title, trigger: trigger }
|
{ required: element.required === true, message: tip + element.title, trigger: trigger }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
return formRules
|
return formRules
|
||||||
@@ -255,8 +257,13 @@ export default {
|
|||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
::v-deep(.el-dialog__body) {
|
::v-deep(.el-drawer__header) {
|
||||||
padding: 20px 20px !important;
|
padding: 10px;
|
||||||
|
border-bottom: 1px solid #DCDFE6;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep(.el-drawer__body) {
|
||||||
|
padding: 10px 10px !important;
|
||||||
height: 90%;
|
height: 90%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<el-form
|
<el-form
|
||||||
ref="searchForm"
|
ref="searchForm"
|
||||||
:inline="true"
|
:inline="true"
|
||||||
:model.sync="model"
|
:model="model"
|
||||||
label-position="right"
|
label-position="right"
|
||||||
label-width="90px"
|
label-width="90px"
|
||||||
size="small"
|
size="small"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<el-form
|
<el-form
|
||||||
ref="searchForm"
|
ref="searchForm"
|
||||||
:inline="true"
|
:inline="true"
|
||||||
:model.sync="model"
|
:model="model"
|
||||||
label-position="right"
|
label-position="right"
|
||||||
label-width="90px"
|
label-width="90px"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -79,7 +79,7 @@
|
|||||||
<script>
|
<script>
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CuteSearchProForm',
|
name: 'CuteSearchFormPro',
|
||||||
components: {},
|
components: {},
|
||||||
props: {
|
props: {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -10,11 +10,11 @@
|
|||||||
<el-col v-if="showSelect" :span="2" class="selection-box">
|
<el-col v-if="showSelect" :span="2" class="selection-box">
|
||||||
已选 <font class="selection-count">{{ crud.selection && crud.selection.length }}</font> 条
|
已选 <font class="selection-count">{{ crud.selection && crud.selection.length }}</font> 条
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="11" style="text-align: left">
|
<el-col :span="showSelect ? 11 : 12" style="text-align: left">
|
||||||
<!-- 通过 <template v-slot:batchArea> 插槽,数据表格上方左侧 添加 批量操作入口 -->
|
<!-- 通过 <template v-slot:batchArea> 插槽,数据表格上方左侧 添加 批量操作入口 -->
|
||||||
<slot name="batchArea" />
|
<slot name="batchArea" />
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="11" style="text-align: right">
|
<el-col :span="showSelect ? 11 : 12" style="text-align: right">
|
||||||
<!-- 通过 <template v-slot:toolArea> 插槽,数据表格上方右侧 添加 工具入口,比如导出 -->
|
<!-- 通过 <template v-slot:toolArea> 插槽,数据表格上方右侧 添加 工具入口,比如导出 -->
|
||||||
<slot name="toolArea" />
|
<slot name="toolArea" />
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -59,7 +59,7 @@ export default {
|
|||||||
primaryKey: {
|
primaryKey: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
default: null
|
default: 'id'
|
||||||
},
|
},
|
||||||
fetch: {
|
fetch: {
|
||||||
type: Function,
|
type: Function,
|
||||||
|
|||||||
Reference in New Issue
Block a user