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