refactor(xumu): 重构耳标选择器组件

- 新增计算属性 api,用于生成请求 URL
- 将 watch 目标从 action 改为 api
- 优化 getEartag 方法,使用计算属性 api 替代手动构建 URL
This commit is contained in:
aixianling
2025-01-08 15:18:37 +08:00
parent 07a4d0637f
commit 2e93f1465f

View File

@@ -18,8 +18,17 @@ export default {
selected: [] selected: []
} }
}, },
computed: {
api: v => {
let url = v.action
if (v.penId) {
url += `?penId=${v.penId}`
}
return url
}
},
watch: { watch: {
action: { api: {
immediate: true, immediate: true,
handler() { handler() {
this.getEartag() this.getEartag()
@@ -28,11 +37,7 @@ export default {
}, },
methods: { methods: {
getEartag() { getEartag() {
let url = this.action !/undefined/.test(this.api) && this.instance.post(this.api).then(res => {
if (this.penId) {
url += `?penId=${this.penId}`
}
!/undefined/.test(url) && this.instance.post(url).then(res => {
if (res?.data) { if (res?.data) {
this.list = res.data this.list = res.data
} }