11
This commit is contained in:
1 parent
c2cd2dbbc9
commit
69a0ba23ee
2 files changed
+23
-9
No files matched your search
+4
-4
@@ -11,15 +11,15 @@ ENV = 'development'
|
||||
# VITE_ADMIN_PROXY_PATH = http://123.157.250.162:8089/api/ # 测试线上
|
||||
# VITE_ADMIN_PROXY_PATH = http://123.156.230.15:8089/api/ # 测试线上-过期
|
||||
# VITE_ADMIN_PROXY_PATH = http://localhost:9999/
|
||||
# VITE_ADMIN_PROXY_PATH = https://dzc-test-1.fy.takin.cc # 邓-本地
|
||||
VITE_ADMIN_PROXY_PATH = https://stgl.pj.gov.cn/api # 正式环境线上
|
||||
VITE_ADMIN_PROXY_PATH = https://dzc-test-1.fy.takin.cc # 邓-本地
|
||||
# VITE_ADMIN_PROXY_PATH = https://stgl.pj.gov.cn/api # 正式环境线上
|
||||
|
||||
# 图片访问基础地址
|
||||
# VITE_IMAGE_BASE_PATH = http://123.157.250.162:8089/api/ # 测试线上
|
||||
# VITE_IMAGE_BASE_PATH = http://123.156.230.15:8089/api/ # 测试线上-过期
|
||||
# VITE_IMAGE_BASE_PATH = http://localhost:9999
|
||||
# VITE_IMAGE_BASE_PATH = https://dzc-test-1.fy.takin.cc # 邓-本地
|
||||
VITE_IMAGE_BASE_PATH = https://stgl.pj.gov.cn/api/ # 正式环境线上
|
||||
VITE_IMAGE_BASE_PATH = https://dzc-test-1.fy.takin.cc # 邓-本地
|
||||
# VITE_IMAGE_BASE_PATH = https://stgl.pj.gov.cn/api/ # 正式环境线上
|
||||
|
||||
# 代码生成服务地址
|
||||
VITE_GEN_PROXY_PATH = http://192.168.110.156:5003
|
||||
@@ -16,7 +16,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="select-merchant">
|
||||
import { reactive } from "vue"
|
||||
import { reactive, onMounted, watch } from "vue" // 1. 添加 watch 导入
|
||||
import * as mchApi from "/@/api/wallet/mch-manage"
|
||||
|
||||
const selectId = defineModel()
|
||||
@@ -50,23 +50,33 @@ const state = reactive<any>({
|
||||
options: [],
|
||||
})
|
||||
|
||||
// 2. 修改 watch 逻辑
|
||||
watch(
|
||||
selectId,
|
||||
(newVal, oldValue) => {
|
||||
if (newVal == oldValue) return
|
||||
state.selectId = newVal
|
||||
getOptions()
|
||||
// 如果有 newVal 且当前选项列表中没有这个 ID,则带上 ID 查询单条数据以显示 Label
|
||||
if (newVal && !state.options.find((v: any) => v.id === newVal)) {
|
||||
getOptions(newVal)
|
||||
} else if (!newVal) {
|
||||
getOptions()
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
async function getOptions() {
|
||||
async function getOptions(id?: any) {
|
||||
try {
|
||||
state.loading = true
|
||||
const _pa = {
|
||||
...queryForm,
|
||||
...props.apiParams,
|
||||
}
|
||||
// 3. 这里保留您提到的逻辑:如果有 id 参数,就加入搜索条件
|
||||
if (id) {
|
||||
_pa.id = id
|
||||
}
|
||||
const { data } = await mchApi.select(_pa)
|
||||
state.options = data.records ?? []
|
||||
if (props.autoFirst && state.options.length != 0) {
|
||||
@@ -80,6 +90,7 @@ async function getOptions() {
|
||||
function remoteSearch(params: string) {
|
||||
if (params != queryForm.name) {
|
||||
queryForm.name = params
|
||||
// 搜索时会自动调用不带 id 的 getOptions,从而去掉 id 过滤
|
||||
getOptions()
|
||||
}
|
||||
}
|
||||
@@ -90,6 +101,9 @@ function clear() {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
props.autoFirst && getOptions()
|
||||
// 如果没有初始 ID 且开启了 autoFirst,才执行默认查询
|
||||
if (!selectId.value && props.autoFirst) {
|
||||
getOptions()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</script>
|
||||
Reference in new issue
Block a user