|
@@ -54,7 +54,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-import { reactive } from "vue";
|
|
|
|
|
|
|
+import { reactive, onBeforeMount,watchEffect } from "vue";
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
props: {
|
|
props: {
|
|
@@ -83,14 +83,17 @@ export default {
|
|
|
// 表单项的初始值
|
|
// 表单项的初始值
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- props.formItems.forEach(item => {
|
|
|
|
|
- console.log('item', item)
|
|
|
|
|
- if (item.defaultVal) {
|
|
|
|
|
- Object.assign(form, {
|
|
|
|
|
- [item.prop]: item.defaultVal
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ function initFormDefaults() {
|
|
|
|
|
+ props.formItems.forEach(item => {
|
|
|
|
|
+ console.log('item', item)
|
|
|
|
|
+ if (item.defaultVal) {
|
|
|
|
|
+ Object.assign(form, {
|
|
|
|
|
+ [item.prop]: item.defaultVal
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function submitForm() {
|
|
function submitForm() {
|
|
|
// 执行搜索逻辑
|
|
// 执行搜索逻辑
|
|
|
// 可以通过 form 获取表单数据进行搜索操作
|
|
// 可以通过 form 获取表单数据进行搜索操作
|
|
@@ -118,6 +121,14 @@ export default {
|
|
|
emit('addForm')
|
|
emit('addForm')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ onBeforeMount(() => {
|
|
|
|
|
+ initFormDefaults()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ watchEffect(() => {
|
|
|
|
|
+ initFormDefaults()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
return {
|
|
return {
|
|
|
form,
|
|
form,
|
|
|
submitForm,
|
|
submitForm,
|