feat:活动搜索
This commit is contained in:
1 parent
c2b47f2541
commit
25d4d396a7
3 files changed
+106
No files matched your search
@@ -0,0 +1,101 @@
|
||||
<template>
|
||||
<el-select
|
||||
style="width: 100%"
|
||||
v-model="selectId"
|
||||
:placeholder="props.placeholder"
|
||||
clearable
|
||||
remote-show-suffix
|
||||
filterable
|
||||
remote
|
||||
:disabled="props.disabled"
|
||||
:remote-method="remoteSearch"
|
||||
:loading="state.loading"
|
||||
@visible-change="(e: boolean) => e && getOptions()"
|
||||
:multiple="props.multiple"
|
||||
>
|
||||
<el-option v-for="v in state.options" :key="v.id" :label="`${v.actTitle}`" :value="v.id">
|
||||
<div class="flex items-center">
|
||||
<div class="color-primary">{{ v.actTitle }}</div>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="select-merchant">
|
||||
import { reactive } from "vue"
|
||||
import * as actCancelApi from "/@/api/act/actCancel"
|
||||
|
||||
const selectId = defineModel()
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
placeholder?: string
|
||||
apiParams?: any
|
||||
autoFirst?: boolean
|
||||
disabled?: boolean
|
||||
multiple?: boolean
|
||||
}>(),
|
||||
{
|
||||
placeholder: "请选择",
|
||||
apiParams: {},
|
||||
autoFirst: false,
|
||||
disabled: false,
|
||||
multiple: false,
|
||||
},
|
||||
)
|
||||
|
||||
const queryForm = reactive<any>({
|
||||
name: null,
|
||||
current: 1,
|
||||
size: 9999,
|
||||
})
|
||||
|
||||
const state = reactive<any>({
|
||||
loading: true,
|
||||
selectId: selectId.value,
|
||||
options: [],
|
||||
})
|
||||
|
||||
watch(
|
||||
selectId,
|
||||
(newVal, oldValue) => {
|
||||
if (newVal == oldValue) return
|
||||
state.selectId = newVal
|
||||
getOptions()
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
async function getOptions() {
|
||||
try {
|
||||
state.loading = true
|
||||
const _pa = {
|
||||
...queryForm,
|
||||
...props.apiParams,
|
||||
}
|
||||
const { data } = await actCancelApi.fetchList(_pa)
|
||||
state.options = data.records ?? []
|
||||
if (props.autoFirst && state.options.length != 0) {
|
||||
state.selectId = state.options[0].id
|
||||
}
|
||||
} finally {
|
||||
setTimeout(() => (state.loading = false), 500)
|
||||
}
|
||||
}
|
||||
|
||||
function remoteSearch(params: string) {
|
||||
if (params != queryForm.name) {
|
||||
queryForm.name = params
|
||||
getOptions()
|
||||
}
|
||||
}
|
||||
|
||||
function clear() {
|
||||
state.selectId = null
|
||||
getOptions()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
props.autoFirst && getOptions()
|
||||
})
|
||||
</script>
|
||||
@@ -39,6 +39,7 @@ import SelectMchCatory from "/@/components/Select/SelectMchCatory.vue"
|
||||
import SelectCanteenSupplier from "/@/components/Select/SelectCanteenSupplier.vue"
|
||||
import SelectWalletInvoice from "/@/components/Select/SelectWalletInvoice.vue"
|
||||
import SelectNotice from "/@/components/Select/SelectNotice.vue"
|
||||
import SelectAct from "/@/components/Select/SelectAct.vue"
|
||||
// 地图组件
|
||||
import MapSelect from "/@/components/map/map-select.vue"
|
||||
|
||||
@@ -100,6 +101,7 @@ export default {
|
||||
app.component("SelectCanteenSupplier", SelectCanteenSupplier)
|
||||
app.component("SelectWalletInvoice", SelectWalletInvoice)
|
||||
app.component("SelectNotice", SelectNotice)
|
||||
app.component("SelectAct", SelectAct)
|
||||
|
||||
app.component("MapSelect", MapSelect)
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
||||
<el-row>
|
||||
<el-form-item style="width: 300px" label="活动" prop="actId">
|
||||
<select-act v-model="state.queryForm.actId" />
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 300px" label="领取人用户" prop="receiverUserId">
|
||||
<select-user v-model="state.queryForm.receiverUserId" />
|
||||
</el-form-item>
|
||||
|
||||
Reference in new issue
Block a user