perf: 合并参数

This commit is contained in:
2023-09-06 20:03:30 +08:00
parent 0588c30ce6
commit f70dc8d74e
2 changed files with 11 additions and 12 deletions

View File

@ -2,7 +2,7 @@
* @Author: zhaojinfeng 121016171@qq.com
* @Date: 2023-08-14 11:07:15
* @LastEditors: zhaojinfeng 121016171@qq.com
* @LastEditTime: 2023-09-05 18:26:31
* @LastEditTime: 2023-09-06 20:03:04
* @FilePath: \vue3\packages\select-transfer-modal\index.vue
* @Description:
*
@ -19,9 +19,8 @@
:z-index="zIndex" @open="getList" @closed="closed"
>
<div flex>
<slot name="left" :left-params="leftParams" />
<div>
{{ queryParams }}
<slot name="left" />
<div grow>
<el-form ref="queryRef" :model="queryParams" inline>
<el-form-item v-for="formItem in formItems" :key="formItem.prop" :label="formItem.label" :prop="formItem.prop">
<el-select v-if="formItem.selectOptions" :placeholder="formItem.placeholder">
@ -148,8 +147,6 @@ const queryParams = reactive({
pageSize: properties.pageSizes[0] || 10,
})
const leftParams = reactive({})
const data = computed(() => {
const all: any[] = []
const { props: { disabled = 'disabled', key = 'id' }, lockList } = properties
@ -180,7 +177,6 @@ async function getList() {
try {
const response = await properties.request({
...properties.defaultParams,
...leftParams, // 合并参数
...queryParams,
})
const { key = 'id' } = properties.props
@ -241,7 +237,7 @@ function transferValueInit() {
transferValueInit()
watch(() => leftParams, handleQuery)
watch(() => properties.defaultParams, handleQuery, { deep: true })
watch(() => properties.value, transferValueInit)
watch(() => properties.show, (show) => {
showDialog.value = show

View File

@ -2,7 +2,7 @@
* @Author: zhaojinfeng 121016171@qq.com
* @Date: 2023-08-14 11:07:15
* @LastEditors: zhaojinfeng 121016171@qq.com
* @LastEditTime: 2023-09-05 18:19:09
* @LastEditTime: 2023-09-06 20:02:01
* @FilePath: \vue3\stories\SelectTransferModal.stories.ts
* @Description:
*
@ -168,6 +168,10 @@ export const LeftSlot: Story = {
name: '左插槽',
args: {
...meta.args,
width: '90%',
defaultParams: {
name: '',
},
},
render: args => ({
components: { ThSelectTransferModal },
@ -189,10 +193,9 @@ export const LeftSlot: Story = {
:width="args.width"
:z-index="args.zIndex"
>
<template #left="{ queryParams }">
<template #left>
<div style="width:200px">
<input v-model="queryParams.name" />
<input v-model="args.defaultParams.name" />
</div>
</template>
</th-select-transfer-modal>